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 "ability_auto_startup_service.h" 20 #include "bundle_event_callback_host.h" 21 #include "common_event_support.h" 22 #include "task_handler_wrap.h" 23 #include "ability_event_util.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 std::shared_ptr<AbilityRuntime::AbilityAutoStartupService> abilityAutoStartupService); 36 37 ~AbilityBundleEventCallback() = default; 38 39 /** 40 * @brief The main callback function that will be called by BundleManager 41 * when install, uninstall, updates of haps happens to notify AbilityManger. 42 * @param eventData the data passed from BundleManager that includes bundleName, change type of haps 43 * etc. More can be found from BundleCommonEventMgr::NotifyBundleStatus() 44 */ 45 void OnReceiveEvent(const EventFwk::CommonEventData eventData) override; 46 47 private: 48 void HandleUpdatedModuleInfo(const std::string &bundleName, int32_t uid); 49 void HandleAppUpgradeCompleted(const std::string &bundleName, int32_t uid); 50 void HandleRemoveUriPermission(uint32_t tokenId); 51 void HandleRestartResidentProcessDependedOnWeb(); 52 53 DISALLOW_COPY_AND_MOVE(AbilityBundleEventCallback); 54 AbilityEventUtil abilityEventHelper_; 55 std::shared_ptr<TaskHandlerWrap> taskHandler_; 56 std::shared_ptr<AbilityRuntime::AbilityAutoStartupService> abilityAutoStartupService_; 57 }; 58 } // namespace OHOS 59 } // namespace AAFwk 60 #endif // OHOS_ABILITY_RUNTIME_ABILITY_BUNDLE_EVENT_CALLBACK_H