From 87fe955c786c126fec722541b2fba3f3f61e4893 Mon Sep 17 00:00:00 2001 From: wanghang Date: Sat, 30 Aug 2025 01:27:58 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!9919=20?= =?UTF-8?q?:=20=E5=8F=82=E6=95=B0=E4=B8=BA=E7=A9=BA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=97=B6js=E6=8E=A5=E5=8F=A3=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/bundle_manager/bundle_manager.cpp | 27 ++----------------- .../js/bundle_manager/bundle_manager_sync.cpp | 20 -------------- interfaces/kits/js/common/napi_constants.h | 2 -- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/interfaces/kits/js/bundle_manager/bundle_manager.cpp b/interfaces/kits/js/bundle_manager/bundle_manager.cpp index cc88918010..e8953ef86e 100644 --- a/interfaces/kits/js/bundle_manager/bundle_manager.cpp +++ b/interfaces/kits/js/bundle_manager/bundle_manager.cpp @@ -1626,29 +1626,14 @@ napi_value GetAbilityLabel(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, BUNDLE_NAME, TYPE_STRING); return nullptr; } - if (asyncCallbackInfo->bundleName.empty()) { - APP_LOGW("bundleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_BUNDLENAME_EMPTY_ERROR); - return nullptr; - } if (!CommonFunc::ParseString(env, args[ARGS_POS_ONE], asyncCallbackInfo->moduleName)) { BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, MODULE_NAME, TYPE_STRING); return nullptr; } - if (asyncCallbackInfo->moduleName.empty()) { - APP_LOGW("moduleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_MODULENAME_EMPTY_ERROR); - return nullptr; - } if (!CommonFunc::ParseString(env, args[ARGS_POS_TWO], asyncCallbackInfo->abilityName)) { BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, ABILITY_NAME, TYPE_STRING); return nullptr; } - if (asyncCallbackInfo->abilityName.empty()) { - APP_LOGW("abilityName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_ABILITYNAME_EMPTY_ERROR); - return nullptr; - } if (args.GetMaxArgc() == ARGS_SIZE_FOUR) { napi_valuetype valueType = napi_undefined; napi_typeof(env, args[ARGS_POS_THREE], &valueType); @@ -1887,16 +1872,12 @@ napi_value SetApplicationEnabled(napi_env env, napi_callback_info info) } } } - if (asyncCallbackInfo->bundleName.empty()) { - APP_LOGW("bundleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_BUNDLENAME_EMPTY_ERROR); - return nullptr; - } if (callCloneFunc && (args.GetMaxArgc() == ARGS_SIZE_TWO)) { APP_LOGE("params are too few for clone app"); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); return nullptr; } + auto promise = CommonFunc::AsyncCallNativeMethod( env, asyncCallbackInfo, "SetApplicationEnabled", SetApplicationEnabledExec, SetApplicationEnabledComplete); callbackPtr.release(); @@ -4610,11 +4591,7 @@ napi_value GetSpecifiedDistributionType(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, BUNDLE_NAME, TYPE_STRING); return nullptr; } - if (bundleName.empty()) { - APP_LOGW("bundleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_BUNDLENAME_EMPTY_ERROR); - return nullptr; - } + auto iBundleMgr = CommonFunc::GetBundleMgr(); if (iBundleMgr == nullptr) { APP_LOGE("iBundleMgr is null"); diff --git a/interfaces/kits/js/bundle_manager/bundle_manager_sync.cpp b/interfaces/kits/js/bundle_manager/bundle_manager_sync.cpp index 05f89342b2..3ae284ae5e 100644 --- a/interfaces/kits/js/bundle_manager/bundle_manager_sync.cpp +++ b/interfaces/kits/js/bundle_manager/bundle_manager_sync.cpp @@ -126,11 +126,6 @@ napi_value SetApplicationEnabledSync(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, BUNDLE_NAME, TYPE_STRING); return nullptr; } - if (bundleName.empty()) { - APP_LOGW("bundleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_BUNDLENAME_EMPTY_ERROR); - return nullptr; - } if (!CommonFunc::ParseBool(env, args[ARGS_POS_ONE], isEnable)) { APP_LOGE("parse isEnable failed"); BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, IS_ENABLE, TYPE_BOOLEAN); @@ -524,29 +519,14 @@ ErrCode ParamsProcessGetAbilityLabelSync(napi_env env, napi_callback_info info, BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, BUNDLE_NAME, TYPE_STRING); return ERROR_PARAM_CHECK_ERROR; } - if (bundleName.empty()) { - APP_LOGW("bundleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_BUNDLENAME_EMPTY_ERROR); - return ERROR_PARAM_CHECK_ERROR; - } if (!CommonFunc::ParseString(env, args[ARGS_POS_ONE], moduleName)) { BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, MODULE_NAME, TYPE_STRING); return ERROR_PARAM_CHECK_ERROR; } - if (moduleName.empty()) { - APP_LOGW("moduleName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_MODULENAME_EMPTY_ERROR); - return ERROR_PARAM_CHECK_ERROR; - } if (!CommonFunc::ParseString(env, args[ARGS_POS_TWO], abilityName)) { BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, ABILITY_NAME, TYPE_STRING); return ERROR_PARAM_CHECK_ERROR; } - if (abilityName.empty()) { - APP_LOGW("abilityName is empty"); - BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_ABILITYNAME_EMPTY_ERROR); - return ERROR_PARAM_CHECK_ERROR; - } } else { BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); return ERROR_PARAM_CHECK_ERROR; diff --git a/interfaces/kits/js/common/napi_constants.h b/interfaces/kits/js/common/napi_constants.h index 5054360c14..2ae29aa735 100644 --- a/interfaces/kits/js/common/napi_constants.h +++ b/interfaces/kits/js/common/napi_constants.h @@ -126,8 +126,6 @@ constexpr const char* PARAM_BUNDLENAME_EMPTY_ERROR = "BusinessError 401: Parameter error. parameter bundleName is empty"; constexpr const char* PARAM_MODULENAME_EMPTY_ERROR = "BusinessError 401: Parameter error. parameter moduleName is empty"; -constexpr const char* PARAM_ABILITYNAME_EMPTY_ERROR = - "BusinessError 401: Parameter error. parameter abilityName is empty"; constexpr const char* GET_SIGNATURE_INFO_PERMISSIONS = "ohos.permission.GET_SIGNATURE_INFO"; constexpr const char* PARAM_DEVELOPER_ID_EMPTY_ERROR = "BusinessError 401: Parameter error. parameter developerId is empty"; -- Gitee