From 56f1a24ed2c0907bd4d4471f71f76aff60ad5b1d Mon Sep 17 00:00:00 2001 From: xia-bubai Date: Mon, 7 Jul 2025 19:48:02 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0RequestGlobalSwitch?= =?UTF-8?q?Execute=E7=BB=91=E5=AE=9A=E9=80=BB=E8=BE=91=202=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9asyncCallback=EF=BC=8C=E6=8A=9B=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=97=B6=EF=BC=8Cdata=E4=B8=BAundefile=EF=BC=8C?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BF=94=E5=9B=9E=E6=97=B6err=E4=B8=BAundefi?= =?UTF-8?q?ned?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xia-bubai --- .../accesstoken/ets/@ohos.abilityAccessCtrl.ets | 6 ++---- .../accesstoken/src/ani_ability_access_ctrl.cpp | 4 +++- .../ets/ani/privacy/ets/@ohos.privacyManager.ets | 15 +++++---------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets b/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets index c1bf2f105..6aeba2467 100644 --- a/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets +++ b/frameworks/ets/ani/accesstoken/ets/@ohos.abilityAccessCtrl.ets @@ -314,8 +314,7 @@ export default namespace abilityAccessCtrl { let p1 = taskpool.execute((): void => { new AtManagerInner().grantUserGrantedPermissionExecute(tokenID, permissionName, permissionFlags);}); p1.then(() => { - let err = new BusinessError(); - callback(err, undefined); + callback(null, undefined); }, (err: Error): void => { callback(err as BusinessError, undefined); }); @@ -355,8 +354,7 @@ export default namespace abilityAccessCtrl { new AtManagerInner().revokeUserGrantedPermissionExecute(tokenID, permissionName, permissionFlags); }); job.then(() => { - let err = new BusinessError(); - callback(err, undefined); + callback(null, undefined); }, (err: Error): void=> { callback(err as BusinessError, undefined); }); diff --git a/frameworks/ets/ani/accesstoken/src/ani_ability_access_ctrl.cpp b/frameworks/ets/ani/accesstoken/src/ani_ability_access_ctrl.cpp index 1d73ec51d..08dd8ab38 100644 --- a/frameworks/ets/ani/accesstoken/src/ani_ability_access_ctrl.cpp +++ b/frameworks/ets/ani/accesstoken/src/ani_ability_access_ctrl.cpp @@ -841,6 +841,8 @@ void InitAbilityCtrlFunction(ani_env *env) nullptr, reinterpret_cast(RequestPermissionsFromUserExecute) }, ani_native_function { "requestPermissionOnSettingExecute", nullptr, reinterpret_cast(RequestPermissionOnSettingExecute) }, + ani_native_function {"requestGlobalSwitchExecute", + nullptr, reinterpret_cast(RequestGlobalSwitchExecute) }, ani_native_function { "grantUserGrantedPermissionExecute", nullptr, reinterpret_cast(GrantUserGrantedPermissionExecute) }, ani_native_function { "revokeUserGrantedPermissionExecute", @@ -883,4 +885,4 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result) } } // namespace AccessToken } // namespace Security -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets b/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets index a82c0210d..edbe97fea 100644 --- a/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets +++ b/frameworks/ets/ani/privacy/ets/@ohos.privacyManager.ets @@ -80,8 +80,7 @@ export default namespace privacyManager { successCount, failCount, options); }); p.then(() => { - let err = new BusinessError(); - callback(err, undefined); + callback(null, undefined); },(err: Error): void=> { callback(err as BusinessError, undefined); }); @@ -117,8 +116,7 @@ export default namespace privacyManager { let p = taskpool.execute((): void => { return stopUsingPermissionExecute(tokenID, permissionName, -1) }); p.then(() => { - let err = new BusinessError(); - callback(err, undefined); + callback(null, undefined); },(err: Error): void=> { callback(err as BusinessError, undefined); }); @@ -176,8 +174,7 @@ export default namespace privacyManager { return startUsingPermissionExecute(tokenID, permissionName, -1, PermissionUsedType.NORMAL_TYPE) }); p.then(() => { - let err = new BusinessError(); - callback(err, undefined); + callback(null, undefined); },(err: Error): void => { callback(err as BusinessError, undefined); }) @@ -226,11 +223,9 @@ export default namespace privacyManager { return getPermissionUsedRecordExecute(request); }); p1.then((ret: NullishType): void => { - let err = new BusinessError(); - callback(err, ret as PermissionUsedResponse); + callback(null, ret as PermissionUsedResponse); }).catch((err: Error): void => { - let response: PermissionUsedResponse = {}; - callback(err as BusinessError, response); + callback(err as BusinessError, undefined); }) } -- Gitee