• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef OHOS_FORM_FWK_FORM_BUNDLE_EVENT_CALLBACK_H
16 #define OHOS_FORM_FWK_FORM_BUNDLE_EVENT_CALLBACK_H
17 
18 #include "bundle_event_callback_host.h"
19 #include "common_event_support.h"
20 #include "form_event_handler.h"
21 #include "form_event_util.h"
22 #include "hilog_wrapper.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 /**
27  * @brief This class is a callback class that will be registered to BundleManager.
28  * This class will be called by BundleManager when install, uninstall, updates of haps happens,
29  * and executes corresponding functionalities of Form.
30  */
31 class FormBundleEventCallback : public BundleEventCallbackHost {
32 public:
FormBundleEventCallback()33     FormBundleEventCallback() : eventHandler_(nullptr) {}
34 
FormBundleEventCallback(std::shared_ptr<FormEventHandler> eventHandler)35     explicit FormBundleEventCallback(std::shared_ptr<FormEventHandler> eventHandler)
36     {
37         eventHandler_ = eventHandler;
38     }
39 
40     ~FormBundleEventCallback() override = default;
41 
42     /**
43      * @brief The main callback function that will be called by BundleManager
44      * when install, uninstall, updates of haps happens to notify FormManger.
45      * @param eventData the data passed from BundleManager that includes bundleName, change type of haps
46      * etc. More can be found from BundleCommonEventMgr::NotifyBundleStatus()
47      */
48     void OnReceiveEvent(const EventFwk::CommonEventData eventData) override;
49 private:
50     DISALLOW_COPY_AND_MOVE(FormBundleEventCallback);
51     FormEventUtil formEventHelper_;
52     std::shared_ptr<FormEventHandler> eventHandler_ = nullptr;
53 };
54 } // namespace OHOS
55 } // namespace AppExecFwk
56 #endif // OHOS_FORM_FWK_FORM_BUNDLE_EVENT_CALLBACK_H