• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "hilog_wrapper.h"
25 
26 namespace OHOS {
27 namespace AAFwk {
28 /**
29  * @brief This class is a callback class that will be registered to BundleManager.
30  * This class will be called by BundleManager when install, uninstall, updates of haps happens,
31  * and executes corresponding functionalities of ability manager.
32  */
33 class AbilityBundleEventCallback : public AppExecFwk::BundleEventCallbackHost {
34 public:
35     explicit AbilityBundleEventCallback(std::shared_ptr<TaskHandlerWrap> taskHandler,
36         std::shared_ptr<AbilityRuntime::AbilityAutoStartupService> abilityAutoStartupService);
37 
38     ~AbilityBundleEventCallback() = default;
39 
40     /**
41      * @brief The main callback function that will be called by BundleManager
42      * when install, uninstall, updates of haps happens to notify AbilityManger.
43      * @param eventData the data passed from BundleManager that includes bundleName, change type of haps
44      * etc. More can be found from BundleCommonEventMgr::NotifyBundleStatus()
45      */
46     void OnReceiveEvent(const EventFwk::CommonEventData eventData) override;
47 
48 private:
49     void HandleUpdatedModuleInfo(const std::string &bundleName, int32_t uid);
50     void HandleAppUpgradeCompleted(const std::string &bundleName, int32_t uid);
51     void HandleRemoveUriPermission(uint32_t tokenId);
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