openharmony 鸿蒙 changelogs-account_os_account

2026-08-25 浏览 (1)

Account Subsystem Changelog

cl.accountaccount_os_account.1 The Error Code of setAppAccess Is Changed

Access Level

Public API

Change Reason

To prevent resource waste, applications are not allowed to call this API to grant permissions to third-party applications without restrictions. When the number of authorized applications exceeds 1024, the new error code 12400005 is returned.

Change Impact

This change is a non-compatible change.

Before change: If the third-party application bundle name passed to setAppAccess is not installed, the error code 12400001 is returned, indicating that the application is not found.

After change: If the third-party application bundle name passed to setAppAccess is not installed, and the number of authorized applications does not exceed the upper limit, a success message is returned. If the number of authorized applications exceeds the upper limit, the error code 12400005 is returned.

Start API Level

9

Change Since

OpenHarmony 5.0.2.1

Key API/Component Changes

The following APIs in @ohos.account.appAccount.d.ts:

  • setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback: AsyncCallback<void>): void

  • setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise<void>

Adaptation Guide

The error code 12400005 is added to the setAppAccess API. The following is an example:

import { BusinessError } from '@ohos.base';
import account_appAccount from '@ohos.account.appAccount';

let appAccountManager: account_appAccount.AppAccountManager = account_appAccount.createAppAccountManager();

try {
  appAccountManager.setAppAccess('ZhangSan', 'com.example.accountjsdemo', true, (err: BusinessError) => {
	if (err.code === 12400005) {
	  // Handle the issue that the number of authorized applications exceeds the upper limit, for example, by revoking authorization from previously authorized applications.
	} else if (err) {
	  console.log('setAppAccess failed: ' + JSON.stringify(err));
	} else {
	  console.log('setAppAccess successfully');
	}
  });
} catch (err) {
  console.log('setAppAccess exception: ' + JSON.stringify(err));
}

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 changelogs-display

openharmony 鸿蒙 changelogs-window

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/mAvmSO54