1/* 2 * Copyright (c) 2022 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 */ 15import { AsyncCallback } from './basic'; 16import { Callback } from './basic'; 17 18/** 19 * systemScreenLock 20 * @syscap SystemCapability.MiscServices.ScreenLock 21 * @since 7 22 */ 23declare namespace screenLock { 24 25 /** 26 * Checks whether the screen is currently locked. 27 * 28 * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. 29 * @syscap SystemCapability.MiscServices.ScreenLock 30 * @since 7 31 * @deprecated since 9 32 */ 33 function isScreenLocked(callback: AsyncCallback<boolean>): void; 34 35 /** 36 * Checks whether the screen is currently locked. 37 * 38 * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. 39 * @syscap SystemCapability.MiscServices.ScreenLock 40 * @since 7 41 * @deprecated since 9 42 */ 43 function isScreenLocked(): Promise<boolean>; 44 45 /** 46 * Checks whether the screen is currently locked. 47 * 48 * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. 49 * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 50 * @syscap SystemCapability.MiscServices.ScreenLock 51 * @systemapi Hide this for inner system use. 52 * @since 9 53 */ 54 function isLocked(): boolean; 55 56 /** 57 * Checks whether the screen lock of the current device is secure. 58 * 59 * @returns Returns {@code true} if the screen lock of the current device is secure; returns {@code false} otherwise. 60 * @syscap SystemCapability.MiscServices.ScreenLock 61 * @since 7 62 * @deprecated since 9 63 */ 64 function isSecureMode(callback: AsyncCallback<boolean>): void; 65 66 /** 67 * Checks whether the screen lock of the current device is secure. 68 * 69 * @returns Returns {@code true} if the screen lock of the current device is secure; returns {@code false} otherwise. 70 * @syscap SystemCapability.MiscServices.ScreenLock 71 * @since 7 72 * @deprecated since 9 73 */ 74 function isSecureMode(): Promise<boolean>; 75 76 /** 77 * Unlock the screen. 78 * 79 * @syscap SystemCapability.MiscServices.ScreenLock 80 * @since 7 81 * @deprecated since 9 82 */ 83 function unlockScreen(callback: AsyncCallback<void>): void; 84 85 /** 86 * Unlock the screen. 87 * 88 * @syscap SystemCapability.MiscServices.ScreenLock 89 * @since 7 90 * @deprecated since 9 91 */ 92 function unlockScreen():Promise<void>; 93 94 /** 95 * Unlock the screen. 96 * 97 * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 98 * @throws {BusinessError} 401 - parameter error. 99 * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 100 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 101 * @syscap SystemCapability.MiscServices.ScreenLock 102 * @systemapi Hide this for inner system use. 103 * @since 9 104 */ 105 function unlock(callback: AsyncCallback<boolean>): void; 106 107 /** 108 * Unlock the screen. 109 * 110 * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 111 * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 112 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 113 * @syscap SystemCapability.MiscServices.ScreenLock 114 * @systemapi Hide this for inner system use. 115 * @since 9 116 */ 117 function unlock():Promise<boolean>; 118 119 /** 120 * Lock the screen. 121 * 122 * @returns Returns {@code true} if the screen is locked successfully; returns {@code false} otherwise. 123 * @throws {BusinessError} 401 - parameter error. 124 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 125 * @syscap SystemCapability.MiscServices.ScreenLock 126 * @systemapi Hide this for inner system use. 127 * @since 9 128 */ 129 function lock(callback: AsyncCallback<boolean>): void; 130 131 /** 132 * Lock the screen. 133 * 134 * @returns Returns {@code true} if the screen is locked successfully; returns {@code false} otherwise. 135 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 136 * @syscap SystemCapability.MiscServices.ScreenLock 137 * @systemapi Hide this for inner system use. 138 * @since 9 139 */ 140 function lock():Promise<boolean>; 141 142 /** 143 * Indicates the system event type related to the screenlock management service. 144 * 145 * @syscap SystemCapability.MiscServices.ScreenLock 146 * @systemapi Hide this for inner system use. 147 * @since 9 148 */ 149 type EventType = 150 'beginWakeUp' 151 | 'endWakeUp' 152 | 'beginScreenOn' 153 | 'endScreenOn' 154 | 'beginScreenOff' 155 | 'endScreenOff' 156 | 'unlockScreen' 157 | 'lockScreen' 158 | 'beginExitAnimation' 159 | 'beginSleep' 160 | 'endSleep' 161 | 'changeUser' 162 | 'screenlockEnabled' 163 | 'serviceRestart' 164 165 /** 166 * Indicates the system event type and parameter related to the screenlock management service. 167 * 168 * @syscap SystemCapability.MiscServices.ScreenLock 169 * @systemapi Hide this for inner system use. 170 * @since 9 171 */ 172 interface SystemEvent { 173 eventType: EventType, 174 params: string 175 } 176 177 /** 178 * Register system event related to screen lock service. 179 * 180 * @param { Callback<SystemEvent> } callback - the callback function for indicating the system event related screen lock 181 * @returns Returns {@code true} if register system event is success; returns {@code false} otherwise. 182 * @throws {BusinessError} 401 - parameter error. 183 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 184 * @syscap SystemCapability.MiscServices.ScreenLock 185 * @systemapi Hide this for inner system use. 186 * @since 9 187 */ 188 function onSystemEvent(callback: Callback<SystemEvent>): boolean; 189 190 /** 191 * The screen lock app sends the event to the screen lock service. 192 * 193 * @param { String } event - event type. 194 * @param { number } parameter - operation result of the event. 195 * @returns Returns {@code true} if screen lock app send event to screen lock service is success; returns {@code false} otherwise. 196 * @throws {BusinessError} 401 - parameter error. 197 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 198 * @syscap SystemCapability.MiscServices.ScreenLock 199 * @systemapi Hide this for inner system use. 200 * @since 9 201 */ 202 function sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void; 203 204 /** 205 * The screen lock app sends the event to the screen lock service. 206 * 207 * @param { String } event - event type. 208 * @param { number } parameter - operation result of the event. 209 * @returns Returns {@code true} if screen lock app send event to screen lock service is success; returns {@code false} otherwise. 210 * @throws {BusinessError} 401 - parameter error. 211 * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 212 * @syscap SystemCapability.MiscServices.ScreenLock 213 * @systemapi Hide this for inner system use. 214 * @since 9 215 */ 216 function sendScreenLockEvent(event: String, parameter: number): Promise<boolean>; 217} 218 219export default screenLock;