161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file Provides the capability to access data under lock screen. 1861847f8eSopenharmony_ci * @kit AbilityKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * Provides the capability to access data under lock screen. 2361847f8eSopenharmony_ci * 2461847f8eSopenharmony_ci * @namespace screenLockFileManager 2561847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 2661847f8eSopenharmony_ci * @since 12 2761847f8eSopenharmony_ci */ 2861847f8eSopenharmony_cideclare namespace screenLockFileManager { 2961847f8eSopenharmony_ci /** 3061847f8eSopenharmony_ci * Enumerates the types of data under lock screen. 3161847f8eSopenharmony_ci * 3261847f8eSopenharmony_ci * @enum { number } 3361847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 3461847f8eSopenharmony_ci * @since 12 3561847f8eSopenharmony_ci */ 3661847f8eSopenharmony_ci export enum DataType { 3761847f8eSopenharmony_ci /** 3861847f8eSopenharmony_ci * Media photo and video data. 3961847f8eSopenharmony_ci * 4061847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 4161847f8eSopenharmony_ci * @since 12 4261847f8eSopenharmony_ci */ 4361847f8eSopenharmony_ci MEDIA_DATA = 0x00000001, 4461847f8eSopenharmony_ci 4561847f8eSopenharmony_ci /** 4661847f8eSopenharmony_ci * All data type. 4761847f8eSopenharmony_ci * 4861847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 4961847f8eSopenharmony_ci * @since 12 5061847f8eSopenharmony_ci */ 5161847f8eSopenharmony_ci ALL_DATA = 0xffffffff 5261847f8eSopenharmony_ci } 5361847f8eSopenharmony_ci 5461847f8eSopenharmony_ci /** 5561847f8eSopenharmony_ci * AccessStatus. 5661847f8eSopenharmony_ci * 5761847f8eSopenharmony_ci * @enum { number } 5861847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 5961847f8eSopenharmony_ci * @since 12 6061847f8eSopenharmony_ci */ 6161847f8eSopenharmony_ci export enum AccessStatus { 6261847f8eSopenharmony_ci /** 6361847f8eSopenharmony_ci * Acquire the access of data failed. 6461847f8eSopenharmony_ci * 6561847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 6661847f8eSopenharmony_ci * @since 12 6761847f8eSopenharmony_ci */ 6861847f8eSopenharmony_ci ACCESS_DENIED = -1, 6961847f8eSopenharmony_ci 7061847f8eSopenharmony_ci /** 7161847f8eSopenharmony_ci * Acquire the access of data success. 7261847f8eSopenharmony_ci * 7361847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 7461847f8eSopenharmony_ci * @since 12 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci ACCESS_GRANTED = 0 7761847f8eSopenharmony_ci } 7861847f8eSopenharmony_ci 7961847f8eSopenharmony_ci /** 8061847f8eSopenharmony_ci * ReleaseStatus. 8161847f8eSopenharmony_ci * 8261847f8eSopenharmony_ci * @enum { number } 8361847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 8461847f8eSopenharmony_ci * @since 12 8561847f8eSopenharmony_ci */ 8661847f8eSopenharmony_ci export enum ReleaseStatus { 8761847f8eSopenharmony_ci /** 8861847f8eSopenharmony_ci * Release the access of data failed. 8961847f8eSopenharmony_ci * 9061847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 9161847f8eSopenharmony_ci * @since 12 9261847f8eSopenharmony_ci */ 9361847f8eSopenharmony_ci RELEASE_DENIED = -1, 9461847f8eSopenharmony_ci 9561847f8eSopenharmony_ci /** 9661847f8eSopenharmony_ci * Release the access of data success. 9761847f8eSopenharmony_ci * 9861847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 9961847f8eSopenharmony_ci * @since 12 10061847f8eSopenharmony_ci */ 10161847f8eSopenharmony_ci RELEASE_GRANTED = 0 10261847f8eSopenharmony_ci } 10361847f8eSopenharmony_ci 10461847f8eSopenharmony_ci /** 10561847f8eSopenharmony_ci * Acquire the access of the caller data under the lock screen. 10661847f8eSopenharmony_ci * 10761847f8eSopenharmony_ci * @returns { AccessStatus } Returns acquire the access result. 10861847f8eSopenharmony_ci * @throws { BusinessError } 801 - The specified SystemCapability name was not found. 10961847f8eSopenharmony_ci * @throws { BusinessError } 29300002 - The system ability work abnormally. 11061847f8eSopenharmony_ci * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. 11161847f8eSopenharmony_ci * @throws { BusinessError } 29300004 - File access is denied. 11261847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 11361847f8eSopenharmony_ci * @since 12 11461847f8eSopenharmony_ci */ 11561847f8eSopenharmony_ci function acquireAccess(): AccessStatus; 11661847f8eSopenharmony_ci 11761847f8eSopenharmony_ci /** 11861847f8eSopenharmony_ci * Acquire the access of the specified data under the lock screen. 11961847f8eSopenharmony_ci * 12061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA 12161847f8eSopenharmony_ci * @param { DataType } dataType - Indicates the specified data to allow access under the lock screen. 12261847f8eSopenharmony_ci * @returns { AccessStatus } Returns acquire the access result. 12361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken. 12461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 12561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameter is left unspecified. 2. Incorrect parameter types. 12661847f8eSopenharmony_ci * @throws { BusinessError } 801 - The specified SystemCapability name was not found. 12761847f8eSopenharmony_ci * @throws { BusinessError } 29300001 - Invalid parameter. 12861847f8eSopenharmony_ci * @throws { BusinessError } 29300002 - The system ability work abnormally. 12961847f8eSopenharmony_ci * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. 13061847f8eSopenharmony_ci * @throws { BusinessError } 29300004 - File access is denied. 13161847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 13261847f8eSopenharmony_ci * @systemapi 13361847f8eSopenharmony_ci * @since 12 13461847f8eSopenharmony_ci */ 13561847f8eSopenharmony_ci function acquireAccess(dataType: DataType): AccessStatus; 13661847f8eSopenharmony_ci 13761847f8eSopenharmony_ci /** 13861847f8eSopenharmony_ci * Release the access of the caller data and do not allow data access under the lock screen. 13961847f8eSopenharmony_ci * 14061847f8eSopenharmony_ci * @returns { ReleaseStatus } Returns release the access result. 14161847f8eSopenharmony_ci * @throws { BusinessError } 801 - The specified SystemCapability name was not found. 14261847f8eSopenharmony_ci * @throws { BusinessError } 29300002 - The system ability work abnormally. 14361847f8eSopenharmony_ci * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. 14461847f8eSopenharmony_ci * @throws { BusinessError } 29300005 - File access was not acquired. 14561847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 14661847f8eSopenharmony_ci * @since 12 14761847f8eSopenharmony_ci */ 14861847f8eSopenharmony_ci function releaseAccess(): ReleaseStatus; 14961847f8eSopenharmony_ci 15061847f8eSopenharmony_ci /** 15161847f8eSopenharmony_ci * Release the access of the specified data type and do not allow data access under the lock screen. 15261847f8eSopenharmony_ci * 15361847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA 15461847f8eSopenharmony_ci * @param { DataType } dataType - Indicates the specified data type and do not allow data access under the lock screen. 15561847f8eSopenharmony_ci * @returns { ReleaseStatus } Returns release the access result. 15661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken. 15761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 15861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameter is left unspecified. 2. Incorrect parameter types. 15961847f8eSopenharmony_ci * @throws { BusinessError } 801 - The specified SystemCapability name was not found. 16061847f8eSopenharmony_ci * @throws { BusinessError } 29300001 - Invalid parameter. 16161847f8eSopenharmony_ci * @throws { BusinessError } 29300002 - The system ability work abnormally. 16261847f8eSopenharmony_ci * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen. 16361847f8eSopenharmony_ci * @throws { BusinessError } 29300005 - File access was not acquired. 16461847f8eSopenharmony_ci * @syscap SystemCapability.Security.ScreenLockFileManager 16561847f8eSopenharmony_ci * @systemapi 16661847f8eSopenharmony_ci * @since 12 16761847f8eSopenharmony_ci */ 16861847f8eSopenharmony_ci function releaseAccess(dataType: DataType): ReleaseStatus; 16961847f8eSopenharmony_ci} 17061847f8eSopenharmony_ciexport default screenLockFileManager;