From c9b90d70dac739981dc07e5647e5f2fdd3ada0fa Mon Sep 17 00:00:00 2001 From: chennian Date: Fri, 16 May 2025 01:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chennian --- .../ets/@ohos.abilityAccessCtrl.ets | 120 ++++++++---------- .../accesstoken/src/ability_access_ctrl.cpp | 38 +++--- frameworks/ets/ani/common/include/ani_error.h | 2 +- .../ani/privacy/ets/@ohos.privacyManager.ets | 38 +++--- .../ets/ani/privacy/src/privacy_manager.cpp | 32 ++--- 5 files changed, 102 insertions(+), 128 deletions(-) diff --git a/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets b/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets index 4b7136acc..3ea4308bb 100644 --- a/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets +++ b/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets @@ -28,93 +28,69 @@ export { Permissions }; export type PermissionRequestResult = _PermissionRequestResult; export default namespace abilityAccessCtrl { - loadLibrary("accesstoken_ani.z"); export enum GrantStatus { - PERMISSION_DENIED = -1, - PERMISSION_GRANTED = 0 - } + }; export enum PermissionRequestToggleStatus { - CLOSED = 0, - OPEN = 1, - } + }; export enum PermissionStatus { - DENIED = -1, - GRANTED = 0, - NOT_DETERMINED = 1, - INVALID = 2, - RESTRICTED = 3 - } + }; interface PermissionStateChangeInfo { - change: PermissionStateChangeType; - tokenID: int; - permissionName: Permissions; } export enum PermissionStateChangeType { - PERMISSION_REVOKED_OPER = 0, - PERMISSION_GRANTED_OPER = 1 - } + }; export enum SwitchType { - CAMERA = 0, - MICROPHONE = 1, - LOCATION = 2, - } - - enum STSErrorCode { + }; + enum ETSErrorCode { STS_OK = 0, - STS_ERROR_PERMISSION_DENIED = 201, - STS_ERROR_NOT_SYSTEM_APP = 202, - STS_ERROR_PARAM_ILLEGAL = 401, - STS_ERROR_SYSTEM_CAPABILITY_NOT_SUPPORT = 801, - - } ; + }; function validateRequestParams(context: Context, permissionList: Array): void { if (typeof context === "undefined" || context == null) { let err = new BusinessError(); - err.code = STSErrorCode.STS_ERROR_PARAM_ILLEGAL; + err.code = ETSErrorCode.STS_ERROR_PARAM_ILLEGAL; err.data = PARAM_ERROR_MSG("context", "UIAbility or UIExtension Context"); throw err; } if (typeof permissionList !== "object" || !Array.isArray(permissionList) || - permissionList.length == 0 || typeof permissionList[0] !== "string") { + permissionList.length == 0 || typeof permissionList[0] !== 'string') { let err = new BusinessError(); - err.code = STSErrorCode.STS_ERROR_PARAM_ILLEGAL; + err.code = ETSErrorCode.STS_ERROR_PARAM_ILLEGAL; err.data = PARAM_ERROR_MSG("permissionList", "Array"); throw err; } } function validateTokenAndPermission(tokenID: int, permissionName: Permissions): void { - if (typeof permissionName !== "string") { + if (typeof permissionName !== 'string') { let err = new BusinessError(); - err.code = STSErrorCode.STS_ERROR_PARAM_ILLEGAL; + err.code = ETSErrorCode.STS_ERROR_PARAM_ILLEGAL; err.data = PARAM_ERROR_MSG("permissionName", "Permissions"); throw err; } @@ -122,62 +98,60 @@ export default namespace abilityAccessCtrl { native function createAtManager(): AtManager; interface AtManager { - checkAccessTokenANI(tokenID: int, permissionName: Permissions): int; - checkAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus; - checkAccessToken(tokenID: int, permissionName: Permissions): Promise - - verifyAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus; - + checkAccessTokenExecute(tokenID: int, permissionName: Permissions): int; requestPermissionsFromUserExecute( - context: Context, - permissionList: Array):PermissionRequestResult; + context: Context, permissionList: Array):PermissionRequestResult; + requestPermissionOnSettingExecute( + context: Context, permissionList: Array): Array; + checkAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus; + verifyAccessToken(tokenID: int, permissionName: Permissions): Promise; + checkAccessToken(tokenID: int, permissionName: Permissions): Promise; + verifyAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus; requestPermissionsFromUser( context: Context, permissionList: Array, - requestCallback: AsyncCallback + requestCallback: AsyncCallback ): void; requestPermissionsFromUser( - context: Context, - permissionList: Array): Promise; - - requestPermissionOnSettingExecute( - context: Context, - permissionList: Array): Array; + context: Context, permissionList: Array): Promise; requestPermissionOnSetting( - context: Context, - permissionList: Array): Promise>; + context: Context, permissionList: Array): Promise>; } class AtManagerInner implements AtManager { - native checkAccessTokenANI(tokenID: int, permissionName: Permissions): int; + native checkAccessTokenExecute(tokenID: int, permissionName: Permissions): int; + native requestPermissionsFromUserExecute( + context: Context, permissionList: Array): PermissionRequestResult; + native requestPermissionOnSettingExecute( + context: Context, permissionList: Array): Array; verifyAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus { validateTokenAndPermission(tokenID, permissionName); - let result = this.checkAccessTokenANI(tokenID, permissionName); + let result = this.checkAccessTokenExecute(tokenID, permissionName); if (result == 0) { - return GrantStatus.PERMISSION_GRANTED + return GrantStatus.PERMISSION_GRANTED; } - return GrantStatus.PERMISSION_DENIED + return GrantStatus.PERMISSION_DENIED; } checkAccessTokenSync(tokenID: int, permissionName: Permissions): GrantStatus { validateTokenAndPermission(tokenID, permissionName); - let result = this.checkAccessTokenANI(tokenID, permissionName); + let result = this.checkAccessTokenExecute(tokenID, permissionName); if (result == 0) { - return GrantStatus.PERMISSION_GRANTED + return GrantStatus.PERMISSION_GRANTED; } - return GrantStatus.PERMISSION_DENIED + return GrantStatus.PERMISSION_DENIED; } - checkAccessToken(tokenID: int, permissionName: Permissions): Promise { + verifyAccessToken(tokenID: int, permissionName: Permissions): Promise { validateTokenAndPermission(tokenID, permissionName); let p = new Promise((resolve: (v: GrantStatus) => void, reject: (error: BusinessError) => void) => { - let p1 = taskpool.execute((): GrantStatus => { return new AtManagerInner().checkAccessTokenANI(tokenID, - permissionName) as GrantStatus;}); + let p1 = taskpool.execute((): GrantStatus => { + return new AtManagerInner().checkAccessTokenExecute(tokenID, permissionName) as GrantStatus;}); p1.then((e: NullishType) => { resolve(e as GrantStatus); }).catch((err: BusinessError): void => { @@ -187,8 +161,20 @@ export default namespace abilityAccessCtrl { return p; } - native requestPermissionsFromUserExecute(context: Context, - permissionList: Array): PermissionRequestResult; + checkAccessToken(tokenID: int, permissionName: Permissions): Promise { + validateTokenAndPermission(tokenID, permissionName); + let p = new Promise((resolve: (v: GrantStatus) + => void, reject: (error: BusinessError) => void) => { + let p1 = taskpool.execute((): GrantStatus => { + return new AtManagerInner().checkAccessTokenExecute(tokenID, permissionName) as GrantStatus;}); + p1.then((e: NullishType) => { + resolve(e as GrantStatus); + }).catch((err: BusinessError): void => { + reject(err); + }); + }); + return p; + } requestPermissionsFromUser(context: Context, permissionList: Array, callback:AsyncCallback): void { @@ -233,10 +219,6 @@ export default namespace abilityAccessCtrl { return p; } - native requestPermissionOnSettingExecute( - context: Context, - permissionList: Array): Array; - requestPermissionOnSetting(context: Context, permissionList: Array): Promise> { validateRequestParams(context, permissionList); diff --git a/frameworks/ets/ani/accesstoken/src/ability_access_ctrl.cpp b/frameworks/ets/ani/accesstoken/src/ability_access_ctrl.cpp index 7f9a763f5..c5a6b48ec 100644 --- a/frameworks/ets/ani/accesstoken/src/ability_access_ctrl.cpp +++ b/frameworks/ets/ani/accesstoken/src/ability_access_ctrl.cpp @@ -511,12 +511,12 @@ static bool ParseRequestPermissionFromUser(ani_env* env, ani_object aniContext, std::shared_ptr& asyncContext) { if (ConvertContext(env, aniContext, asyncContext) != ANI_OK) { - BusinessErrorAni::ThrowParameterTypeError(env, STSErrorCode::STS_ERROR_PARAM_ILLEGAL, + BusinessErrorAni::ThrowParameterTypeError(env, ETSErrorCode::STS_ERROR_PARAM_ILLEGAL, GetParamErrorMsg("context", "UIAbility or UIExtension Context")); return false; } if (!ProcessArrayString(env, nullptr, permissionList, asyncContext->permissionList)) { - BusinessErrorAni::ThrowParameterTypeError(env, STSErrorCode::STS_ERROR_PARAM_ILLEGAL, + BusinessErrorAni::ThrowParameterTypeError(env, ETSErrorCode::STS_ERROR_PARAM_ILLEGAL, GetParamErrorMsg("permissionList", "Array")); return false; } @@ -529,7 +529,7 @@ static bool RequestPermissionsFromUserProcess([[maybe_unused]] ani_env* env, if (!IsDynamicRequest(asyncContext)) { ACCESSTOKEN_LOG_ERROR(LABEL, "It does not need to request permission"); asyncContext->needDynamicRequest = false; - if ((asyncContext->permissionsState.empty()) && (asyncContext->result == STSErrorCode::STS_OK)) { + if ((asyncContext->permissionsState.empty()) && (asyncContext->result == ETSErrorCode::STS_OK)) { ACCESSTOKEN_LOG_ERROR(LABEL, "GrantResults empty"); asyncContext->result = RET_FAILED; } @@ -869,7 +869,7 @@ static void UpdatePermissionCache(AtManagerAsyncContext* asyncContext) } } -static ani_int CheckAccessTokenSync([[maybe_unused]] ani_env* env, [[maybe_unused]] ani_object object, +static ani_int CheckAccessTokenExecute([[maybe_unused]] ani_env* env, [[maybe_unused]] ani_object object, ani_int tokenID, ani_string permissionName) { if (env == nullptr) { @@ -878,12 +878,12 @@ static ani_int CheckAccessTokenSync([[maybe_unused]] ani_env* env, [[maybe_unuse } if (tokenID == 0) { BusinessErrorAni::ThrowError( - env, STSErrorCode::STS_ERROR_PARAM_INVALID, GetErrorMessage(STSErrorCode::STS_ERROR_PARAM_INVALID)); + env, ETSErrorCode::STS_ERROR_PARAM_INVALID, GetErrorMessage(ETSErrorCode::STS_ERROR_PARAM_INVALID)); return AccessToken::PermissionState::PERMISSION_DENIED; } std::string stdPermissionName = ANIUtils_ANIStringToStdString(env, static_cast(permissionName)); if (stdPermissionName.empty() || stdPermissionName.length() > MAX_LENGTH) { - BusinessErrorAni::ThrowError(env, STSErrorCode::STS_ERROR_PARAM_INVALID, + BusinessErrorAni::ThrowError(env, ETSErrorCode::STS_ERROR_PARAM_INVALID, GetParamErrorMsg("permissionName", "Permissions")); return AccessToken::PermissionState::PERMISSION_DENIED; } @@ -901,7 +901,7 @@ static ani_int CheckAccessTokenSync([[maybe_unused]] ani_env* env, [[maybe_unuse return static_cast(asyncContext->result); } UpdatePermissionCache(asyncContext); - ACCESSTOKEN_LOG_INFO(LABEL, "CheckAccessTokenSync result : %{public}d", asyncContext->result); + ACCESSTOKEN_LOG_INFO(LABEL, "CheckAccessTokenExecute result : %{public}d", asyncContext->result); return static_cast(asyncContext->result); } @@ -944,12 +944,12 @@ static bool ParseRequestPermissionOnSetting(ani_env* env, ani_object& aniContext std::shared_ptr& asyncContext) { if (GetContext(env, aniContext, asyncContext) != ANI_OK) { - BusinessErrorAni::ThrowParameterTypeError(env, STSErrorCode::STS_ERROR_PARAM_ILLEGAL, + BusinessErrorAni::ThrowParameterTypeError(env, ETSErrorCode::STS_ERROR_PARAM_ILLEGAL, GetParamErrorMsg("context", "UIAbility or UIExtension Context")); return false; } if (!ProcessArrayString(env, nullptr, permissionList, asyncContext->permissionList)) { - BusinessErrorAni::ThrowParameterTypeError(env, STSErrorCode::STS_ERROR_PARAM_ILLEGAL, + BusinessErrorAni::ThrowParameterTypeError(env, ETSErrorCode::STS_ERROR_PARAM_ILLEGAL, GetParamErrorMsg("permissionList", "Array")); return false; } @@ -1021,28 +1021,28 @@ static ani_ref ReturnResult(ani_env* env, std::shared_ptrreqContext_->errorCode = code; } int32_t stsCode = TransferToStsErrorCode(this->reqContext_->errorCode); - if (stsCode != STSErrorCode::STS_OK) { + if (stsCode != ETSErrorCode::STS_OK) { this->reqContext_->result = RET_FAILED; } this->reqContext_->loadlock.unlock(); @@ -1346,7 +1346,7 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result) } std::array claMethods = { ani_native_function { - "checkAccessTokenANI", "ILstd/core/String;:I", reinterpret_cast(CheckAccessTokenSync) }, + "checkAccessTokenExecute", "ILstd/core/String;:I", reinterpret_cast(CheckAccessTokenExecute) }, ani_native_function { "requestPermissionsFromUserExecute", "Lapplication/Context/Context;Lescompat/Array;:Lsecurity/PermissionRequestResult/PermissionRequestResult;", reinterpret_cast(RequestPermissionsFromUserExecute) }, diff --git a/frameworks/ets/ani/common/include/ani_error.h b/frameworks/ets/ani/common/include/ani_error.h index d698fd7bf..8099f1780 100644 --- a/frameworks/ets/ani/common/include/ani_error.h +++ b/frameworks/ets/ani/common/include/ani_error.h @@ -44,7 +44,7 @@ typedef enum { STS_ERROR_ALL_PERM_GRANTED = 12100011, STS_ERROR_PERM_REVOKE_BY_USER = 12100012, STS_ERROR_GLOBAL_SWITCH_IS_ALREADY_OPEN = 12100013, -} STSErrorCode; +} ETSErrorCode; std::string GetParamErrorMsg(const std::string& param, const std::string& errMsg); std::string GetErrorMessage(uint32_t errCode); class BusinessErrorAni { diff --git a/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets b/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets index f91c45fe6..f25c90b65 100644 --- a/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets +++ b/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets @@ -20,37 +20,29 @@ function PARAM_ERROR_MSG(param: string, type: string): string { return `Parameter Error. The type of "${param}" must be ${type}.`; } -export { Permissions } +export { Permissions }; export default namespace privacyManager { - loadLibrary("privacy_ani.z"); - enum PermissionUsedType { NORMAL_TYPE = 0, PICKER_TYPE = 1, SECURITY_COMPONENT_TYPE = 2 - } + }; enum PermissionActiveStatus { PERM_INACTIVE = 0, PERM_ACTIVE_IN_FOREGROUND = 1, PERM_ACTIVE_IN_BACKGROUND = 2 - } - - enum STSErrorCode { + }; + enum ETSErrorCode { STS_OK = 0, - STS_ERROR_PERMISSION_DENIED = 201, - STS_ERROR_NOT_SYSTEM_APP = 202, - STS_ERROR_PARAM_ILLEGAL = 401, - STS_ERROR_SYSTEM_CAPABILITY_NOT_SUPPORT = 801, - - } ; + }; interface AddPermissionUsedRecordOptions { usedType?: PermissionUsedType; @@ -61,7 +53,7 @@ export default namespace privacyManager { } class PrivacyManagerInner { - native addPermissionUsedRecordSync(tokenID: int, permissionName: Permissions, successCount: int, failCount: int, + native addPermissionUsedRecordExecute(tokenID: int, permissionName: Permissions, successCount: int, failCount: int, options: AddPermissionUsedRecordOptionsInner): void; } @@ -100,17 +92,17 @@ export default namespace privacyManager { function addPermissionUsedRecord(tokenID: int, permissionName: Permissions, successCount: int, failCount: int, options?: AddPermissionUsedRecordOptions): Promise { - if (typeof permissionName !== "string") { + if (typeof permissionName !== 'string') { let err = new BusinessError(); - err.code = STSErrorCode.STS_ERROR_PARAM_ILLEGAL; - err.data = PARAM_ERROR_MSG("permissionName", "string"); + err.code = ETSErrorCode.STS_ERROR_PARAM_ILLEGAL; + err.data = PARAM_ERROR_MSG("permissionName", 'string'); throw err; } let usedTypeTemp : PermissionUsedType|undefined = options ? options.usedType : PermissionUsedType.NORMAL_TYPE; let optionsLocal: AddPermissionUsedRecordOptionsInner = { usedType: usedTypeTemp }; let p = new Promise((resolve: (v: undefined) => void, reject: (error: BusinessError) => void): void => { - let p1 = taskpool.execute((): void => { return new PrivacyManagerInner().addPermissionUsedRecordSync( + let p1 = taskpool.execute((): void => { return new PrivacyManagerInner().addPermissionUsedRecordExecute( tokenID, permissionName, successCount, failCount, optionsLocal) }); p1.then(() => { resolve(undefined); @@ -123,20 +115,20 @@ export default namespace privacyManager { function addPermissionUsedRecord(tokenID: int, permissionName: Permissions, successCount: int, failCount: int, callback: AsyncCallback): void { - if (typeof permissionName !== "string") { + if (typeof permissionName !== 'string') { let err = new BusinessError(); - err.code = STSErrorCode.STS_ERROR_PARAM_ILLEGAL; - err.data = PARAM_ERROR_MSG("permissionName", "string"); + err.code = ETSErrorCode.STS_ERROR_PARAM_ILLEGAL; + err.data = PARAM_ERROR_MSG("permissionName", 'string'); throw err; } let optionsLocal: AddPermissionUsedRecordOptionsInner = { usedType: PermissionUsedType.NORMAL_TYPE }; let p2 = taskpool.execute((): void => { - return new PrivacyManagerInner().addPermissionUsedRecordSync(tokenID, permissionName, + return new PrivacyManagerInner().addPermissionUsedRecordExecute(tokenID, permissionName, successCount, failCount, optionsLocal)}); p2.then(() => { let err = new BusinessError(); callback(err, undefined); - },(err: BusinessError): void=> { + }, (err: BusinessError): void=> { callback(err, undefined); }) } diff --git a/frameworks/ets/ani/privacy/src/privacy_manager.cpp b/frameworks/ets/ani/privacy/src/privacy_manager.cpp index 3528b7caa..a486a9083 100644 --- a/frameworks/ets/ani/privacy/src/privacy_manager.cpp +++ b/frameworks/ets/ani/privacy/src/privacy_manager.cpp @@ -109,14 +109,14 @@ static void AddPermissionUsedRecord([[maybe_unused]] ani_env* env, [[maybe_unuse ani_int tokenID, ani_string permissionName, ani_int successCount, ani_int failCount, ani_object options) { if (env == nullptr) { - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } ani_size strSize; ani_status status = ANI_ERROR; if (ANI_OK != (status = env->String_GetUTF8Size(permissionName, &strSize))) { ACCESSTOKEN_LOG_ERROR(LABEL, "String_GetUTF8Size_Faild status : %{public}d", status); - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } std::vector buffer(strSize + 1); @@ -124,14 +124,14 @@ static void AddPermissionUsedRecord([[maybe_unused]] ani_env* env, [[maybe_unuse ani_size bytesWritten = 0; if (ANI_OK != (status = env->String_GetUTF8(permissionName, utf8Buffer, strSize + 1, &bytesWritten))) { ACCESSTOKEN_LOG_ERROR(LABEL, "get String_GetUTF8 Faild status : %{public}d", status); - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } utf8Buffer[bytesWritten] = '\0'; std::string outputPermissionName = std::string(utf8Buffer); ani_ref usedTypeRef; if (ANI_OK != (status = env->Object_GetPropertyByName_Ref(options, "usedType", &usedTypeRef))) { - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); ACCESSTOKEN_LOG_ERROR(LABEL, "Object_GetFieldByName_Ref Faild status : %{public}d", status); return; } @@ -139,13 +139,13 @@ static void AddPermissionUsedRecord([[maybe_unused]] ani_env* env, [[maybe_unuse ani_boolean isUndefined = true; if (ANI_OK != (status = env->Reference_IsUndefined(usedTypeRef, &isUndefined))) { ACCESSTOKEN_LOG_ERROR(LABEL, "status : %{public}d", status); - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } if (!isUndefined) { ani_enum_item usedTypeEnum = static_cast(usedTypeRef); if (ANI_OK != env->EnumItem_GetValue_Int(usedTypeEnum, &usedType)) { - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } } @@ -421,7 +421,7 @@ static bool ParseInputToRegister(const ani_string& aniType, const ani_array_ref& bool isUndefined = true; if (!AniIsRefUndefined(context->env, aniCallback, isUndefined)) { BusinessErrorAni::ThrowError( - context->env, STS_ERROR_PARAM_INVALID, GetErrorMessage(STSErrorCode::STS_ERROR_PARAM_INVALID)); + context->env, STS_ERROR_PARAM_INVALID, GetErrorMessage(ETSErrorCode::STS_ERROR_PARAM_INVALID)); return false; } hasCallback = !isUndefined; @@ -495,7 +495,7 @@ static void RegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, ani_string aniType, ani_array_ref aniArray, ani_ref callback) { if (env == nullptr) { - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } @@ -503,7 +503,7 @@ static void RegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, if (context == nullptr) { ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to allocate memory for RegisterPermActiveChangeContext!"); BusinessErrorAni::ThrowError(env, STS_ERROR_OUT_OF_MEMORY, GetErrorMessage( - STSErrorCode::STS_ERROR_OUT_OF_MEMORY)); + ETSErrorCode::STS_ERROR_OUT_OF_MEMORY)); return; } context->env = env; @@ -517,7 +517,7 @@ static void RegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, ACCESSTOKEN_LOG_ERROR(LABEL, "Subscribe failed. The current subscriber has existed or Reference_StrictEquals failed!"); BusinessErrorAni::ThrowError( - env, STSErrorCode::STS_ERROR_NOT_USE_TOGETHER, GetErrorMessage(STSErrorCode::STS_ERROR_NOT_USE_TOGETHER)); + env, ETSErrorCode::STS_ERROR_NOT_USE_TOGETHER, GetErrorMessage(ETSErrorCode::STS_ERROR_NOT_USE_TOGETHER)); return; } @@ -533,8 +533,8 @@ static void RegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, std::lock_guard lock(g_mutex); if (g_subScribers.size() >= MAX_CALLBACK_SIZE) { ACCESSTOKEN_LOG_ERROR(LABEL, "Subscribers size has reached the max %{public}zu.", MAX_CALLBACK_SIZE); - BusinessErrorAni::ThrowError(env, STSErrorCode::STS_ERROR_REGISTERS_EXCEED_LIMITATION, - GetErrorMessage(STSErrorCode::STS_ERROR_REGISTERS_EXCEED_LIMITATION)); + BusinessErrorAni::ThrowError(env, ETSErrorCode::STS_ERROR_REGISTERS_EXCEED_LIMITATION, + GetErrorMessage(ETSErrorCode::STS_ERROR_REGISTERS_EXCEED_LIMITATION)); return; } g_subScribers.emplace_back(context); @@ -624,7 +624,7 @@ static void UnRegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, ani_string aniType, ani_array_ref aniArray, ani_ref callback) { if (env == nullptr) { - BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(STSErrorCode::STS_ERROR_INNER)); + BusinessErrorAni::ThrowError(env, STS_ERROR_INNER, GetErrorMessage(ETSErrorCode::STS_ERROR_INNER)); return; } @@ -632,7 +632,7 @@ static void UnRegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, if (context == nullptr) { ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to allocate memory for RegisterPermActiveChangeContext!"); BusinessErrorAni::ThrowError(env, STS_ERROR_OUT_OF_MEMORY, GetErrorMessage( - STSErrorCode::STS_ERROR_OUT_OF_MEMORY)); + ETSErrorCode::STS_ERROR_OUT_OF_MEMORY)); return; } context->env = env; @@ -647,7 +647,7 @@ static void UnRegisterPermActiveStatusCallback([[maybe_unused]] ani_env* env, ACCESSTOKEN_LOG_ERROR(LABEL, "Unsubscribe failed. The current subscriber does not exist or Reference_StrictEquals failed!"); BusinessErrorAni::ThrowError( - env, STSErrorCode::STS_ERROR_NOT_USE_TOGETHER, GetErrorMessage(STSErrorCode::STS_ERROR_NOT_USE_TOGETHER)); + env, ETSErrorCode::STS_ERROR_NOT_USE_TOGETHER, GetErrorMessage(ETSErrorCode::STS_ERROR_NOT_USE_TOGETHER)); return; } @@ -692,7 +692,7 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result) } std::array methods = { - ani_native_function { "addPermissionUsedRecordSync", + ani_native_function { "addPermissionUsedRecordExecute", "ILstd/core/String;IIL@ohos/privacyManager/privacyManager/AddPermissionUsedRecordOptionsInner;:V", reinterpret_cast(AddPermissionUsedRecord) }, }; -- Gitee