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_GROUP_HANDLER_H 17 #define BUNDLE_ACTIVE_GROUP_HANDLER_H 18 19 #include "event_handler.h" 20 #include "event_runner.h" 21 22 #include "ibundle_active_service.h" 23 #include "bundle_active_group_controller.h" 24 #include "bundle_active_group_common.h" 25 26 namespace OHOS { 27 namespace DeviceUsageStats { 28 class BundleActiveGroupHandlerObject { 29 public: 30 std::string bundleName_; 31 int32_t userId_; 32 BundleActiveGroupHandlerObject(); 33 BundleActiveGroupHandlerObject(const BundleActiveGroupHandlerObject& orig); ~BundleActiveGroupHandlerObject()34 ~BundleActiveGroupHandlerObject() {} 35 }; 36 37 class BundleActiveGroupHandler : public AppExecFwk::EventHandler { 38 public: 39 explicit BundleActiveGroupHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, const bool debug); 40 ~BundleActiveGroupHandler() = default; 41 /** 42 * Process the event. Developers should override this method. 43 * 44 * @param event The event should be processed. 45 */ 46 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 47 void Init(const std::shared_ptr<BundleActiveGroupController>& bundleActiveController); 48 static const int32_t MSG_CHECK_BUNDLE_STATE = 0; 49 static const int32_t MSG_ONE_TIME_CHECK_BUNDLE_STATE = 1; 50 static const int32_t MSG_CHECK_IDLE_STATE = 2; 51 int64_t checkIdleInterval_; 52 53 private: 54 std::shared_ptr<BundleActiveGroupController> bundleActiveGroupController_; 55 }; 56 } // namespace DeviceUsageStats 57 } // namespace OHOS 58 #endif // BUNDLE_ACTIVE_GROUP_HANDLER_H 59 60