未验证 提交 1da076f3 编写于 作者: O openharmony_ci 提交者: Gitee

!13718 [翻译完成】#I6879T

Merge pull request !13718 from Annie_wang/PR13069
# @ohos.privacyManager (Privacy Management) # @ohos.privacyManager (Privacy Management)
The **privacyManager** module provides APIs for privacy management, such as management of permission usage records. The **privacyManager** module provides APIs for privacy management, such as management of permission usage records.
...@@ -42,11 +42,14 @@ The permission usage record includes the application identity (token ID) of the ...@@ -42,11 +42,14 @@ The permission usage record includes the application identity (token ID) of the
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -89,11 +92,14 @@ The permission usage record includes the application identity (token ID) of the ...@@ -89,11 +92,14 @@ The permission usage record includes the application identity (token ID) of the
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -139,11 +145,14 @@ Obtains historical permission usage records. This API uses a promise to return t ...@@ -139,11 +145,14 @@ Obtains historical permission usage records. This API uses a promise to return t
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. the value of flag in request is invalid. |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -191,11 +200,14 @@ Obtains historical permission usage records. This API uses an asynchronous callb ...@@ -191,11 +200,14 @@ Obtains historical permission usage records. This API uses an asynchronous callb
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. the value of flag in request is invalid. |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -251,12 +263,15 @@ Starts to use a permission and flushes the permission usage record. This API is ...@@ -251,12 +263,15 @@ Starts to use a permission and flushes the permission usage record. This API is
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100004 | The interface is not used together. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -296,12 +311,15 @@ Starts to use a permission and flushes the permission usage record. This API is ...@@ -296,12 +311,15 @@ Starts to use a permission and flushes the permission usage record. This API is
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100004 | The interface is not used together. | | 12100004 | The interface is called repeatedly with the same input. It means the application specified by the tokenID has been using the specified permission. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -324,7 +342,7 @@ try { ...@@ -324,7 +342,7 @@ try {
## privacyManager.stopUsingPermission ## privacyManager.stopUsingPermission
stopUsingPermission(tokenID: number, permissionName: string): Promise<void> stopUsingPermission(tokenID: number, permissionName: Permissions): Promise<void>
Stops using a permission. This API is called by a system application and uses a promise to return the result. **startUsingPermission** and **stopUsingPermission** are used in pairs. This API uses a promise to return the result. Stops using a permission. This API is called by a system application and uses a promise to return the result. **startUsingPermission** and **stopUsingPermission** are used in pairs. This API uses a promise to return the result.
...@@ -348,12 +366,15 @@ Stops using a permission. This API is called by a system application and uses a ...@@ -348,12 +366,15 @@ Stops using a permission. This API is called by a system application and uses a
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100004 | The interface is not used together. | | 12100004 | The interface is not used with |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -393,12 +414,15 @@ Stops using a permission. This API is called by a system application and uses a ...@@ -393,12 +414,15 @@ Stops using a permission. This API is called by a system application and uses a
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. | | 12100002 | The specified tokenID does not exist or it does not refer to an application process. |
| 12100003 | Permission does not exist. | | 12100003 | The specified permission does not exist or it is not an user_grant permission. |
| 12100004 | The interface is not used together. | | 12100004 | The interface is not used with |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
...@@ -434,26 +458,29 @@ Subscribes to the permission usage status changes of the specified permissions. ...@@ -434,26 +458,29 @@ Subscribes to the permission usage status changes of the specified permissions.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. | | type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. |
| permissionNameList | Array<Permissions> | No | List of permissions to be observed. If this parameter is left empty, the usage changes of all permissions are observed. | | permissionNameList | 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.| | callback | Callback<[ActiveChangeResponse](#activechangeresponse)> | Yes| Callback invoked to return a change in the permission usage.|
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100004 | The interface is not used together. | | 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The number of listeners exceeds the limit. | | 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
```js ```js
import privacyManager from '@ohos.privacyManager'; import privacyManager from '@ohos.privacyManager';
let permissionNameList: Array<Permissions> = []; let permissionNameList = [];
try { try {
atManager.on('activeStateChange', permissionNameList, (data) => { privacyManager.on('activeStateChange', permissionNameList, (data) => {
console.debug("receive permission state change, data:" + JSON.stringify(data)); console.debug("receive permission state change, data:" + JSON.stringify(data));
}); });
} catch(err) { } catch(err) {
...@@ -476,23 +503,26 @@ Unsubscribes from the permission usage status changes of the specified permissio ...@@ -476,23 +503,26 @@ Unsubscribes from the permission usage status changes of the specified permissio
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. | | type | string | Yes | Event type to subscribe to. The value is **'activeStateChange'**, which indicates the permission usage change event. |
| permissionNameList | Array&lt;Permissions&gt; | No | 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()**.| | permissionNameList | Array&lt;Permissions&gt; | 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&lt;[ActiveChangeResponse](#activechangeresponse)&gt; | No| Callback for the permission usage change event.| | callback | Callback&lt;[ActiveChangeResponse](#activechangeresponse)&gt; | No| Callback for the permission usage change event.|
**Error codes** **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 [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | Parameter invalid. | | 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 together. | | 12100004 | The interface is not used with |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
**Example** **Example**
```js ```js
import privacyManager from '@ohos.privacyManager'; import privacyManager from '@ohos.privacyManager';
let permissionNameList: Array<Permissions> = []; let permissionNameList = [];
try { try {
privacyManager.off('activeStateChange', permissionNameList); privacyManager.off('activeStateChange', permissionNameList);
}catch(err) { }catch(err) {
...@@ -589,7 +619,7 @@ Enumerates the permission usage statuses. ...@@ -589,7 +619,7 @@ Enumerates the permission usage statuses.
**System capability**: SystemCapability.Security.AccessToken **System capability**: SystemCapability.Security.AccessToken
| Name | Default Value| Description | | Name | Value | Description |
| ------------------------- | ------ | ---------------- | | ------------------------- | ------ | ---------------- |
| PERM_INACTIVE | 0 | The permission is not used. | | PERM_INACTIVE | 0 | The permission is not used. |
| PERM_ACTIVE_IN_FOREGROUND | 1 | The permission is being used by an application running in the foreground.| | PERM_ACTIVE_IN_FOREGROUND | 1 | The permission is being used by an application running in the foreground.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册