1e41f4b71Sopenharmony_ci# Theme Framework Subsystem – Screenlock Management Service Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## cl.screenlock.1 Permission Change of isLocked and unlock 5e41f4b71Sopenharmony_ciChanged the **isLocked** and **unlock** APIs to system APIs since API version 9. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciYou need to adapt your application based on the following information. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Change Impact** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci- Involved APIs: 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```js 16e41f4b71Sopenharmony_ci function isLocked(): boolean; 17e41f4b71Sopenharmony_ci function unlock(callback: AsyncCallback<boolean>): void; 18e41f4b71Sopenharmony_ci function unlock():Promise<boolean>; 19e41f4b71Sopenharmony_ci``` 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci- Before change: 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci```js 24e41f4b71Sopenharmony_ci * Checks whether the screen is currently locked. 25e41f4b71Sopenharmony_ci * 26e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. 27e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 28e41f4b71Sopenharmony_ci * @since 9 29e41f4b71Sopenharmony_ci */ 30e41f4b71Sopenharmony_ci function isLocked(): boolean; 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci /** 33e41f4b71Sopenharmony_ci * Unlock the screen. 34e41f4b71Sopenharmony_ci * 35e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 36e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 37e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 38e41f4b71Sopenharmony_ci * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 39e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 40e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 41e41f4b71Sopenharmony_ci * @since 9 42e41f4b71Sopenharmony_ci */ 43e41f4b71Sopenharmony_ci function unlock(callback: AsyncCallback<boolean>): void; 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci /** 46e41f4b71Sopenharmony_ci * Unlock the screen. 47e41f4b71Sopenharmony_ci * 48e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 49e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 50e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 51e41f4b71Sopenharmony_ci * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 52e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 53e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 54e41f4b71Sopenharmony_ci * @since 9 55e41f4b71Sopenharmony_ci */ 56e41f4b71Sopenharmony_ci function unlock():Promise<boolean>; 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci- After change: 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci```js 62e41f4b71Sopenharmony_ci * Checks whether the screen is currently locked. 63e41f4b71Sopenharmony_ci * 64e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. 65e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 66e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 67e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 68e41f4b71Sopenharmony_ci * @since 9 69e41f4b71Sopenharmony_ci */ 70e41f4b71Sopenharmony_ci function isLocked(): boolean; 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci /** 73e41f4b71Sopenharmony_ci * Unlock the screen. 74e41f4b71Sopenharmony_ci * 75e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 76e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 77e41f4b71Sopenharmony_ci * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 78e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 79e41f4b71Sopenharmony_ci * @since 9 80e41f4b71Sopenharmony_ci */ 81e41f4b71Sopenharmony_ci function unlock(callback: AsyncCallback<boolean>): void; 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci /** 84e41f4b71Sopenharmony_ci * Unlock the screen. 85e41f4b71Sopenharmony_ci * 86e41f4b71Sopenharmony_ci * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. 87e41f4b71Sopenharmony_ci * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. 88e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.ScreenLock 89e41f4b71Sopenharmony_ci * @since 9 90e41f4b71Sopenharmony_ci */ 91e41f4b71Sopenharmony_ci function unlock():Promise<boolean>; 92e41f4b71Sopenharmony_ci``` 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**Adaptation Guide** 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ciMake sure the APIs are only invoked by system applications. 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ciThe code snippet is as follows: 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci```js 102e41f4b71Sopenharmony_ci try { 103e41f4b71Sopenharmony_ci let ret = screenLock.isLocked(); 104e41f4b71Sopenharmony_ci console.error(`Obtain whether the screen is locked successfully , ret is: ${ret}`); 105e41f4b71Sopenharmony_ci } catch (error) { 106e41f4b71Sopenharmony_ci console.error(`Failed to obtain whether the screen is locked, error is : ${error.code}, ${error.message}`); 107e41f4b71Sopenharmony_ci } 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci```js 111e41f4b71Sopenharmony_ci screenlock.unlock((err, data) => { 112e41f4b71Sopenharmony_ci if (err) { 113e41f4b71Sopenharmony_ci console.error(`Failed to unlock the screen, because: ${err.message}`); 114e41f4b71Sopenharmony_ci return; 115e41f4b71Sopenharmony_ci } 116e41f4b71Sopenharmony_ci console.info(`unlock the screen successfully. result: ${data}`); 117e41f4b71Sopenharmony_ci }); 118e41f4b71Sopenharmony_ci``` 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci```js 121e41f4b71Sopenharmony_ci screenlock.unlock().then((data) => { 122e41f4b71Sopenharmony_ci console.info(`unlock the screen successfully. result: ${data}`); 123e41f4b71Sopenharmony_ci }).catch((err) => { 124e41f4b71Sopenharmony_ci console.error(`Failed to unlock the screen, because: ${err.message}`); 125e41f4b71Sopenharmony_ci }); 126e41f4b71Sopenharmony_ci``` 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci## cl.screenlock.2 Deprecation of isSecure 130e41f4b71Sopenharmony_ciDeprecated the **isSecure** API since API version 9. 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ciYou need to adapt your application based on the following information. 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci**Change Impact** 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ciThe API can no longer be used after being deleted. 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci- Involved APIs: 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci```js 141e41f4b71Sopenharmony_ci function isSecure(): boolean; 142e41f4b71Sopenharmony_ci``` 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci- Before change: 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci```js 147e41f4b71Sopenharmony_ci function isSecure(): boolean; 148e41f4b71Sopenharmony_ci``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci- After change: 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci The API is deleted. 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci**Adaptation Guide** 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ciUpdate the code so that the deprecated API is not used. 158