• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef SUPPORT_GRAPHICS
20 #include "pixel_map.h"
21 #endif
22 
23 namespace OHOS {
24 namespace Ace {
25 class UIContent;
26 }
27 
28 namespace AppExecFwk {
29 class IAbilityCallback {
30 public:
31     IAbilityCallback() = default;
32     virtual ~IAbilityCallback() = default;
33 #ifdef SUPPORT_GRAPHICS
34     /**
35      * @brief Called back at ability context.
36      *
37      * @return current window mode of the ability.
38      */
39     virtual int GetCurrentWindowMode() = 0;
40 
41     /**
42      * @brief Set mission label of this ability.
43      *
44      * @param label the label of this ability.
45      * @return Returns ERR_OK if success.
46      */
47     virtual ErrCode SetMissionLabel(const std::string &label) = 0;
48 
49     /**
50      * @brief Set mission icon of this ability.
51      *
52      * @param icon the icon of this ability.
53      * @return Returns ERR_OK if success.
54      */
55     virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
56 
57     /**
58      * @brief Called when back press is dispatched.
59      *
60      * @return Return true if ability will be moved to background; return false if will be terminated.
61      */
OnBackPress()62     virtual bool OnBackPress()
63     {
64         return false;
65     }
66 
67     /**
68      * @brief Get window rectangle of this ability.
69      *
70      * @param the left position of window rectangle.
71      * @param the top position of window rectangle.
72      * @param the width position of window rectangle.
73      * @param the height position of window rectangle.
74      */
75     virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) = 0;
76 
77     /**
78      * @brief Get ui content object.
79      *
80      * @return UIContent object of ACE.
81      */
82     virtual Ace::UIContent* GetUIContent() = 0;
83 #endif
84 };
85 }  // namespace AppExecFwk
86 }  // namespace OHOS
87 #endif  // OHOS_ABILITY_RUNTIME_IABILITY_CALLBACK_H
88