diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index 634231b14e689d9a2dbdb5e8cc74b3f0117889b8..62bfa800173c03c08c1402d79a9174b3778375ca 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -291,6 +291,63 @@ try { } ``` +## display.on('privateModeChange')10+ + +on(type: 'privateModeChange', callback: Callback<boolean>): void + +Subscribes to privacy mode changes of this display. When there is a privacy window in the foreground of the display, the display is in privacy mode, and the content in the privacy window cannot be captured or recorded. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at 'privateModeChange', indicating the event of display privacy mode changes.| +| callback | Callback<boolean> | Yes | Callback used to return whether the privacy mode of the display is changed. The value **true** means that the display changes to the privacy mode, and **false** means the opposite.| + +**Example** + +```js +let callback = (data) => { + console.info('Listening enabled. Data: ' + JSON.stringify(data)); +}; +try { + display.on("privateModeChange", callback); +} catch (exception) { + console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); +} +``` + +## display.off('privateModeChange')10+ + +off(type: 'privateModeChange', callback?: Callback<boolean>): void + +Unsubscribes from privacy mode changes of this display. When there is a privacy window in the foreground of the display, the display is in privacy mode, and the content in the privacy window cannot be captured or recorded. + +**System API**: This is a system API. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'privateModeChange'**, indicating the event of display private mode changes.| +| callback | Callback<boolean> | No | Callback used to return whether the privacy mode of the display is changed. The value **true** means that the display changes to the privacy mode, and **false** means the opposite.| + +**Example** + +```js +try { + display.off("privateModeChange"); +} catch (exception) { + console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); +} +``` + ## display.getDefaultDisplay(deprecated) getDefaultDisplay(callback: AsyncCallback<Display>): void