diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index ff89b62d12e370ccaa046c40576405e8cfe72c22..62d2884739a500c0384ffb06049bc535641c740d 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -3,6 +3,7 @@ The **AbilityAccessCtrl** module provides APIs for application permission management, including authentication, authorization, and revocation. > **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -15,7 +16,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' createAtManager(): AtManager -Creates an **AtManager** instance, which is used for ability access control. +Creates an **AtManager** instance, which is used for application access control. **System capability**: SystemCapability.Security.AccessToken @@ -34,7 +35,7 @@ let atManager = abilityAccessCtrl.createAtManager(); ## AtManager -Implements ability access control. +Provides APIs for application access control. ### checkAccessToken9+ @@ -59,11 +60,11 @@ Checks whether a permission is granted to an application. This API uses a promis **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | **Example** @@ -106,11 +107,11 @@ Verifies whether a permission is granted to an application. This API returns the **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | **Example** @@ -123,7 +124,7 @@ console.log(`data->${JSON.stringify(data)}`); ### grantUserGrantedPermission -grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number): Promise<void> +grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number): Promise<void> Grants a user_grant permission to an application. This API uses a promise to return the result. @@ -139,7 +140,7 @@ Grants a user_grant permission to an application. This API uses a promise to ret | --------- | ------------------- | ---- | ------------------------------------------------------------ | | tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). | | permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| -| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.| **Return value** @@ -149,11 +150,11 @@ Grants a user_grant permission to an application. This API uses a promise to ret **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist. | | 12100003 | The specified permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | @@ -166,9 +167,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let atManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. -let permissionFlag = 1; +let permissionFlags = 1; try { - atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => { + atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => { console.log('grantUserGrantedPermission success'); }).catch((err) => { console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`); @@ -180,7 +181,7 @@ try { ### grantUserGrantedPermission -grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number, callback: AsyncCallback<void>): void +grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number, callback: AsyncCallback<void>): void Grants a user_grant permission to an application. This API uses an asynchronous callback to return the result. @@ -196,16 +197,16 @@ Grants a user_grant permission to an application. This API uses an asynchronous | --------- | ------------------- | ---- | ------------------------------------------------------------ | | tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md).| | permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| -| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | -| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is granted successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the permission is granted, **err** is **undefined**. Otherwise, **err** is an error object.| **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | TokenId does not exist. | | 12100003 | Permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | @@ -218,9 +219,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let atManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. -let permissionFlag = 1; +let permissionFlags = 1; try { - atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => { + atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => { if (err) { console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`); } else { @@ -234,7 +235,7 @@ try { ### revokeUserGrantedPermission -revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number): Promise<void> +revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number): Promise<void> Revokes a user_grant permission from an application. This API uses a promise to return the result. @@ -250,7 +251,7 @@ Revokes a user_grant permission from an application. This API uses a promise to | --------- | ------------------- | ---- | ------------------------------------------------------------ | | tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). | | permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| -| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.| **Return value** @@ -260,11 +261,11 @@ Revokes a user_grant permission from an application. This API uses a promise to **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist. | | 12100003 | The specified permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | @@ -277,9 +278,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let atManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. -let permissionFlag = 1; +let permissionFlags = 1; try { - atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => { + atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => { console.log('revokeUserGrantedPermission success'); }).catch((err) => { console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`); @@ -291,7 +292,7 @@ try { ### revokeUserGrantedPermission -revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number, callback: AsyncCallback<void>): void +revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number, callback: AsyncCallback<void>): void Revokes a user_grant permission from an application. This API uses an asynchronous callback to return the result. @@ -307,16 +308,16 @@ Revokes a user_grant permission from an application. This API uses an asynchrono | --------- | ------------------- | ---- | ------------------------------------------------------------ | | tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). | | permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| -| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | -| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is revoked successfully, **err** is **undefined**. Otherwise, **err** is an error object.| +| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the permission is revoked, **err** is **undefined**. Otherwise, **err** is an error object.| **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | TokenId does not exist. | | 12100003 | Permission does not exist. | | 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | @@ -329,9 +330,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let atManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. -let permissionFlag = 1; +let permissionFlags = 1; try { - atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => { + atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => { if (err) { console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`); } else { @@ -347,7 +348,7 @@ try { getPermissionFlags(tokenID: number, permissionName: Permissions): Promise<number> -Obtains the flags of the specified permission of an application. This API uses a promise to return the result. +Obtains the permission flag of an application. This API uses a promise to return the result. **System API**: This is a system API. @@ -366,15 +367,15 @@ Obtains the flags of the specified permission of an application. This API uses a | Type | Description | | :------------ | :---------------------------------- | -| Promise<number> | Promise used to return the result.| +| Promise<number> | Promise used to return the permission flag obtained. | **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist. | | 12100003 | The specified permission does not exist. | | 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. | @@ -426,9 +427,9 @@ promise.then(data => { ### on9+ -on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<Permissions>, callback: Callback<PermissionStateChangeInfo>): void; +on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionList: Array<Permissions>, callback: Callback<PermissionStateChangeInfo>): void; -Subscribes to permission grant state changes of the specified applications and permissions. +Subscribes to permission state changes of the specified applications and permissions. **System API**: This is a system API. @@ -440,18 +441,18 @@ Subscribes to permission grant state changes of the specified applications and p | Name | Type | Mandatory| Description | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'permissionStateChange'**, indicating the permission grant state change event. | -| tokenIDList | Array<number> | Yes | List of token IDs. If this parameter is left empty, the permission grant state changes of all applications are subscribed to. | -| permissionNameList | Array<Permissions> | Yes | List of permission names. If this parameter is left empty, the permission grant state changes of all permissions are subscribed to. | -| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | Yes| Callback used to return the permission grant state change information.| +| type | string | Yes | Event type to subscribe to. The value is **'permissionStateChange'**, which indicates the permission grant state change. | +| tokenIDList | Array<number> | Yes | Token IDs of the applications to observe. If this parameter is left empty, the permission grant state changes of all applications are observed. | +| permissionList | Array<Permissions> | Yes | Permissions to observe. If this parameter is left empty, the grant state changes of all permissions are observed. | +| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | Yes| Callback invoked to return the permission grant state change.| **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100004 | The interface is called repeatedly with the same input. | | 12100005 | The registration time has exceeded the limitation. | | 12100007 | Service is abnormal. | @@ -461,13 +462,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ```js import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import bundle from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); let appInfo = bundle.getApplicationInfoSync('com.example.myapplication', 0, 100); let tokenIDList: Array = [appInfo.accessTokenId]; -let permissionNameList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"]; +let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"]; try { - atManager.on('permissionStateChange', tokenIDList, permissionNameList, (data) => { + atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => { console.debug("receive permission state change, data:" + JSON.stringify(data)); }); } catch(err) { @@ -477,9 +479,9 @@ try { ### off9+ -off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<Permissions>, callback?: Callback<PermissionStateChangeInfo>): void; +off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionList: Array<Permissions>, callback?: Callback<PermissionStateChangeInfo>): void; -Unsubscribes from permission grant state changes of the specified applications and permissions. This API uses an asynchronous callback to return the result. +Unsubscribes from permission grant state changes of the specified applications and permissions. This API uses a callback to return the result. **System API**: This is a system API. @@ -491,19 +493,19 @@ Unsubscribes from permission grant state changes of the specified applications a | Name | Type | Mandatory| Description | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed at **'permissionStateChange'**, indicating the permission grant state change event. | -| tokenIDList | Array<number> | Yes | List of token IDs. If this parameter is left empty, the permission grant state changes of all applications are unsubscribed from. The value must be the same as that passed in **on()**.| -| permissionNameList | Array<Permissions> | Yes | List of permission names. If this parameter is left empty, the permission grant state changes of all permissions are unsubscribed from. The value must be the same as that passed in **on()**.| -| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | No| Callback used to return the permission grant state change information.| +| type | string | Yes | Event type to unsubscribe from. The value is **'permissionStateChange'**, which indicates the permission grant state change. | +| tokenIDList | Array<number> | Yes | Token IDs of the applications. If this parameter is left empty, the permission grant state changes of all applications are unsubscribed from. The value must be the same as that passed in **on()**. | +| permissionList | Array<Permissions> | Yes | Permission names. If this parameter is left empty, the grant state changes of all permissions are unsubscribed from. The value must be the same as that passed in **on()**. | +| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | No| Callback for the permission grant state change. | **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID in list is all invalid | -| 12100004 | The interface is not used with | +| 12100001 | The parameter is invalid. The tokenIDs in the list are all invalid. | +| 12100004 | The API is not used together with "on()". | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -511,13 +513,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ```js import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import bundle from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); let appInfo = bundle.getApplicationInfoSync('com.example.myapplication', 0, 100); let tokenIDList: Array = [appInfo.accessTokenId]; -let permissionNameList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"]; +let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"]; try { - atManager.off('permissionStateChange', tokenIDList, permissionNameList); + atManager.off('permissionStateChange', tokenIDList, permissionList); } catch(err) { console.log(`catch err->${JSON.stringify(err)}`); } @@ -538,7 +541,7 @@ Verifies whether a permission is granted to an application. This API uses a prom | Name | Type | Mandatory| Description | | -------- | ------------------- | ---- | ------------------------------------------ | | tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). | -| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| +| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). | **Return value** @@ -561,9 +564,9 @@ promise.then(data => { ### requestPermissionsFromUser9+ -requestPermissionsFromUser(context: Context, permissions: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; +requestPermissionsFromUser(context: Context, permissionList: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; -Requests user authorization in a dialog box. This API uses an asynchronous callback to return the result. +Requests permissions from the user in a dialog box. This API uses an asynchronous callback to return the result. **Model restriction**: This API can be used only in the stage model. @@ -573,16 +576,16 @@ Requests user authorization in a dialog box. This API uses an asynchronous callb | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context | Context | Yes| Ability context of the application that requests the permission.| -| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| +| context | Context | Yes| Ability context of the application that requests the permissions. | +| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback invoked to return the result.| **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | Parameter invalid. | +| 12100001 | The parameter is invalid. The context is invalid when it does not belong to the application itself. | **Example** @@ -602,9 +605,9 @@ try { ### requestPermissionsFromUser9+ -requestPermissionsFromUser(context: Context, permissions: Array<Permissions>) : Promise<PermissionRequestResult>; +requestPermissionsFromUser(context: Context, permissionList: Array<Permissions>) : Promise<PermissionRequestResult>; -Requests user authorization in a dialog box. This API uses a promise to return the result. +Requests permissions from the user in a dialog box. This API uses a promise to return the result. **Model restriction**: This API can be used only in the stage model. @@ -614,8 +617,8 @@ Requests user authorization in a dialog box. This API uses a promise to return | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| context | Context | Yes| Ability context of the application that requests the permission.| -| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| +| context | Context | Yes| Ability context of the application that requests the permissions. | +| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). | **Return value** @@ -625,10 +628,10 @@ Requests user authorization in a dialog box. This API uses a promise to return **Error codes** -For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md). +For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md). | ID| Error Message| | -------- | -------- | -| 12100001 | Parameter invalid. | +| 12100001 | The parameter is invalid. The context is invalid when it does not belong to the application itself. | **Example** @@ -710,7 +713,7 @@ Enumerates the operations that trigger permission grant state changes. ### PermissionStateChangeInfo9+ -Defines the detailed permission grant state change information. +Defines detailed information about the permission grant state change. **System API**: This is a system API. @@ -719,5 +722,6 @@ Defines the detailed permission grant state change information. | Name | Type | Readable| Writable| Description | | -------------- | ------------------------- | ---- | ---- | ------------------ | | change | [PermissionStateChangeType](#permissionstatechangetype9) | Yes | No | Operation that triggers the permission grant state change. | -| tokenID | number | Yes | No | Token ID of the application whose permission grant state changes are subscribed.| -| permissionName | Permissions | Yes | No | Permission whose authorization status changes. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).| +| tokenID | number | Yes | No | Token ID of the application. | +| permissionName | Permissions | Yes | No | Permission whose grant state changes. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). | + diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md index a26078b7435fadd2599f531612025511b6e63b60..eae4b4a3970507756fab9b96ff76b93b77154ca2 100644 --- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -14,7 +14,7 @@ The **PermissionRequestResult** module defines the result of a permission reques | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | permissions | Array<string> | Yes| No| Permissions requested.| -| authResults | Array<number> | Yes| No|Result of the permission Request.
**-1**: The permission has been set and no dialog box will be displayed. Users can modify the permission in **Settings**.
**0**: No operation is required.
**1**: Dynamic user authorization is required via a dialog window .
**2**: The request is invalid. Possible causes are as follows:
- The permission is not declared in the configuration file.
- The permission name is invalid.
- Special conditions for applying for the permission do not satisfied. See [ohos.permission.LOCATION](../../security/permission-list.md#ohospermissionlocation) and [ohos.permission.APPROXIMATELY_LOCATION](../../security/permission-list.md#ohospermissionapproximately_location).| +| authResults | Array<number> | Yes| No| Result of the permission request.
- **-1**: The permission is not authorized and must be set in **Settings** without displaying a dialog box.
- **0**: The permission is authorized.
- **2**: The permission is not authorized due to an invalid request. The possible causes are as follows:
- The permission is not declared in the configuration file.
- The permission name is invalid.
- Special conditions for applying for the permission are not satisfied. See [ohos.permission.LOCATION](../../security/permission-list.md#ohospermissionlocation) and [ohos.permission.APPROXIMATELY_LOCATION](../../security/permission-list.md#ohospermissionapproximately_location).| ## Usage diff --git a/en/application-dev/reference/apis/js-apis-privacyManager.md b/en/application-dev/reference/apis/js-apis-privacyManager.md index c7da8609952d245b53e82aead09f57f97eeeedf1..09c53c11fabe2f84ec0eaeeda8d0ddae6e6a48c3 100644 --- a/en/application-dev/reference/apis/js-apis-privacyManager.md +++ b/en/application-dev/reference/apis/js-apis-privacyManager.md @@ -3,8 +3,9 @@ The **privacyManager** module provides APIs for privacy management, such as management of permission usage records. > **NOTE** -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> The APIs provided by this module are system APIs. +> +> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs provided by this module are system APIs. ## Modules to Import @@ -45,7 +46,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100007 | Service is abnormal. | @@ -95,7 +96,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100007 | Service is abnormal. | @@ -266,7 +267,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. | @@ -314,7 +315,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. | @@ -369,7 +370,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100004 | The interface is not used with | @@ -417,7 +418,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. | | 12100004 | The interface is not used with | @@ -445,7 +446,7 @@ try { ## privacyManager.on -on(type: 'activeStateChange', permissionNameList: Array<Permissions>, callback: Callback<ActiveChangeResponse>): void +on(type: 'activeStateChange', permissionList: Array<Permissions>, callback: Callback<ActiveChangeResponse>): void Subscribes to the permission usage status changes of the specified permissions. @@ -458,7 +459,7 @@ Subscribes to the permission usage status changes of the specified permissions. | Name | Type | Mandatory| Description | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. | -| permissionNameList | Array<Permissions> | Yes | List of permissions to be observed. If this parameter is left empty, the usage changes of all permissions are observed. | +| permissionList | Array<Permissions> | Yes | List of permissions to be observed. If this parameter is left empty, the usage changes of all permissions are observed. | | callback | Callback<[ActiveChangeResponse](#activechangeresponse)> | Yes| Callback invoked to return a change in the permission usage.| **Error codes** @@ -467,7 +468,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The tokenID is 0 | +| 12100001 | The parameter is invalid. The tokenID is 0. | | 12100004 | The interface is called repeatedly with the same input. | | 12100005 | The registration time has exceeded the limitation. | | 12100007 | Service is abnormal. | @@ -478,9 +479,9 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ```js import privacyManager from '@ohos.privacyManager'; -let permissionNameList = []; +let permissionList = []; try { - privacyManager.on('activeStateChange', permissionNameList, (data) => { + privacyManager.on('activeStateChange', permissionList, (data) => { console.debug("receive permission state change, data:" + JSON.stringify(data)); }); } catch(err) { @@ -490,7 +491,7 @@ try { ## privacyManager.off -off(type: 'activeStateChange', permissionNameList: Array<Permissions>, callback?: Callback<ActiveChangeResponse>): void; +off(type: 'activeStateChange', permissionList: Array<Permissions>, callback?: Callback<ActiveChangeResponse>): void; Unsubscribes from the permission usage status changes of the specified permissions. @@ -503,7 +504,7 @@ Unsubscribes from the permission usage status changes of the specified permissio | Name | Type | Mandatory| Description | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. | -| permissionNameList | Array<Permissions> | Yes | List of permissions to be observed. If this parameter is left blank, the usage changes of all permissions are unsubscribed from. The value must be the same as that specified in **on()**.| +| permissionList | Array<Permissions> | Yes | List of permissions to be observed. If this parameter is left blank, the usage changes of all permissions are unsubscribed from. The value must be the same as that specified in **on()**.| | callback | Callback<[ActiveChangeResponse](#activechangeresponse)> | No| Callback for the permission usage change event.| **Error codes** @@ -512,8 +513,8 @@ For details about the error codes, see [Ability Access Control Error Codes](../e | ID| Error Message| | -------- | -------- | -| 12100001 | The parameter is invalid. The permissionName in list is all invalid or the list size is larger than 1024. | -| 12100004 | The interface is not used with | +| 12100001 | The parameter is invalid. The permission names in the list are all invalid or the list size is larger than 1024. | +| 12100004 | The API is not used together with "on()". | | 12100007 | Service is abnormal. | | 12100008 | Out of memory. | @@ -522,9 +523,9 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ```js import privacyManager from '@ohos.privacyManager'; -let permissionNameList = []; +let permissionList = []; try { - privacyManager.off('activeStateChange', permissionNameList); + privacyManager.off('activeStateChange', permissionList); }catch(err) { console.log(`catch err->${JSON.stringify(err)}`); } diff --git a/en/application-dev/reference/errorcodes/Readme-EN.md b/en/application-dev/reference/errorcodes/Readme-EN.md index 01816017862deefa3c25d97086685e3b8392640a..a02a8f29d4e6ace770d6748a3f8146c45271e084 100644 --- a/en/application-dev/reference/errorcodes/Readme-EN.md +++ b/en/application-dev/reference/errorcodes/Readme-EN.md @@ -26,12 +26,13 @@ - Resource Management - [I18N Error Codes](errorcode-i18n.md) - [Resource Manager Error Codes](errorcode-resource-manager.md) -- Background Tasks +- Resource Scheduling - [backgroundTaskManager Error Codes](errorcode-backgroundTaskMgr.md) + - [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md) - [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) - [workScheduler Error Codes](errorcode-workScheduler.md) - Security - - [Ability Access Control Error Codes](errorcode-access-token.md) + - [Application Access Control Error Codes](errorcode-access-token.md) - [HUKS Error Codes](errorcode-huks.md) - [Crypto Framework Error Codes](errorcode-crypto-framework.md) - [Certificate Error Codes](errorcode-cert.md) @@ -49,6 +50,7 @@ - Connectivity - [NFC Error Codes](errorcode-nfc.md) - [RPC Error Codes](errorcode-rpc.md) + - [Wi-Fi Error Codes](errorcode-wifi.md) - Basic Features - [Accessibility Error Codes](errorcode-accessibility.md) - [FaultLogger Error Codes](errorcode-faultlogger.md) @@ -57,6 +59,7 @@ - [HiDebug Error Codes](errorcode-hiviewdfx-hidebug.md) - [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) - [Pasteboard Error Codes](errorcode-pasteboard.md) + - [Screen Lock Management Error Codes](errorcode-screenlock.md) - [Time and Time Zone Service Error Codes](errorcode-time.md) - [Webview Error Codes](errorcode-webview.md) - Account Management @@ -75,7 +78,6 @@ - [System Parameter Error Codes](errorcode-system-parameterV9.md) - [USB Error Codes](errorcode-usb.md) - [Update Error Codes](errorcode-update.md) - - [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md) - Customization Management - [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) - Utils diff --git a/en/application-dev/reference/errorcodes/errorcode-access-token.md b/en/application-dev/reference/errorcodes/errorcode-access-token.md index da0cb07f0e9947fbe6d86796a72466a926041bb4..b5280137e6fb1751020324750e5c7fa2b56c6127 100644 --- a/en/application-dev/reference/errorcodes/errorcode-access-token.md +++ b/en/application-dev/reference/errorcodes/errorcode-access-token.md @@ -1,4 +1,4 @@ -# Ability Access Control Error Codes +# Application Access Control Error Codes ## 12100001 Invalid Parameters