1 /* 2 * Copyright (c) 2021-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 16 #ifndef OHOS_FORM_FWK_FORM_SYS_EVENT_RECEIVER_H 17 #define OHOS_FORM_FWK_FORM_SYS_EVENT_RECEIVER_H 18 19 #include "common_event_subscriber.h" 20 #include "common_event_subscribe_info.h" 21 #include "form_event_handler.h" 22 #include "form_event_util.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 /** 27 * @class FormSysEventReceiver 28 * Receive system common event. 29 */ 30 class FormSysEventReceiver : public EventFwk::CommonEventSubscriber, 31 public std::enable_shared_from_this<FormSysEventReceiver> { 32 public: 33 FormSysEventReceiver() = default; 34 FormSysEventReceiver(const EventFwk::CommonEventSubscribeInfo &subscriberInfo); 35 virtual ~FormSysEventReceiver() = default; 36 /** 37 * @brief System common event receiver. 38 * @param eventData Common event data. 39 */ 40 virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override; 41 42 /** 43 * @brief SetEventHandler. 44 * @param handler event handler 45 */ SetEventHandler(const std::shared_ptr<FormEventHandler> & handler)46 inline void SetEventHandler(const std::shared_ptr<FormEventHandler> &handler) 47 { 48 eventHandler_ = handler; 49 } 50 private: 51 void HandleUserIdRemoved(const int32_t userId); // multiuser 52 bool IsSameForm(const FormRecord &record, const FormInfo &formInfo); 53 void HandleBundleScanFinished(int32_t userId); 54 private: 55 FormEventUtil formEventHelper_; 56 std::shared_ptr<FormEventHandler> eventHandler_ = nullptr; 57 }; 58 } // namespace AppExecFwk 59 } // namespace OHOS 60 61 #endif // OHOS_FORM_FWK_FORM_SYS_EVENT_RECEIVER_H 62