去除ApplyEfficiencyResources接口中的多余参数

Signed-off-by: Zhao-PengFei35 <zhaopengfei35@huawei.com>
This commit is contained in:
Zhao-PengFei35 2022-09-09 14:16:34 +08:00
parent e5a11fabb1
commit fd396958a3
12 changed files with 17 additions and 33 deletions

View File

@ -115,10 +115,9 @@ public:
* @brief Apply or unapply efficiency resources.
*
* @param resourceInfo Request params.
* @param isSuccess succeed to apply efficiency recources.
* @return Returns ERR_OK on success, others on failure.
*/
ErrCode ApplyEfficiencyResources(const EfficiencyResourceInfo &resourceInfo, bool &isSuccess);
ErrCode ApplyEfficiencyResources(const EfficiencyResourceInfo &resourceInfo);
/**
* @brief Reset all efficiency resources.

View File

@ -109,10 +109,9 @@ public:
* @brief Apply or unapply efficiency resources.
*
* @param resourceInfo Request params.
* @param isSuccess succeed to apply efficiency resources.
* @return Returns ERR_OK on success, others on failure.
*/
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo, bool &isSuccess) override;
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo) override;
/**
* @brief Reset all efficiency resources.

View File

@ -116,10 +116,9 @@ public:
* @brief Apply or unapply efficiency resources.
*
* @param resourceInfo Request params.
* @param isSuccess succeed to apply efficiency resources.
* @return Returns ERR_OK on success, others on failure.
*/
virtual ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo, bool &isSuccess) = 0;
virtual ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo) = 0;
/**
* @brief Reset all efficiency resources apply.

View File

@ -88,7 +88,7 @@ public:
*/
virtual void OnContinuousTaskStop(
const std::shared_ptr<ContinuousTaskCallbackInfo> &continuousTaskCallbackInfo) = 0;
/**
* Called back when the app does not have continuous task.
*

View File

@ -134,7 +134,7 @@ ErrCode BackgroundTaskManager::GetTransientTaskApps(std::vector<std::shared_ptr<
return backgroundTaskMgrProxy_->GetTransientTaskApps(list);
}
ErrCode BackgroundTaskManager::ApplyEfficiencyResources(const EfficiencyResourceInfo &resourceInfo, bool &isSuccess)
ErrCode BackgroundTaskManager::ApplyEfficiencyResources(const EfficiencyResourceInfo &resourceInfo)
{
if (!GetBackgroundTaskManagerProxy()) {
BGTASK_LOGE("GetBackgroundTaskManagerProxy failed.");
@ -145,7 +145,7 @@ ErrCode BackgroundTaskManager::ApplyEfficiencyResources(const EfficiencyResource
BGTASK_LOGE("Failed to create efficiency resource info");
return ERR_BGTASK_NO_MEMORY;
}
ErrCode ret = backgroundTaskMgrProxy_->ApplyEfficiencyResources(resourceInfoPtr, isSuccess);
ErrCode ret = backgroundTaskMgrProxy_->ApplyEfficiencyResources(resourceInfoPtr);
return ret;
}

View File

@ -381,8 +381,7 @@ ErrCode BackgroundTaskMgrProxy::InnerTransact(uint32_t code, MessageOption &flag
}
}
ErrCode BackgroundTaskMgrProxy::ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo,
bool &isSuccess)
ErrCode BackgroundTaskMgrProxy::ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo)
{
if (resourceInfo == nullptr) {
return ERR_BGTASK_INVALID_PARAM;
@ -409,10 +408,6 @@ ErrCode BackgroundTaskMgrProxy::ApplyEfficiencyResources(const sptr<EfficiencyRe
BGTASK_LOGE("ApplyEfficiencyResources fail: read result failed.");
return ERR_BGTASK_PARCELABLE_FAILED;
}
if (!reply.ReadBool(isSuccess)) {
BGTASK_LOGE("ApplyEfficiencyResources fail: read result failed.");
return ERR_BGTASK_PARCELABLE_FAILED;
}
return result;
}

View File

@ -264,16 +264,11 @@ ErrCode BackgroundTaskMgrStub::HandleApplyEfficiencyResources(MessageParcel& dat
BGTASK_LOGE("EfficiencyResourceInfo ReadParcelable failed");
return ERR_BGTASK_PARCELABLE_FAILED;
}
bool isSuccess {false};
ErrCode result = ApplyEfficiencyResources(resourceInfoPtr, isSuccess);
ErrCode result = ApplyEfficiencyResources(resourceInfoPtr);
if (!reply.WriteInt32(result)) {
BGTASK_LOGE("HandleApplyEfficiencyResources write result failed, ErrCode=%{public}d", result);
return ERR_BGTASK_PARCELABLE_FAILED;
}
if (!reply.WriteBool(isSuccess)) {
BGTASK_LOGE("HandleApplyEfficiencyResources Write result fail.");
return ERR_BGTASK_PARCELABLE_FAILED;
}
return ERR_OK;
}

View File

@ -104,14 +104,13 @@ napi_value ApplyEfficiencyResources(napi_env env, napi_callback_info info)
{
BGTASK_LOGD("start ApplyEfficiencyResources");
EfficiencyResourceInfo params;
bool isSuccess = false;
napi_value result = nullptr;
if (ParseParameters(env, info, params) == nullptr || !CheckValidInfo(params)) {
NAPI_CALL(env, napi_get_boolean(env, isSuccess, &result));
NAPI_CALL(env, napi_get_boolean(env, false, &result));
return result;
}
DelayedSingleton<BackgroundTaskManager>::GetInstance()->ApplyEfficiencyResources(params, isSuccess);
NAPI_CALL(env, napi_get_boolean(env, isSuccess, &result));
ErrCode suc = DelayedSingleton<BackgroundTaskManager>::GetInstance()->ApplyEfficiencyResources(params);
NAPI_CALL(env, napi_get_boolean(env, suc == ERR_OK, &result));
return result;
}

View File

@ -61,7 +61,7 @@ public:
ErrCode UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber) override;
ErrCode GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> &list) override;
ErrCode GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list) override;
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo, bool &isSuccess) override;
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo) override;
ErrCode ResetAllEfficiencyResources() override;
ErrCode GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<ResourceCallbackInfo>> &appList,
std::vector<std::shared_ptr<ResourceCallbackInfo>> &procList) override;

View File

@ -167,10 +167,9 @@ void BackgroundTaskMgrService::HandleSubscriberDeath(const wptr<IRemoteObject>&
DelayedSingleton<BgTransientTaskMgr>::GetInstance()->HandleSubscriberDeath(remote);
}
ErrCode BackgroundTaskMgrService::ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo,
bool &isSuccess)
ErrCode BackgroundTaskMgrService::ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo)
{
return DelayedSingleton<BgEfficiencyResourcesMgr>::GetInstance()->ApplyEfficiencyResources(resourceInfo, isSuccess);
return DelayedSingleton<BgEfficiencyResourcesMgr>::GetInstance()->ApplyEfficiencyResources(resourceInfo);
}
ErrCode BackgroundTaskMgrService::ResetAllEfficiencyResources()

View File

@ -49,7 +49,7 @@ public:
bool Init();
void InitNecessaryState();
void Clear();
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo, bool &isSuccess);
ErrCode ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo);
ErrCode ResetAllEfficiencyResources();
ErrCode GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<ResourceCallbackInfo>> &appList,
std::vector<std::shared_ptr<ResourceCallbackInfo>> &procList);

View File

@ -280,7 +280,7 @@ bool CheckResourceInfo(const sptr<EfficiencyResourceInfo> &resourceInfo)
}
ErrCode BgEfficiencyResourcesMgr::ApplyEfficiencyResources(
const sptr<EfficiencyResourceInfo> &resourceInfo, bool &isSuccess)
const sptr<EfficiencyResourceInfo> &resourceInfo)
{
BGTASK_LOGD("start bgtaskefficiency");
if (!isSysReady_.load()) {
@ -303,8 +303,7 @@ ErrCode BgEfficiencyResourcesMgr::ApplyEfficiencyResources(
BGTASK_LOGI("apply efficiency resources failed, running resource apply is false");
return ERR_BGTASK_PERMISSION_DENIED;
}
isSuccess = true;
std::shared_ptr<ResourceCallbackInfo> callbackInfo = std::make_shared<ResourceCallbackInfo>(uid,
pid, resourceInfo->GetResourceNumber(), bundleName);
if (resourceInfo->IsApply()) {