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 FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H 17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H 18 19 #include <iremote_broker.h> 20 #include <nocopyable.h> 21 22 #include "refbase.h" 23 24 namespace OHOS { 25 namespace DevStandbyMgr { 26 class IStandbyServiceSubscriber : public IRemoteBroker { 27 public: 28 IStandbyServiceSubscriber() = default; 29 ~IStandbyServiceSubscriber() override = default; 30 DISALLOW_COPY_AND_MOVE(IStandbyServiceSubscriber); 31 32 /** 33 * @brief Called back when the standby state changed. 34 * 35 * @param napped The device is in the nap mode. 36 * @param sleeping The device is in the sleep mode. 37 */ 38 virtual void OnDeviceIdleMode(bool napped, bool sleeping) = 0; 39 40 /** 41 * @brief report change of allow list to subscriber. 42 * 43 * @param uid uid which changed happens in. 44 * @param name process name of uid. 45 * @param allowType The change of the chang. 46 * @param added add or removed. 47 */ 48 virtual void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) = 0; 49 50 /** 51 * @brief report change of restrict list to subscriber. 52 * 53 * @param uid uid which changed happens in. 54 * @param name process name of uid. 55 * @param allowType The change of the chang. 56 * @param added add or removed. 57 */ 58 virtual void OnRestrictListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) = 0; 59 60 /** 61 * @brief report power over used. 62 * 63 * @param module target callback module. 64 * @param level power overused level. 65 */ 66 virtual void OnPowerOverused(const std::string& module, uint32_t level) = 0; 67 68 /** 69 * @brief report scene policy. 70 * 71 * @param module target callback module. 72 * @param action notify module do action. 73 */ 74 virtual void OnActionChanged(const std::string& module, uint32_t action) = 0; 75 76 /** 77 * @brief get subscriberName. 78 * 79 * @return return subscriberName. 80 */ GetSubscriberName()81 std::string GetSubscriberName() 82 { 83 return subscriberName_; 84 } 85 86 /** 87 * @brief set subscriberName. 88 * 89 * @param name strategy name which will register device_standby callback. 90 */ SetSubscriberName(std::string name)91 void SetSubscriberName(std::string name) 92 { 93 subscriberName_ = name; 94 } 95 /** 96 * @brief get module name. 97 * 98 * @return return module name. 99 */ GetModuleName()100 std::string GetModuleName() const 101 { 102 return moduleName_; 103 } 104 105 /** 106 * @brief set module name. 107 * 108 * @param name module name which will register device_standby callback. 109 */ SetModuleName(std::string name)110 void SetModuleName(std::string name) 111 { 112 moduleName_ = name; 113 } 114 115 public: 116 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IStandbyServiceSubscriber"); 117 118 private: 119 std::string subscriberName_; 120 std::string moduleName_; 121 }; 122 } // namespace DevStandbyMgr 123 } // namespace OHOS 124 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H