未验证 提交 813eb2c7 编写于 作者: O openharmony_ci 提交者: Gitee

!12414 翻译已完成10721+10905+10600+10959+11131+11857+11274+11608

Merge pull request !12414 from shawn_he/10785-a
......@@ -664,6 +664,8 @@ Ends a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -689,6 +691,8 @@ Ends a call based on the specified call ID. This API uses an asynchronous callba
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -715,6 +719,8 @@ Ends a call based on the specified call ID. This API uses a promise to return th
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -748,6 +754,8 @@ Rejects a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -773,6 +781,8 @@ Rejects a call based on the specified options. This API uses an asynchronous cal
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -802,6 +812,8 @@ Rejects a call based on the specified call ID. This API uses an asynchronous cal
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -828,6 +840,8 @@ Rejects a call based on the specified call ID and options. This API uses an asyn
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -858,6 +872,8 @@ Rejects a call based on the specified call ID and options. This API uses a promi
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -895,6 +911,8 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -921,6 +939,8 @@ Holds a call based on the specified call ID. This API uses a promise to return t
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -954,6 +974,8 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -980,6 +1002,8 @@ Unholds a call based on the specified call ID. This API uses a promise to return
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1013,6 +1037,8 @@ Switches a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1039,6 +1065,8 @@ Switches a call. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1308,6 +1336,8 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1334,6 +1364,8 @@ Obtains the call waiting status. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1367,6 +1399,8 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1394,6 +1428,8 @@ Sets the call waiting switch. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1604,6 +1640,8 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1629,6 +1667,8 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1654,6 +1694,8 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1679,6 +1721,8 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1704,6 +1748,8 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1729,6 +1775,8 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1754,6 +1802,8 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1779,6 +1829,8 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1915,6 +1967,8 @@ Obtains the call restriction status. This API uses an asynchronous callback to r
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1942,6 +1996,8 @@ Obtains the call restriction status. This API uses a promise to return the resul
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -1976,6 +2032,8 @@ Sets the call restriction status. This API uses an asynchronous callback to retu
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2008,6 +2066,8 @@ Sets the call restriction status. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2047,6 +2107,8 @@ Obtains call transfer information. This API uses an asynchronous callback to ret
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2074,6 +2136,8 @@ Obtains call transfer information. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2108,6 +2172,8 @@ Sets call transfer information. This API uses an asynchronous callback to return
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2140,6 +2206,8 @@ Sets call transfer information. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2558,6 +2626,8 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2583,6 +2653,8 @@ Enables the IMS switch. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2616,6 +2688,8 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......@@ -2641,6 +2715,8 @@ Disables the IMS switch. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
......
......@@ -353,7 +353,7 @@ Disables listening for screen hopping events.
callback: function(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
}
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.off("cooperation", this.callback);
......@@ -366,7 +366,7 @@ try {
callback: function(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
}
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.off("cooperation");
......
......@@ -27,8 +27,104 @@ Provides the constants of all rule types.
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigint | Caution rule, which is programmed to detect whether ability leakage has occurred. |
## hichecker.addCheckRule<sup>9+</sup>
## hichecker.addRule
addCheckRule(rule: bigint): void
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
**System capability**: SystemCapability.HiviewDFX.HiChecker
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigint | Yes | Rule to be added.|
**Example**
```js
try {
// Add a rule.
hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);}
// Add multiple rules.
hichecker.addCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`);
}
```
## hichecker.removeCheckRule<sup>9+</sup>
removeCheckRule(rule: bigint): void
Removes one or more rules. The removed rules will become ineffective.
**System capability**: SystemCapability.HiviewDFX.HiChecker
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigint | Yes | Rule to be removed.|
**Example**
```js
try {
// Remove a rule.
hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);
// Remove multiple rules.
hichecker.removeCheckRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`);
}
```
## hichecker.containsCheckRule<sup>9+</sup>
containsCheckRule(rule: bigint): boolean
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
**System capability**: SystemCapability.HiviewDFX.HiChecker
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigint | Yes | Rule to be checked.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------------------------- |
| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise.|
**Example**
```js
try {
// Add a rule.
hichecker.addCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
// Check whether the added rule exists in the collection of added rules.
hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true;
hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false;
catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`);
}
```
## hichecker.addRule<sup>(deprecated)</sup>
## hichecker.addRule
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.addCheckRule](#hicheckeraddcheckrule9) instead.
addRule(rule: bigint): void
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
......@@ -52,10 +148,12 @@ hichecker.addRule(
hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH);
```
## hichecker.removeRule
## hichecker.removeRule<sup>(deprecated)</sup>
removeRule(rule: bigint): void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.removeCheckRule](#hicheckerremovecheckrule9) instead.
Removes one or more rules. The removed rules will become ineffective.
**System capability**: SystemCapability.HiviewDFX.HiChecker
......@@ -101,10 +199,12 @@ hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
hichecker.getRule(); // return 1n;
```
## hichecker.contains
## hichecker.contains<sup>(deprecated)</sup>
contains(rule: bigint): boolean
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.containsCheckRule](#hicheckercontainscheckrule9) instead.
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
**System capability**: SystemCapability.HiviewDFX.HiChecker
......
......@@ -18,7 +18,7 @@ Enumerates trace flag types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name | Default Value | Description |
| Name | Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default flag. |
| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. |
......@@ -35,7 +35,7 @@ Enumerates trace point types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value | Description |
| Name| Value | Description |
| -------- | -------- | -------- |
| CS | 0 | Client Send (CS) trace point. |
| CR | 1 | Client Receive (CS) trace point. |
......@@ -49,7 +49,7 @@ Enumerates communication modes.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value | Description |
| Name| Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default communication mode. |
| THREAD | 1 | Inter-thread communication. |
......@@ -84,7 +84,7 @@ Starts call chain tracing. This API works in synchronous manner.
| name | string | Yes| Traced service name. |
| flags | number | No| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -126,7 +126,7 @@ Obtains the trace ID. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -187,7 +187,7 @@ Creates a trace span. This API works in synchronous manner.
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -240,7 +240,7 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......@@ -268,7 +268,7 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled
| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. |
| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. |
**Return Value**
**Return value**
| Type | Description |
| -------- | -------- |
......
# Input Consumer
The Input Consumer module implements listening for key events.
The Input Consumer module implements listening for combination key events.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs provided by this module are system APIs.
## Modules to Import
```
```js
import inputConsumer from '@ohos.multimodalInput.inputConsumer';
```
......@@ -21,32 +21,29 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
on(type: "key", keyOptions: KeyOptions, callback: Callback&lt;KeyOptions&gt;): void
Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOptions** will be passed as an input parameter to **callback**.
This is a system API.
Enables listening for combination key events. This API uses an asynchronous callback to return the combination key data when a combination key event that meets the specified condition occurs.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyoptions) | Yes| Key option, which specifies the condition for combination key input.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback used to return the result.<br> When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.|
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. Currently, only **key** is supported. |
| keyOptions | [KeyOptions](#keyoptions) | Yes | Combination key options. |
| callback | Callback&lt;KeyOptions&gt; | Yes | Callback used to return the combination key data when a combination key event that meets the specified condition occurs.|
**Example**
```
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
```js
let leftAltKey = 2045;
let tabKey = 2049;
try {
inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0}, keyOptions => {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
});
} catch (error) {
console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Subscribe failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -55,49 +52,63 @@ try {
off(type: "key", keyOptions: KeyOptions, callback?: Callback&lt;KeyOptions&gt;): void
Stops listening for combination key events.
This is a system API.
Disables listening for combination key events.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyoptions) | Yes| Key options passed to the key input event when listening starts.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.|
| Name | Type | Mandatory | Description |
| ---------- | -------------------------- | ---- | ------------------------------- |
| type | string | Yes | Event type. Currently, only **key** is supported. |
| keyOptions | [KeyOptions](#keyoptions) | Yes | Combination key options. |
| callback | Callback&lt;KeyOptions&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for a single callback function.
let callback = function (keyOptions) {
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption, callback);
console.log(`Unsubscribe success`);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
```js
let leftAltKey = 2045;
let tabKey = 2049;
// Disable listening for all callback functions.
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
console.log(`keyOptions: ${JSON.stringify(keyOptions)}`);
}
let keyOption = {preKeys: [leftAltKey], finalKey: tabKey, isFinalKeyDown: true, finalKeyDownDuration: 0};
try {
inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback);
inputConsumer.on("key", keyOption, callback);
inputConsumer.off("key", keyOption);
console.log(`Unsubscribe success`);
} catch (error) {
console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## keyOptions
## KeyOptions
Defines the key options that are met when a combination key input event occurs.
This is a system API.
Represents combination key options.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| preKeys | Array | Yes| Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys.|
| finalKey | Number | Yes| Final key in the combination key. This parameter cannot be left blank.|
| isFinalKeyDown | boolean | Yes| Whether the final key is pressed or released. By default, the final key is pressed.|
| finalKeyDownDuration | Number | Yes| Duration for pressing the final key. By default, there is no requirement on the duration.|
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| preKeys | Array\<number> | Yes | No| Front key set. The number of front keys ranges from 0 to 4. There is no requirement on the sequence of the keys.|
| finalKey | number | Yes | No| Final key. This parameter is mandatory. A callback function is triggered by the final key.|
| isFinalKeyDown | boolean | Yes | No| Whether the final key is pressed.|
| finalKeyDownDuration | number | Yes | No| Duration within which the final key is pressed. If the value is **0**, the callback function is triggered immediately. If the value is greater than **0** and the value of **isFinalKeyDown** is **true**, the callback function is triggered when the key press duration is longer than the value of this parameter. If the value of **isFinalKeyDown** is **false**, the callback function is triggered when the duration from key press to key release is less than the value of this parameter. |
......@@ -2,11 +2,11 @@
The Key Injection module implements injection of key events.
> **NOTE**<br>
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs provided by this module are system APIs.
## Modules to Import
......@@ -21,9 +21,7 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient';
injectEvent({KeyEvent: KeyEvent}): void
Injects a key event.
This is a system API.
Injects a key event. Currently, key injection is supported only for the **Back** key (key value 2).
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
......@@ -37,37 +35,36 @@ This is a system API.
```js
try {
var keyEvent = {
let backKeyDown = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent });
var keyEvent1 = {
inputEventClient.injectEvent({ KeyEvent: backKeyDown });
let backKeyUp = {
isPressed: false,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
};
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 });
inputEventClient.injectEvent({ KeyEvent: backKeyUp });
} catch (error) {
console.info("injectKeyEvent " + error.code + " " + error.message);
console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## KeyEvent
Defines the information about the key event to inject.
Represents information about the key event to inject.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters**
| Name | Type | Mandatory | Description |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | Yes | Whether the key is pressed. |
| keyCode | number | Yes | Key code. |
| keyDownDuration | number | Yes | Duration within which the key is pressed. |
| isIntercepted | boolean | Yes | Whether the key can be intercepted.|
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| isPressed | boolean | Yes | No| Whether the key is pressed. |
| keyCode | number | Yes | No| Key value. Currently, only the **Back** key is supported.|
| keyDownDuration | number | Yes | No| Duration within which the key is pressed. |
| isIntercepted | boolean | Yes | No| Whether the key can be intercepted. |
# Input Monitor
The Input Monitor module implements listening for global touch events.
The Input Monitor module implements listening for events of input devices (namely, touchscreen and mouse).
> **NOTE**<br>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> **NOTE**
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The initial APIs of this module are supported since API version 7. 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
......@@ -16,80 +17,73 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## Required Permissions
ohos.permission.INPUT_MONITORING
## inputMonitor.on
on(type: "touch", receiver: TouchEventReceiver): void
Enables listening for global touch events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event. |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch event.|
**Example**
**Example**
```js
try {
inputMonitor.on("touch", (data)=> {
console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`);
return false;
});
inputMonitor.on("touch", (touchEvent) => {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on<sup>9+</sup>
on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
Enables listening for global mouse events.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | Yes | Callback used to return the mouse event. |
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | Yes | Callback used to return the mouse event. |
**Example**
```js
try {
inputMonitor.on("mouse", (data)=> {
console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`);
return false;
});
inputMonitor.on("mouse", (mouseEvent) => {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off
off(type: "touch", receiver?: TouchEventReceiver): void
Stops listening for global touch events.
This is a system API.
Disables listening for global touch events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -97,41 +91,48 @@ This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback used to return the touch event. |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **touch**.|
| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application. |
**Example**
**Example**
```js
// Disable listening globally.
// Disable listening for a single callback function.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.off("touch");
inputMonitor.on("touch", callback);
inputMonitor.off("touch", callback);
console.log(`Monitor off success`);
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("touch", this.callback);
} catch (error) {
console.info("onTouchMonitor " + error.code + " " + error.message)
},
```
```js
// Cancel listening for all callback functions.
function callback(touchEvent) {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
};
try {
inputMonitor.off("touch",this.callback);
inputMonitor.on("touch", callback);
inputMonitor.off("touch");
console.log(`Monitor off success`);
} catch (error) {
console.info("offTouchMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
off(type: "mouse", receiver?:Callback\<MouseEvent>):void
## inputMonitor.off<sup>9+</sup>
Stops listening for global mouse events.
off(type: "mouse", receiver?: Callback&lt;MouseEvent&gt;): void
This is a system API.
Stops listening for global mouse events.
**Required permissions**: ohos.permission.INPUT_MONITORING
......@@ -139,43 +140,48 @@ This is a system API.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | No | Callback used to return the mouse event. |
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | Yes | Type of the input device event. The value is **mouse**.|
| receiver | Callback&lt;MouseEvent&gt; | No | Callback for which listening is disabled. If this parameter is not specified, listening will be disabled for all callbacks registered by the current application.|
**Example**
```js
// Disable listening globally.
// Disable listening for a single callback.
function callback(mouseEvent) {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
};
try {
inputMonitor.off("mouse");
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse", callback);
console.log(`Monitor off success`);
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("mouse", this.callback);
} catch (error) {
console.info("onMouseMonitor " + error.code + " " + error.message)
},
```
```js
// Disable listening for all callback functions.
function callback(mouseEvent) {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
};
try {
inputMonitor.off("mouse", this.callback);
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse");
console.log(`Monitor off success`);
} catch (error) {
console.info("offMouseMonitor " + error.code + " " + error.message)
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## TouchEventReceiver
Provides the callback of touch events.
Represents the callback used to return the touch event.
This is a system API.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
......@@ -183,24 +189,26 @@ This is a system API.
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.|
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Touch event.|
**Return value**
| Type | Description |
| ------- | -------------------------------------- |
| Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.|
| Type | Description |
| ------- | ---------------------------------------- |
| Boolean | Result indicating whether the touch event will be dispatched to the window. The value **true** indicates that the touch event will be dispatched to the window, and the value **false** indicates the opposite.|
**Example**
**Example**
```js
try {
inputMonitor.on("touch", (event) => {
// If true is returned, all subsequent events of this operation will be consumed by the listener, instead of being distributed to the window.
return false;
inputMonitor.on("touch", touchEvent => {
if (touchEvent.touches.length == 3) {// Three fingers are pressed.
return true;
} else {
return false;
}
});
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
# Key Event
The Key Event module provides key events reported by an input device.
Represents key events reported by an input device.
> **NOTE**<br>
> **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.
## Modules to Import
```js
import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent';
import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent';
```
## Action
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| CANCEL | number | Yes| No| Cancellation of a key action.|
| DOWN | number | Yes| No| Pressing of a key.|
| UP | number | Yes| No| Release of a key.|
| Name | Value | Description |
| ------ | ------- | -------- |
| CANCEL | 0 | Cancellation of a key action.|
| DOWN | 1 | Pressing of a key.|
| UP | 2 | Release of a key.|
## Key
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| code | KeyCode | Yes| No| Keycode.|
| pressedTime | number | Yes| No| Time when the key is pressed.|
| deviceId | number | Yes| No| Device to which the key belongs.|
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | -------------- |
| code | KeyCode | Yes | No | Keycode. |
| pressedTime | number | Yes | No | Time when the key is pressed.|
| deviceId | number | Yes | No | ID of the device to which the key belongs. |
## KeyEvent
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| action | Action | Yes| No| Key action.|
| key | Key | Yes| No| Key that has changed.|
| unicodeChar | number | Yes| No| Unicode character corresponding to the key.|
| keys | Key[] | Yes| No| List of pressed keys.|
| ctrlKey | boolean | Yes| No| Whether ctrlKey is being pressed.|
| altKey | boolean | Yes| No| Whether altKey is being pressed.|
| shiftKey | boolean | Yes| No| Whether shiftKey is being pressed.|
| logoKey | boolean | Yes| No| Whether logoKey is being pressed.|
| fnKey | boolean | Yes| No| Whether fnKey is being pressed.|
| capsLock | boolean | Yes| No| Whether capsLock is active.|
| numLock | boolean | Yes| No| Whether numLock is active.|
| scrollLock | boolean | Yes| No| Whether scrollLock is active.|
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | ------------------------------ |
| action | Action | Yes | No | Key action. |
| key | Key | Yes | No | Key for which the event is reported. |
| unicodeChar | number | Yes | No | Unicode character corresponding to the key. |
| keys | Key[] | Yes | No | List of pressed keys. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed. |
| altKey | boolean | Yes | No | Whether altKey is being pressed. |
| shiftKey | boolean | Yes | No | Whether shiftKey is being pressed. |
| logoKey | boolean | Yes | No | Whether logoKey is being pressed. |
| fnKey | boolean | Yes | No | Whether fnKey is being pressed. |
| capsLock | boolean | Yes | No | Whether capsLock is active. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active.|
......@@ -2,7 +2,7 @@
Represents mouse events reported by an input device.
> **NOTE**<br>
> **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.
## Modules to Import
......@@ -15,75 +15,75 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| CANCEL | number | Yes| No| Cancellation of a mouse action.|
| MOVE | number | Yes| No| Moving of the mouse pointer.|
| BUTTON_DOWN | number | Yes| No| Pressing of a mouse button.|
| BUTTON_UP | number | Yes| No| Release of a mouse button.|
| AXIS_BEGIN | number | Yes| No| Beginning of the axis event associated with the mouse.|
| AXIS_UPDATE | number | Yes| No| Updating of the axis event associated with the mouse.|
| AXIS_END | number | Yes| No| Ending of the axis event associated with the mouse.|
| Name | Value| Description |
| ----------- | -------- | -------------------- |
| CANCEL | 0 | Cancellation of a mouse action. |
| MOVE | 1 | Moving of the mouse pointer. |
| BUTTON_DOWN | 2 | Pressing of a mouse button. |
| BUTTON_UP | 3 | Release of a mouse button. |
| AXIS_BEGIN | 4 | Beginning of the axis event associated with the mouse.|
| AXIS_UPDATE | 5 | Updating of the axis event associated with the mouse.|
| AXIS_END | 6 | Ending of the axis event associated with the mouse.|
## Button
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| LEFT | number | Yes| No| Left button on the mouse.|
| MIDDLE | number | Yes| No| Middle button on the mouse.|
| RIGHT | number | Yes| No| Right button on the mouse.|
| SIDE | number | Yes| No| Side button on the mouse.|
| EXTRA | number | Yes| No| Extended button on the mouse.|
| FORWARD | number | Yes| No| Forward button on the mouse.|
| BACK | number | Yes| No| Back button on the mouse.|
| TASK | number | Yes| No| Task button on the mouse.|
| Name | Value | Description |
| ------- | ------| ----- |
| LEFT | 0 | Left button on the mouse. |
| MIDDLE | 1 | Middle button on the mouse. |
| RIGHT | 2 | Right button on the mouse. |
| SIDE | 3 | Side button on the mouse.|
| EXTRA | 4 | Extended button on the mouse.|
| FORWARD | 5 | Forward button on the mouse.|
| BACK | 6 | Back button on the mouse.|
| TASK | 7 | Task button on the mouse.|
## Axis
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| SCROLL_VERTICAL | number | Yes| No| Vertical scroll axis.|
| SCROLL_HORIZONTAL | number | Yes| No| Horizontal scroll axis.|
| PINCH | number | Yes| No| Pinch axis.|
| Name | Value | Description |
| ----------------- | ------- | ----- |
| SCROLL_VERTICAL | 0 | Vertical scroll axis.|
| SCROLL_HORIZONTAL | 1 | Horizontal scroll axis.|
| PINCH | 2 | Pinch axis. |
## AxisValue
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| axis | Axis | Yes| No| Axis type.|
| value | number | Yes| No| Axis value.|
| Name | Type | Readable | Writable | Description |
| ----- | ------ | ---- | ---- | ---- |
| axis | Axis | Yes | No | Axis type. |
| value | number | Yes | No | Axis value. |
## MouseEvent
**System capability**: SystemCapability.MultimodalInput.Input.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| action | Action | Yes| No| Mouse event action.|
| screenX | number | Yes| No| X coordinate of the mouse pointer on the screen.|
| screenY | number | Yes| No| Y coordinate of the mouse pointer on the screen.|
| windowX | number | Yes| No| X coordinate of the mouse pointer in the window.|
| windowY | number | Yes| No| Y coordinate of the mouse pointer in the window.|
| rawDeltaX | number | Yes| No| X axis offset relative to the previous reported mouse pointer position. When the mouse pointer is at the edge of the screen, the value may be less than the difference of the X coordinate reported twice.|
| rawDeltaY | number | Yes| No| Y axis offset relative to the previous reported mouse pointer position.|
| button | Button | Yes| No| Button that is currently pressed or released.|
| pressedButtons | Button[] | Yes| No| Button that is being pressed.|
| axes | AxisValue[] | Yes| No| All axis data contained in the event.|
| pressedKeys | KeyCode[] | Yes| No| List of pressed keys.|
| ctrlKey | boolean | Yes| No| Whether ctrlKey is being pressed.|
| altKey | boolean | Yes| No| Whether altKey is being pressed.|
| shiftKey | boolean | Yes| No| Whether shiftKey is being pressed.|
| logoKey | boolean | Yes| No| Whether logoKey is being pressed.|
| fnKey | boolean | Yes| No| Whether fnKey is being pressed.|
| capsLock | boolean | Yes| No| Whether capsLock is active.|
| numLock | boolean | Yes| No| Whether numLock is active.|
| scrollLock | boolean | Yes| No| Whether scrollLock is active.|
| Name | Type | Readable | Writable | Description |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| action | Action | Yes | No | Mouse event action. |
| screenX | number | Yes | No | Horizontal coordinate of the mouse pointer on the screen. |
| screenY | number | Yes | No | Vertical coordinate of the mouse pointer on the screen. |
| windowX | number | Yes | No | Horizontal coordinate of the mouse pointer in the window. |
| windowY | number | Yes | No | Vertical coordinate of the mouse pointer in the window. |
| rawDeltaX | number | Yes | No | Horizontal coordinate offset relative to the previous reported mouse pointer position.|
| rawDeltaY | number | Yes | No | Vertical coordinate offset relative to the previous reported mouse pointer position. |
| button | Button | Yes | No | Mouse button
| pressedButtons | Button[] | Yes | No | Button being pressed. |
| axes | AxisValue[] | Yes | No | All axis data contained in the event. |
| pressedKeys | KeyCode[] | Yes | No | List of pressed keys. |
| ctrlKey | boolean | Yes | No | Whether ctrlKey is being pressed. |
| altKey | boolean | Yes | No | Whether altKey is being pressed. |
| shiftKey | boolean | Yes | No | Whether shiftKey is being pressed. |
| logoKey | boolean | Yes | No | Whether logoKey is being pressed. |
| fnKey | boolean | Yes | No | Whether fnKey is being pressed. |
| capsLock | boolean | Yes | No | Whether capsLock is active. |
| numLock | boolean | Yes | No | Whether numLock is active. |
| scrollLock | boolean | Yes | No | Whether scrollLock is active. |
......@@ -928,7 +928,8 @@ Sends a cell location update request. This API uses an asynchronous callback to
**System API**: This is a system API.
**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
......@@ -953,7 +954,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi
**System API**: This is a system API.
**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
......@@ -980,7 +982,8 @@ Sends a cell location update request for the SIM card in the specified slot.This
**System API**: This is a system API.
**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
......
......@@ -1155,6 +1155,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses an
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
......@@ -1182,6 +1184,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses a p
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
......@@ -2238,7 +2242,6 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as
let diallingNumbersInof = {
alphaTag: "alpha",
number: "138xxxxxxxx",
recordNumber: 123,
pin2: "1234"
};
sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
......@@ -2278,9 +2281,7 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro
```js
let diallingNumbersInof = {
alphaTag: "alpha",
number: "138xxxxxxxx",
recordNumber: 123,
pin2: "1234"
number: "138xxxxxxxx"
};
let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => {
......@@ -2316,9 +2317,7 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
```js
let diallingNumbersInof = {
alphaTag: "alpha",
number: "138xxxxxxxx",
recordNumber: 123,
pin2: "1234"
number: "138xxxxxxxx"
};
sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -2357,9 +2356,7 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
```js
let diallingNumbersInof = {
alphaTag: "alpha",
number: "138xxxxxxxx",
recordNumber: 123,
pin2: "1234"
number: "138xxxxxxxx"
};
let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => {
......@@ -2395,9 +2392,7 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an
```js
let diallingNumbersInof = {
alphaTag: "alpha",
number: "138xxxxxxxx",
recordNumber: 123,
pin2: "1234"
number: "138xxxxxxxx"
};
sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......
......@@ -18,8 +18,6 @@ getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
Obtains the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Parameters**
......@@ -42,8 +40,6 @@ getDefaultCellularDataSlotId(): Promise\<number\>
Obtains the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
......@@ -63,14 +59,12 @@ promise.then((data) => {
});
```
## data.getDefaultCellularDataSlotIdSync
## data.getDefaultCellularDataSlotIdSync<sup>9+</sup>
getDefaultCellularDataSlotIdSync(): number
Obtains the default SIM card used for mobile data synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
......@@ -85,7 +79,6 @@ Obtains the default SIM card used for mobile data synchronously.
console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
```
## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void
......@@ -102,8 +95,8 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
......@@ -129,13 +122,13 @@ This is a system API.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
**Return value**
| Type | Description |
| -------------- | ------------------------------- |
| Promise<\void\> | Promise used to return the result. |
| Type | Description |
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
......@@ -199,7 +192,7 @@ promise.then((data) => {
getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
Obtains the connection status of the PS domain. This API uses an asynchronous callback to return the result.
Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CellularData
......@@ -256,7 +249,7 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>- **true**: The cellular data service is enabled.<br>- **false**: The cellular data service is disabled.|
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -280,7 +273,7 @@ Checks whether the cellular data service is enabled. This API uses a promise to
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The cellular data service is enabled.<br>- **false**: The cellular data service is disabled.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Example**
......@@ -297,7 +290,7 @@ promise.then((data) => {
isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void
Checks whether the cellular data roaming service is enabled. This API uses an asynchronous callback to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -308,7 +301,7 @@ Checks whether the cellular data roaming service is enabled. This API uses an as
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>- **true**: The cellular data roaming service is enabled. <br>- **false**: The cellular data roaming service is disabled. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -322,7 +315,7 @@ data.isCellularDataRoamingEnabled(0, (err, data) => {
isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
Checks whether the cellular data roaming service is enabled. This API uses a promise to return the result.
Checks whether roaming is enabled for the cellular data service. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
......@@ -338,7 +331,7 @@ Checks whether the cellular data roaming service is enabled. This API uses a pro
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The cellular data roaming service is enabled.<br>- **false**: The cellular data roaming service is disabled.|
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Example**
......@@ -585,7 +578,6 @@ promise.then((data) => {
});
```
## DataFlowType
Defines the cellular data flow type.
......@@ -602,14 +594,14 @@ Defines the cellular data flow type.
## DataConnectState
Describes the connection status of a cellular data connection.
Describes the connection status of a cellular data link.
**System capability**: SystemCapability.Telephony.CellularData
| Name | Value | Description |
| ----------------------- | ---- | -------------------------- |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data connection is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data connection is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data connection is being established.|
| DATA_STATE_CONNECTED | 2 | The cellular data connection is established. |
| DATA_STATE_SUSPENDED | 3 | The cellular data connection is suspended. |
| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. |
| DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. |
| DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.|
| DATA_STATE_CONNECTED | 2 | The cellular data link is connected. |
| DATA_STATE_SUSPENDED | 3 | The cellular data link is suspended. |
......@@ -37,3 +37,4 @@ The table below lists the APIs changes of the power management subsystem in Open
| system.brightness | GetBrightnessOptions | fail?: (data: string, code: number) => void; | Deprecated|
| system.brightness | GetBrightnessOptions | success?: (data: BrightnessResponse) => void; | Deprecated|
| system.brightness | BrightnessResponse | value: number; | Deprecated|
| ohos.batteryInfo | batteryInfo | ohos.batteryinfo -> ohos.batteryInfo | Module name changed |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册