From 936ec57afcb5c0f15b8e7383c3951d6ea7fa7e92 Mon Sep 17 00:00:00 2001 From: huangjieliang Date: Mon, 6 May 2024 23:12:52 +0800 Subject: [PATCH] Add js interface for file manager under lock screen. Signed-off-by: huangjieliang Change-Id: If95b604778d257f9945f59086085329014279267 --- api/@ohos.ability.screenLockFileManager.d.ts | 169 ++++++++++++++++++ api/device-define/default.json | 1 + api/device-define/tablet.json | 1 + .../api_check_plugin/code_style_rule.json | 1 + 4 files changed, 172 insertions(+) create mode 100644 api/@ohos.ability.screenLockFileManager.d.ts diff --git a/api/@ohos.ability.screenLockFileManager.d.ts b/api/@ohos.ability.screenLockFileManager.d.ts new file mode 100644 index 000000000..ec5d82e14 --- /dev/null +++ b/api/@ohos.ability.screenLockFileManager.d.ts @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2024 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. + */ + +/** + * @file Provides the capability to access data under lock screen. + * @kit Ability Kit + */ + +/** + * Provides the capability to access data under lock screen. + * + * @namespace screenLockFileManager + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ +declare namespace screenLockFileManager { + /** + * Enumerates the types of data under lock screen. + * + * @enum { number } + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + export enum DataType { + /** + * Media photo and video data. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + MEDIA_DATA = 0x00000001, + + /** + * All data type. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + ALL_DATA = 0xffffffff + } + + /** + * AccessStatus. + * + * @enum { number } + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + export enum AccessStatus { + /** + * Acquire the access of data failed. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + ACCESS_DENIED = -1, + + /** + * Acquire the access of data success. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + ACCESS_GRANTED = 0 + } + + /** + * ReleaseStatus. + * + * @enum { number } + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + export enum ReleaseStatus { + /** + * Release the access of data failed. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + RELEASE_DENIED = -1, + + /** + * Release the access of data success. + * + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + RELEASE_GRANTED = 0 + } + + /** + * Acquire the access of the caller data under the lock screen. + * + * @returns { AccessStatus } Returns acquire the access result. + * @throws { BusinessError } 801 - The specified SystemCapability name was not found. + * @throws { BusinessError } 29300002 - The system ability work abnormally. + * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. + * @throws { BusinessError } 29300004 - File access is denied. + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + function acquireAccess(): AccessStatus; + + /** + * Acquire the access of the specified data under the lock screen. + * + * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA + * @param { DataType } dataType - Indicates the specified data to allow access under the lock screen. + * @returns { AccessStatus } Returns acquire the access result. + * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken. + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - The specified SystemCapability name was not found. + * @throws { BusinessError } 29300001 - Invalid parameter. + * @throws { BusinessError } 29300002 - The system ability work abnormally. + * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. + * @throws { BusinessError } 29300004 - File access is denied. + * @syscap SystemCapability.Security.ScreenLockFileManager + * @systemapi + * @since 12 + */ + function acquireAccess(dataType: DataType): AccessStatus; + + /** + * Release the access of the caller data and do not allow data access under the lock screen. + * + * @returns { ReleaseStatus } Returns release the access result. + * @throws { BusinessError } 801 - The specified SystemCapability name was not found. + * @throws { BusinessError } 29300002 - The system ability work abnormally. + * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. + * @throws { BusinessError } 29300005 - File access was not acquired. + * @syscap SystemCapability.Security.ScreenLockFileManager + * @since 12 + */ + function releaseAccess(): ReleaseStatus; + + /** + * Release the access of the specified data type and do not allow data access under the lock screen. + * + * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA + * @param { DataType } dataType - Indicates the specified data type and do not allow data access under the lock screen. + * @returns { ReleaseStatus } Returns release the access result. + * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken. + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - The specified SystemCapability name was not found. + * @throws { BusinessError } 29300001 - Invalid parameter. + * @throws { BusinessError } 29300002 - The system ability work abnormally. + * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. + * @throws { BusinessError } 29300005 - File access was not acquired. + * @syscap SystemCapability.Security.ScreenLockFileManager + * @systemapi + * @since 12 + */ + function releaseAccess(dataType: DataType): ReleaseStatus; +} diff --git a/api/device-define/default.json b/api/device-define/default.json index 44699d14b..b5f7e7727 100644 --- a/api/device-define/default.json +++ b/api/device-define/default.json @@ -128,6 +128,7 @@ "SystemCapability.Security.Huks.Extension", "SystemCapability.Security.Asset", "SystemCapability.Security.AccessToken", + "SystemCapability.Security.ScreenLockFileManager", "SystemCapability.Account.OsAccount", "SystemCapability.Account.AppAccount", "SystemCapability.UserIAM.UserAuth.Core", diff --git a/api/device-define/tablet.json b/api/device-define/tablet.json index bec7a8736..9f1a41fbe 100644 --- a/api/device-define/tablet.json +++ b/api/device-define/tablet.json @@ -121,6 +121,7 @@ "SystemCapability.Security.Huks.Extension", "SystemCapability.Security.Asset", "SystemCapability.Security.AccessToken", + "SystemCapability.Security.ScreenLockFileManager", "SystemCapability.Account.OsAccount", "SystemCapability.Account.AppAccount", "SystemCapability.UserIAM.UserAuth.Core", diff --git a/build-tools/api_check_plugin/code_style_rule.json b/build-tools/api_check_plugin/code_style_rule.json index a3dfba8e5..6818d1bb6 100644 --- a/build-tools/api_check_plugin/code_style_rule.json +++ b/build-tools/api_check_plugin/code_style_rule.json @@ -264,6 +264,7 @@ "SystemCapability.Security.CryptoFramework.Cert", "SystemCapability.Security.DataLossPrevention", "SystemCapability.Security.Cert", + "SystemCapability.Security.ScreenLockFileManager", "SystemCapability.Account.OsAccount", "SystemCapability.Account.AppAccount", "SystemCapability.UserIAM.UserAuth.Core",