新增隐私权限使用状态管理相关接口

Signed-off-by:chennian<chennian1@huawei.com>

Signed-off-by: chennian <chennian1@huawei.com>
This commit is contained in:
chennian 2022-08-16 16:50:52 +08:00
parent 064206c823
commit 8cfdff5845

View File

@ -13,21 +13,21 @@
* limitations under the License.
*/
import {AsyncCallback} from './basic'
import {AsyncCallback, Callback} from './basic'
/**
* @syscap SystemCapability.Security.AccessToken
*/
declare namespace privacyManager {
/**
* Add access record of sensitive permission.
* 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 hide this for inner system use
* @systemapi
* @since 9
*/
function addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number): Promise<number>;
@ -36,17 +36,107 @@ import {AsyncCallback} from './basic'
/**
* Queries the access records of sensitive permission.
* @param request The request of permission used records.
* @return Return the reponse of permission used records.
* @return Return the response of permission used records.
* @permission ohos.permission.PERMISSION_USED_STATS.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
function getPermissionUsedRecords(request: PermissionUsedRequest): Promise<PermissionUsedResponse>;
function getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback<PermissionUsedResponse>): 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<number>;
function startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback<number>): 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<number>;
function stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback<number>): void;
/**
* Subscribes to the change of active state of the specified permission.
* @param permissionNameLists Indicated the permission lists, which are specified.
* @permission ohos.permission.PERMISSION_USED_STATS.
* @systemapi
* @since 9
*/
function on(type: 'activeStateChange', permissionNameList: Array<string>, callback: Callback<ActiveChangeResponse>): void;
/**
* Unsubscribes from .
* @param permissionNameLists Indicated the permission lists, which are specified.
* @permission ohos.permission.PERMISSION_USED_STATS.
* @systemapi
* @since 9
*/
function off(type: 'activeStateChange', permissionNameList: Array<string>, callback?: Callback<ActiveChangeResponse>): 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 hide this for inner system use
* @systemapi
* @since 9
*/
enum PermissionUsageFlag {
@ -62,7 +152,7 @@ import {AsyncCallback} from './basic'
/**
* Provides request of querying permission used records.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
interface PermissionUsedRequest {
@ -109,7 +199,7 @@ import {AsyncCallback} from './basic'
/**
* Provides response of querying permission used records.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
interface PermissionUsedResponse {
@ -131,7 +221,7 @@ import {AsyncCallback} from './basic'
/**
* BundleUsedRecord.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
interface BundleUsedRecord {
@ -163,7 +253,7 @@ import {AsyncCallback} from './basic'
/**
* PermissionUsedRecord.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
interface PermissionUsedRecord {
@ -210,7 +300,7 @@ import {AsyncCallback} from './basic'
/**
* UsedRecordDetail.
* @systemapi hide this for inner system use
* @systemapi
* @since 9
*/
interface UsedRecordDetail {