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 get subscriberName. 70 * 71 * @return return subscriberName. 72 */ GetSubscriberName()73 std::string GetSubscriberName() 74 { 75 return subscriberName_; 76 } 77 78 /** 79 * @brief set subscriberName. 80 * 81 * @param name strategy name which will register device_standby callback. 82 */ SetSubscriberName(std::string name)83 void SetSubscriberName(std::string name) 84 { 85 subscriberName_ = name; 86 } 87 /** 88 * @brief get module name. 89 * 90 * @return return module name. 91 */ GetModuleName()92 std::string GetModuleName() const 93 { 94 return moduleName_; 95 } 96 97 /** 98 * @brief set module name. 99 * 100 * @param name module name which will register device_standby callback. 101 */ SetModuleName(std::string name)102 void SetModuleName(std::string name) 103 { 104 moduleName_ = name; 105 } 106 107 public: 108 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IStandbyServiceSubscriber"); 109 110 private: 111 std::string subscriberName_; 112 std::string moduleName_; 113 }; 114 } // namespace DevStandbyMgr 115 } // namespace OHOS 116 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H