• 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 
16 #ifndef BUNDLE_ACTIVE_COMMON_EVENT_SUBSCRIBER_H
17 #define BUNDLE_ACTIVE_COMMON_EVENT_SUBSCRIBER_H
18 
19 #include <memory>
20 
21 #include "common_event_manager.h"
22 #include "common_event_support.h"
23 #include "common_event_data.h"
24 #include "time_service_client.h"
25 
26 #include "ibundle_active_service.h"
27 
28 namespace OHOS {
29 namespace DeviceUsageStats {
30 using CommonEventSubscriber = OHOS::EventFwk::CommonEventSubscriber;
31 using CommonEventData = OHOS::EventFwk::CommonEventData;
32 using CommonEventSubscribeInfo = OHOS::EventFwk::CommonEventSubscribeInfo;
33 using CommonEventSupport = OHOS::EventFwk::CommonEventSupport;
34 using CommonEventManager = OHOS::EventFwk::CommonEventManager;
35 using MatchingSkills = OHOS::EventFwk::MatchingSkills;
36 class BundleActiveGroupController;
37 class BundleActiveReportHandler;
38 
39 class BundleActiveCommonEventSubscriber : public CommonEventSubscriber {
40 public:
BundleActiveCommonEventSubscriber(const CommonEventSubscribeInfo & subscriberInfo,const std::shared_ptr<BundleActiveGroupController> activeGroupController,const std::weak_ptr<BundleActiveReportHandler> bundleActiveReportHandler)41     BundleActiveCommonEventSubscriber(const CommonEventSubscribeInfo &subscriberInfo,
42         const std::shared_ptr<BundleActiveGroupController> activeGroupController,
43         const std::weak_ptr<BundleActiveReportHandler>
44         bundleActiveReportHandler) : CommonEventSubscriber(subscriberInfo),
45         activeGroupController_(activeGroupController),
46         bundleActiveReportHandler_(bundleActiveReportHandler) {}
47     ~BundleActiveCommonEventSubscriber() = default;
48     void OnReceiveEvent(const CommonEventData &data) override;
49     void HandleLockEvent(const std::string& action, const int32_t userId);
50 
51 private:
52     std::mutex mutex_;
53     std::weak_ptr<BundleActiveGroupController> activeGroupController_;
54     std::weak_ptr<BundleActiveReportHandler> bundleActiveReportHandler_;
55 };
56 }  // namespace DeviceUsageStats
57 }  // namespace OHOS
58 #endif  // BUNDLE_ACTIVE_COMMON_EVENT_SUBSCRIBER_H
59 
60