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 #ifdef SUPPORT_SCREEN 23 #include "pixel_map.h" 24 #endif 25 #endif 26 27 namespace OHOS { 28 namespace Ace { 29 class UIContent; 30 } 31 32 namespace AppExecFwk { 33 class IAbilityCallback { 34 public: 35 IAbilityCallback() = default; 36 virtual ~IAbilityCallback() = default; 37 #ifdef SUPPORT_GRAPHICS 38 #ifdef SUPPORT_SCREEN 39 /** 40 * @brief Called back at ability context. 41 * 42 * @return current window mode of the ability. 43 */ 44 virtual int GetCurrentWindowMode() = 0; 45 46 /** 47 * @brief Set mission label of this ability. 48 * 49 * @param label the label of this ability. 50 * @return Returns ERR_OK if success. 51 */ 52 virtual ErrCode SetMissionLabel(const std::string &label) = 0; 53 54 /** 55 * @brief Set mission icon of this ability. 56 * 57 * @param icon the icon of this ability. 58 * @return Returns ERR_OK if success. 59 */ 60 virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0; 61 62 /** 63 * @brief Called when back press is dispatched. 64 * 65 * @return Return true if ability will be moved to background; return false if will be terminated. 66 */ OnBackPress()67 virtual bool OnBackPress() 68 { 69 return false; 70 } 71 72 /** 73 * @brief Get window rectangle of this ability. 74 * 75 * @param the left position of window rectangle. 76 * @param the top position of window rectangle. 77 * @param the width position of window rectangle. 78 * @param the height position of window rectangle. 79 */ 80 virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) = 0; 81 82 /** 83 * @brief Get ui content object. 84 * 85 * @return UIContent object of ACE. 86 */ 87 virtual Ace::UIContent* GetUIContent() = 0; 88 virtual void EraseUIExtension(int32_t sessionId) = 0; 89 #endif 90 #endif 91 92 /** 93 * Register lifecycle observer on ability. 94 * 95 * @param observer the lifecycle observer to be registered on ability. 96 */ 97 virtual void RegisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer) = 0; 98 99 /** 100 * Unregister lifecycle observer on ability. 101 * 102 * @param observer the lifecycle observer to be unregistered on ability. 103 */ 104 virtual void UnregisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer) = 0; 105 106 virtual std::shared_ptr<AAFwk::Want> GetWant() = 0; 107 SetContinueState(int32_t state)108 virtual void SetContinueState(int32_t state) {}; 109 NotifyWindowDestroy()110 virtual void NotifyWindowDestroy() {} 111 }; 112 } // namespace AppExecFwk 113 } // namespace OHOS 114 #endif // OHOS_ABILITY_RUNTIME_IABILITY_CALLBACK_H 115