1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_ABILITY_RUNTIME_IABILITY_CALLBACK_H
17 #define OHOS_ABILITY_RUNTIME_IABILITY_CALLBACK_H
18 
19 #include "ability_lifecycle_observer_interface.h"
20 
21 #ifdef SUPPORT_GRAPHICS
22 #include "pixel_map.h"
23 #endif
24 
25 namespace OHOS {
26 namespace Ace {
27 class UIContent;
28 }
29 
30 namespace AppExecFwk {
31 class IAbilityCallback {
32 public:
33     IAbilityCallback() = default;
34     virtual ~IAbilityCallback() = default;
35 #ifdef SUPPORT_GRAPHICS
36     /**
37      * @brief Called back at ability context.
38      *
39      * @return current window mode of the ability.
40      */
41     virtual int GetCurrentWindowMode() = 0;
42 
43     /**
44      * @brief Set mission label of this ability.
45      *
46      * @param label the label of this ability.
47      * @return Returns ERR_OK if success.
48      */
49     virtual ErrCode SetMissionLabel(const std::string &label) = 0;
50 
51     /**
52      * @brief Set mission icon of this ability.
53      *
54      * @param icon the icon of this ability.
55      * @return Returns ERR_OK if success.
56      */
57     virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
58 
59     /**
60      * @brief Called when back press is dispatched.
61      *
62      * @return Return true if ability will be moved to background; return false if will be terminated.
63      */
OnBackPress()64     virtual bool OnBackPress()
65     {
66         return false;
67     }
68 
69     /**
70      * @brief Get window rectangle of this ability.
71      *
72      * @param the left position of window rectangle.
73      * @param the top position of window rectangle.
74      * @param the width position of window rectangle.
75      * @param the height position of window rectangle.
76      */
77     virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) = 0;
78 
79     /**
80      * @brief Get ui content object.
81      *
82      * @return UIContent object of ACE.
83      */
84     virtual Ace::UIContent* GetUIContent() = 0;
85     virtual void EraseUIExtension(int32_t sessionId) = 0;
86 #endif
87 
88     /**
89      * Register lifecycle observer on ability.
90      *
91      * @param observer the lifecycle observer to be registered on ability.
92      */
93     virtual void RegisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer) = 0;
94 
95     /**
96      * Unregister lifecycle observer on ability.
97      *
98      * @param observer the lifecycle observer to be unregistered on ability.
99      */
100     virtual void UnregisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer) = 0;
101 
102     virtual std::shared_ptr<AAFwk::Want> GetWant() = 0;
103 };
104 }  // namespace AppExecFwk
105 }  // namespace OHOS
106 #endif  // OHOS_ABILITY_RUNTIME_IABILITY_CALLBACK_H
107