1 /* 2 * Copyright (c) 2023 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_ABILITY_BUNDLE_EVENT_CALLBACK_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_BUNDLE_EVENT_CALLBACK_H 18 19 #include "bundle_event_callback_host.h" 20 #include "common_event_support.h" 21 #include "task_handler_wrap.h" 22 #include "ability_event_util.h" 23 #include "hilog_wrapper.h" 24 25 namespace OHOS { 26 namespace AAFwk { 27 /** 28 * @brief This class is a callback class that will be registered to BundleManager. 29 * This class will be called by BundleManager when install, uninstall, updates of haps happens, 30 * and executes corresponding functionalities of ability manager. 31 */ 32 class AbilityBundleEventCallback : public AppExecFwk::BundleEventCallbackHost { 33 public: 34 explicit AbilityBundleEventCallback(std::shared_ptr<TaskHandlerWrap> taskHandler); 35 36 ~AbilityBundleEventCallback() = default; 37 38 /** 39 * @brief The main callback function that will be called by BundleManager 40 * when install, uninstall, updates of haps happens to notify AbilityManger. 41 * @param eventData the data passed from BundleManager that includes bundleName, change type of haps 42 * etc. More can be found from BundleCommonEventMgr::NotifyBundleStatus() 43 */ 44 void OnReceiveEvent(const EventFwk::CommonEventData eventData) override; 45 46 private: 47 void HandleUpdatedModuleInfo(const std::string &bundleName, int32_t uid); 48 void HandleAppUpgradeCompleted(const std::string &bundleName, int32_t uid); 49 void HandleRemoveUriPermission(uint32_t tokenId); 50 51 DISALLOW_COPY_AND_MOVE(AbilityBundleEventCallback); 52 AbilityEventUtil abilityEventHelper_; 53 std::shared_ptr<TaskHandlerWrap> taskHandler_; 54 }; 55 } // namespace OHOS 56 } // namespace AAFwk 57 #endif // OHOS_ABILITY_RUNTIME_ABILITY_BUNDLE_EVENT_CALLBACK_H