diff --git a/api/@ohos.abilityAccessCtrl.d.ts b/api/@ohos.abilityAccessCtrl.d.ts index 5a1421291fbc5182d6b0ac298fe1bfdd0a0bd9ff..bb03c65a2d6ce17c6ba7b627674ec7912580cf76 100644 --- a/api/@ohos.abilityAccessCtrl.d.ts +++ b/api/@ohos.abilityAccessCtrl.d.ts @@ -1,184 +1,212 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AsyncCallback, Callback } from './basic'; - -/** - * @syscap SystemCapability.Security.AccessToken - */ - declare namespace abilityAccessCtrl { - /** - * Obtains the AtManager instance. - * @return returns the instance of the AtManager. - * @since 8 - */ - function createAtManager(): AtManager; - - /** - * Provides methods for managing access_token. - * @name AtManager - */ - interface AtManager { - /** - * Checks whether a specified application has been granted the given permission. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be verified. - * @return Returns permission verify result. - * @since 8 - */ - verifyAccessToken(tokenID: number, permissionName: string): Promise; - - /** - * Checks whether a specified application has been granted the given permission synchronously. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be verified. - * @return Returns permission verify result - * @since 9 - */ - verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus; - - /** - * Grants a specified user_grant permission to the given application. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be granted. - * @param permissionFlag Flag of permission state. - * @permission ohos.permission.GRANT_SENSITIVE_PERMISSIONS. - * @systemapi - * @since 8 - */ - grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise; - grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback): void; - - /** - * Revokes a specified user_grant permission to the given application. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be revoked. - * @param permissionFlag Flag of permission state. - * @permission ohos.permission.REVOKE_SENSITIVE_PERMISSIONS. - * @systemapi - * @since 8 - */ - revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise; - revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback): void; - - /** - * Queries specified permission flag of the given application. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be granted. - * @return Return permission flag. - * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS or ohos.permission.GRANT_SENSITIVE_PERMISSIONS or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS. - * @systemapi - * @since 8 - */ - getPermissionFlags(tokenID: number, permissionName: string): Promise; - - /** - * Queries permission management version. - * @return Return permission version. - * @systemapi - * @since 9 - */ - getVersion(): Promise; - - /** - * Registers a permission state callback so that the application can be notified upon specified permission state of specified applications changes. - * @param tokenIDList A list of tokenids that specifies the applications to be listened on. The value in the list can be: - *
    - *
  • {@code empty} - Indicates that the application can be notified if the specified permission state of any applications changes. - *
  • - *
  • {@code non-empty} - Indicates that the application can only be notified if the specified permission state of the specified applications change. - *
  • - *
- * @param permissionNameList A list of permissions that specifies the permissions to be listened on. The value in the list can be: - *
    - *
  • {@code empty} - Indicates that the application can be notified if any permission state of the specified applications changes. - *
  • - *
  • {@code non-empty} - Indicates that the application can only be notified if the specified permission state of the specified applications changes. - *
  • - *
- * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS. - * @param callback Callback used to listen for the permission state changed event. - * @systemapi - * @since 9 - */ - on(type: 'permissionStateChange', tokenIDList: Array, permissionNameList: Array, callback: Callback): void; - - /** - * Unregisters a permission state callback so that the specified applications cannot be notified upon specified permissions state changes anymore. - * @param tokenIDList A list of tokenids that specifies the applications being listened on. it should correspond to the value registered by function of "on", whose type is "permissionStateChange". - * @param permissionNameList A list of permissions that specifies the permissions being listened on. it should correspond to the value registered by function of "on", whose type is "permissionStateChange". - * @param callback Callback used to listen for the permission state changed event. - * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS. - * @systemapi - * @since 9 - */ - off(type: 'permissionStateChange', tokenIDList: Array, permissionNameList: Array, callback?: Callback): void; - } - - /** - * GrantStatus. - * @since 8 - */ - export enum GrantStatus { - /** - * access_token permission check fail - */ - PERMISSION_DENIED = -1, - /** - * access_token permission check success - */ - PERMISSION_GRANTED = 0, - } - - /** - * Enum for permision state change type. - * @since 9 - */ - export enum PermissionStateChangeType { - /** - * A granted user_grant permission is revoked. - */ - PERMISSION_REVOKED_OPER = 0, - /** - * A user_grant permission is granted. - */ - PERMISSION_GRANTED_OPER = 1, - } - - /** - * Indicates the information of permission state change. - * - * @name PermissionStateChangeInfo - * @since 9 - */ - interface PermissionStateChangeInfo { - /** - * Indicates the permission state change type. - */ - change: PermissionStateChangeType; - - /** - * Indicates the application whose permission state has been changed. - */ - tokenID: number; - - /** - * Indicates the permission whose state has been changed. - */ - permissionName: string; - } - } - - export default abilityAccessCtrl; +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback, Callback } from './basic'; + +/** + * @syscap SystemCapability.Security.AccessToken + */ + declare namespace abilityAccessCtrl { + /** + * Obtains the AtManager instance. + * @return returns the instance of the AtManager. + * @since 8 + */ + function createAtManager(): AtManager; + + /** + * Provides methods for managing access_token. + * @name AtManager + */ + interface AtManager { + /** + * Checks whether a specified application has been granted the given permission. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be verified. + * @return Returns permission verify result. + * @since 8 + */ + verifyAccessToken(tokenID: number, permissionName: string): Promise; + + /** + * Checks whether a specified application has been granted the given permission synchronously. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be verified. + * @return Returns permission verify result + * @since 9 + */ + verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus; + + /** + * Grants a specified user_grant permission to the given application. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be granted. + * @param permissionFlag Flag of permission state. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid. + * @throws { BusinessError } with 12100003 If the specified permissionFlag is invalid. + * @throws { BusinessError } with 12100004 If cross-device operation is not supported. + * @throws { BusinessError } with 12100009 If the application specified by the tokenID did not request the specified permission. + * @throws { BusinessError } with 12100010 If the application specified by the tokenID is prohibited from granting the specified permission. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.GRANT_SENSITIVE_PERMISSIONS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.GRANT_SENSITIVE_PERMISSIONS. + * @systemapi + * @since 8 + */ + grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise; + grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback): void; + + /** + * Revokes a specified user_grant permission to the given application. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be revoked. + * @param permissionFlag Flag of permission state. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid. + * @throws { BusinessError } with 12100003 If the specified permissionFlag is invalid. + * @throws { BusinessError } with 12100004 If cross-device operation is not supported. + * @throws { BusinessError } with 12100009 If the application specified by the tokenID did not request the specified permission. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.REVOKE_SENSITIVE_PERMISSIONS. + * @systemapi + * @since 8 + */ + revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise; + revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback): void; + + /** + * Queries specified permission flag of the given application. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be granted. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid. + * @throws { BusinessError } with 12100009 If the application specified by the tokenID did not request the specified permission. + * @throws { BusinessError } with 12100201 If interface caller does not have specified permission. + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @return Return permission flag. + * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS or ohos.permission.GRANT_SENSITIVE_PERMISSIONS or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS. + * @systemapi + * @since 8 + */ + getPermissionFlags(tokenID: number, permissionName: string): Promise; + + /** + * Queries permission management version. + * @return Return permission version. + * @systemapi + * @since 9 + */ + getVersion(): Promise; + + /** + * Registers a permission state callback so that the application can be notified upon specified permission state of specified applications changes. + * @param tokenIDList A list of tokenids that specifies the applications to be listened on. The value in the list can be: + *
    + *
  • {@code empty} - Indicates that the application can be notified if the specified permission state of any applications changes. + *
  • + *
  • {@code non-empty} - Indicates that the application can only be notified if the specified permission state of the specified applications change. + *
  • + *
+ * @param permissionNameList A list of permissions that specifies the permissions to be listened on. The value in the list can be: + *
    + *
  • {@code empty} - Indicates that the application can be notified if any permission state of the specified applications changes. + *
  • + *
  • {@code non-empty} - Indicates that the application can only be notified if the specified permission state of the specified applications changes. + *
  • + *
+ * @throws { BusinessError } with 12100005 If the specified tokenID or permissionName in the input list is all invalid or the list size has exceeded the limit. + * @throws { BusinessError } with 12100006 If the interface is called repeatedly. + * @throws { BusinessError } with 12100008 If The maximum enrollment limit is exceeded. + * @throws { BusinessError } with 12100201 If interface caller does not have specified permission "ohos.permission.GET_SENSITIVE_PERMISSIONS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS. + * @param callback Callback used to listen for the permission state changed event. + * @systemapi + * @since 9 + */ + on(type: 'permissionStateChange', tokenIDList: Array, permissionNameList: Array, callback: Callback): void; + + /** + * Unregisters a permission state callback so that the specified applications cannot be notified upon specified permissions state changes anymore. + * @param tokenIDList A list of tokenids that specifies the applications being listened on. it should correspond to the value registered by function of "on", whose type is "permissionStateChange". + * @param permissionNameList A list of permissions that specifies the permissions being listened on. it should correspond to the value registered by function of "on", whose type is "permissionStateChange". + * @param callback Callback used to listen for the permission state changed event. + * @throws { BusinessError } with 12100007 If The use of the interface does not match with function "on". + * @throws { BusinessError } with 12100201 If interface caller does not have specified permission "ohos.permission.GET_SENSITIVE_PERMISSIONS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.GET_SENSITIVE_PERMISSIONS. + * @systemapi + * @since 9 + */ + off(type: 'permissionStateChange', tokenIDList: Array, permissionNameList: Array, callback?: Callback): void; + } + + /** + * GrantStatus. + * @since 8 + */ + export enum GrantStatus { + /** + * access_token permission check fail + */ + PERMISSION_DENIED = -1, + /** + * access_token permission check success + */ + PERMISSION_GRANTED = 0, + } + + /** + * Enum for permision state change type. + * @since 9 + */ + export enum PermissionStateChangeType { + /** + * A granted user_grant permission is revoked. + */ + PERMISSION_REVOKED_OPER = 0, + /** + * A user_grant permission is granted. + */ + PERMISSION_GRANTED_OPER = 1, + } + + /** + * Indicates the information of permission state change. + * + * @name PermissionStateChangeInfo + * @since 9 + */ + interface PermissionStateChangeInfo { + /** + * Indicates the permission state change type. + */ + change: PermissionStateChangeType; + + /** + * Indicates the application whose permission state has been changed. + */ + tokenID: number; + + /** + * Indicates the permission whose state has been changed. + */ + permissionName: string; + } + } + + export default abilityAccessCtrl; \ No newline at end of file diff --git a/api/@ohos.privacyManager.d.ts b/api/@ohos.privacyManager.d.ts index 7ca324cc1971025338364a704fb46740fa521575..1907b378837082418c37d78bef8db37b914f057e 100644 --- a/api/@ohos.privacyManager.d.ts +++ b/api/@ohos.privacyManager.d.ts @@ -1,324 +1,356 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AsyncCallback, Callback} from './basic' - -/** - * @syscap SystemCapability.Security.AccessToken - */ - declare namespace privacyManager { - /** - * Adds access record of sensitive permission. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be added. - * @param successCount Access count. - * @param failCount Reject account. - * @return Returns 0 if the method is called successfully, returns -1 otherwise. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number): Promise; - function addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number, callback: AsyncCallback): void; - - /** - * Queries the access records of sensitive permission. - * @param request The request of permission used records. - * @return Return the response of permission used records. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function getPermissionUsedRecords(request: PermissionUsedRequest): Promise; - function getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback): void; - - /** - * Start using sensitive permission. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be started. - * @return Returns 0 if the method is called successfully, returns -1 otherwise. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function startUsingPermission(tokenID: number, permissionName: string): Promise; - function startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback): void; - - /** - * Stop using sensitive permission. - * @param tokenID The tokenId of specified application. - * @param permissionName The permission name to be stopped. - * @return Returns 0 if the method is called successfully, returns -1 otherwise. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function stopUsingPermission(tokenID: number, permissionName: string): Promise; - function stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback): void; - - /** - * Subscribes to the change of active state of the specified permission. - * @param permissionNameLists Indicates the permission lists, which are specified. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function on(type: 'activeStateChange', permissionNameList: Array, callback: Callback): void; - - /** - * Unsubscribes to the change of active state of the specified permission. - * @param permissionNameLists Indicates the permission lists, which are specified. - * @permission ohos.permission.PERMISSION_USED_STATS. - * @systemapi - * @since 9 - */ - function off(type: 'activeStateChange', permissionNameList: Array, callback?: Callback): void; - - /** - * Enum for permission for status. - * @systemapi - * @since 9 - */ - enum PermissionActiveStatus { - /** - * permission is not used yet. - */ - PERM_INACTIVE = 0, - - /** - * permission is used in front_end. - */ - PERM_ACTIVE_IN_FOREGROUND = 1, - - /** - * permission is used in back_end. - */ - PERM_ACTIVE_IN_BACKGROUND = 2, - } - - /** - * Indicates the response of permission active status. - * @systemapi - * @since 9 - */ - interface ActiveChangeResponse { - /** - * AccessTokenID - */ - tokenId: number; - - /** - * The permission name - */ - permissionName: string; - - /** - * The device id - */ - deviceId: string; - /** - * The active status name - */ - activeStatus: PermissionActiveStatus; - } - - /** - * PermissionUsageFlag. - * @systemapi - * @since 9 - */ - enum PermissionUsageFlag { - /** - * permission used summary - */ - FLAG_PERMISSION_USAGE_SUMMARY = 0, - /** - * permission used detail - */ - FLAG_PERMISSION_USAGE_DETAIL = 1, - } - - /** - * Provides request of querying permission used records. - * @systemapi - * @since 9 - */ - interface PermissionUsedRequest { - /** - * AccessTokenID - */ - tokenId: number; - - /** - * Distribute flag - */ - isRemote: boolean; - - /** - * The device id - */ - deviceId: string; - - /** - * The bundle name - */ - bundleName: string; - - /** - * The list of permision name - */ - permissionNames: Array; - - /** - * The begin time, in milliseconds - */ - beginTime: number; - - /** - * The end time, in milliseconds - */ - endTime: number; - - /** - * The permission usage flag - */ - flag: PermissionUsageFlag; - } - - /** - * Provides response of querying permission used records. - * @systemapi - * @since 9 - */ - interface PermissionUsedResponse { - /** - * The begin time, in milliseconds - */ - beginTime: number; - - /** - * The end time, in milliseconds - */ - endTime: number; - - /** - * The list of permision used records of bundle - */ - bundleRecords: Array; - } - - /** - * BundleUsedRecord. - * @systemapi - * @since 9 - */ - interface BundleUsedRecord { - /** - * AccessTokenID - */ - tokenId: number; - - /** - * Distribute flag - */ - isRemote: boolean; - - /** - * The device id - */ - deviceId: string; - - /** - * The bundle name - */ - bundleName: string; - - /** - * The list of permission used records - */ - permissionRecords: Array; - } - - /** - * PermissionUsedRecord. - * @systemapi - * @since 9 - */ - interface PermissionUsedRecord { - /** - * The permission name - */ - permissionName: string; - - /** - * The access counts - */ - accessCount: number; - - /** - * The reject counts - */ - rejectCount: number; - - /** - * The last access time, in milliseconds - */ - lastAccessTime: number; - - /** - * The last reject time, in milliseconds - */ - lastRejectTime: number; - - /** - * The last access duration, in milliseconds - */ - lastAccessDuration: number; - - /** - * The list of access records of details - */ - accessRecords: Array; - - /** - * The list of reject records of details - */ - rejectRecords: Array; - } - - /** - * UsedRecordDetail. - * @systemapi - * @since 9 - */ - interface UsedRecordDetail { - /** - * The status - */ - status: number; - - /** - * Timestamp, in milliseconds - */ - timestamp: number; - - /** - * Access duration, in milliseconds - */ - accessDuration: number; - } -} - +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback, Callback} from './basic' + +/** + * @syscap SystemCapability.Security.AccessToken + */ + declare namespace privacyManager { + /** + * Adds access record of sensitive permission. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be added. + * @param successCount Access count. + * @param failCount Reject account. + * @return Returns 0 if the method is called successfully, returns -1 otherwise. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid or it is not an user_grant permission. + * @throws { BusinessError } with 12100017 If the specified successCount or failCount is invalid. + * @throws { BusinessError } with 12100014 If the specified tokenID does not belong to an application process. + * @throws { BusinessError } with 12100016 If the specified permission has not been used by the application specified by the tokenID. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @throws { BusinessError } If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number): Promise; + function addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number, callback: AsyncCallback): void; + + /** + * Queries the access records of sensitive permission. + * @param request The request of permission used records. + * @return Return the response of permission used records. + * @throws { BusinessError } with 12100014 If the specified tokenID does not belong to an application process. + * @throws { BusinessError } with 12100019 If specfied time or flag is invalid. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function getPermissionUsedRecords(request: PermissionUsedRequest): Promise; + function getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback): void; + + /** + * Start using sensitive permission. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be started. + * @return Returns 0 if the method is called successfully, returns -1 otherwise. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid or it is not an user_grant permission. + * @throws { BusinessError } with 12100006 Repeated calls. + * @throws { BusinessError } with 12100014 If the specified tokenID does not belong to an application process. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function startUsingPermission(tokenID: number, permissionName: string): Promise; + function startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback): void; + + /** + * Stop using sensitive permission. + * @param tokenID The tokenId of specified application. + * @param permissionName The permission name to be stopped. + * @return Returns 0 if the method is called successfully, returns -1 otherwise. + * @throws { BusinessError } with 12100001 If the specified tokenID is invalid. + * @throws { BusinessError } with 12100002 If the specified permissionName is invalid or it is not an user_grant permission. + * @throws { BusinessError } with 12100007 The use of the interface does not match with function "startUsingPermission". + * @throws { BusinessError } with 12100014 If the specified tokenID does not belong to an application process. + * @throws { BusinessError } with 12100201 If interface caller does not have permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function stopUsingPermission(tokenID: number, permissionName: string): Promise; + function stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback): void; + + /** + * Subscribes to the change of active state of the specified permission. + * @param permissionNameLists Indicates the permission lists, which are specified. + * @throws { BusinessError } with 12100005 If the specified permissionName in the input list is all invalid or the list size has exceeded the limit. + * @throws { BusinessError } with 12100006 If the interface is called repeatedly. + * @throws { BusinessError } with 12100008 If The maximum enrollment limit is exceeded. + * @throws { BusinessError } with 12100201 If interface caller does not have specified permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function on(type: 'activeStateChange', permissionNameList: Array, callback: Callback): void; + + /** + * Unsubscribes to the change of active state of the specified permission. + * @param permissionNameLists Indicates the permission lists, which are specified. + * @throws { BusinessError } with 12100007 If The use of the interface does not match with function "on". + * @throws { BusinessError } with 12100201 If interface caller does not have specified permission "ohos.permission.PERMISSION_USED_STATS". + * @throws { BusinessError } with 12100401 If the input parameter is not valid parameter. + * @permission ohos.permission.PERMISSION_USED_STATS. + * @systemapi + * @since 9 + */ + function off(type: 'activeStateChange', permissionNameList: Array, callback?: Callback): void; + + /** + * Enum for permission for status. + * @systemapi + * @since 9 + */ + enum PermissionActiveStatus { + /** + * permission is not used yet. + */ + PERM_INACTIVE = 0, + + /** + * permission is used in front_end. + */ + PERM_ACTIVE_IN_FOREGROUND = 1, + + /** + * permission is used in back_end. + */ + PERM_ACTIVE_IN_BACKGROUND = 2, + } + + /** + * Indicates the response of permission active status. + * @systemapi + * @since 9 + */ + interface ActiveChangeResponse { + /** + * AccessTokenID + */ + tokenId: number; + + /** + * The permission name + */ + permissionName: string; + + /** + * The device id + */ + deviceId: string; + /** + * The active status name + */ + activeStatus: PermissionActiveStatus; + } + + /** + * PermissionUsageFlag. + * @systemapi + * @since 9 + */ + enum PermissionUsageFlag { + /** + * permission used summary + */ + FLAG_PERMISSION_USAGE_SUMMARY = 0, + /** + * permission used detail + */ + FLAG_PERMISSION_USAGE_DETAIL = 1, + } + + /** + * Provides request of querying permission used records. + * @systemapi + * @since 9 + */ + interface PermissionUsedRequest { + /** + * AccessTokenID + */ + tokenId: number; + + /** + * Distribute flag + */ + isRemote: boolean; + + /** + * The device id + */ + deviceId: string; + + /** + * The bundle name + */ + bundleName: string; + + /** + * The list of permision name + */ + permissionNames: Array; + + /** + * The begin time, in milliseconds + */ + beginTime: number; + + /** + * The end time, in milliseconds + */ + endTime: number; + + /** + * The permission usage flag + */ + flag: PermissionUsageFlag; + } + + /** + * Provides response of querying permission used records. + * @systemapi + * @since 9 + */ + interface PermissionUsedResponse { + /** + * The begin time, in milliseconds + */ + beginTime: number; + + /** + * The end time, in milliseconds + */ + endTime: number; + + /** + * The list of permision used records of bundle + */ + bundleRecords: Array; + } + + /** + * BundleUsedRecord. + * @systemapi + * @since 9 + */ + interface BundleUsedRecord { + /** + * AccessTokenID + */ + tokenId: number; + + /** + * Distribute flag + */ + isRemote: boolean; + + /** + * The device id + */ + deviceId: string; + + /** + * The bundle name + */ + bundleName: string; + + /** + * The list of permission used records + */ + permissionRecords: Array; + } + + /** + * PermissionUsedRecord. + * @systemapi + * @since 9 + */ + interface PermissionUsedRecord { + /** + * The permission name + */ + permissionName: string; + + /** + * The access counts + */ + accessCount: number; + + /** + * The reject counts + */ + rejectCount: number; + + /** + * The last access time, in milliseconds + */ + lastAccessTime: number; + + /** + * The last reject time, in milliseconds + */ + lastRejectTime: number; + + /** + * The last access duration, in milliseconds + */ + lastAccessDuration: number; + + /** + * The list of access records of details + */ + accessRecords: Array; + + /** + * The list of reject records of details + */ + rejectRecords: Array; + } + + /** + * UsedRecordDetail. + * @systemapi + * @since 9 + */ + interface UsedRecordDetail { + /** + * The status + */ + status: number; + + /** + * Timestamp, in milliseconds + */ + timestamp: number; + + /** + * Access duration, in milliseconds + */ + accessDuration: number; + } +} + export default privacyManager; \ No newline at end of file