• 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 "bundle_event_callback_host.h"
20 #include "common_event_support.h"
21 #include "ability_event_handler.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     AbilityBundleEventCallback();
35     explicit AbilityBundleEventCallback(std::shared_ptr<AbilityEventHandler> eventHandler);
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     DISALLOW_COPY_AND_MOVE(AbilityBundleEventCallback);
49     AbilityEventUtil abilityEventHelper_;
50     std::shared_ptr<AbilityEventHandler> eventHandler_ = nullptr;
51 };
52 } // namespace OHOS
53 } // namespace AAFwk
54 #endif // OHOS_ABILITY_RUNTIME_ABILITY_BUNDLE_EVENT_CALLBACK_H