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 get subscriberName. 52 * 53 * @return return subscriberName. 54 */ GetSubscriberName()55 std::string GetSubscriberName() 56 { 57 return subscriberName_; 58 } 59 60 /** 61 * @brief set subscriberName. 62 * 63 * @param name strategy name which will register device_standby callback. 64 */ SetSubscriberName(std::string name)65 void SetSubscriberName(std::string name) 66 { 67 subscriberName_ = name; 68 } 69 70 public: 71 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IStandbyServiceSubscriber"); 72 73 private: 74 std::string subscriberName_; 75 }; 76 } // namespace DevStandbyMgr 77 } // namespace OHOS 78 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_ISTANDBY_SERVICE_SUBSCRIBER_H