未验证 提交 2c45dba5 编写于 作者: O openharmony_ci 提交者: Gitee

!10116 翻译完成 9054/9843

Merge pull request !10116 from ester.zhou/9054
......@@ -202,7 +202,7 @@ struct DialogTest {
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The **\<List>** component is a scrollable container. By default, it taks up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\<List>** component to take up the remaining height instead of the entire screen height.
The **\<List>** component is a scrollable container. By default, it takes up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\<List>** component to take up the remaining height instead of the entire screen height.
## How do I center child components in a grid container?
......
......@@ -30,7 +30,7 @@ let options = {trim : false, declarationKey:"_declaration",
nameKey : "_name", elementsKey : "_elements"}
let result:any = conv.convert(xml, options) // Convert fields in the XML file into JavaScript objects.
console.log('Test: ' + JSON.stringify(result))
console.log('Test: ' + result._declaration._attributes.version) // vesion field in XML file
console.log('Test: ' + result._declaration._attributes.version) // version field in XML file
console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // title field in XML file
```
......
# System Accessibility Configuration
The **config** module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```typescript
import config from "@ohos.accessibility.config";
```
## Attributes
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| highContrastText | [Config](#config)\<boolean>| Yes| Yes| Whether to enable high-contrast text.|
| invertColor | [Config](#config)\<boolean>| Yes| Yes| Whether to enable color inversion.|
| daltonizationColorFilter | [Config](#config)&lt;[DaltonizationColorFilter](#daltonizationcolorfilter)&gt;| Yes| Yes| Configuration of the daltonization filter.|
| contentTimeout | [Config](#config)\<number>| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
| animationOff | [Config](#config)\<boolean>| Yes| Yes| Whether to enable animation.|
| brightnessDiscount | [Config](#config)\<number>| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
| mouseKey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the mouse button feature.|
| mouseAutoClick | [Config](#config)\<number>| Yes| Yes| Interval for the automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
| shortkey | [Config](#config)\<boolean>| Yes| Yes| Whether to enable the accessibility extension shortcut key.|
| shortkeyTarget | [Config](#config)\<string>| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is bundleName/abilityName.|
| captions | [Config](#config)\<boolean>| Yes| Yes| Whether to enable captions.|
| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](./js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;): Promise&lt;void&gt;;
Enables an accessibility extension ability. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;) | Yes| Capability of the accessibility extension ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.enableAbility("com.ohos.example/axExtension", ['retrieve'])
.then(() => {
console.info('enable succeed');
}).catch((error) => {
console.error('enable failed');
});
```
## enableAbility
enableAbility(name: string, capability: Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt;, callback: AsyncCallback&lt;void&gt;): void;
Enables an accessibility extension ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| capability | Array&lt;[accessibility.Capability](./js-apis-accessibility.md#capability)&gt; | Yes| Capability of the accessibility extension ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.enableAbility("com.ohos.example/axExtension", ['retrieve'], (err, data) => {
if (err) {
console.error('enable failed');
return;
}
console.info('enable succeed');
})
```
## disableAbility
disableAbility(name: string): Promise&lt;void&gt;;
Disables an accessibility extension ability. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.disableAbility("com.ohos.example/axExtension")
.then(() => {
console.info('disable succeed');
}).catch((error) => {
console.error('disable failed');
});
```
## disableAbility
disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void;
Disables an accessibility extension ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.disableAbility("com.ohos.example/axExtension", (err, data) => {
if (err) {
console.error('disable failed');
return;
}
console.info('disable succeed');
})
```
## on('enableAbilityListsStateChanged')
on(type: 'enableAbilityListsStateChanged', callback: Callback&lt;void&gt;): void;
Adds a listener for changes in the list of enabled accessibility extension abilities.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
```typescript
config.on('enableAbilityListsStateChanged',() => {
console.info('ax extension ability enable list changed');
});
```
## off('enableAbilityListsStateChanged')
off(type: 'enableAbilityListsStateChanged', callback?: Callback&lt;void&gt;): void;
Cancels the listener for changes in the list of enabled accessibility extension abilities.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating that the changes in the list of enabled accessibility extension abilities.|
| callback | Callback&lt;void&gt; | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
```typescript
config.off('enableAbilityListsStateChanged');
```
## Config
Implements configuration, acquisition, and listening for attributes.
### set
set(value: T): Promise&lt;void&gt;;
Sets this attribute. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Attribute value to set.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```typescript
config.highContrastText.set(true)
.then(() => {
console.info('highContrastText set succeed');
}).catch((error) => {
console.error('highContrastText set failed');
});
```
### set
set(value: T, callback: AsyncCallback&lt;void&gt;): void;
Sets this attribute. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Attribute value to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
**Example**
```typescript
config.highContrastText.set(true, (err, data) => {
if (err) {
console.error('highContrastText set failed');
return;
}
console.info('highContrastText set succeed');
})
```
### get
get(): Promise&lt;T&gt;;
Obtains the value of this attribute. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;T&gt; | Promise used to return the attribute value.|
**Example**
```typescript
config.highContrastText.get()
.then((value) => {
console.info('highContrastText get succeed');
}).catch((error) => {
console.error('highContrastText get failed');
});
```
### get
get(callback: AsyncCallback&lt;T&gt;): void;
Obtains the value of this attribute. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the attribute value.|
**Example**
```typescript
config.highContrastText.get((err, data) => {
if (err) {
console.error('highContrastText get failed');
return;
}
console.info('highContrastText get succeed');
})
```
### on
on(callback: Callback&lt;T&gt;): void;
Adds a listener for attribute changes.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | Yes| Callback invoked when the attribute changes.|
**Example**
```typescript
config.highContrastText.on(() => {
console.info('highContrastText changed');
});
```
### off
off(callback?: Callback&lt;T&gt;): void;
Cancels the listener for attribute changes.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback&lt;T&gt; | No| Callback invoked when the attribute changes.|
**Example**
```typescript
config.highContrastText.off();
```
## DaltonizationColorFilter
Enumerates the daltonization filters.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
| Name| Description|
| -------- | -------- |
| Normal | Filter for normal users.|
| Protanomaly | Filter for protanomaly.|
| Deuteranomaly | Filter for deuteranomaly.|
| Tritanomaly | Filter for tritanomaly.|
......@@ -47,7 +47,7 @@ Obtains an **[InputMethodController](#inputmethodcontroller)** instance.
| Type | Description |
| ----------------------------------------------- | ------------------------ |
| [InputMethodController](#inputmethodcontroller) | Returns the current **InputMethodController** instance.|
| [InputMethodController](#inputmethodcontroller) | Current **InputMethodController** instance.|
**Example**
......@@ -67,7 +67,7 @@ Obtains an **[InputMethodSetting](#inputmethodsetting8)** instance.
| Type | Description |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#inputmethodsetting8) | Returns the current **InputMethodSetting** instance.|
| [InputMethodSetting](#inputmethodsetting8) | Current **InputMethodSetting** instance.|
**Example**
......@@ -94,15 +94,15 @@ Switches to another input method. This API can be used only in the stage model.
**Example**
```js
inputMethod.switchInputMethod({packageName:"com.example.kikakeyboard", methodId:"com.example.kikakeyboard"} ,(err,result) => {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'} ,(err,result) => {
if (err) {
console.error("switchInputMethod err: " + JSON.stringify(err));
console.error('switchInputMethod err: ' + JSON.stringify(err));
return;
}
if (result) {
console.info("Success to switchInputMethod.(callback)");
console.info('Success to switchInputMethod.(callback)');
} else {
console.error("Failed to switchInputMethod.(callback)");
console.error('Failed to switchInputMethod.(callback)');
}
});
```
......@@ -129,14 +129,14 @@ Switches to another input method. This API can be used only in the stage model.
```js
inputMethod.switchInputMethod({packageName:"com.example.kikakeyboard", methodId:"com.example.kikakeyboard"}).then((result) => {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}).then((result) => {
if (result) {
console.info("Success to switchInputMethod.(promise)");
console.info('Success to switchInputMethod.(promise)');
} else {
console.error("Failed to switchInputMethod.(promise)");
console.error('Failed to switchInputMethod.(promise)');
}
}).catch((err) => {
console.error("switchInputMethod promise err: " + err);
console.error('switchInputMethod promise err: ' + err);
})
```
## inputMethod.getCurrentInputMethod<sup>9+</sup>
......@@ -151,7 +151,7 @@ Obtains the current input method. This API synchronously returns the **Inputmeth
| Type | Description |
| -------------------------------------------- | ------------------------ |
| [InputmethodProperty](#inputmethodproperty8) | **InputmethodProperty** instance of the current input method. |
| [InputmethodProperty](#inputmethodproperty8) | **InputmethodProperty** instance of the current input method.|
**Example**
......@@ -183,13 +183,13 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
```js
InputMethodController.stopInput((error, result) => {
if (error) {
console.error("failed to stopInput because: " + JSON.stringify(error));
console.error('failed to stopInput because: ' + JSON.stringify(error));
return;
}
if (result) {
console.info("Success to stopInput.(callback)");
console.info('Success to stopInput.(callback)');
} else {
console.error("Failed to stopInput.(callback)");
console.error('Failed to stopInput.(callback)');
}
});
```
......@@ -214,12 +214,12 @@ Hides the keyboard. This API uses a promise to return the result. If any paramet
```js
InputMethodController.stopInput().then((result) => {
if (result) {
console.info("Success to stopInput.(promise)");
console.info('Success to stopInput.(promise)');
} else {
console.error("Failed to stopInput.(promise)");
console.error('Failed to stopInput.(promise)');
}
}).catch((err) => {
console.error("stopInput promise err: " + err);
console.error('stopInput promise err: ' + err);
})
```
......@@ -241,7 +241,7 @@ Shows this soft keyboard. This API uses an asynchronous callback to return the r
```js
InputMethodController.showSoftKeyboard((err) => {
if (err == undefined) {
if (err === undefined) {
console.info('showSoftKeyboard success');
} else {
console.error('showSoftKeyboard failed because : ' + JSON.stringify(err));
......@@ -292,7 +292,7 @@ Hides this soft keyboard. This API uses an asynchronous callback to return the r
```js
InputMethodController.hideSoftKeyboard((err) => {
if (err == undefined) {
if (err === undefined) {
console.info('hideSoftKeyboard success');
} else {
console.error('hideSoftKeyboard failed because : ' + JSON.stringify(err));
......@@ -342,19 +342,17 @@ Obtains a list of activated or deactivated input methods. This API uses an async
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ----------------------------- |
| enable | boolean | Yes | Whether to return a list of activated input methods. The value **true** means to return a list of activated input methods, and **false** means to return a list of deactivated input methods. |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | Yes | Callback used to return a list of activated or deactivated input methods. |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | Yes | Callback used to return a list of activated or deactivated input methods.|
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod(true, (err,data) => {
if (err) {
console.error("listInputMethod failed because: " + JSON.stringify(err));
console.error('listInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.log("listInputMethod success");
this.imeList = data;
console.log('listInputMethod success');
});
```
......@@ -376,17 +374,15 @@ Obtains a list of activated or deactivated input methods. This API uses a promis
| Type | Description |
| ------------------------------------------------------------ | ----------------------------- |
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of activated or deactivated input methods. |
| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | Promise used to return a list of activated or deactivated input methods.|
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod(true).then((data) => {
console.info("listInputMethod success");
this.imeList = data;
console.info('listInputMethod success');
}).catch((err) => {
console.error("listInputMethod promise err: " + err);
console.error('listInputMethod promise err: ' + err);
})
```
......@@ -407,14 +403,12 @@ Obtains a list of installed input methods. This API uses an asynchronous callbac
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod((err,data) => {
if (err) {
console.error("listInputMethod failed because: " + JSON.stringify(err));
console.error('listInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.log("listInputMethod success");
this.imeList = data;
console.log('listInputMethod success');
});
```
......@@ -435,12 +429,10 @@ Obtains a list of installed input methods. This API uses a promise to return the
**Example**
```js
imeList: Array<inputMethod.InputMethodProperty> = null
InputMethodSetting.listInputMethod().then((data) => {
console.info("listInputMethod success");
this.imeList = data;
console.info('listInputMethod success');
}).catch((err) => {
console.error("listInputMethod promise err: " + err);
console.error('listInputMethod promise err: ' + err);
})
```
......@@ -463,20 +455,20 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
```js
InputMethodSetting.displayOptionalInputMethod((err) => {
if (err) {
console.error("displayOptionalInputMethod failed because: " + JSON.stringify(err));
console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err));
return;
}
console.info("displayOptionalInputMethod success");
console.info('displayOptionalInputMethod success');
});
```
### displayOptionalInputMethod
displayOptionalInputMethod(): Promise&lt;void&gt;
displayOptionalInputMethod(): Promise&lt;void&gt;
Displays a dialog box for selecting an input method. This API uses a promise to return the result. If any parameter is passed in, an exception is thrown.
Displays a dialog box for selecting an input method. This API uses a promise to return the result. If any parameter is passed in, an exception is thrown.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**System capability**: SystemCapability.MiscServices.InputMethodFramework
**Return value**
......@@ -488,8 +480,8 @@ Displays a dialog box for selecting an input method. This API uses a promise to
```js
InputMethodSetting.displayOptionalInputMethod().then(() => {
console.info("displayOptionalInputMethod success.(promise)");
console.info('displayOptionalInputMethod success.(promise)');
}).catch((err) => {
console.error("displayOptionalInputMethod promise err: " + err);
console.error('displayOptionalInputMethod promise err: ' + err);
})
```
......@@ -233,61 +233,46 @@ Locks the screen. This API uses a promise to return the result.
});
```
## EventType
## screenlock.on<sup>9+</sup>
on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback\<void\>): void
Subscribes to screen lock status changes.
Defines the system event type.
**System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.|
| callback | Callback\<void\> | Yes| Callback used to return the result.|
**Example**
```js
screenlock.on('beginWakeUp', () => {
console.log('beginWakeUp triggered');
});
```
## screenlock.on<sup>9+</sup>
on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<number\>): void
Subscribes to screen lock status changes.
| Name| Description|
| -------- | -------- |
| beginWakeUp | Wakeup starts when the event starts.|
| endWakeUp | Wakeup ends when the event ends.|
| beginScreenOn | Screen turn-on starts when the event starts.|
| endScreenOn | Screen turn-on ends when the event ends.|
| beginScreenOff | Screen turn-off starts when the event starts.|
| endScreenOff | Screen turn-off ends when the event ends.|
| unlockScreen | The screen is unlocked.|
| lockScreen | The screen is locked.|
| beginExitAnimation | Animation starts to exit.|
| beginSleep | The screen enters sleep mode.|
| endSleep | The screen exits sleep mode.|
| changeUser | The user is switched.|
| screenlockEnabled | Screen lock is enabled.|
| serviceRestart | The screen lock service is restarted.|
## SystemEvent
Defines the structure of the system event callback.
**System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
| callback | Callback\<number\> | Yes| Callback used to return the result. |
**Example**
| Name| Description|
| -------- | -------- |
| eventType | System event type.|
| params | System event parameters.|
```js
screenlock.on('beginSleep', (why) => {
console.log('beginSleep triggered:' + why);
});
```
## screenlock.on<sup>9+</sup>
## screenlock.onSystemEvent<sup>9+</sup>
on(type: 'screenlockEnabled', callback: Callback\<boolean\>): void
onSystemEvent(callback: Callback\<SystemEvent\>): boolean
Subscribes to screen lock status changes.
Registers a callback for system events related to screen locking.
**System capability**: SystemCapability.MiscServices.ScreenLock
......@@ -297,41 +282,26 @@ Subscribes to screen lock status changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"screenlockEnabled"**: Screen lock is enabled.|
| callback | Callback\<boolean\> | Yes| Callback used to return the result. |
**Example**
```js
screenlock.on('screenlockEnabled', (isEnabled) => {
console.log('screenlockEnabled triggered, result:' + isEnabled);
});
```
## screenlock.off<sup>9+</sup>
| callback | Callback\<SystemEvent\> | Yes| Callback for system events related to screen locking|
off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff'
| 'unlockScreen' | 'beginExitAnimation' | 'screenlockEnabled' | 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<void\>): void
Unsubscribes from screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
**Return value**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.<br>- **"screenlockEnabled"**: Screen lock is enabled.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
| callback | Callback\<void\> | Yes| Callback used to return the result.|
| Type | Description |
| ------- | -------------------------------------------- |
| boolean | The value **true** means that the callback is registered successfully, and **false** means the opposite.|
**Example**
```js
screenlock.off('beginWakeUp', () => {
console.log("callback");
});
let isSuccess = screenlock.onSystemEvent((err, event)=>{
console.log(`onSystemEvent:callback:${event.eventType}`)
if (err) {
console.log(`onSystemEvent callback error -> ${JSON.stringify(err)}`);
}
});
if (!isSuccess) {
console.log(`onSystemEvent result is false`)
}
```
## screenlock.sendScreenLockEvent<sup>9+</sup>
......@@ -375,7 +345,7 @@ Sends an event to the screen lock service. This API uses a promise to return the
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock fails.<br>- **2**: The unlock is canceled.|
**Return value**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册