• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file Provides the capability to access data under lock screen.
18 * @kit AbilityKit
19 */
20
21/**
22 * Provides the capability to access data under lock screen.
23 *
24 * @namespace screenLockFileManager
25 * @syscap SystemCapability.Security.ScreenLockFileManager
26 * @since 12
27 */
28declare namespace screenLockFileManager {
29  /**
30   * Enumerates the types of data under lock screen.
31   *
32   * @enum { number }
33   * @syscap SystemCapability.Security.ScreenLockFileManager
34   * @since 12
35   */
36  export enum DataType {
37    /**
38     * Media photo and video data.
39     *
40     * @syscap SystemCapability.Security.ScreenLockFileManager
41     * @since 12
42     */
43    MEDIA_DATA = 0x00000001,
44
45    /**
46     * All data type.
47     *
48     * @syscap SystemCapability.Security.ScreenLockFileManager
49     * @since 12
50     */
51    ALL_DATA = 0xffffffff
52  }
53
54  /**
55   * AccessStatus.
56   *
57   * @enum { number }
58   * @syscap SystemCapability.Security.ScreenLockFileManager
59   * @since 12
60   */
61  export enum AccessStatus {
62    /**
63     * Acquire the access of data failed.
64     *
65     * @syscap SystemCapability.Security.ScreenLockFileManager
66     * @since 12
67     */
68    ACCESS_DENIED = -1,
69
70    /**
71     * Acquire the access of data success.
72     *
73     * @syscap SystemCapability.Security.ScreenLockFileManager
74     * @since 12
75     */
76    ACCESS_GRANTED = 0
77  }
78
79  /**
80   * ReleaseStatus.
81   *
82   * @enum { number }
83   * @syscap SystemCapability.Security.ScreenLockFileManager
84   * @since 12
85   */
86  export enum ReleaseStatus {
87    /**
88     * Release the access of data failed.
89     *
90     * @syscap SystemCapability.Security.ScreenLockFileManager
91     * @since 12
92     */
93    RELEASE_DENIED = -1,
94
95    /**
96     * Release the access of data success.
97     *
98     * @syscap SystemCapability.Security.ScreenLockFileManager
99     * @since 12
100     */
101    RELEASE_GRANTED = 0
102  }
103
104  /**
105   * KeyStatus.
106   *
107   * @enum { number }
108   * @syscap SystemCapability.Security.ScreenLockFileManager
109   * @since 18
110   */
111  export enum KeyStatus {
112    /**
113     * The application is not enabled the data protection under lock screen.
114     *
115     * @syscap SystemCapability.Security.ScreenLockFileManager
116     * @since 18
117     */
118    KEY_NOT_EXIST = -2,
119
120    /**
121     * AppKey has been released.
122     *
123     * @syscap SystemCapability.Security.ScreenLockFileManager
124     * @since 18
125     */
126    KEY_RELEASED = -1,
127
128    /**
129     * AppKey exists.
130     *
131     * @syscap SystemCapability.Security.ScreenLockFileManager
132     * @since 18
133     */
134    KEY_EXIST = 0
135  }
136
137  /**
138   * Acquire the access of the caller data under the lock screen.
139   *
140   * @returns { AccessStatus } Returns acquire the access result.
141   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
142   * @throws { BusinessError } 29300002 - The system ability work abnormally.
143   * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen.
144   * @throws { BusinessError } 29300004 - File access is denied.
145   * @syscap SystemCapability.Security.ScreenLockFileManager
146   * @since 12
147   */
148  function acquireAccess(): AccessStatus;
149
150  /**
151   * Acquire the access of the specified data under the lock screen.
152   *
153   * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA
154   * @param { DataType } dataType - Indicates the specified data to allow access under the lock screen.
155   * @returns { AccessStatus } Returns acquire the access result.
156   * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken.
157   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
158   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameter is left unspecified. 2. Incorrect parameter types.
159   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
160   * @throws { BusinessError } 29300001 - Invalid DataType.
161   * @throws { BusinessError } 29300002 - The system ability work abnormally.
162   * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen.
163   * @throws { BusinessError } 29300004 - File access is denied.
164   * @syscap SystemCapability.Security.ScreenLockFileManager
165   * @systemapi
166   * @since 12
167   */
168  function acquireAccess(dataType: DataType): AccessStatus;
169
170  /**
171   * Release the access of the caller data and do not allow data access under the lock screen.
172   *
173   * @returns { ReleaseStatus } Returns release the access result.
174   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
175   * @throws { BusinessError } 29300002 - The system ability work abnormally.
176   * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen.
177   * @throws { BusinessError } 29300005 - File access was not acquired.
178   * @syscap SystemCapability.Security.ScreenLockFileManager
179   * @since 12
180   */
181  function releaseAccess(): ReleaseStatus;
182
183  /**
184   * Release the access of the specified data type and do not allow data access under the lock screen.
185   *
186   * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA
187   * @param { DataType } dataType - Indicates the specified data type and do not allow data access under the lock screen.
188   * @returns { ReleaseStatus } Returns release the access result.
189   * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken.
190   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
191   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameter is left unspecified. 2. Incorrect parameter types.
192   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
193   * @throws { BusinessError } 29300001 - Invalid DataType.
194   * @throws { BusinessError } 29300002 - The system ability work abnormally.
195   * @throws { BusinessError } 29300003 - The application is not enabled the data protection under lock screen.
196   * @throws { BusinessError } 29300005 - File access was not acquired.
197   * @syscap SystemCapability.Security.ScreenLockFileManager
198   * @systemapi
199   * @since 12
200   */
201  function releaseAccess(dataType: DataType): ReleaseStatus;
202
203  /**
204   * Query the AppKey's status of the caller.
205   *
206   * @returns { KeyStatus } Returns the AppKey status.
207   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
208   * @throws { BusinessError } 29300002 - The system ability work abnormally.
209   * @syscap SystemCapability.Security.ScreenLockFileManager
210   * @since 18
211   */
212  function queryAppKeyState(): KeyStatus;
213
214  /**
215   * Query the specified AppKey's status.
216   *
217   * @permission ohos.permission.ACCESS_SCREEN_LOCK_MEDIA_DATA or ohos.permission.ACCESS_SCREEN_LOCK_ALL_DATA
218   * @param { DataType } dataType - Indicates the specified data to allow access.
219   * @returns { KeyStatus } Returns the AppKey status.
220   * @throws { BusinessError } 201 - Permission verification failed, usually returned by VerifyAccessToken.
221   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
222   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameter is left unspecified. 2. Incorrect parameter types.
223   * @throws { BusinessError } 801 - The specified SystemCapability name was not found.
224   * @throws { BusinessError } 29300001 - Invalid DataType.
225   * @throws { BusinessError } 29300002 - The system ability work abnormally.
226   * @syscap SystemCapability.Security.ScreenLockFileManager
227   * @systemapi
228   * @since 18
229   */
230  function queryAppKeyState(dataType: DataType): KeyStatus;
231}
232export default screenLockFileManager;