diff --git a/bundle.json b/bundle.json index a463af2832c3a00a1c03e03b188a2bae2d24638e..9af3e4d8269ddcc1d09760c8f32e1672e28fd447 100644 --- a/bundle.json +++ b/bundle.json @@ -74,9 +74,9 @@ "header": { "header_base": "//foundation/resourceschedule/device_standby/interfaces/innerkits/include", "header_files": [ - "allow_info.h", - "allow_type.h", - "resourcce_request.h", + "exempted_app_info.h", + "resource_type.h", + "resource_request.h", "standby_service_client.h", "standby_service_subscriber_stub.h", "standby_state.h" @@ -150,7 +150,7 @@ "standby_state/include/dark_state.h", "standby_state/include/maintenance_state.h", "standby_state/include/nap_state.h", - "standby_state/include/sleep_state.h", + "standby_state/include/idle_state.h", "standby_state/include/state_manager_adapter.h", "standby_state/include/working_state.h", "strategy/include/network_strategy.h", diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index 8a9df2e59ad2d0977c94301e3e5f3b0e13973058..ab1c4ab750625a041511653b38bbb2487e4f2741 100644 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -24,8 +24,8 @@ config("standby_fwk_public_config") { ohos_shared_library("standby_fwk") { sources = [ - "${standby_innerkits_path}/src/allow_info.cpp", - "${standby_innerkits_path}/src/resourcce_request.cpp", + "${standby_innerkits_path}/src/exempted_app_info.cpp", + "${standby_innerkits_path}/src/resource_request.cpp", "src/standby_service_proxy.cpp", "src/standby_service_stub.cpp", "src/standby_service_subscriber_proxy.cpp", diff --git a/frameworks/include/istandby_ipc_inteface_code.h b/frameworks/include/istandby_ipc_inteface_code.h index fcac47c6e44ff26a2174cc106be07f956745b8d2..d8b3b19e073d333b4ec2affb2c7acf3e10018d86 100644 --- a/frameworks/include/istandby_ipc_inteface_code.h +++ b/frameworks/include/istandby_ipc_inteface_code.h @@ -24,12 +24,12 @@ namespace DevStandbyMgr { enum class IStandbyInterfaceCode { SUBSCRIBE_STANDBY_CALLBACK = MIN_TRANSACTION_ID, UNSUBSCRIBE_STANDBY_CALLBACK, - APPLY_ALLOW_RESOURCE, - UNAPPLY_ALLOW_RESOURCE, - GET_ALLOW_LIST, + REQUEST_EXEMPTION_RESOURCE, + RELEASE_EXEMPTION_RESOURCE, + GET_EXEMPTED_APPS, IS_DEVICE_IN_STANDBY, REPORT_WORK_SCHEDULER_STATUS, - GET_RESTRICT_LIST, + GET_RESTRICTED_APPS, IS_STRATEGY_ENABLED, REPORT_DEVICE_STATE_CHANGED, }; diff --git a/frameworks/include/istandby_service.h b/frameworks/include/istandby_service.h index 62edaafb79522c59ad8c301d8175fe0f06b0c310..32a6d153a30c662dd045195253ecd1b0f1145625 100644 --- a/frameworks/include/istandby_service.h +++ b/frameworks/include/istandby_service.h @@ -23,8 +23,8 @@ #include #include -#include "allow_info.h" -#include "resourcce_request.h" +#include "exempted_app_info.h" +#include "resource_request.h" #include "standby_service_errors.h" #include "istandby_service_subscriber.h" @@ -59,30 +59,30 @@ public: virtual ErrCode UnsubscribeStandbyCallback(const sptr& subscriber) = 0; /** - * @brief add allow list for some services or apps. + * @brief request exemption resource for some services or apps. * * @param resourceRequest resource to be added. * @return ErrCode ERR_OK if success, others if fail. */ - virtual ErrCode ApplyAllowResource(const sptr& resourceRequest) = 0; + virtual ErrCode RequestExemptionResource(const sptr& resourceRequest) = 0; /** - * @brief remove uid with allow type from allow list. + * @brief remove exemption resource of uid from exemption record. * * @param resourceRequest resource to be removed. * @return ErrCode ErrCode ERR_OK if success, others if fail. */ - virtual ErrCode UnapplyAllowResource(const sptr& resourceRequest) = 0; + virtual ErrCode ReleaseExemptionResource(const sptr& resourceRequest) = 0; /** * @brief Get the Allow List object. * - * @param allowType the allow type to be retrieved. - * @param allowInfoList result represents allowed types and apps. + * @param resourceType the exempted resoruce type to be retrieved. + * @param exemptedAppList result represents exempted types and apps. * @param reasonCode represents the reason why invoke the api. * @return ErrCode ERR_OK if success, others if fail. */ - virtual ErrCode GetAllowList(uint32_t allowType, std::vector& allowInfoList, + virtual ErrCode GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) = 0; /** @@ -93,7 +93,7 @@ public: * @param reasonCode represents the reason why invoke the api. * @return ErrCode ERR_OK if success, others if fail. */ - virtual ErrCode GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, + virtual ErrCode GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) = 0; /** @@ -134,18 +134,6 @@ public: public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IStandbyService"); - -protected: - enum InterfaceId : uint32_t { - SUBSCRIBE_STANDBY_CALLBACK = MIN_TRANSACTION_ID, - UNSUBSCRIBE_STANDBY_CALLBACK, - APPLY_ALLOW_RESOURCE, - UNAPPLY_ALLOW_RESOURCE, - GET_ALLOW_LIST, - IS_DEVICE_IN_STANDBY, - REPORT_WORK_SCHEDULER_STATUS, - REPORT_DEVICE_STATE_CHANGED, - }; }; } // namespace DevStandbyMgr } // namespace OHOS diff --git a/frameworks/include/istandby_service_subscriber.h b/frameworks/include/istandby_service_subscriber.h index 7b86ca942ac6b184a813fc75aeebaa1d561a09d5..52cadb9fc55d7b5f3100a47b5873832d542220c8 100644 --- a/frameworks/include/istandby_service_subscriber.h +++ b/frameworks/include/istandby_service_subscriber.h @@ -33,19 +33,19 @@ public: * @brief Called back when the standby state changed. * * @param napped The device is in the nap mode. - * @param sleeping The device is in the sleep mode. + * @param idIdleThe device is in the idle mode. */ - virtual void OnDeviceIdleMode(bool napped, bool sleeping) = 0; + virtual void OnDeviceIdleMode(bool napped, bool isIdle) = 0; /** * @brief report change of allow list to subscriber. * * @param uid uid which changed happens in. * @param name process name of uid. - * @param allowType The change of the chang. + * @param resourceType The change of the chang. * @param added add or removed. */ - virtual void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) = 0; + virtual void OnExemptedAppsChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added) = 0; /** * @brief get subscriberName. diff --git a/frameworks/include/standby_ipc_interface_code.h b/frameworks/include/standby_ipc_interface_code.h index 1dd520d7202a965c378845170a26868dda6ea3e9..08a6430886da91af1500b72fe875ce83c6c379db 100644 --- a/frameworks/include/standby_ipc_interface_code.h +++ b/frameworks/include/standby_ipc_interface_code.h @@ -23,7 +23,7 @@ namespace OHOS { namespace DevStandbyMgr { enum class StandbySubscriberInterfaceCode { ON_DEVICE_IDLE_MODE = FIRST_CALL_TRANSACTION, - ON_ALLOW_LIST_CHANGED, + ON_EXEMPTED_APPS_CHANGED, }; } // namespace DevStandbyMgr } // namespace OHOS diff --git a/frameworks/include/standby_service_proxy.h b/frameworks/include/standby_service_proxy.h index cc2f816ec190df5347503ea95aeff52df4a1866b..b03b85007df34f3aa396d3523cecd541e823cbc3 100644 --- a/frameworks/include/standby_service_proxy.h +++ b/frameworks/include/standby_service_proxy.h @@ -46,30 +46,30 @@ public: ErrCode UnsubscribeStandbyCallback(const sptr& subscriber) override; /** - * @brief add allow list for some services or apps. + * @brief request exemption resource for some services or apps. * * @param resourceRequest resource to be added. * @return ErrCode ERR_OK if success, others if fail. */ - ErrCode ApplyAllowResource(const sptr& resourceRequest) override; + ErrCode RequestExemptionResource(const sptr& resourceRequest) override; /** - * @brief remove uid with allow type from allow list. + * @brief remove exemption resource of uid from exemption record. * * @param resourceRequest resource to be removed. * @return ErrCode ErrCode ERR_OK if success, others if fail. */ - ErrCode UnapplyAllowResource(const sptr& resourceRequest) override; + ErrCode ReleaseExemptionResource(const sptr& resourceRequest) override; /** * @brief Get the Allow List object. * - * @param allowType the allow type to be retrieved. - * @param allowInfoList result represents allowed types and apps. + * @param resourceType the exempted resoruce type to be retrieved. + * @param exemptedAppList result represents exempted types and apps. * @param isApp represents the reason why invoke the api. * @return ErrCode ERR_OK if success, others if fail. */ - ErrCode GetAllowList(uint32_t allowType, std::vector& allowInfoList, + ErrCode GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) override; /** @@ -92,12 +92,12 @@ public: /** * @brief Get the Restrict List object. * - * @param allowType the allow type to be retrieved. - * @param allowInfoList result represents allowed types and apps. + * @param resourceType the exempted resoruce type to be retrieved. + * @param exemptedAppList result represents exempted types and apps. * @param reasonCode represents the reason why invoke the api. * @return ErrCode ERR_OK if success, others if fail. */ - ErrCode GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, + ErrCode GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) override; /** diff --git a/frameworks/include/standby_service_stub.h b/frameworks/include/standby_service_stub.h index a0741592a93b6de0e998ff708f8f8e54364b8042..8350fa3bee7d72706294c98e134917b026983f66 100644 --- a/frameworks/include/standby_service_stub.h +++ b/frameworks/include/standby_service_stub.h @@ -47,12 +47,12 @@ private: std::function> interfaces_; ErrCode HandleSubscribeStandbyCallback(MessageParcel& data, MessageParcel& reply); ErrCode HandleUnsubscribeStandbyCallback(MessageParcel& data, MessageParcel& reply); - ErrCode HandleApplyAllowResource(MessageParcel& data, MessageParcel& reply); - ErrCode HandleUnapplyAllowResource(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAllowList(MessageParcel& data, MessageParcel& reply); + ErrCode HandleRequestExemptionResource(MessageParcel& data, MessageParcel& reply); + ErrCode HandleReleaseExemptionResource(MessageParcel& data, MessageParcel& reply); + ErrCode HandleGetExemptedApps(MessageParcel& data, MessageParcel& reply); ErrCode HandleIsDeviceInStandby(MessageParcel& data, MessageParcel& reply); ErrCode HandleReportWorkSchedulerStatus(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetRestrictList(MessageParcel& data, MessageParcel& reply); + ErrCode HandleGetRestrictedApps(MessageParcel& data, MessageParcel& reply); ErrCode HandleIsStrategyEnabled(MessageParcel& data, MessageParcel& reply); ErrCode HandleReportDeviceStateChanged(MessageParcel& data, MessageParcel& reply); }; diff --git a/frameworks/include/standby_service_subscriber_proxy.h b/frameworks/include/standby_service_subscriber_proxy.h index 8e1af1a48c1e672ce76475518fdcc03e589a29c6..a22f3939a84d1854895a7fddf07a5d52b4217e33 100644 --- a/frameworks/include/standby_service_subscriber_proxy.h +++ b/frameworks/include/standby_service_subscriber_proxy.h @@ -33,19 +33,19 @@ public: * @brief Called back when the standby state changed. * * @param napped The device is in the nap mode. - * @param sleeping The device is in the sleeping mode. + * @param isIdle The device is in the idlemode. */ - void OnDeviceIdleMode(bool napped, bool sleeping) override; + void OnDeviceIdleMode(bool napped, bool isIdle) override; /** * @brief report change of allow list to subscriber. * * @param uid uid which changed happens in. * @param name process name of uid. - * @param allowType The change of the chang. + * @param resourceType The change of the chang. * @param added add or removed. */ - void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) override; + void OnExemptedAppsChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added) override; private: static inline BrokerDelegator delegator_; }; diff --git a/frameworks/src/standby_service_proxy.cpp b/frameworks/src/standby_service_proxy.cpp index 891aa5c14faac658929534047500fe771e402b97..ed945e9721b623fed05fe21bcfeef886c3d11367 100644 --- a/frameworks/src/standby_service_proxy.cpp +++ b/frameworks/src/standby_service_proxy.cpp @@ -30,7 +30,7 @@ StandbyServiceProxy::~StandbyServiceProxy() {} ErrCode StandbyServiceProxy::SubscribeStandbyCallback(const sptr& subscriber) { if (subscriber == nullptr) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent subscriber is null"); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback subscriber is null"); return ERR_STANDBY_PARCELABLE_FAILED; } @@ -38,30 +38,30 @@ ErrCode StandbyServiceProxy::SubscribeStandbyCallback(const sptrAsObject())) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent write subscriber failed"); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback write subscriber failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (!data.WriteString(subscriber->GetSubscriberName())) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent write SubscriberName failed"); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback write SubscriberName failed"); return ERR_STANDBY_PARCELABLE_FAILED; } ErrCode result = InnerTransact( static_cast(IStandbyInterfaceCode::SUBSCRIBE_STANDBY_CALLBACK), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent fail: read result failed"); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback fail: read result failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("SubscribeSleepStateEvent failed"); + STANDBYSERVICE_LOGW("SubscribeStandbyCallback failed"); } return result; } @@ -69,7 +69,7 @@ ErrCode StandbyServiceProxy::SubscribeStandbyCallback(const sptr& subscriber) { if (subscriber == nullptr) { - STANDBYSERVICE_LOGW("UnsubscribeSleepStateEvent subscriber is null"); + STANDBYSERVICE_LOGW("UnsubscribeStandbyCallback subscriber is null"); return ERR_STANDBY_PARCELABLE_FAILED; } @@ -77,127 +77,127 @@ ErrCode StandbyServiceProxy::UnsubscribeStandbyCallback(const sptrAsObject())) { - STANDBYSERVICE_LOGW("UnsubscribeSleepStateEvent write subscriber failed"); + STANDBYSERVICE_LOGW("UnsubscribeStandbyCallback write subscriber failed"); return ERR_STANDBY_PARCELABLE_FAILED; } ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::UNSUBSCRIBE_STANDBY_CALLBACK), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("UnsubscribeSleepStateEvent fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("UnsubscribeStandbyCallback fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("UnsubscribeSleepStateEvent fail: read result failed"); + STANDBYSERVICE_LOGW("UnsubscribeStandbyCallback fail: read result failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("UnsubscribeSleepStateEvent failed"); + STANDBYSERVICE_LOGW("UnsubscribeStandbyCallback failed"); return result; } return result; } -ErrCode StandbyServiceProxy::ApplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceProxy::RequestExemptionResource(const sptr& resourceRequest) { MessageParcel data; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; if (!data.WriteInterfaceToken(StandbyServiceProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("ApplyAllowResource write descriptor failed"); + STANDBYSERVICE_LOGW("RequestExemptionResource write descriptor failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (!resourceRequest->Marshalling(data)) { - STANDBYSERVICE_LOGW("ApplyAllowResource write parameter failed"); + STANDBYSERVICE_LOGW("RequestExemptionResource write parameter failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::APPLY_ALLOW_RESOURCE), + ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::REQUEST_EXEMPTION_RESOURCE), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("ApplyAllowResource fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("RequestExemptionResource fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("ApplyAllowResource fail: read result failed"); + STANDBYSERVICE_LOGW("RequestExemptionResource fail: read result failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("ApplyAllowResource failed"); + STANDBYSERVICE_LOGW("RequestExemptionResource failed"); return result; } return result; } -ErrCode StandbyServiceProxy::UnapplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceProxy::ReleaseExemptionResource(const sptr& resourceRequest) { MessageParcel data; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; if (!data.WriteInterfaceToken(StandbyServiceProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("RemoveAllowList write descriptor failed"); + STANDBYSERVICE_LOGW("ReleaseExemptionResource write descriptor failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (!resourceRequest->Marshalling(data)) { - STANDBYSERVICE_LOGW("RemoveAllowList write parameter failed"); + STANDBYSERVICE_LOGW("ReleaseExemptionResource write parameter failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::UNAPPLY_ALLOW_RESOURCE), + ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::RELEASE_EXEMPTION_RESOURCE), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("RemoveAllowList fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("ReleaseExemptionResource fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("RemoveAllowList fail: read result failed"); + STANDBYSERVICE_LOGW("ReleaseExemptionResource fail: read result failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("RemoveAllowList failed"); + STANDBYSERVICE_LOGW("ReleaseExemptionResource failed"); return result; } return result; } -ErrCode StandbyServiceProxy::GetAllowList(uint32_t allowType, std::vector& allowInfoList, +ErrCode StandbyServiceProxy::GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) { MessageParcel data; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; if (!data.WriteInterfaceToken(StandbyServiceProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("GetAllowList write descriptor failed"); + STANDBYSERVICE_LOGW("GetExemptedApps write descriptor failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - if (!data.WriteUint32(allowType) || !data.WriteUint32(reasonCode)) { - STANDBYSERVICE_LOGW("GetAllowList write parameter failed"); + if (!data.WriteUint32(resourceType) || !data.WriteUint32(reasonCode)) { + STANDBYSERVICE_LOGW("GetExemptedApps write parameter failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::GET_ALLOW_LIST), + ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::GET_EXEMPTED_APPS), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("GetAllowList fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("GetExemptedApps fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("GetAllowList fail: read result failed."); + STANDBYSERVICE_LOGW("GetExemptedApps fail: read result failed."); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("GetAllowList failed"); + STANDBYSERVICE_LOGW("GetExemptedApps failed"); return result; } uint32_t infoSize = reply.ReadUint32(); for (uint32_t i = 0; i < infoSize; i++) { - auto info = AllowInfo::Unmarshalling(reply); + auto info = ExemptedAppInfo::Unmarshalling(reply); if (info == nullptr) { - STANDBYSERVICE_LOGW("GetAllowList Read Parcelable infos failed."); + STANDBYSERVICE_LOGW("GetExemptedApps Read Parcelable infos failed."); return ERR_STANDBY_PARCELABLE_FAILED; } allowInfoList.emplace_back(*info); @@ -243,7 +243,7 @@ ErrCode StandbyServiceProxy::ReportWorkSchedulerStatus(bool started, int32_t uid MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; if (!data.WriteInterfaceToken(StandbyServiceProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("IsDeviceInStandby write descriptor failed"); + STANDBYSERVICE_LOGW("ReportWorkSchedulerStatus write descriptor failed"); return ERR_STANDBY_PARCELABLE_FAILED; } @@ -268,40 +268,40 @@ ErrCode StandbyServiceProxy::ReportWorkSchedulerStatus(bool started, int32_t uid return result; } -ErrCode StandbyServiceProxy::GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, +ErrCode StandbyServiceProxy::GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) { MessageParcel data; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; if (!data.WriteInterfaceToken(StandbyServiceProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("GetRestrictList write descriptor failed"); + STANDBYSERVICE_LOGW("GetRestrictedApps write descriptor failed"); return ERR_STANDBY_PARCELABLE_FAILED; } if (!data.WriteUint32(restrictType) || !data.WriteUint32(reasonCode)) { - STANDBYSERVICE_LOGW("GetRestrictList write parameter failed"); + STANDBYSERVICE_LOGW("GetRestrictedApps write parameter failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::GET_RESTRICT_LIST), + ErrCode result = InnerTransact(static_cast(IStandbyInterfaceCode::GET_RESTRICTED_APPS), option, data, reply); if (result != ERR_OK) { - STANDBYSERVICE_LOGW("GetRestrictList fail: transact ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("GetRestrictedApps fail: transact ErrCode=%{public}d", result); return ERR_STANDBY_TRANSACT_FAILED; } if (!reply.ReadInt32(result)) { - STANDBYSERVICE_LOGW("GetRestrictList fail: read result failed."); + STANDBYSERVICE_LOGW("GetRestrictedApps fail: read result failed."); return ERR_STANDBY_PARCELABLE_FAILED; } if (result != ERR_OK) { - STANDBYSERVICE_LOGW("GetRestrictList failed"); + STANDBYSERVICE_LOGW("GetRestrictedApps failed"); return result; } uint32_t infoSize = reply.ReadUint32(); for (uint32_t i = 0; i < infoSize; i++) { - auto info = AllowInfo::Unmarshalling(reply); + auto info = ExemptedAppInfo::Unmarshalling(reply); if (info == nullptr) { - STANDBYSERVICE_LOGW("GetRestrictList Read Parcelable infos failed."); + STANDBYSERVICE_LOGW("GetRestrictedApps Read Parcelable infos failed."); return ERR_STANDBY_PARCELABLE_FAILED; } restrictInfoList.emplace_back(*info); diff --git a/frameworks/src/standby_service_stub.cpp b/frameworks/src/standby_service_stub.cpp index 662a994695111f0cfb7c66556912a8980a646f02..78407144a9256cbccaec26ff743bde8f58f1372f 100644 --- a/frameworks/src/standby_service_stub.cpp +++ b/frameworks/src/standby_service_stub.cpp @@ -42,14 +42,14 @@ ErrCode StandbyServiceStub::OnRemoteRequest(uint32_t code, case static_cast(IStandbyInterfaceCode::UNSUBSCRIBE_STANDBY_CALLBACK): HandleUnsubscribeStandbyCallback(data, reply); break; - case static_cast(IStandbyInterfaceCode::APPLY_ALLOW_RESOURCE): - HandleApplyAllowResource(data, reply); + case static_cast(IStandbyInterfaceCode::REQUEST_EXEMPTION_RESOURCE): + HandleRequestExemptionResource(data, reply); break; - case static_cast(IStandbyInterfaceCode::UNAPPLY_ALLOW_RESOURCE): - HandleUnapplyAllowResource(data, reply); + case static_cast(IStandbyInterfaceCode::RELEASE_EXEMPTION_RESOURCE): + HandleReleaseExemptionResource(data, reply); break; - case static_cast(IStandbyInterfaceCode::GET_ALLOW_LIST): - HandleGetAllowList(data, reply); + case static_cast(IStandbyInterfaceCode::GET_EXEMPTED_APPS): + HandleGetExemptedApps(data, reply); break; case static_cast(IStandbyInterfaceCode::IS_DEVICE_IN_STANDBY): HandleIsDeviceInStandby(data, reply); @@ -57,8 +57,8 @@ ErrCode StandbyServiceStub::OnRemoteRequest(uint32_t code, case static_cast(IStandbyInterfaceCode::REPORT_WORK_SCHEDULER_STATUS): HandleReportWorkSchedulerStatus(data, reply); break; - case static_cast(IStandbyInterfaceCode::GET_RESTRICT_LIST): - HandleGetRestrictList(data, reply); + case static_cast(IStandbyInterfaceCode::GET_RESTRICTED_APPS): + HandleGetRestrictedApps(data, reply); break; case static_cast(IStandbyInterfaceCode::IS_STRATEGY_ENABLED): HandleIsStrategyEnabled(data, reply); @@ -109,22 +109,22 @@ ErrCode StandbyServiceStub::HandleReportWorkSchedulerStatus(MessageParcel& data, return ERR_OK; } -ErrCode StandbyServiceStub::HandleGetRestrictList(MessageParcel& data, MessageParcel& reply) +ErrCode StandbyServiceStub::HandleGetRestrictedApps(MessageParcel& data, MessageParcel& reply) { uint32_t restrictType {0}; uint32_t reasonCode {0}; if (!data.ReadUint32(restrictType) || !data.ReadUint32(reasonCode)) { - STANDBYSERVICE_LOGW("HandleGetRestrictList ReadParcelable failed"); + STANDBYSERVICE_LOGW("HandleGetRestrictedApps ReadParcelable failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - std::vector restrictInfoList {}; - ErrCode result = GetRestrictList(restrictType, restrictInfoList, reasonCode); + std::vector restrictInfoList {}; + ErrCode result = GetRestrictedApps(restrictType, restrictInfoList, reasonCode); if (!reply.WriteInt32(result)) { - STANDBYSERVICE_LOGW("HandleGetRestrictList Write result failed, ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("HandleGetRestrictedApps Write result failed, ErrCode=%{public}d", result); return ERR_STANDBY_PARCELABLE_FAILED; } if (!reply.WriteUint32(restrictInfoList.size())) { - STANDBYSERVICE_LOGW("HandleGetRestrictList Write result size failed"); + STANDBYSERVICE_LOGW("HandleGetRestrictedApps Write result size failed"); return ERR_STANDBY_PARCELABLE_FAILED; } for (auto& info : restrictInfoList) { @@ -171,52 +171,52 @@ ErrCode StandbyServiceStub::HandleUnsubscribeStandbyCallback(MessageParcel& data return ERR_OK; } -ErrCode StandbyServiceStub::HandleApplyAllowResource(MessageParcel& data, MessageParcel& reply) +ErrCode StandbyServiceStub::HandleRequestExemptionResource(MessageParcel& data, MessageParcel& reply) { auto resourceRequest = ResourceRequest::Unmarshalling(data); if (resourceRequest == nullptr) { - STANDBYSERVICE_LOGW("HandleApplyAllowResource ReadParcelable failed"); + STANDBYSERVICE_LOGW("HandleRequestExemptionResource ReadParcelable failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = ApplyAllowResource(resourceRequest); + ErrCode result = RequestExemptionResource(resourceRequest); if (!reply.WriteInt32(result)) { - STANDBYSERVICE_LOGW("HandleApplyAllowResource Write result failed, ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("HandleRequestExemptionResource Write result failed, ErrCode=%{public}d", result); return ERR_STANDBY_PARCELABLE_FAILED; } return ERR_OK; } -ErrCode StandbyServiceStub::HandleUnapplyAllowResource(MessageParcel& data, MessageParcel& reply) +ErrCode StandbyServiceStub::HandleReleaseExemptionResource(MessageParcel& data, MessageParcel& reply) { auto resourceRequest = ResourceRequest::Unmarshalling(data); if (resourceRequest == nullptr) { - STANDBYSERVICE_LOGW("HandleUnapplyAllowResource ReadParcelable failed"); + STANDBYSERVICE_LOGW("HandleReleaseExemptionResource ReadParcelable failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - ErrCode result = UnapplyAllowResource(resourceRequest); + ErrCode result = ReleaseExemptionResource(resourceRequest); if (!reply.WriteInt32(result)) { - STANDBYSERVICE_LOGW("HandleUnapplyAllowResource Write result failed, ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("HandleReleaseExemptionResource Write result failed, ErrCode=%{public}d", result); return ERR_STANDBY_PARCELABLE_FAILED; } return ERR_OK; } -ErrCode StandbyServiceStub::HandleGetAllowList(MessageParcel& data, MessageParcel& reply) +ErrCode StandbyServiceStub::HandleGetExemptedApps(MessageParcel& data, MessageParcel& reply) { - uint32_t allowType {0}; + uint32_t resourceType {0}; uint32_t reasonCode {0}; - if (!data.ReadUint32(allowType) || !data.ReadUint32(reasonCode)) { - STANDBYSERVICE_LOGW("HandleGetAllowList ReadParcelable failed"); + if (!data.ReadUint32(resourceType) || !data.ReadUint32(reasonCode)) { + STANDBYSERVICE_LOGW("HandleGetExemptedApps ReadParcelable failed"); return ERR_STANDBY_PARCELABLE_FAILED; } - std::vector allowInfoList {}; - ErrCode result = GetAllowList(allowType, allowInfoList, reasonCode); + std::vector allowInfoList {}; + ErrCode result = GetExemptedApps(resourceType, allowInfoList, reasonCode); if (!reply.WriteInt32(result)) { - STANDBYSERVICE_LOGW("HandleGetAllowList Write result failed, ErrCode=%{public}d", result); + STANDBYSERVICE_LOGW("HandleGetExemptedApps Write result failed, ErrCode=%{public}d", result); return ERR_STANDBY_PARCELABLE_FAILED; } if (!reply.WriteUint32(allowInfoList.size())) { - STANDBYSERVICE_LOGW("HandleGetAllowList Write result size failed"); + STANDBYSERVICE_LOGW("HandleGetExemptedApps Write result size failed"); return ERR_STANDBY_PARCELABLE_FAILED; } for (auto& info : allowInfoList) { diff --git a/frameworks/src/standby_service_subscriber_proxy.cpp b/frameworks/src/standby_service_subscriber_proxy.cpp index 9b11ff1789dceec276933934f995273d02269a0e..2613c67edee76150d92e9103e18d781d159541fe 100644 --- a/frameworks/src/standby_service_subscriber_proxy.cpp +++ b/frameworks/src/standby_service_subscriber_proxy.cpp @@ -27,7 +27,7 @@ StandbyServiceSubscriberProxy::StandbyServiceSubscriberProxy(const sptr(impl) {} StandbyServiceSubscriberProxy::~StandbyServiceSubscriberProxy() {} -void StandbyServiceSubscriberProxy::OnDeviceIdleMode(bool napped, bool sleeping) +void StandbyServiceSubscriberProxy::OnDeviceIdleMode(bool napped, bool isIdle) { sptr remote = Remote(); if (remote == nullptr) { @@ -40,7 +40,7 @@ void StandbyServiceSubscriberProxy::OnDeviceIdleMode(bool napped, bool sleeping) return; } - if (!data.WriteBool(napped) || !data.WriteBool(sleeping)) { + if (!data.WriteBool(napped) || !data.WriteBool(isIdle)) { STANDBYSERVICE_LOGW("OnDeviceIdleMode write parameter failed."); return; } @@ -54,32 +54,32 @@ void StandbyServiceSubscriberProxy::OnDeviceIdleMode(bool napped, bool sleeping) } } -void StandbyServiceSubscriberProxy::OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, +void StandbyServiceSubscriberProxy::OnExemptedAppsChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added) { sptr remote = Remote(); if (remote == nullptr) { - STANDBYSERVICE_LOGW("OnAllowListChanged remote is dead."); + STANDBYSERVICE_LOGW("OnExemptedAppsChanged remote is dead."); return; } MessageParcel data; if (!data.WriteInterfaceToken(StandbyServiceSubscriberProxy::GetDescriptor())) { - STANDBYSERVICE_LOGW("OnAllowListChanged write interface token failed."); + STANDBYSERVICE_LOGW("OnExemptedAppsChanged write interface token failed."); return; } if (!data.WriteInt32(uid) || !data.WriteString(name) || - !data.WriteUint32(allowType) || !data.WriteBool(added)) { - STANDBYSERVICE_LOGW("OnAllowListChanged write notification failed."); + !data.WriteUint32(resourceType) || !data.WriteBool(added)) { + STANDBYSERVICE_LOGW("OnExemptedAppsChanged write notification failed."); return; } MessageParcel reply; MessageOption option = {MessageOption::TF_ASYNC}; int32_t ret = remote->SendRequest( - static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED), data, reply, option); + static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED), data, reply, option); if (ret!= ERR_OK) { - STANDBYSERVICE_LOGE("OnAllowListChanged SendRequest failed, error code: %d", ret); + STANDBYSERVICE_LOGE("OnExemptedAppsChanged SendRequest failed, error code: %d", ret); } } } // namespace DevStandbyMgr diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 32468dad0e905e403f4c6e3d5fef968751d3a9dd..c87cbbbf9c477c8dade725b1fff470cac2a41335 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -21,9 +21,9 @@ config("standby_innerkits_public_config") { ohos_shared_library("standby_innerkits") { sources = [ - "src/allow_info.cpp", - "src/allow_type.cpp", - "src/resourcce_request.cpp", + "src/exempted_app_info.cpp", + "src/resource_type.cpp", + "src/resource_request.cpp", "src/standby_service_client.cpp", "src/standby_service_subscriber_stub.cpp", ] diff --git a/interfaces/innerkits/include/allow_info.h b/interfaces/innerkits/include/exempted_app_info.h similarity index 75% rename from interfaces/innerkits/include/allow_info.h rename to interfaces/innerkits/include/exempted_app_info.h index cbb3efa25d731ed860d55e99f7cc1cdeaf43d3ad..cb8bc27f626640746174eee27e5d071e77ef1468 100644 --- a/interfaces/innerkits/include/allow_info.h +++ b/interfaces/innerkits/include/exempted_app_info.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H -#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H +#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_EXEMPTED_APP_INFO_H +#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_EXEMPTED_APP_INFO_H #include #include @@ -22,10 +22,10 @@ #include "parcel.h" namespace OHOS { namespace DevStandbyMgr { -class AllowInfo : public Parcelable { +class ExemptedApp : public Parcelable { public: - AllowInfo() = default; - AllowInfo(uint32_t allowType, const std::string& name, int32_t duration) :allowType_(allowType), + ExemptedApp() = default; + ExemptedApp(uint32_t resourceType, const std::string& name, int32_t duration) :resourceType_(resourceType), name_(name), duration_(duration) {} /** @@ -34,7 +34,7 @@ public: * @param parcel Indicates the parcel object for unmarshalling. * @return The info of delay suspend. */ - static sptr Unmarshalling(Parcel& in); + static sptr Unmarshalling(Parcel& in); /** * @brief Marshals a purpose into a parcel. @@ -45,13 +45,13 @@ public: bool Marshalling(Parcel& out) const override; /** - * @brief Get the allow type used to represent resource type. + * @brief Get the resource type used to represent resource type. * - * @return the allow type. + * @return the resource type. */ - inline uint32_t GetAllowType() const + inline uint32_t GetResourceType() const { - return allowType_; + return resourceType_; } /** @@ -75,13 +75,13 @@ public: } /** - * @brief Set the allow type which represents the resources. + * @brief Set the resource type which represents the resources. * - * @param allowType represents allow type. + * @param resourceType represents exempted resource type. */ - inline void SetAllowType(uint32_t allowType) + inline void GetResourceType(uint32_t resourceType) { - allowType_ = allowType; + resourceType_ = resourceType; } /** @@ -106,10 +106,10 @@ public: private: bool ReadFromParcel(Parcel& in); - uint32_t allowType_; + uint32_t resourceType_; std::string name_; int32_t duration_; }; } // namespace DevStandbyMgr } // namespace OHOS -#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H \ No newline at end of file +#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_EXEMPTED_APP_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/include/resourcce_request.h b/interfaces/innerkits/include/resource_request.h similarity index 86% rename from interfaces/innerkits/include/resourcce_request.h rename to interfaces/innerkits/include/resource_request.h index 11ff865a17d981ec74fdd1dd899e1513a245dd46..a507fc8458581fb604c4a782262b465e43a7665a 100644 --- a/interfaces/innerkits/include/resourcce_request.h +++ b/interfaces/innerkits/include/resource_request.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_TYPE_H -#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_TYPE_H +#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_REQUEST_H +#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_REQUEST_H #include #include @@ -31,8 +31,8 @@ struct ReasonCodeEnum { class ResourceRequest : public Parcelable { public: ResourceRequest() = default; - ResourceRequest(uint32_t allowType, int32_t uid, const std::string& name, int32_t duration, - const std::string& reason, uint32_t reasonCode) : allowType_(allowType), uid_(uid), name_(name), + ResourceRequest(uint32_t resourceType, int32_t uid, const std::string& name, int32_t duration, + const std::string& reason, uint32_t reasonCode) : resourceType_(resourceType), uid_(uid), name_(name), duration_(duration), reason_(reason), reasonCode_(reasonCode) {} /** @@ -54,21 +54,21 @@ public: /** * @brief Get the uid of the resource request. * - * @return the allow type. + * @return the resource type. */ - inline uint32_t GetAllowType() const + inline uint32_t GetResourceType() const { - return allowType_; + return resourceType_; } /** - * @brief Set the allow type which represents the resources. + * @brief Set the resource type which represents the resources. * - * @param allowType represents allow type. + * @param resourceType represents exempted resource type. */ - inline void SetAllowType(uint32_t allowType) + inline void SetResourceType(uint32_t resourceType) { - allowType_ = allowType; + resourceType_ = resourceType; } /** @@ -174,7 +174,7 @@ public: private: bool ReadFromParcel(Parcel& in); - uint32_t allowType_; + uint32_t resourceType_; int32_t uid_; std::string name_; int32_t duration_; @@ -183,4 +183,4 @@ private: }; } // namespace DevStandbyMgr } // namespace OHOS -#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_TYPE_H \ No newline at end of file +#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_RESOURCE_REQUEST_H \ No newline at end of file diff --git a/interfaces/innerkits/include/allow_type.h b/interfaces/innerkits/include/resource_type.h similarity index 80% rename from interfaces/innerkits/include/allow_type.h rename to interfaces/innerkits/include/resource_type.h index 634db733cbe39f78a8ea77a63e9ba7479bf32803..82f5bcce8d7143a04481248f3987db8b86bd51a6 100644 --- a/interfaces/innerkits/include/allow_type.h +++ b/interfaces/innerkits/include/resource_type.h @@ -13,15 +13,15 @@ * limitations under the License. */ -#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_ALLOW_TYPE_H -#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_ALLOW_TYPE_H +#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_RESOURCE_TYPE_H +#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_RESOURCE_TYPE_H #include #include namespace OHOS { namespace DevStandbyMgr { -struct AllowType { +struct ResourceType{ enum : uint32_t { NETWORK = 1, RUNNING_LOCK = 1 << 1, @@ -33,9 +33,9 @@ struct AllowType { }; }; -extern const std::vector AllowTypeName; -extern const uint32_t MAX_ALLOW_TYPE_NUM; -extern const uint32_t MAX_ALLOW_TYPE_NUMBER; +extern const std::vector ResourceTypeName; +extern const uint32_t MAX_RESOURCE_TYPE_NUM; +extern const uint32_t MAX_RESOURCE_TYPE_NUMBER; } // namespace DevStandbyMgr } // namespace OHOS -#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_ALLOW_TYPE_H \ No newline at end of file +#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_INCLUDE_RESOURCE_TYPE_H \ No newline at end of file diff --git a/interfaces/innerkits/include/standby_service_client.h b/interfaces/innerkits/include/standby_service_client.h index 8d86c909767fa43b02c5be920e4426cd3b04d08b..0b8f0364660efc51ce0da17bc2ccb46ca8049885 100644 --- a/interfaces/innerkits/include/standby_service_client.h +++ b/interfaces/innerkits/include/standby_service_client.h @@ -51,30 +51,30 @@ public: ErrCode UnsubscribeStandbyCallback(const sptr& subscriber); /** - * @brief add allow list for some services or apps. + * @brief request exemption resource for some services or apps. * * @param resourceRequest resource to be added. * @return ErrCode ERR_OK if success, others if fail. */ - ErrCode ApplyAllowResource(const sptr& resourceRequest); + ErrCode RequestExemptionResource(const sptr& resourceRequest); /** - * @brief remove uid with allow type from allow list. + * @brief remove exemption resource of uid from exemption record. * * @param resourceRequest resource to be removed. * @return ErrCode ErrCode ERR_OK if success, others if fail. */ - ErrCode UnapplyAllowResource(const sptr& resourceRequest); + ErrCode ReleaseExemptionResource(const sptr& resourceRequest); /** * @brief Get the Allow List object. * - * @param allowType the allow type to be retrieved. - * @param allowInfoList result represents allowed types and apps. + * @param resourceType the exempted resoruce type to be retrieved. + * @param exemptedAppList result represents exempted types and apps. * @param reasonCode represents the reason why invoke the api. * @return ErrCode ERR_OK if success, else fail. */ - ErrCode GetAllowList(uint32_t allowType, std::vector& allowInfoList, + ErrCode GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode); /** @@ -85,7 +85,7 @@ public: * @param reasonCode represents the reason why invoke the api. * @return ErrCode ERR_OK if success, others if fail. */ - ErrCode GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, + ErrCode GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode); /** diff --git a/interfaces/innerkits/include/standby_service_subscriber_stub.h b/interfaces/innerkits/include/standby_service_subscriber_stub.h index 3c6aa82a30524682e31d93a27a6db2aef61ae9cd..5d81651431908d1555bdc8d095e240a252c6968e 100644 --- a/interfaces/innerkits/include/standby_service_subscriber_stub.h +++ b/interfaces/innerkits/include/standby_service_subscriber_stub.h @@ -39,11 +39,11 @@ public: * @return ERR_OK if success, else fail. */ int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - void OnDeviceIdleMode(bool napped, bool sleeping) override; - void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) override; + void OnDeviceIdleMode(bool napped, bool isIdle) override; + void OnExemptedAppsChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added) override; private: ErrCode HandleOnDeviceIdleMode(MessageParcel& data); - ErrCode HandleOnAllowListChanged(MessageParcel& data); + ErrCode HandleOnExemptedAppsChanged(MessageParcel& data); ErrCode OnRemoteRequestInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option); diff --git a/interfaces/innerkits/include/standby_state.h b/interfaces/innerkits/include/standby_state.h index ff6147afecf0d23a7f040995e292cd326dea4115..0bde040c647af3213d59204744576e3c955c5dc0 100644 --- a/interfaces/innerkits/include/standby_state.h +++ b/interfaces/innerkits/include/standby_state.h @@ -24,7 +24,7 @@ struct StandbyState { DARK = 1, NAP, MAINTENANCE, - SLEEP, + IDLE, }; }; @@ -37,7 +37,7 @@ struct NapStatePhase { }; }; -struct SleepStatePhase { +struct IdleStatePhase { enum : uint32_t { SYS_RES_DEEP = 0, APP_RES_DEEP, diff --git a/interfaces/innerkits/libstandby_innerkits.versionscript b/interfaces/innerkits/libstandby_innerkits.versionscript index 1dde55995d9065d6dc35e73419979091dc59aa3e..27498cae5f7a203c1051c3a15098b298f1180e50 100644 --- a/interfaces/innerkits/libstandby_innerkits.versionscript +++ b/interfaces/innerkits/libstandby_innerkits.versionscript @@ -13,19 +13,19 @@ 1.0 { global: - *AllowInfo*; + *ExemptedApp*; *AllowType*; - *AllowTypeName*; - *MAX_ALLOW_TYPE_NUM*; + *ResourceTypeName*; + *MAX_RESOURCE_TYPE_NUM*; *BackgroundTaskSubscriber*; - *MAX_ALLOW_TYPE_NUMBER*; + *MAX_RESOURCE_TYPE_NUMBER*; *ReasonCodeEnum*; *ResourceRequest*; *StandbyServiceClient*; *StandbyServiceSubscriberStub*; *StandbyState*; *NapStatePhase*; - *SleepStatePhase*; + *IdleStatePhase*; local: *; }; diff --git a/interfaces/innerkits/src/allow_info.cpp b/interfaces/innerkits/src/exempted_app_info.cpp similarity index 73% rename from interfaces/innerkits/src/allow_info.cpp rename to interfaces/innerkits/src/exempted_app_info.cpp index f77f0a61ea534d354554c1c8bf2133fa48fe1702..3fd97a74db6e219a5ef8c7a1fea0de90723cbfb1 100644 --- a/interfaces/innerkits/src/allow_info.cpp +++ b/interfaces/innerkits/src/exempted_app_info.cpp @@ -13,23 +13,23 @@ * limitations under the License. */ -#include "allow_info.h" +#include "exempted_app_info.h" #include "ipc_util.h" #include "standby_service_log.h" namespace OHOS { namespace DevStandbyMgr { -bool AllowInfo::Marshalling(Parcel& out) const +bool ExemptedAppInfo::Marshalling(Parcel& out) const { - WRITE_PARCEL_WITH_RET(out, Uint32, allowType_, false); + WRITE_PARCEL_WITH_RET(out, Uint32, resourceType_, false); WRITE_PARCEL_WITH_RET(out, String, name_, false); WRITE_PARCEL_WITH_RET(out, Int32, duration_, false); return true; } -sptr AllowInfo::Unmarshalling(Parcel& in) +sptr ExemptedAppInfo::Unmarshalling(Parcel& in) { - sptr info = new (std::nothrow) AllowInfo(); + sptr info = new (std::nothrow) ExemptedAppInfo(); if (info != nullptr && !info->ReadFromParcel(in)) { STANDBYSERVICE_LOGE("read from parcel failed"); info = nullptr; @@ -37,9 +37,9 @@ sptr AllowInfo::Unmarshalling(Parcel& in) return info; } -bool AllowInfo::ReadFromParcel(Parcel& in) +bool ExemptedAppInfo::ReadFromParcel(Parcel& in) { - READ_PARCEL_WITH_RET(in, Uint32, allowType_, false); + READ_PARCEL_WITH_RET(in, Uint32, resourceType_, false); READ_PARCEL_WITH_RET(in, String, name_, false); READ_PARCEL_WITH_RET(in, Int32, duration_, false); return true; diff --git a/interfaces/innerkits/src/resourcce_request.cpp b/interfaces/innerkits/src/resource_request.cpp similarity index 90% rename from interfaces/innerkits/src/resourcce_request.cpp rename to interfaces/innerkits/src/resource_request.cpp index 9a874b0d899c96e9a07b3a5e69bdcbc497a9d875..8257b01e5df0a0cc6cc32ae83dc7d3b0a02c47dd 100644 --- a/interfaces/innerkits/src/resourcce_request.cpp +++ b/interfaces/innerkits/src/resource_request.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "resourcce_request.h" +#include "resource_request.h" #include "ipc_util.h" #include "standby_service_log.h" @@ -22,7 +22,7 @@ namespace OHOS { namespace DevStandbyMgr { bool ResourceRequest::Marshalling(Parcel& out) const { - WRITE_PARCEL_WITH_RET(out, Uint32, allowType_, false); + WRITE_PARCEL_WITH_RET(out, Uint32, resourceType_, false); WRITE_PARCEL_WITH_RET(out, Int32, uid_, false); WRITE_PARCEL_WITH_RET(out, String, name_, false); WRITE_PARCEL_WITH_RET(out, Int32, duration_, false); @@ -43,7 +43,7 @@ sptr ResourceRequest::Unmarshalling(Parcel& in) bool ResourceRequest::ReadFromParcel(Parcel& in) { - READ_PARCEL_WITH_RET(in, Uint32, allowType_, false); + READ_PARCEL_WITH_RET(in, Uint32, resourceType_, false); READ_PARCEL_WITH_RET(in, Int32, uid_, false); READ_PARCEL_WITH_RET(in, String, name_, false); READ_PARCEL_WITH_RET(in, Int32, duration_, false); diff --git a/interfaces/innerkits/src/allow_type.cpp b/interfaces/innerkits/src/resource_type.cpp similarity index 76% rename from interfaces/innerkits/src/allow_type.cpp rename to interfaces/innerkits/src/resource_type.cpp index 1a03a122bfa64f9051a58d0f4aeebf6aede12a64..f207f679a8a3b0fe182d96d58551e80a3550b097 100644 --- a/interfaces/innerkits/src/allow_type.cpp +++ b/interfaces/innerkits/src/resource_type.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "allow_type.h" +#include "resource_type.h" namespace OHOS { namespace DevStandbyMgr { -const std::vector AllowTypeName = { +const std::vector ResourceTypeName = { "NETWORK", "RUNNING_LOCK", "TIMER", @@ -26,7 +26,7 @@ const std::vector AllowTypeName = { "PUSH", "FREEZE" }; -const uint32_t MAX_ALLOW_TYPE_NUM = AllowTypeName.size(); -const uint32_t MAX_ALLOW_TYPE_NUMBER = (1 << MAX_ALLOW_TYPE_NUM) - 1; +const uint32_t MAX_RESOURCE_TYPE_NUM = ResourceTypeName.size(); +const uint32_t MAX_RESOURCE_TYPE_NUMBER = (1 << MAX_RESOURCE_TYPE_NUM) - 1; } // namespace DevStandbyMgr } // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/src/standby_service_client.cpp b/interfaces/innerkits/src/standby_service_client.cpp index 240e7f0cb79b3ff927977c3d699f107db2268ccf..e1ae15fb81100f78569655a1e757a579f0a0bbce 100644 --- a/interfaces/innerkits/src/standby_service_client.cpp +++ b/interfaces/innerkits/src/standby_service_client.cpp @@ -63,7 +63,7 @@ ErrCode StandbyServiceClient::UnsubscribeStandbyCallback(const sptrUnsubscribeStandbyCallback(subscriber); } -ErrCode StandbyServiceClient::ApplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceClient::RequestExemptionResource(const sptr& resourceRequest) { std::lock_guard lock(mutex_); if (!GetStandbyServiceProxy()) { @@ -74,10 +74,10 @@ ErrCode StandbyServiceClient::ApplyAllowResource(const sptr& re STANDBYSERVICE_LOGE("resource request is nullptr"); return ERR_STANDBY_INVALID_PARAM; } - return standbyServiceProxy_->ApplyAllowResource(resourceRequest); + return standbyServiceProxy_->RequestExemptionResource(resourceRequest); } -ErrCode StandbyServiceClient::UnapplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceClient::ReleaseExemptionResource(const sptr& resourceRequest) { std::lock_guard lock(mutex_); if (!GetStandbyServiceProxy()) { @@ -88,10 +88,10 @@ ErrCode StandbyServiceClient::UnapplyAllowResource(const sptr& STANDBYSERVICE_LOGE("resource request is nullptr"); return ERR_STANDBY_INVALID_PARAM; } - return standbyServiceProxy_->UnapplyAllowResource(resourceRequest); + return standbyServiceProxy_->ReleaseExemptionResource(resourceRequest); } -ErrCode StandbyServiceClient::GetAllowList(uint32_t allowType, std::vector& allowInfoArray, +ErrCode StandbyServiceClient::GetExemptedApps(uint32_t resourceType, std::vector& allowInfoArray, uint32_t reasonCode) { std::lock_guard lock(mutex_); @@ -103,7 +103,7 @@ ErrCode StandbyServiceClient::GetAllowList(uint32_t allowType, std::vectorGetAllowList(allowType, allowInfoArray, reasonCode); + return standbyServiceProxy_->GetExemptedApps(resourceType, allowInfoArray, reasonCode); } ErrCode StandbyServiceClient::IsDeviceInStandby(bool& isStandby) @@ -126,7 +126,7 @@ ErrCode StandbyServiceClient::ReportWorkSchedulerStatus(bool started, int32_t ui return standbyServiceProxy_->ReportWorkSchedulerStatus(started, uid, bundleName); } -ErrCode StandbyServiceClient::GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, +ErrCode StandbyServiceClient::GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) { std::lock_guard lock(mutex_); @@ -138,7 +138,7 @@ ErrCode StandbyServiceClient::GetRestrictList(uint32_t restrictType, std::vector STANDBYSERVICE_LOGW("restrict info array is not empty"); restrictInfoList.clear(); } - return standbyServiceProxy_->GetRestrictList(restrictType, restrictInfoList, reasonCode); + return standbyServiceProxy_->GetRestrictedApps(restrictType, restrictInfoList, reasonCode); } ErrCode StandbyServiceClient::IsStrategyEnabled(const std::string& strategyName, bool& isEnabled) diff --git a/interfaces/innerkits/src/standby_service_subscriber_stub.cpp b/interfaces/innerkits/src/standby_service_subscriber_stub.cpp index a708d431188ae2c94e92fdee22009dcbf2ad1d6a..cf2eea63be3eb390f663b913faf8e3cb03450f76 100644 --- a/interfaces/innerkits/src/standby_service_subscriber_stub.cpp +++ b/interfaces/innerkits/src/standby_service_subscriber_stub.cpp @@ -46,8 +46,8 @@ ErrCode StandbyServiceSubscriberStub::OnRemoteRequestInner(uint32_t code, case (static_cast(StandbySubscriberInterfaceCode::ON_DEVICE_IDLE_MODE)): { return HandleOnDeviceIdleMode(data); } - case (static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED)): { - return HandleOnAllowListChanged(data); + case (static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED)): { + return HandleOnExemptedAppsChanged(data); } default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -58,7 +58,7 @@ ErrCode StandbyServiceSubscriberStub::OnRemoteRequestInner(uint32_t code, void StandbyServiceSubscriberStub::OnDeviceIdleMode(bool napped, bool sleeped) {} -void StandbyServiceSubscriberStub::OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, +void StandbyServiceSubscriberStub::OnExemptedAppsChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added) {} @@ -74,18 +74,18 @@ ErrCode StandbyServiceSubscriberStub::HandleOnDeviceIdleMode(MessageParcel& data return ERR_OK; } -ErrCode StandbyServiceSubscriberStub::HandleOnAllowListChanged(MessageParcel& data) +ErrCode StandbyServiceSubscriberStub::HandleOnExemptedAppsChanged(MessageParcel& data) { int32_t uid {0}; std::string name; - uint32_t allowType {0}; + uint32_t resourceType {0}; bool added {false}; if (!data.ReadInt32(uid) || !data.ReadString(name) || - !data.ReadUint32(allowType) || !data.ReadBool(added)) { - STANDBYSERVICE_LOGW("HandleOnAllowListChanged Read parcel failed."); + !data.ReadUint32(resourceType) || !data.ReadBool(added)) { + STANDBYSERVICE_LOGW("HandleOnExemptedAppsChanged Read parcel failed."); return ERR_INVALID_DATA; } - OnAllowListChanged(uid, name, allowType, added); + OnExemptedAppsChanged(uid, name, resourceType, added); return ERR_OK; } } // namespace DevStandbyMgr diff --git a/interfaces/innerkits/test/unittest/mock_standby_client_unit_test.cpp b/interfaces/innerkits/test/unittest/mock_standby_client_unit_test.cpp index 40299818afb779aab1f936ce7ef690e30bbd3357..3668d2a3a67a6e4ebdc24bbb953d072b40a90e1d 100644 --- a/interfaces/innerkits/test/unittest/mock_standby_client_unit_test.cpp +++ b/interfaces/innerkits/test/unittest/mock_standby_client_unit_test.cpp @@ -20,7 +20,7 @@ #include "gtest/gtest.h" #include "singleton.h" -#include "allow_type.h" +#include "resource_type.h" #include "standby_service_client.h" #include "standby_service_subscriber_stub.h" using namespace testing::ext; @@ -50,12 +50,12 @@ HWTEST_F(StandbyServiceClientUnitTest, MockStandbyServiceClientUnitTest_001, Tes EXPECT_NE(StandbyServiceClient::GetInstance().SubscribeStandbyCallback(nullSubscriber), ERR_OK); EXPECT_NE(StandbyServiceClient::GetInstance().UnsubscribeStandbyCallback(nullSubscriber), ERR_OK); sptr nullRequest = nullptr; - EXPECT_NE(StandbyServiceClient::GetInstance().ApplyAllowResource(nullRequest), ERR_OK); - EXPECT_NE(StandbyServiceClient::GetInstance().UnapplyAllowResource(nullRequest), ERR_OK); - std::vector allowInfoList; + EXPECT_NE(StandbyServiceClient::GetInstance().RequestExemptionResource(nullRequest), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().ReleaseExemptionResource(nullRequest), ERR_OK); + std::vector allowInfoList; nullRequest = nullptr; - EXPECT_NE(StandbyServiceClient::GetInstance().GetAllowList(AllowType::NETWORK, allowInfoList, 0), ERR_OK); - EXPECT_NE(StandbyServiceClient::GetInstance().GetAllowList(0, allowInfoList, 0), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().GetExemptedApps(AllowType::NETWORK, allowInfoList, 0), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().GetExemptedApps(0, allowInfoList, 0), ERR_OK); bool isStandby {false}; EXPECT_NE(StandbyServiceClient::GetInstance().IsDeviceInStandby(isStandby), ERR_OK); StandbyServiceClient::GetInstance().ReportWorkSchedulerStatus(false, -1, ""); @@ -79,10 +79,10 @@ HWTEST_F(StandbyServiceClientUnitTest, MockStandbyServiceClientUnitTest_002, Tes EXPECT_NE(proxy->SubscribeStandbyCallback(subscriber), ERR_OK); EXPECT_NE(proxy->UnsubscribeStandbyCallback(subscriber), ERR_OK); sptr resouarceRequest = new (std::nothrow) ResourceRequest(); - EXPECT_NE(proxy->ApplyAllowResource(resouarceRequest), ERR_OK); - EXPECT_NE(proxy->UnapplyAllowResource(resouarceRequest), ERR_OK); - std::vector allowInfoList; - EXPECT_NE(proxy->GetAllowList(0, allowInfoList, 0), ERR_OK); + EXPECT_NE(proxy->RequestExemptionResource(resouarceRequest), ERR_OK); + EXPECT_NE(proxy->ReleaseExemptionResource(resouarceRequest), ERR_OK); + std::vector allowInfoList; + EXPECT_NE(proxy->GetExemptedApps(0, allowInfoList, 0), ERR_OK); bool isStandby {false}; proxy->IsDeviceInStandby(isStandby); proxy->ReportWorkSchedulerStatus(false, -1, ""); @@ -90,9 +90,9 @@ HWTEST_F(StandbyServiceClientUnitTest, MockStandbyServiceClientUnitTest_002, Tes MockSendRequest(false); EXPECT_NE(proxy->SubscribeStandbyCallback(subscriber), ERR_OK); EXPECT_NE(proxy->UnsubscribeStandbyCallback(subscriber), ERR_OK); - EXPECT_NE(proxy->ApplyAllowResource(resouarceRequest), ERR_OK); - EXPECT_NE(proxy->UnapplyAllowResource(resouarceRequest), ERR_OK); - EXPECT_NE(proxy->GetAllowList(0, allowInfoList, 0), ERR_OK); + EXPECT_NE(proxy->RequestExemptionResource(resouarceRequest), ERR_OK); + EXPECT_NE(proxy->ReleaseExemptionResource(resouarceRequest), ERR_OK); + EXPECT_NE(proxy->GetExemptedApps(0, allowInfoList, 0), ERR_OK); proxy->IsDeviceInStandby(isStandby); proxy->ReportWorkSchedulerStatus(false, -1, ""); } diff --git a/interfaces/innerkits/test/unittest/standby_client_unit_test.cpp b/interfaces/innerkits/test/unittest/standby_client_unit_test.cpp index 94c81c28544295ce70db61957f6edd6f12196f27..f928f31245820b9f14e25e9ded3797991abf2e91 100644 --- a/interfaces/innerkits/test/unittest/standby_client_unit_test.cpp +++ b/interfaces/innerkits/test/unittest/standby_client_unit_test.cpp @@ -20,9 +20,9 @@ #include "gtest/gtest.h" #include "singleton.h" -#include "allow_type.h" +#include "resource_type.h" #include "istandby_service.h" -#include "resourcce_request.h" +#include "resource_request.h" #include "standby_ipc_interface_code.h" #include "standby_service_client.h" #include "standby_service_subscriber_stub.h" @@ -61,24 +61,24 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_001, TestSiz /** * @tc.name: StandbyServiceClientUnitTest_002 - * @tc.desc: test ApplyAllowResource. + * @tc.desc: test RequestExemptionResource. * @tc.type: FUNC * @tc.require: */ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_002, TestSize.Level1) { sptr nullRequest = nullptr; - EXPECT_NE(StandbyServiceClient::GetInstance().ApplyAllowResource(nullRequest), ERR_OK); - EXPECT_NE(StandbyServiceClient::GetInstance().UnapplyAllowResource(nullRequest), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().RequestExemptionResource(nullRequest), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().ReleaseExemptionResource(nullRequest), ERR_OK); sptr resouarceRequest = new (std::nothrow) ResourceRequest(); - EXPECT_NE(StandbyServiceClient::GetInstance().ApplyAllowResource(resouarceRequest), ERR_OK); - EXPECT_NE(StandbyServiceClient::GetInstance().UnapplyAllowResource(resouarceRequest), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().RequestExemptionResource(resouarceRequest), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().ReleaseExemptionResource(resouarceRequest), ERR_OK); sptr validResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, 0, "test_process", 100, "test", 1); - EXPECT_EQ(StandbyServiceClient::GetInstance().ApplyAllowResource(validResRequest), ERR_OK); - EXPECT_EQ(StandbyServiceClient::GetInstance().UnapplyAllowResource(validResRequest), ERR_OK); + EXPECT_EQ(StandbyServiceClient::GetInstance().RequestExemptionResource(validResRequest), ERR_OK); + EXPECT_EQ(StandbyServiceClient::GetInstance().ReleaseExemptionResource(validResRequest), ERR_OK); } /** @@ -89,13 +89,13 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_002, TestSiz */ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_003, TestSize.Level1) { - std::vector allowInfoList; + std::vector allowInfoList; sptr nullRequest = nullptr; - EXPECT_EQ(StandbyServiceClient::GetInstance().GetAllowList(AllowType::NETWORK, allowInfoList, 0), ERR_OK); - EXPECT_NE(StandbyServiceClient::GetInstance().GetAllowList(0, allowInfoList, 0), ERR_OK); - EXPECT_EQ(StandbyServiceClient::GetInstance().GetAllowList((1 << 6), allowInfoList, 0), ERR_OK); - allowInfoList.emplace_back(AllowInfo {}); - StandbyServiceClient::GetInstance().GetAllowList((1 << 6), allowInfoList, 0); + EXPECT_EQ(StandbyServiceClient::GetInstance().GetExemptedApps(AllowType::NETWORK, allowInfoList, 0), ERR_OK); + EXPECT_NE(StandbyServiceClient::GetInstance().GetExemptedApps(0, allowInfoList, 0), ERR_OK); + EXPECT_EQ(StandbyServiceClient::GetInstance().GetExemptedApps((1 << 6), allowInfoList, 0), ERR_OK); + allowInfoList.emplace_back(ExemptedApp {}); + StandbyServiceClient::GetInstance().GetExemptedApps((1 << 6), allowInfoList, 0); } /** @@ -119,7 +119,7 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_004, TestSiz HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_005, TestSize.Level1) { MessageParcel data; - EXPECT_EQ(AllowInfo::Unmarshalling(data), nullptr); + EXPECT_EQ(ExemptedAppInfo::Unmarshalling(data), nullptr); EXPECT_EQ(ResourceRequest::Unmarshalling(data), nullptr); } @@ -151,28 +151,28 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_007, TestSiz MessageParcel reply {}; MessageOption option {}; subscriber->OnRemoteRequestInner( - (static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED)), data, reply, option); + (static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED)), data, reply, option); subscriber->OnRemoteRequestInner( - (static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED)) + 1, data, reply, option); + (static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED)) + 1, data, reply, option); EXPECT_NE(subscriber->HandleOnDeviceIdleMode(data), ERR_OK); - subscriber->HandleOnAllowListChanged(data); + subscriber->HandleOnExemptedAppsChanged(data); data.WriteBool(false); subscriber->HandleOnDeviceIdleMode(data); data.WriteBool(false); subscriber->HandleOnDeviceIdleMode(data); - subscriber->HandleOnAllowListChanged(data); + subscriber->HandleOnExemptedAppsChanged(data); MessageParcel allowListData {}; - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); allowListData.WriteInt32(0); - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); allowListData.WriteInt32(0); - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); allowListData.WriteString(""); - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); allowListData.WriteUint32(0); - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); allowListData.WriteBool(false); - subscriber->HandleOnAllowListChanged(allowListData); + subscriber->HandleOnExemptedAppsChanged(allowListData); } /** @@ -215,7 +215,7 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_010, TestSiz sptr proxy = new (std::nothrow) StandbyServiceSubscriberProxy(impl); sptr nullSubscriber = nullptr; proxy->OnDeviceIdleMode(false, false); - proxy->OnAllowListChanged(-1, "", 0, false); + proxy->OnExemptedAppsChanged(-1, "", 0, false); EXPECT_NE(proxy, nullptr); } @@ -254,9 +254,9 @@ HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_012, TestSiz HWTEST_F(StandbyServiceClientUnitTest, StandbyServiceClientUnitTest_013, TestSize.Level1) { uint32_t restrictType = 1; - std::vector restrictInfoList; + std::vector restrictInfoList; uint32_t reasonCode = ReasonCodeEnum::REASON_APP_API; - EXPECT_EQ(StandbyServiceClient::GetInstance().GetRestrictList(restrictType, restrictInfoList, reasonCode), ERR_OK); + EXPECT_EQ(StandbyServiceClient::GetInstance().GetRestrictedApps(restrictType, restrictInfoList, reasonCode), ERR_OK); } } // namespace DevStandbyMgr } // namespace OHOS diff --git a/interfaces/kits/napi/include/standby_napi_module.h b/interfaces/kits/napi/include/standby_napi_module.h index accc14a8c41d07dfd5e5e8f367ba4e81ee01ef2c..d0515e40616a835624a73dbbf8ac879e842160b9 100644 --- a/interfaces/kits/napi/include/standby_napi_module.h +++ b/interfaces/kits/napi/include/standby_napi_module.h @@ -22,9 +22,9 @@ namespace OHOS { namespace DevStandbyMgr { -napi_value ApplyAllowResource(napi_env env, napi_callback_info info); +napi_value RequestExemptionResource(napi_env env, napi_callback_info info); -napi_value UnapplyAllowResource(napi_env env, napi_callback_info info); +napi_value ReleaseExemptionResource(napi_env env, napi_callback_info info); napi_value IsDeviceInStandby(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/src/init.cpp b/interfaces/kits/napi/src/init.cpp index eec5e4348003bffd696c651b704b105615b383ec..5d4602d7677319b58a9817078546272c85268723 100644 --- a/interfaces/kits/napi/src/init.cpp +++ b/interfaces/kits/napi/src/init.cpp @@ -15,7 +15,7 @@ #include "init.h" -#include "allow_type.h" +#include "resource_type.h" #include "common.h" #include "standby_napi_module.h" @@ -28,8 +28,8 @@ napi_value DeviceStandbyFuncInit(napi_env env, napi_value exports) napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("isDeviceInStandby", IsDeviceInStandby), DECLARE_NAPI_FUNCTION("getExemptedApps", GetExemptionListApps), - DECLARE_NAPI_FUNCTION("requestExemptionResource", ApplyAllowResource), - DECLARE_NAPI_FUNCTION("releaseExemptionResource", UnapplyAllowResource), + DECLARE_NAPI_FUNCTION("requestExemptionResource", RequestExemptionResource), + DECLARE_NAPI_FUNCTION("releaseExemptionResource", ReleaseExemptionResource), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); diff --git a/interfaces/kits/napi/src/standby_napi_module.cpp b/interfaces/kits/napi/src/standby_napi_module.cpp index cb4ff48a25ec36fe6ce867ab678a3209f95b55f5..dd8879fb725fb0e8060e57337cd1af76d748b5f1 100644 --- a/interfaces/kits/napi/src/standby_napi_module.cpp +++ b/interfaces/kits/napi/src/standby_napi_module.cpp @@ -20,9 +20,9 @@ #include "napi_base_context.h" #include "singleton.h" -#include "allow_info.h" -#include "allow_type.h" -#include "resourcce_request.h" +#include "exempted_app_info.h" +#include "resource_type.h" +#include "resource_request.h" #include "standby_service_log.h" #include "standby_service_client.h" @@ -33,9 +33,9 @@ namespace DevStandbyMgr { namespace { constexpr uint32_t IS_DEVICE_IN_STANDBY_MIN_PARAMS = 0; constexpr uint32_t IS_DEVICE_IN_STANDBY_PARAMS = 1; -constexpr uint32_t GET_ALLOW_LIST_MIN_PARAMS = 1; -constexpr uint32_t GET_ALLOW_LIST_STANDBY_PARAMS = 2; -constexpr uint32_t APPLY_ALLOW_RESOURCE_PARAMS = 1; +constexpr uint32_t GET_EXEMPTED_APPS_MIN_PARAMS = 1; +constexpr uint32_t GET_EXEMPTED_APPS_STANDBY_PARAMS = 2; +constexpr uint32_t REQUEST_EXEMPTION_RESOURCE_PARAMS = 1; } struct AsyncCallbackInfoIsDeviceInStandby : public AsyncWorkData { @@ -125,31 +125,31 @@ napi_value IsDeviceInStandby(napi_env env, napi_callback_info info) return promise; } -struct AsyncCallbackInfoGetAllowList : public AsyncWorkData { - explicit AsyncCallbackInfoGetAllowList(napi_env env) : AsyncWorkData(env) {} - uint32_t allowType = 0; - std::vector allowInfoArray {}; +struct AsyncCallbackInfoGetExemptedApps : public AsyncWorkData { + explicit AsyncCallbackInfoGetExemptedApps(napi_env env) : AsyncWorkData(env) {} + uint32_t resourceType = 0; + std::vector allowInfoArray {}; }; struct GetAllowListParamsInfo { - uint32_t allowType = 0; + uint32_t resourceType = 0; napi_ref callback = nullptr; }; void AddGetAllowListExecuteCB(napi_env env, void *data) { - AsyncCallbackInfoGetAllowList *asyncCallbackInfo = - static_cast(data); + AsyncCallbackInfoGetExemptedApps *asyncCallbackInfo = + static_cast(data); if (asyncCallbackInfo != nullptr) { - asyncCallbackInfo->errCode = StandbyServiceClient::GetInstance().GetAllowList( - asyncCallbackInfo->allowType, asyncCallbackInfo->allowInfoArray, ReasonCodeEnum::REASON_APP_API); + asyncCallbackInfo->errCode = StandbyServiceClient::GetInstance().GetExemptedApps( + asyncCallbackInfo->resourceType, asyncCallbackInfo->allowInfoArray, ReasonCodeEnum::REASON_APP_API); } } void AddGetAllowListCallbackCompleteCB(napi_env env, napi_status status, void *data) { - AsyncCallbackInfoGetAllowList *asyncCallbackInfo = - static_cast(data); + AsyncCallbackInfoGetExemptedApps *asyncCallbackInfo = + static_cast(data); std::unique_ptr callbackPtr {asyncCallbackInfo}; if (asyncCallbackInfo != nullptr) { napi_value result = nullptr; @@ -158,7 +158,7 @@ void AddGetAllowListCallbackCompleteCB(napi_env env, napi_status status, void *d for (const auto& allowInfo : asyncCallbackInfo->allowInfoArray) { napi_value allowInfoObj = nullptr; napi_create_object(env, &allowInfoObj); - Common::SetUint32Value(env, "resourceTypes", static_cast(allowInfo.GetAllowType()), allowInfoObj); + Common::SetUint32Value(env, "resourceTypes", static_cast(allowInfo.GetResourceType()), allowInfoObj); Common::SetStringValue(env, "name", allowInfo.GetName(), allowInfoObj); Common::SetInt32Value(env, "duration", allowInfo.GetDuration(), allowInfoObj); napi_set_element(env, result, index, allowInfoObj); @@ -172,23 +172,23 @@ void AddGetAllowListCallbackCompleteCB(napi_env env, napi_status status, void *d napi_value ParseGetAllowListParameters(const napi_env& env, const napi_callback_info& info, GetAllowListParamsInfo& params) { - size_t argc = GET_ALLOW_LIST_STANDBY_PARAMS; - napi_value argv[GET_ALLOW_LIST_STANDBY_PARAMS] = {nullptr}; + size_t argc = GET_EXEMPTED_APPS_STANDBY_PARAMS; + napi_value argv[GET_EXEMPTED_APPS_STANDBY_PARAMS] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - if (argc != GET_ALLOW_LIST_MIN_PARAMS && argc != GET_ALLOW_LIST_STANDBY_PARAMS) { + if (argc != GET_EXEMPTED_APPS_MIN_PARAMS && argc != GET_EXEMPTED_APPS_STANDBY_PARAMS) { Common::HandleParamErr(env, ERR_PARAM_NUMBER_ERR); return nullptr; } - // argv[0]: allowType - if (Common::GetUint32Value(env, argv[0], params.allowType) == nullptr) { - STANDBYSERVICE_LOGE("ParseParameters failed, allowType is nullptr."); + // argv[0]: resourceType + if (Common::GetUint32Value(env, argv[0], params.resourceType) == nullptr) { + STANDBYSERVICE_LOGE("ParseParameters failed, resourceType is nullptr."); Common::HandleParamErr(env, ERR_RESOURCE_TYPES_INVALID); return nullptr; } // argv[1]: callback - if (argc == GET_ALLOW_LIST_STANDBY_PARAMS) { + if (argc == GET_EXEMPTED_APPS_STANDBY_PARAMS) { napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[1], &valuetype)); if (valuetype != napi_function) { @@ -198,7 +198,7 @@ napi_value ParseGetAllowListParameters(const napi_env& env, const napi_callback_ NAPI_CALL(env, napi_create_reference(env, argv[1], 1, ¶ms.callback)); } - if (params.allowType == 0) { + if (params.resourceType == 0) { Common::HandleParamErr(env, ERR_RESOURCE_TYPES_INVALID); return nullptr; } @@ -214,13 +214,13 @@ napi_value GetExemptionListApps(napi_env env, napi_callback_info info) } napi_value promise = nullptr; - AsyncCallbackInfoGetAllowList *asyncCallbackInfo = - new (std::nothrow) AsyncCallbackInfoGetAllowList(env); + AsyncCallbackInfoGetExemptedApps *asyncCallbackInfo = + new (std::nothrow) AsyncCallbackInfoGetExemptedApps(env); if (!asyncCallbackInfo) { return nullptr; } std::unique_ptr callbackPtr {asyncCallbackInfo}; - asyncCallbackInfo->allowType = params.allowType; + asyncCallbackInfo->resourceType = params.resourceType; Common::PaddingAsyncWorkData(env, params.callback, *asyncCallbackInfo, promise); napi_value resourceName = nullptr; @@ -241,21 +241,21 @@ napi_value GetExemptionListApps(napi_env env, napi_callback_info info) napi_value ParseAllowResParameters(const napi_env &env, const napi_callback_info &info, sptr &resourceRequest) { - size_t argc = APPLY_ALLOW_RESOURCE_PARAMS; - napi_value argv[APPLY_ALLOW_RESOURCE_PARAMS] = {nullptr}; + size_t argc = REQUEST_EXEMPTION_RESOURCE_PARAMS; + napi_value argv[REQUEST_EXEMPTION_RESOURCE_PARAMS] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - if (argc != APPLY_ALLOW_RESOURCE_PARAMS) { + if (argc != REQUEST_EXEMPTION_RESOURCE_PARAMS) { Common::HandleParamErr(env, ERR_PARAM_NUMBER_ERR); return nullptr; } - int32_t allowType {0}; + int32_t resourceType {0}; int32_t uid {0}; std::string name {}; int32_t duration {0}; std::string reason {}; - if (!Common::GetNamedInt32Value(env, argv[0], "resourceTypes", allowType) || allowType <= 0 - || static_cast(allowType) > MAX_ALLOW_TYPE_NUMBER) { + if (!Common::GetNamedInt32Value(env, argv[0], "resourceTypes", resourceType) || resourceType <= 0 + || static_cast(resourceType) > MAX_RESOURCE_TYPE_NUMBER) { Common::HandleParamErr(env, ERR_RESOURCE_TYPES_INVALID); return nullptr; } @@ -275,29 +275,29 @@ napi_value ParseAllowResParameters(const napi_env &env, const napi_callback_info Common::HandleParamErr(env, ERR_REASON_INVALID_TYPE_ERR); return nullptr; } - resourceRequest = new (std::nothrow) ResourceRequest(allowType, uid, + resourceRequest = new (std::nothrow) ResourceRequest(resourceType, uid, name, duration, reason, ReasonCodeEnum::REASON_APP_API); return Common::NapiGetNull(env); } -napi_value ApplyAllowResource(napi_env env, napi_callback_info info) +napi_value RequestExemptionResource(napi_env env, napi_callback_info info) { sptr resourceRequest {}; if (ParseAllowResParameters(env, info, resourceRequest) == nullptr) { return Common::NapiGetNull(env); } - ErrCode errCode = StandbyServiceClient::GetInstance().ApplyAllowResource(resourceRequest); + ErrCode errCode = StandbyServiceClient::GetInstance().RequestExemptionResource(resourceRequest); Common::HandleErrCode(env, errCode); return Common::NapiGetNull(env); } -napi_value UnapplyAllowResource(napi_env env, napi_callback_info info) +napi_value ReleaseExemptionResource(napi_env env, napi_callback_info info) { sptr resourceRequest {}; if (ParseAllowResParameters(env, info, resourceRequest) == nullptr) { return Common::NapiGetNull(env); } - ErrCode errCode = StandbyServiceClient::GetInstance().UnapplyAllowResource(resourceRequest); + ErrCode errCode = StandbyServiceClient::GetInstance().ReleaseExemptionResource(resourceRequest); Common::HandleErrCode(env, errCode); return Common::NapiGetNull(env); } diff --git a/plugins/BUILD.gn b/plugins/BUILD.gn index 542cebd7df2a940374a5d57d00b7b4bb5bde26a0..72a75fe154cb129f497db759150487f5ed4189f5 100644 --- a/plugins/BUILD.gn +++ b/plugins/BUILD.gn @@ -41,7 +41,7 @@ ohos_shared_library("standby_plugin") { "${standby_service_standby_state_path}/src/export_plugin.cpp", "${standby_service_standby_state_path}/src/maintenance_state.cpp", "${standby_service_standby_state_path}/src/nap_state.cpp", - "${standby_service_standby_state_path}/src/sleep_state.cpp", + "${standby_service_standby_state_path}/src/idle_state.cpp", "${standby_service_standby_state_path}/src/state_manager_adapter.cpp", "${standby_service_standby_state_path}/src/working_state.cpp", "${standby_service_strategy_path}/src/base_network_strategy.cpp", diff --git a/plugins/extend_constraints/src/constraint_manager_adapter.cpp b/plugins/extend_constraints/src/constraint_manager_adapter.cpp index 487cb96765987d3111c9fabf63c07335fdc2bbcb..99c8bdd6548cfaedd61f8e7c8d46f868527a2ae7 100644 --- a/plugins/extend_constraints/src/constraint_manager_adapter.cpp +++ b/plugins/extend_constraints/src/constraint_manager_adapter.cpp @@ -32,14 +32,14 @@ bool ConstraintManagerAdapter::Init() } constraintMonitorList_.emplace_back(std::make_shared()); if (StandbyConfigManager::GetInstance()->GetStandbySwitch(DETECT_MOTION_CONFIG)) { - ConstraintEvalParam motionDetectParams{StandbyState::NAP, NapStatePhase::END, StandbyState::SLEEP, - SleepStatePhase::SYS_RES_DEEP}; + ConstraintEvalParam motionDetectParams{StandbyState::NAP, NapStatePhase::END, StandbyState::IDLE, + IdleStatePhase::SYS_RES_DEEP}; motionConstraint_ = std::make_shared(MOTION_DETECTION_TIMEOUT, REST_TIMEOUT, TOTAL_TIMEOUT, motionDetectParams); constraintMonitorList_.emplace_back(motionConstraint_); - ConstraintEvalParam repeatedMotionParams{StandbyState::SLEEP, SleepStatePhase::END, StandbyState::SLEEP, - SleepStatePhase::END}; + ConstraintEvalParam repeatedMotionParams{StandbyState::IDLE, IdleStatePhase::END, StandbyState::IDLE, + IdleStatePhase::END}; repeatedMotionParams.isRepeatedDetection_ = true; repeatedMotionConstraint_ = std::make_shared(PERIODLY_TASK_DECTION_TIMEOUT, PERIODLY_TASK_REST_TIMEOUT, PERIODLY_TASK_TOTAL_TIMEOUT, repeatedMotionParams); diff --git a/plugins/libstandby_plugin.versionscript b/plugins/libstandby_plugin.versionscript new file mode 100644 index 0000000000000000000000000000000000000000..0dde5d924211214f8b48119bcfce398c52eea485 --- /dev/null +++ b/plugins/libstandby_plugin.versionscript @@ -0,0 +1,48 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +1.0 { + global: + *OnPluginRegister*; + *CalculateMaintTimeOut*; + *StandbyMessage*; + *IBaseStrategy*; + *IConstraintManagerAdapter*; + *IListenerManagerAdapter*; + *IStateManagerAdapter*; + *IStrategyManagerAdapter*; + *ChargeStateMonitor*; + *ConstraintManagerAdapter*; + *MotionSensorMonitor*; + *ExemptionTypeFlag*; + *BaseNetworkStrategy*; + *NetworkStrategy*; + *StateManagerAdapter*; + *RunningLockStrategy*; + *BaseState*; + *WorkingState*; + *DarkState*; + *NapState*; + *IdleState*; + *MaintenanceState*; + *HandleEvent*; + *StartListener*; + *StopListener*; + *OnCreated*; + *OnDestroy*; + *ShellDump*; + *Init*; + *UnInit*; + local: + *; +}; \ No newline at end of file diff --git a/plugins/standby_state/include/sleep_state.h b/plugins/standby_state/include/idle_state.h similarity index 86% rename from plugins/standby_state/include/sleep_state.h rename to plugins/standby_state/include/idle_state.h index c87b29baef930213c238e893ec03cd036f3662cf..59888da3d3531374cf78479a1a8b80c4fb21e72f 100644 --- a/plugins/standby_state/include/sleep_state.h +++ b/plugins/standby_state/include/idle_state.h @@ -12,17 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_SLEEP_STATE_H -#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_SLEEP_STATE_H +#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_IDLE_STATE_H +#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_IDLE_STATE_H #include "base_state.h" namespace OHOS { namespace DevStandbyMgr { class IStateManagerAdapter; -class SleepState : public BaseState, public StateWithMaint, public std::enable_shared_from_this { +class IdleState : public BaseState, public StateWithMaint, public std::enable_shared_from_this { public: - SleepState(uint32_t curState, uint32_t curPhase, const std::shared_ptr& + IdleState(uint32_t curState, uint32_t curPhase, const std::shared_ptr& stateManager, std::shared_ptr& handler); ErrCode Init(const std::shared_ptr& statePtr) override; ErrCode UnInit() override; @@ -45,4 +45,4 @@ private: }; } // namespace DevStandbyMgr } // namespace OHOS -#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_SLEEP_STATE_H \ No newline at end of file +#endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_SERVICES_CORE_INCLUDE_IDLE_STATE_H \ No newline at end of file diff --git a/plugins/standby_state/include/nap_state.h b/plugins/standby_state/include/nap_state.h index 2930ac3d5543ab7fc4090d0809bcfab1f28f8b26..5a45b3067b167937d720c4885a7bf55ed97c791f 100644 --- a/plugins/standby_state/include/nap_state.h +++ b/plugins/standby_state/include/nap_state.h @@ -33,7 +33,7 @@ protected: bool IsInFinalPhase() override; private: void SetPhaseTransitTask(bool evalResult); - void HandleEvalResToSleepState(bool evalResult); + void HandleEvalResToIdleState(bool evalResult); }; } // namespace DevStandbyMgr } // namespace OHOS diff --git a/plugins/standby_state/include/state_manager_adapter.h b/plugins/standby_state/include/state_manager_adapter.h index f39e7add292d071ab82d42824c50a69e2cb6f026..08ece52e22024fe7051dd96468940f799cdc6f09 100644 --- a/plugins/standby_state/include/state_manager_adapter.h +++ b/plugins/standby_state/include/state_manager_adapter.h @@ -60,7 +60,7 @@ private: std::shared_ptr darkStatePtr_ {nullptr}; std::shared_ptr maintStatePtr_ {nullptr}; std::shared_ptr napStatePtr_ {nullptr}; - std::shared_ptr sleepStatePtr_ {nullptr}; + std::shared_ptr idleStatePtr_ {nullptr}; std::shared_ptr workingStatePtr_ {nullptr}; std::vector> indexToState_ {}; }; diff --git a/plugins/standby_state/src/dark_state.cpp b/plugins/standby_state/src/dark_state.cpp index 2436c1243f6ebdc2e3b59ebc68fe9033d9f50314..6ac2058c40a19d721a131785d3f79bf80589947a 100644 --- a/plugins/standby_state/src/dark_state.cpp +++ b/plugins/standby_state/src/dark_state.cpp @@ -35,7 +35,7 @@ DarkState::DarkState(uint32_t curState, uint32_t curPhase, const std::shared_ptr if (StandbyConfigManager::GetInstance()->GetStandbySwitch(NAP_SWITCH)) { nextState_ = StandbyState::NAP; } else if (StandbyConfigManager::GetInstance()->GetStandbySwitch(SLEEP_SWITCH)) { - nextState_ = StandbyState::SLEEP; + nextState_ = StandbyState::IDLE; } } diff --git a/plugins/standby_state/src/sleep_state.cpp b/plugins/standby_state/src/idle_state.cpp similarity index 74% rename from plugins/standby_state/src/sleep_state.cpp rename to plugins/standby_state/src/idle_state.cpp index 9cc7d59d06130a48aaca5eb08b46745c08f81fba..e160a91c851b7eeba3a2dba286a5792c22d3f792 100644 --- a/plugins/standby_state/src/sleep_state.cpp +++ b/plugins/standby_state/src/idle_state.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "sleep_state.h" +#include "idle_state.h" #include #include "itimer_info.h" @@ -34,7 +34,7 @@ namespace { constexpr int32_t DUMP_REPEAT_DETECTION_TIMEOUT = 100; } -SleepState::SleepState(uint32_t curState, uint32_t curPhase, const std::shared_ptr& +IdleState::IdleState(uint32_t curState, uint32_t curPhase, const std::shared_ptr& stateManager, std::shared_ptr& handler): BaseState(curState, curPhase, stateManager, handler) { @@ -42,7 +42,7 @@ SleepState::SleepState(uint32_t curState, uint32_t curPhase, const std::shared_p nextState_ = StandbyState::MAINTENANCE; } -ErrCode SleepState::Init(const std::shared_ptr& statePtr) +ErrCode IdleState::Init(const std::shared_ptr& statePtr) { auto callbackTask = [statePtr]() { statePtr->StartTransitNextState(statePtr); }; enterStandbyTimerId_ = TimedTask::CreateTimer(false, 0, true, true, callbackTask); @@ -54,7 +54,7 @@ ErrCode SleepState::Init(const std::shared_ptr& statePtr) if (!StandbyConfigManager::GetInstance()->GetStandbySwitch(DETECT_MOTION_CONFIG)) { return ERR_OK; } - auto callback = [sleepState = shared_from_this()]() { sleepState->StartPeriodlyMotionDetection(); }; + auto callback = [idleState = shared_from_this()]() { idleState->StartPeriodlyMotionDetection(); }; repeatedDetectionTimerId_ = TimedTask::CreateTimer(true, REPEATED_MOTION_DETECTION_INTERVAL, true, false, callback); if (repeatedDetectionTimerId_ == 0) { STANDBYSERVICE_LOGE("%{public}s init failed", STATE_NAME_LIST[GetCurState()].c_str()); @@ -64,14 +64,14 @@ ErrCode SleepState::Init(const std::shared_ptr& statePtr) return ERR_OK; } -void SleepState::StartPeriodlyMotionDetection() +void IdleState::StartPeriodlyMotionDetection() { - handler_->PostTask([sleepState = shared_from_this()]() { - sleepState->isRepeatedDetection_ = true; - ConstraintEvalParam params{sleepState->curState_, sleepState->curPhase_, - sleepState->curState_, sleepState->curPhase_}; + handler_->PostTask([idleState = shared_from_this()]() { + idleState->isRepeatedDetection_ = true; + ConstraintEvalParam params{idleState->curState_, idleState->curPhase_, + idleState->curState_, idleState->curPhase_}; params.isRepeatedDetection_ = true; - auto stateManagerPtr = sleepState->stateManager_.lock(); + auto stateManagerPtr = idleState->stateManager_.lock(); if (!stateManagerPtr) { return; } @@ -79,7 +79,7 @@ void SleepState::StartPeriodlyMotionDetection() }, REPEATED_MOTION_DETECTION_TASK); } -ErrCode SleepState::UnInit() +ErrCode IdleState::UnInit() { BaseState::UnInit(); isRepeatedDetection_ = false; @@ -87,7 +87,7 @@ ErrCode SleepState::UnInit() return ERR_OK; } -ErrCode SleepState::BeginState() +ErrCode IdleState::BeginState() { auto stateManagerPtr = stateManager_.lock(); if (!stateManagerPtr) { @@ -105,31 +105,31 @@ ErrCode SleepState::BeginState() } maintIntervalIndex_ = 0; - curPhase_ = SleepStatePhase::SYS_RES_DEEP; + curPhase_ = IdleStatePhase::SYS_RES_DEEP; maintIntervalTimeOut = CalculateMaintTimeOut(stateManagerPtr, true); - handler_->PostTask([sleepState = shared_from_this()]() { + handler_->PostTask([idleState = shared_from_this()]() { BaseState::AcquireStandbyRunningLock(); - sleepState->TransitToPhase(sleepState->curPhase_, sleepState->curPhase_ + 1); + idleState->TransitToPhase(idleState->curPhase_, idleState->curPhase_ + 1); }, TRANSIT_NEXT_PHASE_INSTANT_TASK); StartStateTransitionTimer(maintIntervalTimeOut); CheckScrenOffHalfHour(); return ERR_OK; } -void SleepState::TryToEnterNextPhase(const std::shared_ptr& stateManagerPtr, +void IdleState::TryToEnterNextPhase(const std::shared_ptr& stateManagerPtr, int32_t retryTimeOut) { if (stateManagerPtr->IsEvalution()) { STANDBYSERVICE_LOGW("state is in evalution, postpone to enter next phase"); - handler_->PostTask([sleepState = shared_from_this(), stateManagerPtr, retryTimeOut]() { - sleepState->TryToEnterNextPhase(stateManagerPtr, retryTimeOut); + handler_->PostTask([idleState = shared_from_this(), stateManagerPtr, retryTimeOut]() { + idleState->TryToEnterNextPhase(stateManagerPtr, retryTimeOut); }, TRANSIT_NEXT_PHASE_INSTANT_TASK, retryTimeOut); - } else if (curPhase_ < SleepStatePhase::END) { + } else if (curPhase_ < IdleStatePhase::END) { TransitToPhase(curPhase_, curPhase_ + 1); } } -ErrCode SleepState::EndState() +ErrCode IdleState::EndState() { StopTimedTask(TRANSIT_NEXT_STATE_TIMED_TASK); StopTimedTask(REPEATED_MOTION_DETECTION_TASK); @@ -139,7 +139,7 @@ ErrCode SleepState::EndState() return ERR_OK; } -bool SleepState::CheckTransitionValid(uint32_t nextState) +bool IdleState::CheckTransitionValid(uint32_t nextState) { if (nextState == StandbyState::NAP) { STANDBYSERVICE_LOGE("can not transit from sleep to nap"); @@ -148,14 +148,14 @@ bool SleepState::CheckTransitionValid(uint32_t nextState) return true; } -void SleepState::EndEvalCurrentState(bool evalResult) +void IdleState::EndEvalCurrentState(bool evalResult) { auto stateManagerPtr = stateManager_.lock(); if (!stateManagerPtr) { STANDBYSERVICE_LOGW("state manager is nullptr, cannot end eval sleep state"); return; } - if (curPhase_ < SleepStatePhase::END) { + if (curPhase_ < IdleStatePhase::END) { if (evalResult) { TransitToPhaseInner(curPhase_, curPhase_ + 1); } @@ -168,12 +168,12 @@ void SleepState::EndEvalCurrentState(bool evalResult) isRepeatedDetection_ = false; } -void SleepState::SetPhaseTransitOrRepeatedTask() +void IdleState::SetPhaseTransitOrRepeatedTask() { curPhase_ += 1; - if (curPhase_ < SleepStatePhase::END) { - handler_->PostTask([sleepState = shared_from_this()]() { - sleepState->TransitToPhase(sleepState->curPhase_, sleepState->curPhase_ + 1); + if (curPhase_ < IdleStatePhase::END) { + handler_->PostTask([idleState = shared_from_this()]() { + idleState->TransitToPhase(idleState->curPhase_, idleState->curPhase_ + 1); }, TRANSIT_NEXT_PHASE_INSTANT_TASK); } else { BaseState::ReleaseStandbyRunningLock(); @@ -185,21 +185,21 @@ void SleepState::SetPhaseTransitOrRepeatedTask() } } -void SleepState::ShellDump(const std::vector& argsInStr, std::string& result) +void IdleState::ShellDump(const std::vector& argsInStr, std::string& result) { if (argsInStr[DUMP_FIRST_PARAM] == DUMP_SIMULATE_SENSOR) { if (argsInStr[DUMP_SECOND_PARAM] == "--repeat") { StartPeriodlyMotionDetection(); - handler_->PostTask([sleepState = shared_from_this()]() { + handler_->PostTask([idleState = shared_from_this()]() { STANDBYSERVICE_LOGD("after 100ms, stop sensor"); - sleepState->stateManager_.lock()->EndEvalCurrentState(false); + idleState->stateManager_.lock()->EndEvalCurrentState(false); }, DUMP_REPEAT_DETECTION_TIMEOUT); result += "finished start repeated sensor\n"; } } } -void SleepState::CheckScrenOffHalfHour() +void IdleState::CheckScrenOffHalfHour() { auto stateManagerPtr = stateManager_.lock(); if (!stateManagerPtr) { @@ -212,9 +212,9 @@ void SleepState::CheckScrenOffHalfHour() } } -bool SleepState::IsInFinalPhase() +bool IdleState::IsInFinalPhase() { - return curPhase_ == SleepStatePhase::END; + return curPhase_ == IdleStatePhase::END; } } // namespace DevStandbyMgr } // namespace OHOS \ No newline at end of file diff --git a/plugins/standby_state/src/nap_state.cpp b/plugins/standby_state/src/nap_state.cpp index d9e937bbf442e333205fb62b23f48c3be21e302a..11b1e3252b2a2ced07118a3f208c90cc36b8f4ad 100644 --- a/plugins/standby_state/src/nap_state.cpp +++ b/plugins/standby_state/src/nap_state.cpp @@ -55,7 +55,7 @@ ErrCode NapState::BeginState() maintIntervalIndex_ = 0; curPhase_ = NapStatePhase::CONNECTION; if (StandbyConfigManager::GetInstance()->GetStandbySwitch(SLEEP_SWITCH)) { - nextState_ = StandbyState::SLEEP; + nextState_ = StandbyState::IDLE; int64_t napTimeOut = std::min(TimeConstant::MSEC_PER_SEC * StandbyConfigManager::GetInstance()-> GetStandbyParam(NAP_TIMEOUT), TimeProvider::GetNapTimeOut()); StartStateTransitionTimer(napTimeOut); @@ -83,7 +83,7 @@ bool NapState::CheckTransitionValid(uint32_t nextState) void NapState::EndEvalCurrentState(bool evalResult) { if (curPhase_ == NapStatePhase::END) { - HandleEvalResToSleepState(evalResult); + HandleEvalResToIdleState(evalResult); return; } SetPhaseTransitTask(evalResult); @@ -104,7 +104,7 @@ void NapState::SetPhaseTransitTask(bool evalResult) } } -void NapState::HandleEvalResToSleepState(bool evalResult) +void NapState::HandleEvalResToIdleState(bool evalResult) { auto stateManagerPtr = stateManager_.lock(); if (!stateManagerPtr) { @@ -113,7 +113,7 @@ void NapState::HandleEvalResToSleepState(bool evalResult) if (!evalResult) { stateManagerPtr->TransitToState(StandbyState::WORKING); } else if (nextState_ != StandbyState::NAP) { - stateManagerPtr->TransitToStateInner(StandbyState::SLEEP); + stateManagerPtr->TransitToStateInner(StandbyState::IDLE); } } diff --git a/plugins/standby_state/src/state_manager_adapter.cpp b/plugins/standby_state/src/state_manager_adapter.cpp index 6e8adfcabd396ab427480bcc2578ee965b5e9d29..1bfc0ed890c8f57ef155b0e84bd73afd44c10141 100644 --- a/plugins/standby_state/src/state_manager_adapter.cpp +++ b/plugins/standby_state/src/state_manager_adapter.cpp @@ -24,7 +24,7 @@ #include "dark_state.h" #include "maintenance_state.h" #include "nap_state.h" -#include "sleep_state.h" +#include "idle_state.h" #include "working_state.h" namespace OHOS { @@ -41,9 +41,9 @@ bool StateManagerAdapter::Init() darkStatePtr_ = std::make_shared(StandbyState::DARK, 0, stateManager, handler_); napStatePtr_ = std::make_shared(StandbyState::NAP, 0, stateManager, handler_); maintStatePtr_ = std::make_shared(StandbyState::MAINTENANCE, 0, stateManager, handler_); - sleepStatePtr_ = std::make_shared(StandbyState::SLEEP, 0, stateManager, handler_); + idleStatePtr_ = std::make_shared(StandbyState::IDLE, 0, stateManager, handler_); indexToState_ = { - workingStatePtr_, darkStatePtr_, napStatePtr_, maintStatePtr_, sleepStatePtr_ + workingStatePtr_, darkStatePtr_, napStatePtr_, maintStatePtr_, idleStatePtr_ }; auto callbackTask = [this]() { this->OnScreenOffHalfHour(true, false); }; scrOffHalfHourTimerId_ = TimedTask::CreateTimer(false, 0, true, false, callbackTask); @@ -150,10 +150,10 @@ void StateManagerAdapter::HandleOpenCloseLid(const StandbyMessage& message) { if (message.action_ == LID_OPEN) { TransitToState(StandbyState::WORKING); - } else if (message.action_ == LID_CLOSE && (curStatePtr_->GetCurState() != StandbyState::SLEEP && + } else if (message.action_ == LID_CLOSE && (curStatePtr_->GetCurState() != StandbyState::IDLE && curStatePtr_->GetCurState() != StandbyState::MAINTENANCE)) { UnblockCurrentState(); - TransitToStateInner(StandbyState::SLEEP); + TransitToStateInner(StandbyState::IDLE); } } @@ -293,7 +293,7 @@ void StateManagerAdapter::OnScreenOffHalfHourInner(bool scrOffHalfHourCtrl, bool uint32_t preState = preStatePtr_->GetCurState(); STANDBYSERVICE_LOGD("screen off half hour, cur state is %{public}s, pre state is %{public}s", STATE_NAME_LIST[curState].c_str(), STATE_NAME_LIST[preState].c_str()); - if (scrOffHalfHourCtrl && !(curState == StandbyState::SLEEP || (preState == StandbyState::SLEEP && + if (scrOffHalfHourCtrl && !(curState == StandbyState::IDLE || (preState == StandbyState::IDLE && curState == StandbyState::MAINTENANCE))) { return; } @@ -370,7 +370,7 @@ void StateManagerAdapter::DumpActivateMotion(const std::vector& arg } else if (argsInStr[DUMP_SECOND_PARAM] == "--powersave") { STANDBYSERVICE_LOGD("after 3000ms, start powersavenetwork"); UnblockCurrentState(); - TransitToStateInner(StandbyState::SLEEP); + TransitToStateInner(StandbyState::IDLE); OnScreenOffHalfHourInner(true, true); StandbyServiceImpl::GetInstance()->ShellDumpInner({"-D", "--strategy", "powersave"}, result); } diff --git a/plugins/strategy/src/base_network_strategy.cpp b/plugins/strategy/src/base_network_strategy.cpp index 10adc0ba4810acdb4f442b6cd31f69c9585d5357..f9dba5c574cab34e16fd2c84e9a02911cb617550 100644 --- a/plugins/strategy/src/base_network_strategy.cpp +++ b/plugins/strategy/src/base_network_strategy.cpp @@ -25,7 +25,7 @@ #include "background_task_helper.h" #include "app_mgr_helper.h" #include "standby_service.h" -#include "allow_type.h" +#include "resource_type.h" #include "standby_state.h" #include "bundle_manager_helper.h" #include "net_policy_client.h" @@ -86,9 +86,9 @@ ErrCode BaseNetworkStrategy::OnDestroy() ErrCode BaseNetworkStrategy::UpdateExemptionList(const StandbyMessage& message) { - uint32_t allowType = static_cast(message.want_->GetIntParam("allowType", 0)); - if ((allowType & AllowType::NETWORK) == 0) { - STANDBYSERVICE_LOGD("allowType is not network, currentType is %{public}d", allowType); + uint32_t resourceType = static_cast(message.want_->GetIntParam("resourceType", 0)); + if ((resourceType & AllowType::NETWORK) == 0) { + STANDBYSERVICE_LOGD("resourceType is not network, currentType is %{public}d", resourceType); return ERR_STANDBY_STRATEGY_NOT_MATCH; } if (!isFirewallEnabled_) { @@ -259,7 +259,7 @@ void BaseNetworkStrategy::AddExemptionFlagByUid(int32_t uid, uint8_t flag) ErrCode BaseNetworkStrategy::GetExemptionConfig() { // if app in exemption list, add exemption flag - std::vector allowInfoList {}; + std::vector allowInfoList {}; StandbyServiceImpl::GetInstance()->GetAllowListInner(AllowType::NETWORK, allowInfoList, ReasonCodeEnum::REASON_APP_API); std::set allowNameList {}; @@ -288,7 +288,7 @@ ErrCode BaseNetworkStrategy::GetExemptionConfig() ErrCode BaseNetworkStrategy::GetExemptionConfigForApp(NetLimtedAppInfo& appInfo, const std::string& bundleName) { // if app in exemption list, add exemption flag - std::vector allowInfoList {}; + std::vector allowInfoList {}; StandbyServiceImpl::GetInstance()->GetAllowListInner(AllowType::NETWORK, allowInfoList, ReasonCodeEnum::REASON_APP_API); std::set allowNameList {}; @@ -332,15 +332,15 @@ ErrCode BaseNetworkStrategy::DisableNetworkFirewall(const StandbyMessage& messag } uint32_t preState = static_cast(message.want_->GetIntParam(PREVIOUS_STATE, 0)); uint32_t curState = static_cast(message.want_->GetIntParam(CURRENT_STATE, 0)); - if ((curState == StandbyState::MAINTENANCE) && (preState == StandbyState::SLEEP)) { + if ((curState == StandbyState::MAINTENANCE) && (preState == StandbyState::IDLE)) { // restart net limit mode SetFirewallStatus(false); isIdleMaintence_ = true; - } else if ((curState == StandbyState::SLEEP) && (preState == StandbyState::MAINTENANCE)) { + } else if ((curState == StandbyState::IDLE) && (preState == StandbyState::MAINTENANCE)) { isIdleMaintence_ = false; // stop net limit mode SetFirewallStatus(true); - } else if (preState == StandbyState::SLEEP || preState == StandbyState::MAINTENANCE) { + } else if (preState == StandbyState::IDLE || preState == StandbyState::MAINTENANCE) { DisableNetworkFirewallInner(); isIdleMaintence_ = false; isFirewallEnabled_ = false; diff --git a/plugins/strategy/src/network_strategy.cpp b/plugins/strategy/src/network_strategy.cpp index e8ac62ab97faab4cb17a946358442a07f10747d9..4adda0bd18ba8282d4c2b0c7e889ec18d01ab459 100644 --- a/plugins/strategy/src/network_strategy.cpp +++ b/plugins/strategy/src/network_strategy.cpp @@ -20,7 +20,7 @@ #include "istandby_service.h" #include "standby_service_log.h" #include "net_policy_client.h" - + namespace OHOS { namespace DevStandbyMgr { ErrCode NetworkStrategy::OnCreated() @@ -30,7 +30,7 @@ ErrCode NetworkStrategy::OnCreated() ResetFirewallAllowList(); return ERR_OK; } - + ErrCode NetworkStrategy::OnDestroy() { STANDBYSERVICE_LOGI("NetworkStrategy is now OnDestroy"); @@ -98,7 +98,7 @@ void NetworkStrategy::StartNetLimit(const StandbyMessage& message) STANDBYSERVICE_LOGD("enter NetworkStrategy StartNetLimit, eventId is %{public}d", message.eventId_); uint32_t current_phase = static_cast(message.want_->GetIntParam(CURRENT_PHASE, 0)); uint32_t current_state = static_cast(message.want_->GetIntParam(CURRENT_STATE, 0)); - if ((current_state != StandbyState::SLEEP) || (current_phase != SleepStatePhase::APP_RES_DEEP)) { + if ((current_state != StandbyState::IDLE) || (current_phase != IdleStatePhase::APP_RES_DEEP)) { STANDBYSERVICE_LOGD("current state is not SLEEP or current phase is not APP_RES_DEEP!"); return; } @@ -141,7 +141,7 @@ ErrCode NetworkStrategy::SetFirewallStatus(bool enableFirewall) SetNetAllowApps(enableFirewall); return ERR_OK; } - + void NetworkStrategy::ShellDump(const std::vector& argsInStr, std::string& result) { STANDBYSERVICE_LOGD("enter NetworkStrategy::ShellDump"); diff --git a/plugins/strategy/src/running_lock_strategy.cpp b/plugins/strategy/src/running_lock_strategy.cpp index 79ab11371d61b42ece12a4c36a745ab7fc5664c2..a0ef44bc1ea7cf103332b6b14f1a37e7105c0f26 100644 --- a/plugins/strategy/src/running_lock_strategy.cpp +++ b/plugins/strategy/src/running_lock_strategy.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "running_lock_strategy.h" #include #include "standby_service_log.h" @@ -25,12 +25,12 @@ #include "power_mgr_client.h" #include "workscheduler_srv_client.h" -#include "allow_type.h" +#include "resource_type.h" #include "standby_state.h" #include "bundle_manager_helper.h" #include "standby_service_impl.h" #include "common_constant.h" - + namespace OHOS { namespace DevStandbyMgr { namespace { @@ -71,13 +71,13 @@ void RunningLockStrategy::HandleEvent(const StandbyMessage& message) break; } } - + ErrCode RunningLockStrategy::OnCreated() { PowerMgr::PowerMgrClient::GetInstance().ResetRunningLocks(); return ERR_OK; } - + ErrCode RunningLockStrategy::OnDestroy() { if (isProxied_ && !isIdleMaintence_) { @@ -90,9 +90,9 @@ ErrCode RunningLockStrategy::OnDestroy() ErrCode RunningLockStrategy::UpdateExemptionList(const StandbyMessage& message) { - uint32_t allowType = static_cast(message.want_->GetIntParam("allowType", 0)); - if ((allowType & AllowType::RUNNING_LOCK) == 0) { - STANDBYSERVICE_LOGD("allowType is not running lock, currentType is %{public}d", allowType); + uint32_t resourceType = static_cast(message.want_->GetIntParam("resourceType", 0)); + if ((resourceType & AllowType::RUNNING_LOCK) == 0) { + STANDBYSERVICE_LOGD("resourceType is not running lock, currentType is %{public}d", resourceType); return ERR_STANDBY_STRATEGY_NOT_MATCH; } if (!isProxied_) { @@ -129,7 +129,7 @@ ErrCode RunningLockStrategy::StartProxy(const StandbyMessage& message) } uint32_t curPhase = static_cast(message.want_->GetIntParam(CURRENT_PHASE, 0)); uint32_t curState = static_cast(message.want_->GetIntParam(CURRENT_STATE, 0)); - if ((curState != StandbyState::SLEEP) || (curPhase != SleepStatePhase::APP_RES_DEEP)) { + if ((curState != StandbyState::IDLE) || (curPhase != IdleStatePhase::APP_RES_DEEP)) { return ERR_STANDBY_CURRENT_STATE_NOT_MATCH; } STANDBYSERVICE_LOGD("start proxy running lock, current state is %{public}d, current phase is %{public}d", @@ -305,7 +305,7 @@ ErrCode RunningLockStrategy::GetBackgroundTaskApp() ErrCode RunningLockStrategy::GetExemptionConfig() { // if app in exemption list, add its exemption flag - std::vector allowInfoList {}; + std::vector allowInfoList {}; StandbyServiceImpl::GetInstance()->GetAllowListInner(AllowType::RUNNING_LOCK, allowInfoList, ReasonCodeEnum::REASON_APP_API); std::set allowNameList {}; @@ -361,15 +361,15 @@ ErrCode RunningLockStrategy::StopProxy(const StandbyMessage& message) } uint32_t preState = static_cast(message.want_->GetIntParam(PREVIOUS_STATE, 0)); uint32_t curState = static_cast(message.want_->GetIntParam(CURRENT_STATE, 0)); - if ((curState == StandbyState::MAINTENANCE) && (preState == StandbyState::SLEEP)) { + if ((curState == StandbyState::MAINTENANCE) && (preState == StandbyState::IDLE)) { // enter maintenance, stop proxy ProxyAppAndProcess(false); isIdleMaintence_ = true; - } else if ((curState == StandbyState::SLEEP) && (preState == StandbyState::MAINTENANCE)) { + } else if ((curState == StandbyState::IDLE) && (preState == StandbyState::MAINTENANCE)) { isIdleMaintence_ = false; // exit maintenance, enter sleep, start proxy ProxyAppAndProcess(true); - } else if (preState == StandbyState::SLEEP || preState == StandbyState::MAINTENANCE) { + } else if (preState == StandbyState::IDLE || preState == StandbyState::MAINTENANCE) { StopProxyInner(); isProxied_ = false; isIdleMaintence_ = false; @@ -501,7 +501,7 @@ void RunningLockStrategy::GetAndCreateAppInfo(uint32_t uid, uint32_t pid, const ErrCode RunningLockStrategy::GetExemptionConfigForApp(ProxiedProcInfo& appInfo, const std::string& bundleName) { // if app in exemption list, add exemption flag - std::vector allowInfoList {}; + std::vector allowInfoList {}; StandbyServiceImpl::GetInstance()->GetAllowListInner(AllowType::NETWORK, allowInfoList, ReasonCodeEnum::REASON_APP_API); std::set allowNameList {}; diff --git a/plugins/test/unittest/standby_plugin_unit_test.cpp b/plugins/test/unittest/standby_plugin_unit_test.cpp index 5d99b1553b7230d256a7cb2130be8799fcf0b248..ccbd9754dd4f29f8865ae85d52efaa216a841ad6 100644 --- a/plugins/test/unittest/standby_plugin_unit_test.cpp +++ b/plugins/test/unittest/standby_plugin_unit_test.cpp @@ -26,7 +26,7 @@ #include "common_event_support.h" #include "common_event_observer.h" -#include "allow_type.h" +#include "resource_type.h" #include "standby_service_client.h" #include "standby_service.h" #include "standby_service_impl.h" @@ -250,13 +250,13 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_006, TestSize.Level1) constraintManager_->RegisterConstraintCallback(params, monitor); constraintManager_->StartEvalution(params); constraintManager_->constraintMap_.erase(params.GetHashValue()); - ConstraintEvalParam repeatedMotionParams{StandbyState::SLEEP, SleepStatePhase::END, StandbyState::SLEEP, - SleepStatePhase::END}; + ConstraintEvalParam repeatedMotionParams{StandbyState::IDLE, IdleStatePhase::END, StandbyState::IDLE, + IdleStatePhase::END}; repeatedMotionParams.isRepeatedDetection_ = true; constraintManager_->StartEvalution(repeatedMotionParams); SleepForFC(); - ConstraintEvalParam motionDetectParams{StandbyState::NAP, NapStatePhase::END, StandbyState::SLEEP, - SleepStatePhase::SYS_RES_DEEP}; + ConstraintEvalParam motionDetectParams{StandbyState::NAP, NapStatePhase::END, StandbyState::IDLE, + IdleStatePhase::SYS_RES_DEEP}; constraintManager_->StartEvalution(motionDetectParams); constraintManager_->StopEvalution(); standbyStateManager_->ExitStandby(StandbyState::WORKING); @@ -292,7 +292,7 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_007, TestSize.Level1) HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_008, TestSize.Level1) { for (auto &statePtr : standbyStateManager_->indexToState_) { - for (uint32_t nextState = StandbyState::WORKING; nextState <= StandbyState::SLEEP; ++nextState) { + for (uint32_t nextState = StandbyState::WORKING; nextState <= StandbyState::IDLE; ++nextState) { statePtr->CheckTransitionValid(nextState); } } @@ -364,25 +364,25 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_010, TestSize.Level1) /** * @tc.name: StandbyPluginUnitTest_011 - * @tc.desc: test SleepState of StandbyPlugin. + * @tc.desc: test IdleState of StandbyPlugin. * @tc.type: FUNC * @tc.require: */ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_011, TestSize.Level1) { - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(true); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(true); - standbyStateManager_->sleepStatePtr_->curPhase_ = SleepStatePhase::SYS_RES_DEEP; - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(true); + standbyStateManager_->idleStatePtr_->curPhase_ = IdleStatePhase::SYS_RES_DEEP; + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(true); SleepForFC(); - standbyStateManager_->sleepStatePtr_->curPhase_ = SleepStatePhase::APP_RES_HARDWARE; - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(true); + standbyStateManager_->idleStatePtr_->curPhase_ = IdleStatePhase::APP_RES_HARDWARE; + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(true); SleepForFC(); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(true); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(true); SleepForFC(); EXPECT_NE(standbyStateManager_->curStatePtr_->GetCurState(), StandbyState::WORKING); } @@ -401,10 +401,10 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_012, TestSize.Level1) SleepForFC(); standbyStateManager_->TransitToStateInner(StandbyState::MAINTENANCE); standbyStateManager_->TransitToStateInner(StandbyState::NAP); - standbyStateManager_->TransitToStateInner(StandbyState::SLEEP); + standbyStateManager_->TransitToStateInner(StandbyState::IDLE); SleepForFC(); standbyStateManager_->TransitToStateInner(StandbyState::MAINTENANCE); - standbyStateManager_->TransitToStateInner(StandbyState::SLEEP); + standbyStateManager_->TransitToStateInner(StandbyState::IDLE); EXPECT_NE(standbyStateManager_->curStatePtr_->GetCurState(), StandbyState::WORKING); } @@ -810,16 +810,16 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_0034, TestSize.Level1) standbyStateManager_->OnScreenOffHalfHourInner(scrOffHalfHourCtrl, repeated); EXPECT_TRUE(standbyStateManager_->scrOffHalfHourCtrl_ == false); - standbyStateManager_->curStatePtr_ = standbyStateManager_->sleepStatePtr_; + standbyStateManager_->curStatePtr_ = standbyStateManager_->idleStatePtr_; standbyStateManager_->preStatePtr_ = standbyStateManager_->maintStatePtr_; standbyStateManager_->OnScreenOffHalfHourInner(true, false); standbyStateManager_->curStatePtr_ = standbyStateManager_->maintStatePtr_; - standbyStateManager_->preStatePtr_ = standbyStateManager_->sleepStatePtr_; + standbyStateManager_->preStatePtr_ = standbyStateManager_->idleStatePtr_; standbyStateManager_->OnScreenOffHalfHourInner(true, false); standbyStateManager_->curStatePtr_ = standbyStateManager_->workingStatePtr_; - standbyStateManager_->preStatePtr_ = standbyStateManager_->sleepStatePtr_; + standbyStateManager_->preStatePtr_ = standbyStateManager_->idleStatePtr_; standbyStateManager_->OnScreenOffHalfHourInner(true, false); } @@ -952,16 +952,16 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_040, TestSize.Level1) */ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_041, TestSize.Level1) { - standbyStateManager_->sleepStatePtr_->stateManager_.reset(); - standbyStateManager_->sleepStatePtr_->TransitToPhaseInner(0, 0); - standbyStateManager_->sleepStatePtr_->StartTransitNextState(standbyStateManager_->sleepStatePtr_); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); - standbyStateManager_->sleepStatePtr_->stateManager_ = standbyStateManager_; + standbyStateManager_->idleStatePtr_->stateManager_.reset(); + standbyStateManager_->idleStatePtr_->TransitToPhaseInner(0, 0); + standbyStateManager_->idleStatePtr_->StartTransitNextState(standbyStateManager_->idleStatePtr_); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->stateManager_ = standbyStateManager_; standbyStateManager_->isEvalution_ = true; - standbyStateManager_->sleepStatePtr_->nextState_ = 0; - standbyStateManager_->sleepStatePtr_->StartTransitNextState(standbyStateManager_->sleepStatePtr_); + standbyStateManager_->idleStatePtr_->nextState_ = 0; + standbyStateManager_->idleStatePtr_->StartTransitNextState(standbyStateManager_->idleStatePtr_); SleepForFC(); - EXPECT_FALSE(standbyStateManager_->sleepStatePtr_ == nullptr); + EXPECT_FALSE(standbyStateManager_->idleStatePtr_ == nullptr); } /** @@ -1003,17 +1003,17 @@ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_043, TestSize.Level1) /** * @tc.name: StandbyPluginUnitTest_044 - * @tc.desc: test SleepState. + * @tc.desc: test IdleState. * @tc.type: FUNC * @tc.require: */ HWTEST_F(StandbyPluginUnitTest, StandbyPluginUnitTest_044, TestSize.Level1) { std::string result {""}; - standbyStateManager_->sleepStatePtr_->ShellDump({"-D", "--repeat"}, result); - standbyStateManager_->sleepStatePtr_->ShellDump({"-S", "--r"}, result); - standbyStateManager_->sleepStatePtr_->ShellDump({"-S", "--repeat"}, result); - standbyStateManager_->sleepStatePtr_->EndEvalCurrentState(false); + standbyStateManager_->idleStatePtr_->ShellDump({"-D", "--repeat"}, result); + standbyStateManager_->idleStatePtr_->ShellDump({"-S", "--r"}, result); + standbyStateManager_->idleStatePtr_->ShellDump({"-S", "--repeat"}, result); + standbyStateManager_->idleStatePtr_->EndEvalCurrentState(false); SleepForFC(); EXPECT_TRUE(standbyStateManager_->workingStatePtr_->timedTaskMap_.empty()); } diff --git a/services/core/include/allow_record.h b/services/core/include/allow_record.h index 319fffab8e0d56cbbae84f3b50e30d77a7a23409..30f5b0b6a43338649ddd6c7322fca207dc39a708 100644 --- a/services/core/include/allow_record.h +++ b/services/core/include/allow_record.h @@ -25,24 +25,24 @@ namespace OHOS { namespace DevStandbyMgr { struct AllowTime { AllowTime() = default; - AllowTime(uint32_t allowTypeIndex, int64_t endTime, const std::string& reason) - : allowTypeIndex_(allowTypeIndex), endTime_(endTime), reason_(reason) {} - uint32_t allowTypeIndex_; + AllowTime(uint32_t resourceTypeIndex, int64_t endTime, const std::string& reason) + : resourceTypeIndex_(resourceTypeIndex), endTime_(endTime), reason_(reason) {} + uint32_t resourceTypeIndex_; int64_t endTime_ {0}; std::string reason_ {""}; }; struct AllowRecord { AllowRecord() = default; - AllowRecord(int32_t uid, int32_t pid, const std::string& name, uint32_t allowType) - : uid_(uid), pid_(pid), name_(name), allowType_(allowType) {} + AllowRecord(int32_t uid, int32_t pid, const std::string& name, uint32_t resourceType) + : uid_(uid), pid_(pid), name_(name), resourceType_(resourceType) {} nlohmann::json ParseToJson(); bool ParseFromJson(const nlohmann::json& value); int32_t uid_ {-1}; int32_t pid_ {-1}; std::string name_ {""}; - uint32_t allowType_ {0}; + uint32_t resourceType_ {0}; std::list allowTimeList_ {}; uint32_t reasonCode_ {0}; }; diff --git a/services/core/include/standby_service.h b/services/core/include/standby_service.h index 2e6ba0ab9f7d03ef832d6001777321dbfc00a0e1..3e1c873a9012b0289ed31f3ef7eb8a1eb0780f43 100644 --- a/services/core/include/standby_service.h +++ b/services/core/include/standby_service.h @@ -48,13 +48,13 @@ public: ErrCode SubscribeStandbyCallback(const sptr& subscriber) override; ErrCode UnsubscribeStandbyCallback(const sptr& subscriber) override; - ErrCode ApplyAllowResource(const sptr& resourceRequest) override; - ErrCode UnapplyAllowResource(const sptr& resourceRequest) override; - ErrCode GetAllowList(uint32_t allowType, std::vector& allowInfoList, + ErrCode RequestExemptionResource(const sptr& resourceRequest) override; + ErrCode ReleaseExemptionResource(const sptr& resourceRequest) override; + ErrCode GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) override; ErrCode IsDeviceInStandby(bool& isStandby) override; ErrCode ReportWorkSchedulerStatus(bool started, int32_t uid, const std::string& bundleName) override; - ErrCode GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, + ErrCode GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) override; ErrCode IsStrategyEnabled(const std::string& strategyName, bool& isEnabled) override; ErrCode ReportDeviceStateChanged(DeviceStateType type, bool enabled) override; diff --git a/services/core/include/standby_service_impl.h b/services/core/include/standby_service_impl.h index 3a2a20e4ca342f815bcd0154115b072c41e42c7c..461358ea736f72150dc7e8f55bb11fc7cab7c7c0 100644 --- a/services/core/include/standby_service_impl.h +++ b/services/core/include/standby_service_impl.h @@ -31,9 +31,9 @@ #include "event_handler.h" #include "istandby_service.h" -#include "allow_info.h" +#include "exempted_app_info.h" #include "allow_record.h" -#include "resourcce_request.h" +#include "resource_request.h" #include "standby_state_subscriber.h" #include "istandby_service_subscriber.h" #include "iconstraint_manager_adapter.h" @@ -69,15 +69,15 @@ public: ErrCode SubscribeStandbyCallback(const sptr& subscriber); ErrCode UnsubscribeStandbyCallback(const sptr& subscriber); - ErrCode ApplyAllowResource(const sptr& resourceRequest); - ErrCode UnapplyAllowResource(const sptr& resourceRequest); - ErrCode GetAllowList(uint32_t allowType, std::vector& allowInfoList, + ErrCode RequestExemptionResource(const sptr& resourceRequest); + ErrCode ReleaseExemptionResource(const sptr& resourceRequest); + ErrCode GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode); - ErrCode GetEligiableRestrictSet(uint32_t allowType, const std::string& strategyName, + ErrCode GetEligiableRestrictSet(uint32_t resourceType, const std::string& strategyName, uint32_t resonCode, std::set& restrictSet); ErrCode IsDeviceInStandby(bool& isStandby); ErrCode ReportWorkSchedulerStatus(bool started, int32_t uid, const std::string& bundleName); - ErrCode GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, + ErrCode GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode); ErrCode IsStrategyEnabled(const std::string& strategyName, bool& isEnabled); ErrCode ReportDeviceStateChanged(DeviceStateType type, bool enabled); @@ -97,7 +97,7 @@ public: void ShellDump(const std::vector& argsInStr, std::string& result); void ShellDumpInner(const std::vector& argsInStr, std::string& result); - void GetAllowListInner(uint32_t allowType, std::vector& allowInfoList, + void GetAllowListInner(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode); void DispatchEvent(const StandbyMessage& message); bool IsDebugMode(); @@ -106,13 +106,13 @@ public: private: void ApplyAllowResInner(const sptr& resourceRequest, int32_t pid); void UpdateRecord(std::shared_ptr& allowRecord, const sptr& resourceRequest); - void UnapplyAllowResInner(int32_t uid, const std::string& name, uint32_t allowType, bool removeAll); - void GetTemporaryAllowList(uint32_t allowTypeIndex, std::vector& allowInfoList, + void UnapplyAllowResInner(int32_t uid, const std::string& name, uint32_t resourceType, bool removeAll); + void GetTemporaryAllowList(uint32_t resourceTypeIndex, std::vector& exemptedAppList, uint32_t reasonCode); - void GetPersistAllowList(uint32_t allowTypeIndex, std::vector& allowInfoList, bool isAllow, bool isApp); - void GetRestrictListInner(uint32_t restrictType, std::vector& restrictInfoList, + void GetPersistAllowList(uint32_t resourceTypeIndex, std::vector& exemptedAppList, bool isAllow, bool isApp); + void GetRestrictedAppsInner(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode); - void NotifyAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added); + void NotifyAllowListChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added); void RecoverTimeLimitedTask(); bool ParsePersistentData(); @@ -122,7 +122,7 @@ private: ErrCode CheckCallerPermission(uint32_t reasonCode); ErrCode IsSystemAppWithPermission(int32_t uid, Security::AccessToken::AccessTokenID tokenId, uint32_t reasonCode); ErrCode CheckNativePermission(Security::AccessToken::AccessTokenID tokenId); - bool CheckAllowTypeInfo(uint32_t allowType); + bool CheckAllowTypeInfo(uint32_t resourceType); ErrCode CheckRunningResourcesApply(const int32_t uid, const std::string& bundleName); int32_t GetUserIdByUid(int32_t uid); diff --git a/services/core/src/allow_record.cpp b/services/core/src/allow_record.cpp index d0a846a6fe089ef1e1e3202975fef1c5b044b076..3da344e7fda7f8925be24878cf57ea667ff050a7 100644 --- a/services/core/src/allow_record.cpp +++ b/services/core/src/allow_record.cpp @@ -23,13 +23,13 @@ nlohmann::json AllowRecord::ParseToJson() value["uid"] = uid_; value["pid"] = pid_; value["name"] = name_; - value["allowType"] = allowType_; + value["resourceType"] = resourceType_; value["reasonCode"] = reasonCode_; if (!allowTimeList_.empty()) { nlohmann::json allowList; for (const auto &iter : allowTimeList_) { nlohmann::json info; - info["allowTypeIndex"] = iter.allowTypeIndex_; + info["resourceTypeIndex"] = iter.resourceTypeIndex_; info["endTime"] = iter.endTime_; info["reason"] = iter.reason_; allowList.push_back(info); @@ -47,17 +47,17 @@ bool AllowRecord::ParseFromJson(const nlohmann::json& value) this->uid_ = value.at("uid").get(); this->pid_ = value.at("pid").get(); this->name_ = value.at("name").get(); - this->allowType_ = value.at("allowType").get(); + this->resourceType_ = value.at("resourceType").get(); this->reasonCode_ = value.at("reasonCode").get(); if (value.contains("allowTimeList")) { const nlohmann::json &allowTimeVal = value.at("allowTimeList"); auto nums = static_cast(allowTimeVal.size()); for (int i = 0; i < nums; ++i) { const nlohmann::json &persistTime = allowTimeVal.at(i); - uint32_t allowTypeIndex = persistTime.at("allowTypeIndex").get(); + uint32_t resourceTypeIndex = persistTime.at("resourceTypeIndex").get(); int64_t endTime_ = persistTime.at("endTime").get(); std::string reason_ = persistTime.at("reason").get(); - this->allowTimeList_.emplace_back(AllowTime {allowTypeIndex, endTime_, + this->allowTimeList_.emplace_back(AllowTime {resourceTypeIndex, endTime_, reason_}); } } diff --git a/services/core/src/standby_service.cpp b/services/core/src/standby_service.cpp index 6f41a0b64fb276db414f06220c867417fcdc51f7..0d0d7b3c4213f9e5e7e87f32a820bf295b298a71 100644 --- a/services/core/src/standby_service.cpp +++ b/services/core/src/standby_service.cpp @@ -192,32 +192,32 @@ ErrCode StandbyService::UnsubscribeStandbyCallback(const sptrUnsubscribeStandbyCallback(subscriber); } -ErrCode StandbyService::ApplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyService::RequestExemptionResource(const sptr& resourceRequest) { if (state_ != ServiceRunningState::STATE_RUNNING) { STANDBYSERVICE_LOGW("standby service is not running"); return ERR_STANDBY_SYS_NOT_READY; } - return StandbyServiceImpl::GetInstance()->ApplyAllowResource(resourceRequest); + return StandbyServiceImpl::GetInstance()->RequestExemptionResource(resourceRequest); } -ErrCode StandbyService::UnapplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyService::ReleaseExemptionResource(const sptr& resourceRequest) { if (state_ != ServiceRunningState::STATE_RUNNING) { STANDBYSERVICE_LOGW("standby service is not running"); return ERR_STANDBY_SYS_NOT_READY; } - return StandbyServiceImpl::GetInstance()->UnapplyAllowResource(resourceRequest); + return StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(resourceRequest); } -ErrCode StandbyService::GetAllowList(uint32_t allowType, std::vector& allowInfoList, +ErrCode StandbyService::GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) { if (state_ != ServiceRunningState::STATE_RUNNING) { STANDBYSERVICE_LOGW("standby service is not running"); return ERR_STANDBY_SYS_NOT_READY; } - return StandbyServiceImpl::GetInstance()->GetAllowList(allowType, allowInfoList, reasonCode); + return StandbyServiceImpl::GetInstance()->GetExemptedApps(resourceType, allowInfoList, reasonCode); } ErrCode StandbyService::IsDeviceInStandby(bool& isStandby) @@ -262,14 +262,14 @@ ErrCode StandbyService::ReportWorkSchedulerStatus(bool started, int32_t uid, con return StandbyServiceImpl::GetInstance()->ReportWorkSchedulerStatus(started, uid, bundleName); } -ErrCode StandbyService::GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, +ErrCode StandbyService::GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) { if (state_ != ServiceRunningState::STATE_RUNNING) { STANDBYSERVICE_LOGW("standby service is not running"); return ERR_STANDBY_SYS_NOT_READY; } - return StandbyServiceImpl::GetInstance()->GetRestrictList(restrictType, restrictInfoList, reasonCode); + return StandbyServiceImpl::GetInstance()->GetRestrictedApps(restrictType, restrictInfoList, reasonCode); } ErrCode StandbyService::IsStrategyEnabled(const std::string& strategyName, bool& isEnabled) diff --git a/services/core/src/standby_service_impl.cpp b/services/core/src/standby_service_impl.cpp index c78a5c23aaa0a06296cd499ede9a2f43f9fca0cc..5ff73d0047fd5cd0985e0924ff04cd9bbfd99800 100644 --- a/services/core/src/standby_service_impl.cpp +++ b/services/core/src/standby_service_impl.cpp @@ -39,7 +39,7 @@ #include "istandby_service.h" #include "device_standby_switch.h" #include "standby_config_manager.h" -#include "allow_type.h" +#include "resource_type.h" #include "app_mgr_helper.h" #include "ability_manager_helper.h" #include "bundle_manager_helper.h" @@ -185,7 +185,7 @@ void StandbyServiceImpl::DayNightSwitchCallback() return; } auto curState = standbyImpl->standbyStateManager_->GetCurState(); - if (curState == StandbyState::SLEEP) { + if (curState == StandbyState::IDLE) { StandbyMessage standbyMessage {StandbyMessageType::RES_CTRL_CONDITION_CHANGED}; standbyMessage.want_ = AAFwk::Want{}; uint32_t condition = TimeProvider::GetCondition(); @@ -405,7 +405,7 @@ void StandbyServiceImpl::RecoverTimeLimitedTask() auto &allowTimeList = iter->second->allowTimeList_; for (auto allowTimeIter = allowTimeList.begin(); allowTimeIter != allowTimeList.end(); ++allowTimeIter) { auto task = [mgr, uid = iter->second->uid_, name = iter->second->name_] () { - mgr->UnapplyAllowResInner(uid, name, MAX_ALLOW_TYPE_NUMBER, false); + mgr->UnapplyAllowResInner(uid, name, MAX_RESOURCE_TYPE_NUMBER, false); }; int32_t timeOut = static_cast(allowTimeIter->endTime_ - MiscServices::TimeServiceClient::GetInstance()->GetMonotonicTimeMs()); @@ -433,9 +433,9 @@ void StandbyServiceImpl::UnInit() STANDBYSERVICE_LOGI("succeed to clear stawndby service implement"); } -bool StandbyServiceImpl::CheckAllowTypeInfo(uint32_t allowType) +bool StandbyServiceImpl::CheckAllowTypeInfo(uint32_t resourceType) { - return allowType > 0 && allowType <= MAX_ALLOW_TYPE_NUMBER; + return resourceType > 0 && resourceType <= MAX_RESOURCE_TYPE_NUMBER; } ErrCode StandbyServiceImpl::RemoveAppAllowRecord(int32_t uid, const std::string &bundleName, bool resetAll) @@ -445,9 +445,9 @@ ErrCode StandbyServiceImpl::RemoveAppAllowRecord(int32_t uid, const std::string return ERR_STANDBY_SYS_NOT_READY; } STANDBYSERVICE_LOGD("app died, uid: %{public}d, bundleName: %{public}s", uid, bundleName.c_str()); - int allowType = resetAll ? MAX_ALLOW_TYPE_NUMBER : (MAX_ALLOW_TYPE_NUMBER ^ AllowType::TIMER ^ + int resourceType = resetAll ? MAX_RESOURCE_TYPE_NUMBER : (MAX_RESOURCE_TYPE_NUMBER ^ AllowType::TIMER ^ AllowType::WORK_SCHEDULER); - this->UnapplyAllowResInner(uid, bundleName, allowType, true); + this->UnapplyAllowResInner(uid, bundleName, resourceType, true); return ERR_OK; } @@ -546,7 +546,7 @@ ErrCode StandbyServiceImpl::UnsubscribeStandbyCallback(const sptrRemoveSubscriber(subscriber); } -ErrCode StandbyServiceImpl::ApplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceImpl::RequestExemptionResource(const sptr& resourceRequest) { if (!isServiceReady_.load()) { STANDBYSERVICE_LOGD("standby service is not ready"); @@ -556,7 +556,7 @@ ErrCode StandbyServiceImpl::ApplyAllowResource(const sptr& reso if (auto checkRet = CheckCallerPermission(resourceRequest->GetReasonCode()); checkRet != ERR_OK) { return checkRet; } - if (!CheckAllowTypeInfo(resourceRequest->GetAllowType()) || resourceRequest->GetUid() < 0) { + if (!CheckAllowTypeInfo(resourceRequest->GetResourceType()) || resourceRequest->GetUid() < 0) { STANDBYSERVICE_LOGE("resourceRequest param is invalid"); return ERR_RESOURCE_TYPES_INVALID; } @@ -571,15 +571,15 @@ ErrCode StandbyServiceImpl::ApplyAllowResource(const sptr& reso void StandbyServiceImpl::ApplyAllowResInner(const sptr& resourceRequest, int32_t pid) { - STANDBYSERVICE_LOGI("apply res inner, uid: %{public}d, name: %{public}s, allowType: %{public}u,"\ + STANDBYSERVICE_LOGI("apply res inner, uid: %{public}d, name: %{public}s, resourceType: %{public}u,"\ " duration: %{public}d, reason: %{public}s", resourceRequest->GetUid(), - resourceRequest->GetName().c_str(), resourceRequest->GetAllowType(), + resourceRequest->GetName().c_str(), resourceRequest->GetResourceType(), resourceRequest->GetDuration(), resourceRequest->GetReason().c_str()); int32_t uid = resourceRequest->GetUid(); const std::string& name = resourceRequest->GetName(); std::string keyStr = std::to_string(uid) + "_" + name; - uint32_t preAllowType = 0; + uint32_t preResourceType= 0; std::lock_guard allowRecordLock(allowRecordMutex_); auto iter = allowInfoMap_.find(keyStr); @@ -588,19 +588,19 @@ void StandbyServiceImpl::ApplyAllowResInner(const sptr& resourc allowInfoMap_.emplace(keyStr, std::make_shared(uid, pid, name, 0)); iter->second->reasonCode_ = resourceRequest->GetReasonCode(); } else { - preAllowType = iter->second->allowType_; + preResourceType= iter->second->resourceType_; iter->second->pid_ = pid; } UpdateRecord(iter->second, resourceRequest); - if (preAllowType != iter->second->allowType_) { - uint32_t alowTypeDiff = iter->second->allowType_ ^ (preAllowType & - iter->second->allowType_); + if (preResourceType!= iter->second->resourceType_) { + uint32_t alowTypeDiff = iter->second->resourceType_ ^ (preResourceType& + iter->second->resourceType_); STANDBYSERVICE_LOGD("after update record, there is added exemption type: %{public}d", alowTypeDiff); StandbyStateSubscriber::GetInstance()->ReportAllowListChanged(uid, name, alowTypeDiff, true); NotifyAllowListChanged(uid, name, alowTypeDiff, true); } - if (iter->second->allowType_ == 0) { + if (iter->second->resourceType_ == 0) { STANDBYSERVICE_LOGD("%{public}s does not have valid record, delete record", keyStr.c_str()); allowInfoMap_.erase(iter); } @@ -613,20 +613,20 @@ void StandbyServiceImpl::UpdateRecord(std::shared_ptr& allowRecord, STANDBYSERVICE_LOGD("start UpdateRecord"); int32_t uid = resourceRequest->GetUid(); const std::string& name = resourceRequest->GetName(); - uint32_t allowType = resourceRequest->GetAllowType(); + uint32_t resourceType = resourceRequest->GetResourceType(); bool isApp = (resourceRequest->GetReasonCode() == ReasonCodeEnum::REASON_APP_API); int64_t curTime = MiscServices::TimeServiceClient::GetInstance()->GetMonotonicTimeMs(); int64_t endTime {0}; uint32_t condition = TimeProvider::GetCondition(); - for (uint32_t allowTypeIndex = 0; allowTypeIndex < MAX_ALLOW_TYPE_NUM; ++allowTypeIndex) { - uint32_t allowNumber = allowType & (1 << allowTypeIndex); + for (uint32_t resourceTypeIndex = 0; resourceTypeIndex < MAX_RESOURCE_TYPE_NUM; ++resourceTypeIndex) { + uint32_t allowNumber = resourceType & (1 << resourceTypeIndex); if (allowNumber == 0) { continue; } int64_t maxDuration = 0; if (allowNumber != AllowType::WORK_SCHEDULER) { maxDuration = std::min(resourceRequest->GetDuration(), StandbyConfigManager::GetInstance()-> - GetMaxDuration(name, AllowTypeName[allowTypeIndex], condition, isApp)) * TimeConstant::MSEC_PER_SEC; + GetMaxDuration(name, ResourceTypeName[resourceTypeIndex], condition, isApp)) * TimeConstant::MSEC_PER_SEC; } else { maxDuration = resourceRequest->GetDuration() * TimeConstant::MSEC_PER_SEC; } @@ -635,46 +635,46 @@ void StandbyServiceImpl::UpdateRecord(std::shared_ptr& allowRecord, } endTime = curTime + maxDuration; auto& allowTimeList = allowRecord->allowTimeList_; - auto findRecordTask = [allowTypeIndex](const auto& it) { return it.allowTypeIndex_ == allowTypeIndex; }; + auto findRecordTask = [resourceTypeIndex](const auto& it) { return it.resourceTypeIndex_ == resourceTypeIndex; }; auto it = std::find_if(allowTimeList.begin(), allowTimeList.end(), findRecordTask); if (it == allowTimeList.end()) { - allowTimeList.emplace_back(AllowTime{allowTypeIndex, endTime, resourceRequest->GetReason()}); + allowTimeList.emplace_back(AllowTime{resourceTypeIndex, endTime, resourceRequest->GetReason()}); } else { it->reason_ = resourceRequest->GetReason(); it->endTime_ = std::max(it->endTime_, endTime); } - allowRecord->allowType_ = (allowRecord->allowType_ | allowNumber); - auto task = [this, uid, name, allowType] () { - this->UnapplyAllowResInner(uid, name, allowType, false); + allowRecord->resourceType_ = (allowRecord->resourceType_ | allowNumber); + auto task = [this, uid, name, resourceType] () { + this->UnapplyAllowResInner(uid, name, resourceType, false); }; handler_->PostTask(task, maxDuration); } STANDBYSERVICE_LOGE("update end time of allow list"); } -ErrCode StandbyServiceImpl::UnapplyAllowResource(const sptr& resourceRequest) +ErrCode StandbyServiceImpl::ReleaseExemptionResource(const sptr& resourceRequest) { if (!isServiceReady_.load()) { STANDBYSERVICE_LOGD("standby service is not ready"); return ERR_STANDBY_SYS_NOT_READY; } - STANDBYSERVICE_LOGD("start UnapplyAllowResource"); + STANDBYSERVICE_LOGD("start ReleaseExemptionResource"); if (auto checkRet = CheckCallerPermission(resourceRequest->GetReasonCode()); checkRet != ERR_OK) { return checkRet; } - if (!CheckAllowTypeInfo(resourceRequest->GetAllowType()) || resourceRequest->GetUid() < 0) { + if (!CheckAllowTypeInfo(resourceRequest->GetResourceType()) || resourceRequest->GetUid() < 0) { STANDBYSERVICE_LOGE("param of resourceRequest is invalid"); return ERR_RESOURCE_TYPES_INVALID; } - UnapplyAllowResInner(resourceRequest->GetUid(), resourceRequest->GetName(), resourceRequest->GetAllowType(), true); + UnapplyAllowResInner(resourceRequest->GetUid(), resourceRequest->GetName(), resourceRequest->GetResourceType(), true); return ERR_OK; } void StandbyServiceImpl::UnapplyAllowResInner(int32_t uid, const std::string& name, - uint32_t allowType, bool removeAll) + uint32_t resourceType, bool removeAll) { - STANDBYSERVICE_LOGD("start UnapplyAllowResInner, uid is %{public}d, allowType is %{public}d, removeAll is "\ - "%{public}d", uid, allowType, removeAll); + STANDBYSERVICE_LOGD("start UnapplyAllowResInner, uid is %{public}d, resourceType is %{public}d, removeAll is "\ + "%{public}d", uid, resourceType, removeAll); std::string keyStr = std::to_string(uid) + "_" + name; std::lock_guard allowRecordLock(allowRecordMutex_); @@ -683,7 +683,7 @@ void StandbyServiceImpl::UnapplyAllowResInner(int32_t uid, const std::string& na STANDBYSERVICE_LOGW("uid has no corresponding allow list"); return; } - if ((allowType & iter->second->allowType_) == 0) { + if ((resourceType & iter->second->resourceType_) == 0) { STANDBYSERVICE_LOGW("allow list has no corresponding allow type"); return; } @@ -692,7 +692,7 @@ void StandbyServiceImpl::UnapplyAllowResInner(int32_t uid, const std::string& na uint32_t removedNumber = 0; int64_t curTime = MiscServices::TimeServiceClient::GetInstance()->GetMonotonicTimeMs(); for (auto it = allowTimeList.begin(); it != allowTimeList.end();) { - uint32_t allowNumber = allowType & (1 << it->allowTypeIndex_); + uint32_t allowNumber = resourceType & (1 << it->resourceTypeIndex_); if (allowNumber != 0 && (removeAll || curTime >= it->endTime_)) { it = allowTimeList.erase(it); removedNumber |= allowNumber; @@ -705,11 +705,11 @@ void StandbyServiceImpl::UnapplyAllowResInner(int32_t uid, const std::string& na STANDBYSERVICE_LOGW("none member of the allow list should be removed"); return; } - if (removedNumber == allowRecordPtr->allowType_) { + if (removedNumber == allowRecordPtr->resourceType_) { allowInfoMap_.erase(keyStr); STANDBYSERVICE_LOGI("allow list has been delete"); } - allowRecordPtr->allowType_ = allowRecordPtr->allowType_ - removedNumber; + allowRecordPtr->resourceType_ = allowRecordPtr->resourceType_ - removedNumber; StandbyStateSubscriber::GetInstance()->ReportAllowListChanged(uid, name, removedNumber, false); NotifyAllowListChanged(uid, name, removedNumber, false); DumpPersistantData(); @@ -733,18 +733,18 @@ void StandbyServiceImpl::OnProcessStatusChanged(int32_t uid, int32_t pid, const } void StandbyServiceImpl::NotifyAllowListChanged(int32_t uid, const std::string& name, - uint32_t allowType, bool added) + uint32_t resourceType, bool added) { StandbyMessage standbyMessage {StandbyMessageType::ALLOW_LIST_CHANGED}; standbyMessage.want_ = AAFwk::Want{}; standbyMessage.want_->SetParam("uid", uid); standbyMessage.want_->SetParam("name", name); - standbyMessage.want_->SetParam("allowType", static_cast(allowType)); + standbyMessage.want_->SetParam("resourceType", static_cast(resourceType)); standbyMessage.want_->SetParam("added", added); DispatchEvent(standbyMessage); } -ErrCode StandbyServiceImpl::GetAllowList(uint32_t allowType, std::vector& allowInfoList, +ErrCode StandbyServiceImpl::GetExemptedApps(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) { if (!isServiceReady_.load()) { @@ -755,38 +755,38 @@ ErrCode StandbyServiceImpl::GetAllowList(uint32_t allowType, std::vector& allowInfoList, +void StandbyServiceImpl::GetAllowListInner(uint32_t resourceType, std::vector& exemptedAppList, uint32_t reasonCode) { - STANDBYSERVICE_LOGD("start GetAllowListInner, allowType is %{public}d", allowType); + STANDBYSERVICE_LOGD("start GetAllowListInner, resourceType is %{public}d", resourceType); std::lock_guard allowRecordLock(allowRecordMutex_); - for (uint32_t allowTypeIndex = 0; allowTypeIndex < MAX_ALLOW_TYPE_NUM; ++allowTypeIndex) { - uint32_t allowNumber = allowType & (1 << allowTypeIndex); + for (uint32_t resourceTypeIndex = 0; resourceTypeIndex < MAX_RESOURCE_TYPE_NUM; ++resourceTypeIndex) { + uint32_t allowNumber = resourceType & (1 << resourceTypeIndex); if (allowNumber == 0) { continue; } - GetTemporaryAllowList(allowTypeIndex, allowInfoList, reasonCode); + GetTemporaryAllowList(resourceTypeIndex, allowInfoList, reasonCode); bool isApp = (reasonCode == ReasonCodeEnum::REASON_APP_API); - GetPersistAllowList(allowTypeIndex, allowInfoList, true, isApp); + GetPersistAllowList(resourceTypeIndex, allowInfoList, true, isApp); } } -void StandbyServiceImpl::GetTemporaryAllowList(uint32_t allowTypeIndex, std::vector& +void StandbyServiceImpl::GetTemporaryAllowList(uint32_t resourceTypeIndex, std::vector& allowInfoList, uint32_t reasonCode) { int32_t curTime = MiscServices::TimeServiceClient::GetInstance()->GetMonotonicTimeMs(); - auto findRecordTask = [allowTypeIndex](const auto& it) { return it.allowTypeIndex_ == allowTypeIndex; }; + auto findRecordTask = [resourceTypeIndex](const auto& it) { return it.resourceTypeIndex_ == resourceTypeIndex; }; for (auto& [key, allowRecordPtr] : allowInfoMap_) { - if ((allowRecordPtr->allowType_ & (1 << allowTypeIndex)) == 0) { + if ((allowRecordPtr->resourceType_ & (1 << resourceTypeIndex)) == 0) { continue; } if (allowRecordPtr->reasonCode_ != reasonCode) { @@ -797,25 +797,25 @@ void StandbyServiceImpl::GetTemporaryAllowList(uint32_t allowTypeIndex, std::vec if (it == allowTimeList.end()) { continue; } - allowInfoList.emplace_back((1 << allowTypeIndex), allowRecordPtr->name_, + allowInfoList.emplace_back((1 << resourceTypeIndex), allowRecordPtr->name_, std::max(static_cast(it->endTime_ - curTime), 0L)); } } -void StandbyServiceImpl::GetPersistAllowList(uint32_t allowTypeIndex, std::vector& allowInfoList, +void StandbyServiceImpl::GetPersistAllowList(uint32_t resourceTypeIndex, std::vector& exemptedAppList, bool isAllow, bool isApp) { uint32_t condition = TimeProvider::GetCondition(); std::set psersistAllowList; if (isApp) { psersistAllowList = StandbyConfigManager::GetInstance()->GetEligiblePersistAllowConfig( - AllowTypeName[allowTypeIndex], condition, isAllow, true); + ResourceTypeName[resourceTypeIndex], condition, isAllow, true); } else { psersistAllowList = StandbyConfigManager::GetInstance()->GetEligiblePersistAllowConfig( - AllowTypeName[allowTypeIndex], condition, isAllow, false); + ResourceTypeName[resourceTypeIndex], condition, isAllow, false); } for (const auto& allowName : psersistAllowList) { - allowInfoList.emplace_back((1 << allowTypeIndex), allowName, -1); + allowInfoList.emplace_back((1 << resourceTypeIndex), allowName, -1); } } @@ -827,22 +827,22 @@ ErrCode StandbyServiceImpl::IsDeviceInStandby(bool& isStandby) } handler_->PostSyncTask([this, &isStandby]() { auto curState = standbyStateManager_->GetCurState(); - isStandby = (curState == StandbyState::SLEEP); + isStandby = (curState == StandbyState::IDLE); }, AppExecFwk::EventQueue::Priority::HIGH); return ERR_OK; } -ErrCode StandbyServiceImpl::GetEligiableRestrictSet(uint32_t allowType, const std::string& strategyName, +ErrCode StandbyServiceImpl::GetEligiableRestrictSet(uint32_t resourceType, const std::string& strategyName, uint32_t resonCode, std::set& restrictSet) { uint32_t condition = TimeProvider::GetCondition(); std::set originRestrictSet = StandbyConfigManager::GetInstance()->GetEligiblePersistAllowConfig( strategyName, condition, false, resonCode == ReasonCodeEnum::REASON_APP_API); - std::vector allowInfoList; - GetAllowListInner(allowType, allowInfoList, resonCode); + std::vector allowInfoList; + GetAllowListInner(resourceType, allowInfoList, resonCode); std::set allowSet; for_each(allowInfoList.begin(), allowInfoList.end(), - [&allowSet](AllowInfo& allowInfo) { allowSet.insert(allowInfo.GetName()); }); + [&allowSet](ExemptedApp& allowInfo) { allowSet.insert(allowInfo.GetName()); }); std::set_difference(originRestrictSet.begin(), originRestrictSet.end(), allowSet.begin(), allowSet.end(), std::inserter(restrictSet, restrictSet.begin())); @@ -873,14 +873,14 @@ ErrCode StandbyServiceImpl::ReportWorkSchedulerStatus(bool started, int32_t uid, return ERR_OK; } -ErrCode StandbyServiceImpl::GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, +ErrCode StandbyServiceImpl::GetRestrictedApps(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) { if (!isServiceReady_.load()) { STANDBYSERVICE_LOGD("standby service is not ready"); return ERR_STANDBY_SYS_NOT_READY; } - STANDBYSERVICE_LOGD("start GetRestrictList"); + STANDBYSERVICE_LOGD("start GetRestrictedApps"); if (CheckNativePermission(OHOS::IPCSkeleton::GetCallingTokenID()) != ERR_OK) { STANDBYSERVICE_LOGW("invoker is unpermitted due to not native process or shell"); return ERR_STANDBY_PERMISSION_DENIED; @@ -889,15 +889,15 @@ ErrCode StandbyServiceImpl::GetRestrictList(uint32_t restrictType, std::vector& restrictInfoList, +void StandbyServiceImpl::GetRestrictedAppsInner(uint32_t restrictType, std::vector& restrictInfoList, uint32_t reasonCode) { - STANDBYSERVICE_LOGD("start GetRestrictListInner, restrictType is %{public}d", restrictType); - for (uint32_t restrictTypeIndex = 0; restrictTypeIndex < MAX_ALLOW_TYPE_NUM; ++restrictTypeIndex) { + STANDBYSERVICE_LOGD("start GetRestrictedAppsInner, restrictType is %{public}d", restrictType); + for (uint32_t restrictTypeIndex = 0; restrictTypeIndex < MAX_RESOURCE_TYPE_NUM; ++restrictTypeIndex) { uint32_t restrictNumber = restrictType & (1 << restrictTypeIndex); if (restrictNumber == 0) { continue; @@ -1078,13 +1078,13 @@ void StandbyServiceImpl::DumpAllowListInfo(std::string& result) stream << "\tallow record: " << "\n"; stream << "\t\tname: " << iter->second->name_ << "\n"; stream << "\t\tpid: " << iter->second->pid_ << "\n"; - stream << "\t\tallow type: " << iter->second->allowType_ << "\n"; + stream << "\t\tallow type: " << iter->second->resourceType_ << "\n"; stream << "\t\treason code: " << iter->second->reasonCode_ << "\n"; int64_t curTime = MiscServices::TimeServiceClient::GetInstance()->GetMonotonicTimeMs(); auto &allowTimeList = iter->second->allowTimeList_; for (auto unitIter = allowTimeList.begin(); unitIter != allowTimeList.end(); ++unitIter) { - stream << "\t\t\tallow type: " << AllowTypeName[unitIter->allowTypeIndex_] << "\n"; + stream << "\t\t\tallow type: " << ResourceTypeName[unitIter->resourceTypeIndex_] << "\n"; stream << "\t\t\tremainTime: " << unitIter->endTime_ - curTime << "\n"; stream << "\t\t\treason: " << unitIter->reason_ << "\n"; } @@ -1124,32 +1124,32 @@ void StandbyServiceImpl::DumpModifyAllowList(const std::vector& arg int32_t uid = std::atoi(argsInStr[DUMP_THIRD_PARAM].c_str()); std::string name = argsInStr[DUMP_FOURTH_PARAM]; if (argsInStr[DUMP_SECOND_PARAM] == "--apply") { - uint32_t allowType = static_cast(std::atoi(argsInStr[DUMP_FIFTH_PARAM].c_str())); + uint32_t resourceType = static_cast(std::atoi(argsInStr[DUMP_FIFTH_PARAM].c_str())); int32_t duration = std::atoi(argsInStr[DUMP_SIXTH_PARAM].c_str()); - sptr resourceRequest = new (std::nothrow) ResourceRequest(allowType, + sptr resourceRequest = new (std::nothrow) ResourceRequest(resourceType, uid, name, duration, "dump", std::atoi(argsInStr[DUMP_SEVENTH_PARAM].c_str())); - ApplyAllowResource(resourceRequest); + RequestExemptionResource(resourceRequest); result += "add one object to allow list\n"; } else if (argsInStr[DUMP_SECOND_PARAM] == "--unapply") { - uint32_t allowType = static_cast(std::atoi(argsInStr[DUMP_FIFTH_PARAM].c_str())); - sptr resourceRequest = new (std::nothrow) ResourceRequest(allowType, + uint32_t resourceType = static_cast(std::atoi(argsInStr[DUMP_FIFTH_PARAM].c_str())); + sptr resourceRequest = new (std::nothrow) ResourceRequest(resourceType, uid, name, 0, "dump", std::atoi(argsInStr[DUMP_SEVENTH_PARAM].c_str())); - UnapplyAllowResource(resourceRequest); + ReleaseExemptionResource(resourceRequest); result += "remove one object to allow list\n"; } else if (argsInStr[DUMP_SECOND_PARAM] == "--get") { - uint32_t allowType = static_cast(std::atoi(argsInStr[DUMP_THIRD_PARAM].c_str())); + uint32_t resourceType = static_cast(std::atoi(argsInStr[DUMP_THIRD_PARAM].c_str())); bool isApp = (std::atoi(argsInStr[DUMP_FOURTH_PARAM].c_str()) == 0); - std::vector allowInfoList; - GetAllowListInner(allowType, allowInfoList, isApp); + std::vector allowInfoList; + GetAllowListInner(resourceType, allowInfoList, isApp); for (const auto& allowInfo : allowInfoList) { - result += "allowType: " + std::to_string(allowInfo.GetAllowType()) + "\n" + + result += "resourceType: " + std::to_string(allowInfo.GetResourceType()) + "\n" + "name: " + allowInfo.GetName() + "\n" + "duration: " + std::to_string(allowInfo.GetDuration()) + "\n"; } allowInfoList.clear(); - GetRestrictListInner(allowType, allowInfoList, isApp); + GetRestrictedAppsInner(resourceType, allowInfoList, isApp); for (const auto& allowInfo : allowInfoList) { - result += "restrictType: " + std::to_string(allowInfo.GetAllowType()) + "\n" + + result += "restrictType: " + std::to_string(allowInfo.GetResourceType()) + "\n" + "name: " + allowInfo.GetName() + "\n"; } } diff --git a/services/notification/include/standby_state_subscriber.h b/services/notification/include/standby_state_subscriber.h index 6d0f5069e89aac643c90ccc6e2485a655fcfaefa..c83f3af6c4b0ccb63cfc71938278029d1f6e7922 100644 --- a/services/notification/include/standby_state_subscriber.h +++ b/services/notification/include/standby_state_subscriber.h @@ -24,7 +24,7 @@ #include "singleton.h" #include "iremote_object.h" -#include "allow_type.h" +#include "resource_type.h" #include "single_instance.h" #include "standby_service_errors.h" #include "istandby_service_subscriber.h" @@ -41,15 +41,15 @@ public: ErrCode AddSubscriber(const sptr& subscriber); ErrCode RemoveSubscriber(const sptr& subscriber); void ReportStandbyState(uint32_t curState); - void ReportAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added); + void ReportAllowListChanged(int32_t uid, const std::string& name, uint32_t resourceType, bool added); void HandleSubscriberDeath(const wptr& remote); void ShellDump(const std::vector& argsInStr, std::string& result); private: - void NotifyIdleModeByCallback(bool napped, bool sleeping); - void NotifyIdleModeByCommonEvent(bool napped, bool sleeping); - void NotifyAllowChangedByCallback(int32_t uid, const std::string& name, uint32_t allowType, bool added); - void NotifyAllowChangedByCommonEvent(int32_t uid, const std::string& name, uint32_t allowType, bool added); + void NotifyIdleModeByCallback(bool napped, bool isIdle); + void NotifyIdleModeByCommonEvent(bool napped, bool isIdle); + void NotifyAllowChangedByCallback(int32_t uid, const std::string& name, uint32_t resourceType, bool added); + void NotifyAllowChangedByCommonEvent(int32_t uid, const std::string& name, uint32_t resourceType, bool added); std::list>::iterator FindSubcriberObject(sptr& proxy); private: diff --git a/services/notification/src/standby_state_subscriber.cpp b/services/notification/src/standby_state_subscriber.cpp index ea803b4d95d1f2f5717897d8943dd6af629892ab..afff4ef0a7a2059b7706ba3fc287eeda81e61f71 100644 --- a/services/notification/src/standby_state_subscriber.cpp +++ b/services/notification/src/standby_state_subscriber.cpp @@ -95,13 +95,13 @@ ErrCode StandbyStateSubscriber::RemoveSubscriber(const sptr subcriberLock(subscriberLock_); if (subscriberList_.empty()) { @@ -109,17 +109,17 @@ void StandbyStateSubscriber::NotifyIdleModeByCallback(bool napped, bool sleeping return; } for (auto iter = subscriberList_.begin(); iter != subscriberList_.end(); ++iter) { - (*iter)->OnDeviceIdleMode(napped, sleeping); + (*iter)->OnDeviceIdleMode(napped, isIdle); } STANDBYSERVICE_LOGD("stop callback subscriber list"); } -void StandbyStateSubscriber::NotifyIdleModeByCommonEvent(bool napped, bool sleeping) +void StandbyStateSubscriber::NotifyIdleModeByCommonEvent(bool napped, bool isIdle) { AAFwk::Want want; want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED); want.SetParam("napped", napped); - want.SetParam("sleeping", sleeping); + want.SetParam("isIdle", isIdle); EventFwk::CommonEventData commonEventData; commonEventData.SetWant(want); if (!EventFwk::CommonEventManager::PublishCommonEvent(commonEventData)) { @@ -130,16 +130,16 @@ void StandbyStateSubscriber::NotifyIdleModeByCommonEvent(bool napped, bool sleep } void StandbyStateSubscriber::ReportAllowListChanged(int32_t uid, const std::string& name, - uint32_t allowType, bool added) + uint32_t resourceType, bool added) { STANDBYSERVICE_LOGI("start ReportAllowListChanged, uid is %{public}d"\ - ", name is %{public}s, allowType is %{public}d", uid, name.c_str(), allowType); - NotifyAllowChangedByCallback(uid, name, allowType, added); - NotifyAllowChangedByCommonEvent(uid, name, allowType, added); + ", name is %{public}s, resourceType is %{public}d", uid, name.c_str(), resourceType); + NotifyAllowChangedByCallback(uid, name, resourceType, added); + NotifyAllowChangedByCommonEvent(uid, name, resourceType, added); } void StandbyStateSubscriber::NotifyAllowChangedByCallback(int32_t uid, const std::string& name, - uint32_t allowType, bool added) + uint32_t resourceType, bool added) { std::lock_guard subcriberLock(subscriberLock_); if (subscriberList_.empty()) { @@ -147,18 +147,18 @@ void StandbyStateSubscriber::NotifyAllowChangedByCallback(int32_t uid, const std return; } for (auto iter = subscriberList_.begin(); iter != subscriberList_.end(); ++iter) { - (*iter)->OnAllowListChanged(uid, name, allowType, added); + (*iter)->OnExemptedAppsChanged(uid, name, resourceType, added); } } void StandbyStateSubscriber::NotifyAllowChangedByCommonEvent(int32_t uid, const std::string& name, - uint32_t allowType, bool added) + uint32_t resourceType, bool added) { AAFwk::Want want; want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_EXEMPTION_LIST_UPDATED); want.SetParam("uid", uid); want.SetParam("name", name); - want.SetParam("resourceType", static_cast(allowType)); + want.SetParam("resourceType", static_cast(resourceType)); want.SetParam("added", added); EventFwk::CommonEventData commonEventData; commonEventData.SetWant(want); diff --git a/services/test/unittest/standby_service_unit_test.cpp b/services/test/unittest/standby_service_unit_test.cpp index 4f0ba08e164033cd8a3bfdc49d639b0ccdcad9cb..2df2f3302f088e786288c29c7fa5dbc009b0bf4a 100644 --- a/services/test/unittest/standby_service_unit_test.cpp +++ b/services/test/unittest/standby_service_unit_test.cpp @@ -35,7 +35,7 @@ #include "strategy_manager_adapter.h" #include "standby_state.h" -#include "allow_type.h" +#include "resource_type.h" #include "standby_ipc_interface_code.h" #include "standby_service_client.h" #include "standby_service.h" @@ -197,11 +197,11 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_003, TestSize.Level1) StandbyService::GetInstance()->UnsubscribeStandbyCallback(subscriber); sptr resourceRequest = new (std::nothrow) ResourceRequest(); - EXPECT_NE(StandbyService::GetInstance()->ApplyAllowResource(resourceRequest), ERR_OK); - EXPECT_NE(StandbyService::GetInstance()->UnapplyAllowResource(resourceRequest), ERR_OK); + EXPECT_NE(StandbyService::GetInstance()->RequestExemptionResource(resourceRequest), ERR_OK); + EXPECT_NE(StandbyService::GetInstance()->ReleaseExemptionResource(resourceRequest), ERR_OK); - std::vector allowInfoList; - EXPECT_NE(StandbyService::GetInstance()->GetAllowList(AllowType::NETWORK, allowInfoList, 0), ERR_OK); + std::vector allowInfoList; + EXPECT_NE(StandbyService::GetInstance()->GetExemptedApps(AllowType::NETWORK, allowInfoList, 0), ERR_OK); bool isStandby {false}; EXPECT_NE(StandbyService::GetInstance()->IsDeviceInStandby(isStandby), ERR_OK); StandbyService::GetInstance()->ReportWorkSchedulerStatus(true, -1, ""); @@ -209,9 +209,9 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_003, TestSize.Level1) EXPECT_TRUE(StandbyServiceImpl::GetInstance()->isServiceReady_.load()); StandbyService::GetInstance()->SubscribeStandbyCallback(subscriber); StandbyService::GetInstance()->UnsubscribeStandbyCallback(subscriber); - StandbyService::GetInstance()->ApplyAllowResource(resourceRequest); - StandbyService::GetInstance()->UnapplyAllowResource(resourceRequest); - EXPECT_EQ(StandbyService::GetInstance()->GetAllowList(AllowType::NETWORK, allowInfoList, 0), ERR_OK); + StandbyService::GetInstance()->RequestExemptionResource(resourceRequest); + StandbyService::GetInstance()->ReleaseExemptionResource(resourceRequest); + EXPECT_EQ(StandbyService::GetInstance()->GetExemptedApps(AllowType::NETWORK, allowInfoList, 0), ERR_OK); EXPECT_EQ(StandbyService::GetInstance()->IsDeviceInStandby(isStandby), ERR_OK); StandbyService::GetInstance()->ReportWorkSchedulerStatus(true, -1, ""); } @@ -233,10 +233,10 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_004, TestSize.Level1) MockStartTimer(true); StandbyServiceImpl::GetInstance()->RemoveAppAllowRecord(DEFAULT_UID, DEFAULT_BUNDLENAME, true); sptr resourceRequest = new (std::nothrow) ResourceRequest(); - StandbyServiceImpl::GetInstance()->ApplyAllowResource(resourceRequest); - StandbyServiceImpl::GetInstance()->UnapplyAllowResource(resourceRequest); - std::vector allowInfoList; - StandbyServiceImpl::GetInstance()->GetAllowList(AllowType::NETWORK, allowInfoList, 0); + StandbyServiceImpl::GetInstance()->RequestExemptionResource(resourceRequest); + StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(resourceRequest); + std::vector allowInfoList; + StandbyServiceImpl::GetInstance()->GetExemptedApps(AllowType::NETWORK, allowInfoList, 0); bool isStandby {false}; EXPECT_NE(StandbyServiceImpl::GetInstance()->IsDeviceInStandby(isStandby), ERR_OK); std::vector argsInStr {}; @@ -432,14 +432,14 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_012, TestSize.Level1) /** * @tc.name: StandbyServiceUnitTest_013 - * @tc.desc: test ApplyAllowResource of StandbyService. + * @tc.desc: test RequestExemptionResource of StandbyService. * @tc.type: FUNC * @tc.require: */ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_013, TestSize.Level1) { sptr resourceRequest = new (std::nothrow) ResourceRequest(); - StandbyServiceImpl::GetInstance()->ApplyAllowResource(resourceRequest); + StandbyServiceImpl::GetInstance()->RequestExemptionResource(resourceRequest); SleepForFC(); StandbyServiceImpl::GetInstance()->ApplyAllowResInner(resourceRequest, -1); EXPECT_EQ(StandbyServiceImpl::GetInstance()->allowInfoMap_.size(), 0); @@ -470,7 +470,7 @@ HWTEST_F(StandbyServiceUnitTest, UpdateRecord_014, TestSize.Level1) HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_015, TestSize.Level1) { std::shared_ptr allowRecord = std::make_shared(); - sptr resourceRequest = new (std::nothrow) ResourceRequest(MAX_ALLOW_TYPE_NUMBER, DEFAULT_UID, + sptr resourceRequest = new (std::nothrow) ResourceRequest(MAX_RESOURCE_TYPE_NUMBER, DEFAULT_UID, DEFAULT_BUNDLENAME, 10, "reason", ReasonCodeEnum::REASON_APP_API); StandbyServiceImpl::GetInstance()->UpdateRecord(allowRecord, resourceRequest); SleepForFC(); @@ -489,7 +489,7 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_016, TestSize.Level1) SleepForFC(); StandbyServiceImpl::GetInstance()->DayNightSwitchCallback(); SleepForFC(); - StandbyServiceImpl::GetInstance()->standbyStateManager_->TransitToStateInner(StandbyState::SLEEP); + StandbyServiceImpl::GetInstance()->standbyStateManager_->TransitToStateInner(StandbyState::IDLE); SleepForFC(); StandbyServiceImpl::GetInstance()->DayNightSwitchCallback(); SleepForFC(); @@ -520,42 +520,42 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_017, TestSize.Level1) allowRecord->allowTimeList_.emplace_back(AllowTime{0, INT64_MAX, "reason"}); StandbyServiceImpl::GetInstance()->allowInfoMap_.emplace(DEFAULT_KEY, allowRecord); - std::vector allowInfoList; - StandbyServiceImpl::GetInstance()->GetAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + std::vector allowInfoList; + StandbyServiceImpl::GetInstance()->GetExemptedApps(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_APP_API); - StandbyServiceImpl::GetInstance()->GetAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetExemptedApps(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_NATIVE_API); std::string result {""}; StandbyServiceImpl::GetInstance()->ShellDumpInner({"-A", "--get", "127", "true"}, result); - StandbyServiceImpl::GetInstance()->GetAllowListInner(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetAllowListInner(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_APP_API); - StandbyServiceImpl::GetInstance()->GetAllowListInner(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetAllowListInner(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_NATIVE_API); StandbyServiceImpl::GetInstance()->GetAllowListInner(0, allowInfoList, ReasonCodeEnum::REASON_NATIVE_API); - StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_APP_API); - StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_NATIVE_API); - StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, true, true); - StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, true, false); sptr resourceRequest = new (std::nothrow) ResourceRequest(); - StandbyServiceImpl::GetInstance()->UnapplyAllowResource(resourceRequest); + StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(resourceRequest); StandbyServiceImpl::GetInstance()->DayNightSwitchCallback(); SleepForFC(); StandbyServiceImpl::GetInstance()->UnapplyAllowResInner(DEFAULT_UID, DEFAULT_BUNDLENAME, 1, false); StandbyServiceImpl::GetInstance()->UnapplyAllowResInner(DEFAULT_UID, DEFAULT_BUNDLENAME, 1, true); - allowRecord = std::make_shared(0, 0, "name", MAX_ALLOW_TYPE_NUMBER); + allowRecord = std::make_shared(0, 0, "name", MAX_RESOURCE_TYPE_NUMBER); allowRecord->allowTimeList_.emplace_back(AllowTime{0, INT64_MAX, "reason"}); allowRecord->allowTimeList_.emplace_back(AllowTime{1, INT64_MAX, "reason"}); StandbyServiceImpl::GetInstance()->allowInfoMap_.emplace(DEFAULT_KEY, allowRecord); - StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetTemporaryAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, ReasonCodeEnum::REASON_NATIVE_API); - StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, true, true); - StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_ALLOW_TYPE_NUMBER, allowInfoList, + StandbyServiceImpl::GetInstance()->GetPersistAllowList(MAX_RESOURCE_TYPE_NUMBER, allowInfoList, false, true); StandbyServiceImpl::GetInstance()->allowInfoMap_.clear(); EXPECT_EQ(StandbyServiceImpl::GetInstance()->allowInfoMap_.size(), 0); @@ -784,54 +784,54 @@ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_027, TestSize.Level1, 2 /** * @tc.name: StandbyServiceUnitTest_028 - * @tc.desc: test multithread ApplyAllowResource of StandbyService. + * @tc.desc: test multithread RequestExemptionResource of StandbyService. * @tc.type: FUNC * @tc.require: */ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_028, TestSize.Level1, 20) { sptr resourceRequest = new (std::nothrow) ResourceRequest(); - StandbyServiceImpl::GetInstance()->ApplyAllowResource(resourceRequest); + StandbyServiceImpl::GetInstance()->RequestExemptionResource(resourceRequest); sptr validResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, 0, "test_process", 100, "test", 1); - EXPECT_EQ(StandbyServiceImpl::GetInstance()->ApplyAllowResource(validResRequest), ERR_OK); + EXPECT_EQ(StandbyServiceImpl::GetInstance()->RequestExemptionResource(validResRequest), ERR_OK); sptr invalidResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, -1, "test_process", 100, "test", 1); - StandbyServiceImpl::GetInstance()->ApplyAllowResource(invalidResRequest); + StandbyServiceImpl::GetInstance()->RequestExemptionResource(invalidResRequest); sptr negResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, 0, "test_process", -1, "test", 1); - StandbyServiceImpl::GetInstance()->ApplyAllowResource(negResRequest); + StandbyServiceImpl::GetInstance()->RequestExemptionResource(negResRequest); StandbyServiceUnitTest::SleepForFC(); } /** * @tc.name: StandbyServiceUnitTest_029 - * @tc.desc: test multithread UnapplyAllowResource of StandbyService. + * @tc.desc: test multithread ReleaseExemptionResource of StandbyService. * @tc.type: FUNC * @tc.require: */ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_029, TestSize.Level1, 20) { sptr resourceRequest = new (std::nothrow) ResourceRequest(); - StandbyServiceImpl::GetInstance()->UnapplyAllowResource(resourceRequest); + StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(resourceRequest); sptr validResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, 0, "test_process", 100, "test", 1); - EXPECT_EQ(StandbyServiceImpl::GetInstance()->UnapplyAllowResource(validResRequest), ERR_OK); + EXPECT_EQ(StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(validResRequest), ERR_OK); sptr invalidResRequest = new (std::nothrow) ResourceRequest(AllowType::NETWORK, -1, "test_process", 100, "test", 1); - StandbyServiceImpl::GetInstance()->UnapplyAllowResource(invalidResRequest); + StandbyServiceImpl::GetInstance()->ReleaseExemptionResource(invalidResRequest); } /** * @tc.name: StandbyServiceUnitTest_030 - * @tc.desc: test multithread GetAllowList of StandbyService. + * @tc.desc: test multithread GetExemptedApps of StandbyService. * @tc.type: FUNC * @tc.require: */ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_030, TestSize.Level1, 20) { - std::vector allowInfoList; - StandbyServiceImpl::GetInstance()->GetAllowList(AllowType::NETWORK, allowInfoList, 0); + std::vector allowInfoList; + StandbyServiceImpl::GetInstance()->GetExemptedApps(AllowType::NETWORK, allowInfoList, 0); EXPECT_EQ(allowInfoList.size(), 0); } @@ -916,11 +916,11 @@ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_035, TestSize.Level1, 2 MockPublishCommonEvent(true); StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::WORKING); StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::NAP); - StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::SLEEP); + StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::IDLE); MockPublishCommonEvent(false); StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::WORKING); StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::NAP); - StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::SLEEP); + StandbyStateSubscriber::GetInstance()->ReportStandbyState(StandbyState::IDLE); MockPublishCommonEvent(true); EXPECT_TRUE(true); } @@ -941,9 +941,9 @@ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_036, TestSize.Level1, 2 subscriber->OnRemoteRequest( (static_cast(StandbySubscriberInterfaceCode::ON_DEVICE_IDLE_MODE)), data, reply, option); subscriber->OnRemoteRequest( - (static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED)), data, reply, option); + (static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED)), data, reply, option); auto ret = subscriber->OnRemoteRequest( - static_cast(StandbySubscriberInterfaceCode::ON_ALLOW_LIST_CHANGED) + 1, data, reply, option); + static_cast(StandbySubscriberInterfaceCode::ON_EXEMPTED_APPS_CHANGED) + 1, data, reply, option); EXPECT_NE(ret, ERR_OK); } @@ -962,20 +962,20 @@ HWMTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_037, TestSize.Level1, 2 StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::SUBSCRIBE_STANDBY_CALLBACK, data, reply, option); StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::UNSUBSCRIBE_STANDBY_CALLBACK, data, reply, option); - StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::APPLY_ALLOW_RESOURCE, data, reply, option); - StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::UNAPPLY_ALLOW_RESOURCE, data, reply, option); - StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::GET_ALLOW_LIST, data, reply, option); + StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::REQUEST_EXEMPTION_RESOURCE, data, reply, option); + StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::RELEASE_EXEMPTION_RESOURCE, data, reply, option); + StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::GET_EXEMPTED_APPS, data, reply, option); StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::IS_DEVICE_IN_STANDBY, data, reply, option); StandbyService::GetInstance()->OnRemoteRequest( StandbyServiceStub::REPORT_WORK_SCHEDULER_STATUS, data, reply, option); auto ret = StandbyService::GetInstance()->OnRemoteRequest(StandbyServiceStub::REPORT_WORK_SCHEDULER_STATUS + 1, data, reply, option); StandbyService::GetInstance()->OnRemoteRequest( - (static_cast(IStandbyInterfaceCode::APPLY_ALLOW_RESOURCE)), data, reply, option); + (static_cast(IStandbyInterfaceCode::REQUEST_EXEMPTION_RESOURCE)), data, reply, option); StandbyService::GetInstance()->OnRemoteRequest( - (static_cast(IStandbyInterfaceCode::UNAPPLY_ALLOW_RESOURCE)), data, reply, option); + (static_cast(IStandbyInterfaceCode::RELEASE_EXEMPTION_RESOURCE)), data, reply, option); StandbyService::GetInstance()->OnRemoteRequest( - (static_cast(IStandbyInterfaceCode::GET_ALLOW_LIST)), data, reply, option); + (static_cast(IStandbyInterfaceCode::GET_EXEMPTED_APPS)), data, reply, option); StandbyService::GetInstance()->OnRemoteRequest( (static_cast(IStandbyInterfaceCode::IS_DEVICE_IN_STANDBY)), data, reply, option); ret = StandbyService::GetInstance()->OnRemoteRequest( @@ -1041,8 +1041,8 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_040, TestSize.Level1) MessageParcel reply; MessageOption option = {MessageOption::TF_ASYNC}; data.WriteInterfaceToken(IStandbyService::GetDescriptor()); - StandbyService::GetInstance()->HandleApplyAllowResource(data, reply); - EXPECT_NE(StandbyService::GetInstance()->HandleUnapplyAllowResource(data, reply), ERR_OK); + StandbyService::GetInstance()->HandleRequestExemptionResource(data, reply); + EXPECT_NE(StandbyService::GetInstance()->HandleReleaseExemptionResource(data, reply), ERR_OK); MessageParcel workSchedulerData; workSchedulerData.WriteBool(false); @@ -1107,7 +1107,7 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_042, TestSize.Level1) /** * @tc.name: StandbyServiceUnitTest_043 - * @tc.desc: test GetRestrictList. + * @tc.desc: test GetRestrictedApps. * @tc.type: FUNC * @tc.require: */ @@ -1115,13 +1115,13 @@ HWTEST_F(StandbyServiceUnitTest, StandbyServiceUnitTest_043, TestSize.Level1) { StandbyService::GetInstance()->state_ = ServiceRunningState::STATE_RUNNING; uint32_t restrictType = 1; - std::vector restrictInfoList; + std::vector restrictInfoList; uint32_t reasonCode = 1; - EXPECT_EQ(StandbyService::GetInstance()->GetRestrictList(restrictType, restrictInfoList, reasonCode), ERR_OK); + EXPECT_EQ(StandbyService::GetInstance()->GetRestrictedApps(restrictType, restrictInfoList, reasonCode), ERR_OK); StandbyService::GetInstance()->state_ = ServiceRunningState::STATE_NOT_START; EXPECT_EQ(StandbyService::GetInstance()-> - GetRestrictList(restrictType, restrictInfoList, reasonCode), ERR_STANDBY_SYS_NOT_READY); + GetRestrictedApps(restrictType, restrictInfoList, reasonCode), ERR_STANDBY_SYS_NOT_READY); } /**