46 Star 173 Fork 4.7K

OpenHarmony/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.screenLock.d.ts 21.65 KB
一键复制 编辑 原始数据 按行查看 历史
chenzhuo 提交于 3个月前 . fix_api
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
/*
* Copyright (c) 2022 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
* @kit BasicServicesKit
*/
import { AsyncCallback } from './@ohos.base';
import { Callback } from './@ohos.base';
/**
* systemScreenLock
*
* @namespace screenLock
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
*/
declare namespace screenLock {
/**
* Checks whether the screen is currently locked.
*
* @param { AsyncCallback<boolean> } callback - the callback of isScreenLocked.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function isScreenLocked(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the screen is currently locked.
*
* @returns { Promise<boolean> } the promise returned by the function.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function isScreenLocked(): Promise<boolean>;
/**
* Checks whether the screen is currently locked.
*
* @returns { boolean } returns true if the screen is currently locked, returns false otherwise.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function isLocked(): boolean;
/**
* Checks whether the screen lock of the current device is secure.
*
* @param { AsyncCallback<boolean> } callback - the callback of isSecureMode.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function isSecureMode(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the screen lock of the current device is secure.
*
* @returns { Promise<boolean> } the promise returned by the function.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function isSecureMode(): Promise<boolean>;
/**
* Unlock the screen.
*
* @param { AsyncCallback<void> } callback - the callback of unlockScreen.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function unlockScreen(callback: AsyncCallback<void>): void;
/**
* Unlock the screen.
*
* @returns { Promise<void> } the promise returned by the function.
* @syscap SystemCapability.MiscServices.ScreenLock
* @since 7
* @deprecated since 9
*/
function unlockScreen(): Promise<void>;
/**
* Unlock the screen.
*
* @param { AsyncCallback<boolean> } callback - the callback of unlock.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
/**
* Unlock the screen.
*
* @param { AsyncCallback<boolean> } callback - the callback of unlock.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @throws { BusinessError } 13200003 - Invalid use.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 11
*/
function unlock(callback: AsyncCallback<boolean>): void;
/**
* Unlock the screen.
*
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
/**
* Unlock the screen.
*
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @throws { BusinessError } 13200003 - Invalid use.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 11
*/
function unlock(): Promise<boolean>;
/**
* Lock the screen.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @param { AsyncCallback<boolean> } callback - the callback of lock.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function lock(callback: AsyncCallback<boolean>): void;
/**
* Lock the screen.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function lock(): Promise<boolean>;
/**
* Indicates the system event type related to the screenlock management service.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
/**
* Indicates the system event type related to the screenlock management service. Adding strongAuthChanged and screenLockDisabledChanged.
*
* @typedef {('beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen'
* | 'lockScreen' | 'beginExitAnimation' | 'beginSleep' | 'endSleep' | 'changeUser' | 'screenlockEnabled' | 'serviceRestart'
* | 'strongAuthChanged' | 'screenLockDisabledChanged')}
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
type EventType =
'beginWakeUp'
| 'endWakeUp'
| 'beginScreenOn'
| 'endScreenOn'
| 'beginScreenOff'
| 'endScreenOff'
| 'unlockScreen'
| 'lockScreen'
| 'beginExitAnimation'
| 'beginSleep'
| 'endSleep'
| 'changeUser'
| 'screenlockEnabled'
| 'serviceRestart'
| 'strongAuthChanged'
| 'screenLockDisabledChanged';
/**
* Indicates the strong authentication reason flags used to request.
*
* @enum { number }
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
enum StrongAuthReasonFlags {
/**
* Indicates that there are no strong authentication reason flags.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
NONE = 0x00000000,
/**
* Indicates the strong authentication reason requested after boot.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
AFTER_BOOT = 0x00000001,
/**
* Indicates the strong authentication reason requested after timeout.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
AFTER_TIMEOUT = 0x00000002,
/**
* Indicates the strong authentication reason requested by active request.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
ACTIVE_REQUEST = 0x00000004,
/**
* Indicates the strong authentication reason requested by policy restriction.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
POLICY_RESTRICTION = 0x00000008
}
/**
* Indicates the screen lock authentication state.
*
* @enum { number }
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
enum AuthState {
/**
* Indicates the screen lock is not authenticated.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
NOT_AUTHED = 0,
/**
* Indicates the screen lock is pre authenticated by credential.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
PRE_AUTHED_BY_CREDENTIAL = 1,
/**
* Indicates the screen lock is pre authenticated by fingerprint.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
PRE_AUTHED_BY_FINGERPRINT = 2,
/**
* Indicates the screen lock is pre authenticated by face.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
PRE_AUTHED_BY_FACE = 3,
/**
* Indicates the screen lock is authenticated by credential.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
AUTHED_BY_CREDENTIAL = 4,
/**
* Indicates the screen lock is authenticated by fingerprint.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
AUTHED_BY_FINGERPRINT = 5,
/**
* Indicates the screen lock is authenticated by face.
*
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
AUTHED_BY_FACE = 6,
}
/**
* Indicates the system event type and parameter related to the screenlock management service.
*
* @typedef SystemEvent
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
interface SystemEvent {
/**
* Indicates the system event type related to the screenlock management service.
*
* @type { EventType }
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
eventType: EventType;
/**
* Identifies the customized extended parameter of an event.
*
* @type { string }
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
params: string;
}
/**
* Register system event related to screen lock service.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @param { Callback<SystemEvent> } callback - the callback of onSystemEvent.
* @returns { boolean } returns true if register system event is success, returns false otherwise.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function onSystemEvent(callback: Callback<SystemEvent>): boolean;
/**
* The screen lock app sends the event to the screen lock service.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @param { String } event - event type.
* @param { number } parameter - operation result of the event.
* @param { AsyncCallback<boolean> } callback - the callback of sendScreenLockEvent.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void;
/**
* The screen lock app sends the event to the screen lock service.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @param { String } event - event type.
* @param { number } parameter - operation result of the event.
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 9
*/
function sendScreenLockEvent(event: String, parameter: number): Promise<boolean>;
/**
* Request strong authentication for os account local userId.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK
* @param { StrongAuthReasonFlags } reasonFlag - The strong authentication reason flag.
* @param { number } userId - Os account local userId.
* @returns { Promise<void> } the promise returned by the function.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function requestStrongAuth(reasonFlag: StrongAuthReasonFlags, userId: number): Promise<void>;
/**
* Obtain strong authentication reason flags for os account local userId.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK
* @param { number } userId - Os account local userId.
* @returns { number } the strong authentication reason flags.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed. A non-system application calls a system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function getStrongAuth(userId: number): number;
/**
* Disable screen lock showing for os account local userId. This only becomes effective when there is no password.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK
* @param { boolean } disable - disable or enable screen lock showing.
* @param { number } userId - Os account local userId.
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function setScreenLockDisabled(disable: boolean, userId: number): Promise<boolean>;
/**
* Check whether screen lock is disabled for os account local userId.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK
* @param { number } userId - Os account local userId.
* @returns { boolean } whether screen lock is disabled.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function isScreenLockDisabled(userId: number): boolean;
/**
* Set the screen lock authentication state for os account local userId.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK_INNER
* @param { AuthState } state - the screen lock authentication state.
* @param { number } userId - Os account local userId.
* @param { Uint8Array } authToken - the authentication token for this state
* @returns { Promise<boolean> } the promise returned by the function.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function setScreenLockAuthState(state: AuthState, userId: number, authToken: Uint8Array): Promise<boolean>;
/**
* Obtain the screen lock authentication state for os account local userId.
*
* @permission ohos.permission.ACCESS_SCREEN_LOCK
* @param { number } userId - Os account local userId.
* @returns { AuthState } the screen lock authentication state.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* <br>2. Incorrect parameter types.
* @throws { BusinessError } 201 - permission denied.
* @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - the screenlock management service is abnormal.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 12
*/
function getScreenLockAuthState(userId: number): AuthState;
/**
* Check whether the device is currently locked and the screenlock requires an identity to authenticate and unlock.
*
* @param { number } userId - Os account local userId.
* @returns { boolean } Whether the device is currently locked.
* @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
* @throws { BusinessError } 13200002 - The screenlock management service is abnormal.
* @throws { BusinessError } 13200004 - The userId is not same as the caller, and is not allowed for the caller.
* @syscap SystemCapability.MiscServices.ScreenLock
* @systemapi Hide this for inner system use.
* @since 20
*/
function isDeviceLocked(userId: number): boolean;
}
export default screenLock;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/interface_sdk-js.git
git@gitee.com:openharmony/interface_sdk-js.git
openharmony
interface_sdk-js
interface_sdk-js
master

搜索帮助