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 power over used. 52 * 53 * @param module target callback module. 54 * @param level power overused level. 55 */ 56 virtual void OnPowerOverused(const std::string& module, uint32_t level) = 0; 57 58 /** 59 * @brief get subscriberName. 60 * 61 * @return return subscriberName. 62 */ GetSubscriberName()63 std::string GetSubscriberName() 64 { 65 return subscriberName_; 66 } 67 68 /** 69 * @brief set subscriberName. 70 * 71 * @param name strategy name which will register device_standby callback. 72 */ SetSubscriberName(std::string name)73 void SetSubscriberName(std::string name) 74 { 75 subscriberName_ = name; 76 } 77 /** 78 * @brief get module name. 79 * 80 * @return return module name. 81 */ GetModuleName()82 std::string GetModuleName() const 83 { 84 return moduleName_; 85 } 86 87 /** 88 * @brief set module name. 89 * 90 * @param name module name which will register device_standby callback. 91 */ SetModuleName(std::string name)92 void SetModuleName(std::string name) 93 { 94 moduleName_ = name; 95 } 96 97 public: 98 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IStandbyServiceSubscriber"); 99 100 private: 101 std::string subscriberName_; 102 std::string moduleName_; 103 }; 104 } // namespace DevStandbyMgr 105 } // namespace OHOS 106 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H