提交 6a9b5514 编写于 作者: S sienna1128 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into docs/0929

Signed-off-by: Nsienna1128 <lixiaoyan45@huawei.com>
......@@ -151,9 +151,9 @@ zh-cn/application-dev/work-scheduler/ @HelloCrease
zh-cn/application-dev/internationalization/ @HelloCrease
zh-cn/application-dev/device/usb-overview.md @ge-yafang
zh-cn/application-dev/device/usb-guidelines.md @ge-yafang
zh-cn/application-dev/device/device-location-overview.md @sun-yue14
zh-cn/application-dev/device/device-location-info.md @sun-yue14
zh-cn/application-dev/device/device-location-geocoding.md @sun-yue14
zh-cn/application-dev/device/device-location-overview.md @zengyawen
zh-cn/application-dev/device/device-location-info.md @zengyawen
zh-cn/application-dev/device/device-location-geocoding.md @zengyawen
zh-cn/application-dev/device/sensor-overview.md @HelloCrease
zh-cn/application-dev/device/sensor-guidelines.md @HelloCrease
zh-cn/application-dev/device/vibrator-overview.md @HelloCrease
......@@ -277,14 +277,14 @@ zh-cn/application-dev/reference/apis/js-apis-http.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-request.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-socket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-tagSession.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-nfcTech.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-tagSession.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-rpc.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-wifi.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-wifi.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-accessibility.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @zengyawen
......@@ -293,18 +293,18 @@ zh-cn/application-dev/reference/apis/js-apis-hidebug.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hilog.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-system-time.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @bmeangel
zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-time.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-timer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-battery-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-brightness.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-device-info.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
zh-cn/application-dev/reference/apis/js-apis-geolocation.md @sun-yue14
zh-cn/application-dev/reference/apis/js-apis-geolocation.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @HelloCrease
......
......@@ -50,18 +50,41 @@ The following uses a single KV store as an example to describe the development p
This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
```js
// FA model
import featureAbility from '@ohos.ability.featureAbility';
function grantPermission() {
console.info('grantPermission');
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
console.info('end grantPermission');
console.info('grantPermission');
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => {
console.info('success: ${data}');
}).catch((error) => {
console.info('failed: ${error}');
})
}
grantPermission();
// Stage model
import Ability from '@ohos.application.Ability';
let context = null;
function grantPermission() {
class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
let context = this.context;
}
}
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success: ${data}');
}).catch((error) => {
console.log('failed: ${error}');
});
}
grantPermission();
```
......@@ -73,25 +96,39 @@ The following uses a single KV store as an example to describe the development p
The sample code is as follows:
```js
// Obtain the context of the FA model.
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
// Obtain the context of the stage model.
import AbilityStage from '@ohos.application.Ability';
let context = null;
class MainAbility extends AbilityStage{
onWindowStageCreate(windowStage){
context = this.context;
}
}
let kvManager;
try {
const kvManagerConfig = {
bundleName: 'com.example.datamanagertest',
userInfo: {
context:context,
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("createKVManager err: " + JSON.stringify(err));
console.log('Failed to create KVManager: ${error}');
return;
}
console.log("createKVManager success");
console.log('Created KVManager successfully');
kvManager = manager;
});
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
console.log('An unexpected error occurred. Error: ${e}');
}
```
......@@ -115,14 +152,14 @@ The following uses a single KV store as an example to describe the development p
};
kvManager.getKVStore('storeId', options, function (err, store) {
if (err) {
console.log("getKVStore err: " + JSON.stringify(err));
console.log('Failed to get KVStore: ${err}');
return;
}
console.log("getKVStore success");
console.log('Got KVStore successfully');
kvStore = store;
});
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
console.log('An unexpected error occurred. Error: ${e}');
}
```
......@@ -136,7 +173,7 @@ The following uses a single KV store as an example to describe the development p
```js
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.log("dataChange callback call data: " + JSON.stringify(data));
console.log("dataChange callback call data: ${data}");
});
```
......@@ -153,13 +190,13 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
console.log('Failed to put data: ${error}');
return;
}
console.log("put success");
console.log('Put data successfully');
});
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
console.log('An unexpected error occurred. Error: ${e}');
}
```
......@@ -176,16 +213,16 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
console.log('Failed to put data: ${error}');
return;
}
console.log("put success");
console.log('Put data successfully');
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
console.log("get success data: " + data);
console.log('Got data successfully: ${data}');
});
});
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
console.log('An unexpected error occurred. Error: ${e}');
}
```
......@@ -204,7 +241,7 @@ The following uses a single KV store as an example to describe the development p
let devManager;
// Create deviceManager.
deviceManager.createDeviceManager("bundleName", (err, value) => {
deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) {
devManager = value;
// deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync().
......@@ -219,7 +256,7 @@ The following uses a single KV store as an example to describe the development p
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000);
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
console.log('An unexpected error occurred. Error: ${e}');
}
}
});
......
......@@ -2,8 +2,6 @@
The **Vibrator** module provides APIs for triggering or stopping vibration.
Misc devices, including vibrators and LED lights, are used to send signals externally. You can call the APIs of this module to control the vibration of vibrators and turning-on/off of LED lights.
> **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.
......@@ -19,25 +17,26 @@ import vibrator from '@ohos.vibrator';
vibrate(duration: number): Promise&lt;void&gt;
Triggers vibration with a specific duration. This API uses a promise to return the execution result.
Triggers vibration with the specified duration. This API uses a promise to return the result.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------ |
| duration | number | Yes | Vibration duration.|
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- |
| duration | number | Yes | Vibration duration, in ms.|
**Return value**
| Type | Description |
| ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.|
| Type | Description |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
......@@ -46,28 +45,67 @@ Triggers vibration with a specific duration. This API uses a promise to return t
});
```
## vibrator.vibrate<sup>9+</sup>
vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise&lt;void&gt;
Triggers vibration with the specified effect and attribute. This API uses a promise to return the result.
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | -------------------------------------- | ---- | :------------- |
| effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect.|
| attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute.|
**Return value**
| Type | Description |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
vibrator.vibrate({
type: 'time',
duration: 1000
}, {
id: 0,
usage: 'alarm'
}).then(()=>{
console.log("Promise returned to indicate a successful vibration");
}).catch((error)=>{
console.log("error.code" + error.code + "error.message" + error.message);
})
```
## vibrator.vibrate
vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
Triggers vibration with a specific duration. This API uses an asynchronous callback to return the execution result.
Triggers vibration with the specified duration. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- |
| duration | number | Yes | Vibration duration. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| duration | number | Yes | Vibration duration, in ms. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
vibrator.vibrate(1000,function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
console.log("error.code" + error.code + "error.message" + error.message);
}else{
console.log("Callback returned to indicate a successful vibration.");
}
......@@ -79,28 +117,28 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb
vibrate(effectId: EffectId): Promise&lt;void&gt;
Triggers vibration with a specific effect. This API uses a promise to return the execution result.
Triggers vibration with the specified effect. This API uses a promise to return the result.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | ------------- |
| effectId | [EffectId](#effectid) | Yes | Vibration effect. |
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------ |
| effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID.|
**Return value**
| Type | Description |
| ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.|
| Type | Description |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message);
console.log("error.code" + error.code + "error.message" + error.message);
});
```
......@@ -109,56 +147,94 @@ Triggers vibration with a specific effect. This API uses a promise to return the
vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
Triggers vibration with a specific effect. This API uses an asynchronous callback to return the execution result.
Triggers vibration with the specified effect. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- |
| effectId | [EffectId](#effectid) | Yes | Vibration effect. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------------------------------------- |
| effectId | [EffectId](#effectid) | Yes | Preset vibration effect ID. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
console.log("error.code" + error.code + "error.message" + error.message);
}else{
console.log("Callback returned to indicate a successful vibration.");
}
})
```
## vibrator.vibrate<sup>9+</sup>
vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback&lt;void&gt;): void
Triggers vibration with the specified effect and attribute. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- |
| effect | [VibrateEffect](#vibrateeffect9) | Yes | Vibration effect. |
| attribute | [VibrateAttribute](#vibrateattribute9) | Yes | Vibration attribute. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to the result. If the vibration starts, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
vibrator.vibrate({
type:'time',
duration:1000,
},{
id:0,
usage: 'alarm'
}, (error)=>{
if(error){
console.log("vibrate fail, error.code:" + error.code + ",error.message:" + error.message);
}else{
console.log("Callback returned to indicate a successful vibration.");
}
});
```
## vibrator.stop
stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
Stops the vibration based on the specified **stopMode**. This API uses a promise to return the execution result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called.
Stops the vibration with the specified **stopMode**. This API uses a promise to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | --------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration.|
**Return value**
| Type | Description |
| ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully.|
| Type | Description |
| ------------------- | -------------------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message);
console.log("error.code" + error.code + "error.message" + error.message);
});
```
......@@ -167,23 +243,24 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise
stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
Stops the vibration based on the specified **stopMode**. This API uses an asynchronous callback to return the execution result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called.
Stops the vibration with the specified **stopMode**. This API uses an asynchronous callback to return the result. If the specified **stopMode** is different from the mode used to trigger the vibration, this API fails to be called.
**Required permissions**: ohos.permission.VIBRATE (a system permission)
**Required permissions**: ohos.permission.VIBRATE
**System capability**: SystemCapability.Sensors.MiscDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | ----------------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Mode to stop the vibration. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to the result. If the vibration stops, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
console.log("error.code" + error.code + "error.message" + error.message);
}else{
console.log("Callback returned to indicate a successful stop.");
}
......@@ -193,22 +270,85 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch
## EffectId
Describes the vibration effect.
Describes the vibration effect ID.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description |
| ------------------ | -------------------- | --------------- |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.|
| Name | Default Value | Description |
| ------------------ | -------------------- | ------------------ |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Preset vibration effect ID.|
## VibratorStopMode
Describes the vibration mode to stop.
Enumerates the modes available to stop the vibration.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description |
| ------------------------- | -------- | ---------------------------------------- |
| Name | Default Value | Description |
| ------------------------- | -------- | ------------------------------------------------------------ |
| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.|
| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.|
## VibrateEffect<sup>9+</sup>
Describes the vibration effect.
**System capability**: SystemCapability.Sensors.MiscDevice
| Type | Description |
| -------------------------------- | ------------------------------ |
| [VibrateTime](#vibratetime9) | Triggers vibration with the specified duration. This API uses a promise to return the result.|
| [VibratePreset](#vibratepreset9) | Vibration with a preset effect.|
## VibrateTime<sup>9+</sup>
Describes the vibration with the specified duration.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value| Description |
| -------- | ------ | ------------------------------ |
| type | "time" | Vibration with the specified duration.|
| duration | - | Vibration duration, in ms. |
## VibratePreset<sup>9+</sup>
Describes the vibration with a preset effect.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description |
| -------- | -------- | ------------------------------ |
| type | "preset" | Vibration with the specified effect.|
| effectId | - | Preset vibration effect ID. |
| count | - | Number of vibrations to repeat. |
## VibrateAttribute<sup>9+</sup>
Describes the vibration attribute.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value| Description |
| ----- | ------ | -------------- |
| id | 0 | Vibrator ID. |
| usage | - | Vibration scenario.|
## Usage<sup>9+</sup>
Enumerates the vibration scenarios.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Description |
| ---------------- | ------ | ------------------------------ |
| unknown | string | Unknown scenario, with the lowest priority.|
| alarm | string | Vibration for alarms. |
| ring | string | Vibration for incoming calls. |
| notification | string | Vibration for notifications. |
| communication | string | Vibration for communication. |
| touch | string | Touch vibration scenario. |
| media | string | Multimedia vibration scenario. |
| physicalFeedback | string | Physical feedback vibration scenario. |
| simulateReality | string | Simulated reality vibration scenario. |
# OpenHarmony Version Definitions
## Branches
To ensure smooth version evolution and continuous stability and reliability of historical versions, the OpenHarmony community periodically pulls branches such as Long Term Support (LTS), Release, and Beta from Master and manages them based on the OpenHarmony lifecycle definition.
![1.png](figures/1.png)
### Master
Master is the main branch in the OpenHarmony community, to which code updates of all software packages' Master branches in the community are proactively merged for real-time build.
### LTS
LTS is a branch pulled from Master in the OpenHarmony community in the third quarter of each year. This branch is compiled, built, and tested in a centralized manner, and finally reviewed and released by the community.
### Release
Release is a branch pulled from Master in the OpenHarmony community in the first quarter of each year. This branch is compiled, built, and tested in a centralized manner, and finally reviewed and released by the community. A Release branch has the same release requirements but a shorter maintenance period when compared with an LTS branch.
### Beta
Beta is a branch pulled from Master in the OpenHarmony community irregularly. This branch has centralized compilation, building, and basic function verification finished, and can be used for development and debugging.
### Tag
A tag version is a stable and reliable version created by applying patches to an LTS or a Release branch, with the purpose of fixing individual bugs, security vulnerabilities, and other necessary adaptation modifications.
## Maintenance Policies
### Lifecycle Policies
OpenHarmony provides lifecycle management services for LTS and Release branches as follows:
#### Release -> Stop proactive maintenance
The Release SIG periodically makes and maintains tag version plans to resolve individual bugs, security vulnerabilities, and other major issues to ensure continuously stable and available branches.
#### Stop proactive maintenance -> Stop maintenance
The Release SIG no longer proactively plans and releases tag versions. It only fixes security vulnerabilities and major defects in corresponding branches.
### LTS and Release Maintenance Policies
For an LTS branch, the OpenHarmony community provides 2-year proactive maintenance and 1.5-year passive maintenance since its release.
For a Release branch, the OpenHarmony community provides 1-year proactive maintenance and 1-year passive maintenance since its release.
### Branch Merge Policies
The Release SIG is responsible for lifecycle management of an LTS or a Release branch. During the maintenance period, the SIG accepts only code updates that resolve security vulnerabilities, ACTS issues, and other major issues. All code updates can be merged into the branch only after the related pull request has been approved by the [owner](https://gitee.com/openharmony/community/blob/master/zh/BRANCHOWNER).
### Maintenance Schedule
The following table lists the maintenance schedule of the LTS and Release branches that have been released in the OpenHarmony community.
| No. | Branch Name | Branch Type| Release Date | End of Proactive Maintenance| End of Maintenance |
| :--- | ------------- | :------- | :-------- | :----------- | :-------- |
| 1 | 1.0.1-Release | Release | 2021-03-30| 2022-03-30 | 2023-03-30|
| 2 | 3.0-LTS | LTS | 2021-09-30| 2023-09-30 | 2025-03-30|
| 3 | 3.1-Release | Release | 2022-03-30| 2023-03-30 | 2024-03-30|
### Version Plan
The OpenHarmony Release SIG periodically releases, updates, and maintains branch version plans. For details, visit [OpenHarmony-SIG-RoadMap](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/OpenHarmony-SIG-RoadMap.md).
......@@ -20,5 +20,5 @@ display.getDefaultDisplay((err, data) => {
}
console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
console.info('Test densityDPI:' + JSON.stringify(data.densityDPI));
});https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-device-info.md)
});
```
......@@ -13,25 +13,33 @@ convertxml中convert方法提供了转换xml文本为JavaScript对象的能力
```
import convertxml from '@ohos.convertxml';
// 代码片段
xml =
// xml格式的字符串
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let conv = new convertxml.ConvertXML();
// 转换选项, 参考文档使用
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result:any = conv.convert(xml, options) // 将xml文本转为JS对象
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
}
let result: any = conv.convert(xml, options) // 将xml文本转为JS对象
console.log('Test: ' + JSON.stringify(result))
console.log('Test: ' + result._declaration._attributes.version) // xml代码片段version字段信息
console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // xml代码片段title字段内容
console.log('Test: ' + result._declaration._attributes.version) // xml字符串中version字段信息console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // xml字符串中title字段内容
```
参考文档:[xml转换JavaScript](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-convertxml.md)
......
......@@ -21,45 +21,43 @@ let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {
// 创建pixelmap对象
const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } }
image.createPixelMap(color, opts, pixelmap => {
expect(pixelmap !== null).assertTrue();
console.info('TC_001-1 success');
done();
})
image.createPixelMap(color, opts, pixelmap => {
console.log('Succeeded in creating pixelmap.');
})
// 用于读像素
pixelmap.readPixels(area,(data) => {
if(data !== null) {
var bufferArr = new Uint8Array(area.pixels);
if(data !== null) {
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021-1 buffer ' + bufferArr[i]);
if(res) {
if(bufferArr[i] == 0) {
res = false;
console.info('TC_021-1 Success');
expect(true).assertTrue();
done();
break;
}
}
console.info(' buffer ' + bufferArr[i]);
if(res) {
if(bufferArr[i] == 0) {
res = false;
console.log('readPixels end.');
break;
}
}
}
}
})
// 用于存像素
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer,() => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if(res) {
if (bufferArr[i] !== 0) {
res = false;
console.info('TC_020-1 Success');
expect(true).assertTrue();
done();
break;
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if(res) {
if (bufferArr[i] !== 0) {
res = false;
console.log('readPixelsToBuffer end.');
break;
}
}
}
}
})
// 用于写像素
pixelmap.writePixels(area,() => {
......@@ -71,56 +69,51 @@ pixelmap.writePixels(area,() => {
if(res) {
if (readArr[i] !== 0) {
res = false;
console.info('TC_022-1 Success');
expect(true).assertTrue();
done();
console.log('readPixels end.please check buffer');
break;
}
}
}
})
})
// 用于写像素到缓冲区
pixelmap.writeBufferToPixels(writeColor).then(() => {
const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then (() => {
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if(res) {
if (bufferArr[i] !== i) {
res = false;
console.info('TC_023 Success');
expect(true).assertTrue()
done();
var bufferArr = new Uint8Array(readBuffer);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
if(res) {
if (bufferArr[i] !== i) {
res = false;
console.log('readPixels end.please check buffer');
break;
}
}
}
})
})
// 用于获取图片信息
pixelmap.getImageInfo( imageInfo => {
if (imageInfo !== null) {
console.info('TC_024-1 imageInfo is ready');
expect(imageInfo.size.height == 4).assertTrue();
expect(imageInfo.size.width == 6).assertTrue();
expect(imageInfo.pixelFormat == 4).assertTrue();
done();
console.log('Succeeded in getting imageInfo');
}
})
// 用于释放pixelmap
pixelmap.release(()=>{
expect(true).assertTrue();
console.log('TC_027-1 suc');
done();
console.log('Succeeded in releasing pixelmap');
})
let path = '/data/local/tmp/test.jpg';
// 用于创建imagesource(uri)
const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.jpg'
let path = '/data/local/tmp/test.jpg';
const imageSourceApi = image.createImageSource(path);
// 用于创建imagesource(fd)
const imageSourceApi = image.createImageSource(29);
let fd = 29;
const imageSourceApi = image.createImageSource(fd);
// 用于创建imagesource(data)
const data = new ArrayBuffer(96);
......@@ -128,15 +121,15 @@ const imageSourceApi = image.createImageSource(data);
// 用于释放imagesource
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
})
console.log('Succeeded in releasing imagesource');
})
// 用于编码
const imagePackerApi = image.createImagePacker();
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => {
console.info('TC_062-1 finished');
expect(data !== null).assertTrue();
done();
console.log('Succeeded in packing');
})
// 用于释放imagepacker
......@@ -164,75 +157,54 @@ let decodingOptions = {
// 用于回调方式创建pixelmap
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.info('TC_050 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
})
}
console.log('Succeeded in creating pixelmap.');
})
// 用于promise创建pixelmap
imageSourceApi.createPixelMap().then(pixelmap => {
console.info('TC_050-11 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
console.log('Succeeded in creating pixelmap.');
})
// 函数调用发生异常时,捕捉错误信息
catch(error => {
console.log('TC_050-11 error: ' + error);
expect().assertFail();
done();
console.log('Failed in creating pixelmap.' + error);
})
// 用于获取像素每行字节数
pixelmap.getBytesNumberPerRow( num => {
console.info('TC_025-1 num is ' + num);
expect(num == expectNum).assertTrue();
done();
console.log('Succeeded in getting BytesNumber PerRow.');
})
// 用于获取像素总字节数
pixelmap.getPixelBytesNumber(num => {
console.info('TC_026-1 num is ' + num);
expect(num == expectNum).assertTrue();
done();
console.log('Succeeded in getting PixelBytesNumber.');
})
// 用于获取pixelmap信息
pixelmap.getImageInfo( imageInfo => {})
// 用于打印获取失败信息
console.info('TC_024-1 imageInfo is empty');
expect(false).assertTrue()
// 用于释放pixelmap
pixelmap.release(()=>{
expect(true).assertTrue();
console.log('TC_027-1 suc');
done();
console.log('Succeeded in releasing pixelmap');
})
// 用于捕捉释放失败信息
catch(error => {
console.log('TC_027-1 error: ' + error);
expect().assertFail();
done();
console.log('Failed in releasing pixelmap.' + error);
})
```
### 编码场景
```js
let path = '/data/local/tmp/test.png' // 设置创建imagesource的路径
let path = '/data/local/tmp/test.png'; // 设置创建imagesource的路径
// 用于设置imagesource
const imageSourceApi = image.createImageSource(path); // '/data/local/tmp/test.png'
// 如果创建imagesource失败,打印错误信息
if (imageSourceApi == null) {
console.info('TC_062 create image source failed');
expect(false).assertTrue();
done();
console.log('Failed in creating imageSource.');
}
// 如果创建imagesource成功,则创建imagepacker
......@@ -240,9 +212,7 @@ const imagePackerApi = image.createImagePacker();
// 如果创建失败,打印错误信息
if (imagePackerApi == null) {
console.info('TC_062 create image packer failed');
expect(false).assertTrue();
done();
console.log('Failed in creating imagePacker.');
}
// 如果创建imagepacker成功,则设置编码参数
......@@ -252,19 +222,15 @@ let packOpts = { format:["image/jpeg"], // 支持编码的格式为jpg
// 用于编码
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
console.info('TC_062 finished');
expect(data !== null).assertTrue();
done();
console.log('Succeeded in packing');
})
// 编码完成,释放imagepacker
imagePackerApi.release();
// 用于获取imagesource信息
imageSourceApi.getImageInfo(imageInfo => {
console.info('TC_045 imageInfo');
expect(imageInfo !== null).assertTrue();
done();
console.log('Succeeded in getting imageInfo');
})
// 用于更新增量数据
......
......@@ -16,11 +16,11 @@
OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架)。方舟开发框架可为开发者提供应用UI开发所必需的能力,比如多种组件、布局计算、动画能力、UI交互、绘制等。
方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于TS扩展的声明式开发范式(简称“声明式开发范式”)和基于JS扩展的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。
方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于eTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。
| **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** |
| -------- | -------- | -------- | -------- | -------- |
| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 |
| 声明式开发范式 | eTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 |
| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 |
更多UI框架的开发内容及指导,详见[UI开发](../ui/arkui-overview.md)
......
......@@ -73,6 +73,9 @@ function listener(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}
// 监听输入设备的热插拔事件
inputDevice.on("change", listener);
// 单独取消listener的监听。
inputDevice.off("change", listener);
......
......@@ -228,7 +228,7 @@ Codec MIME类型枚举。
| VIDEO_MPEG2 | 'video/mpeg2' | 表示视频/mpeg2类型。 |
| VIDEO_MPEG4 | 'video/mp4v-es' | 表示视频/mpeg4类型。 |
| VIDEO_VP8 | 'video/x-vnd.on2.vp8' | 表示视频/vp8类型。 |
| AUDIO_AAC | "audio/mp4a-latm" | 表示音频/mp4a-latm类型。 |
| AUDIO_AAC | 'audio/mp4a-latm' | 表示音频/mp4a-latm类型。 |
| AUDIO_VORBIS | 'audio/vorbis' | 表示音频/vorbis类型。 |
| AUDIO_FLAC | 'audio/flac' | 表示音频/flac类型。 |
......@@ -240,16 +240,16 @@ Codec MIME类型枚举。
| 名称 | 值 | 说明 |
| ------------------------ | --------------- | ------------------------------------------------------------ |
| MD_KEY_TRACK_INDEX | "track_index" | 表示轨道序号,其对应键值类型为number。 |
| MD_KEY_TRACK_TYPE | "track_type" | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。 |
| MD_KEY_CODEC_MIME | "codec_mime" | 表示codec_mime类型,其对应键值类型为string。 |
| MD_KEY_DURATION | "duration" | 表示媒体时长,其对应键值类型为number,单位为毫秒(ms)。 |
| MD_KEY_BITRATE | "bitrate" | 表示比特率,其对应键值类型为number,单位为比特率(bps)。 |
| MD_KEY_WIDTH | "width" | 表示视频宽度,其对应键值类型为number,单位为像素(px)。 |
| MD_KEY_HEIGHT | "height" | 表示视频高度,其对应键值类型为number,单位为像素(px)。 |
| MD_KEY_FRAME_RATE | "frame_rate" | 表示视频帧率,其对应键值类型为number,单位为100帧每秒(100fps)。 |
| MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | 表示声道数,其对应键值类型为number。 |
| MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | 表示采样率,其对应键值类型为number,单位为赫兹(Hz)。 |
| MD_KEY_TRACK_INDEX | 'track_index' | 表示轨道序号,其对应键值类型为number。 |
| MD_KEY_TRACK_TYPE | 'track_type' | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。 |
| MD_KEY_CODEC_MIME | 'codec_mime' | 表示codec_mime类型,其对应键值类型为string。 |
| MD_KEY_DURATION | 'duration' | 表示媒体时长,其对应键值类型为number,单位为毫秒(ms)。 |
| MD_KEY_BITRATE | 'bitrate' | 表示比特率,其对应键值类型为number,单位为比特率(bps)。 |
| MD_KEY_WIDTH | 'width' | 表示视频宽度,其对应键值类型为number,单位为像素(px)。 |
| MD_KEY_HEIGHT | 'height' | 表示视频高度,其对应键值类型为number,单位为像素(px)。 |
| MD_KEY_FRAME_RATE | 'frame_rate' | 表示视频帧率,其对应键值类型为number,单位为100帧每秒(100fps)。 |
| MD_KEY_AUD_CHANNEL_COUNT | 'channel_count' | 表示声道数,其对应键值类型为number。 |
| MD_KEY_AUD_SAMPLE_RATE | 'sample_rate' | 表示采样率,其对应键值类型为number,单位为赫兹(Hz)。 |
## BufferingInfoType<sup>8+</sup>
......@@ -441,10 +441,10 @@ function printfDescription(obj) {
}
}
audioPlayer.getTrackDescription((error, arrlist) => {
if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]);
audioPlayer.getTrackDescription((error, arrList) => {
if (arrList != null) {
for (let i = 0; i < arrList.length; i++) {
printfDescription(arrList[i]);
}
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
......@@ -477,9 +477,9 @@ function printfDescription(obj) {
}
}
let arrayDescription = null
audioPlayer.getTrackDescription().then((arrlist) => {
if (arrlist != null) {
arrayDescription = arrlist;
audioPlayer.getTrackDescription().then((arrList) => {
if (arrList != null) {
arrayDescription = arrList;
} else {
console.log('audio getTrackDescription fail');
}
......@@ -1234,10 +1234,10 @@ function printfDescription(obj) {
}
}
videoPlayer.getTrackDescription((error, arrlist) => {
if ((arrlist) != null) {
for (let i = 0; i < arrlist.length; i++) {
printfDescription(arrlist[i]);
videoPlayer.getTrackDescription((error, arrList) => {
if ((arrList) != null) {
for (let i = 0; i < arrList.length; i++) {
printfDescription(arrList[i]);
}
} else {
console.log(`video getTrackDescription fail, error:${error}`);
......@@ -1271,9 +1271,9 @@ function printfDescription(obj) {
}
let arrayDescription;
videoPlayer.getTrackDescription().then((arrlist) => {
if (arrlist != null) {
arrayDescription = arrlist;
videoPlayer.getTrackDescription().then((arrList) => {
if (arrList != null) {
arrayDescription = arrList;
} else {
console.log('video getTrackDescription fail');
}
......@@ -1617,10 +1617,10 @@ function printfItemDescription(obj, key) {
console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey]
}
let audioPlayer = media.createAudioPlayer();
audioPlayer.getTrackDescription((error, arrlist) => {
if (arrlist != null) {
for (let i = 0; i < arrlist.length; i++) {
printfItemDescription(arrlist[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
audioPlayer.getTrackDescription((error, arrList) => {
if (arrList != null) {
for (let i = 0; i < arrList.length; i++) {
printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
}
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
......@@ -2532,8 +2532,8 @@ videoRecorder.on('error', (error) => { // 设
| 名称 | 值 | 说明 |
| ----------- | ----- | --------------------- |
| CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。 |
| CFT_MPEG_4A | "m4a" | 音频的容器格式,M4A。 |
| CFT_MPEG_4 | 'mp4' | 视频的容器格式,MP4。 |
| CFT_MPEG_4A | 'm4a' | 音频的容器格式,M4A。 |
## Location
......
......@@ -162,7 +162,7 @@ connection.getAllNets(function (error, nets) {
getAllNets(): Promise&lt;Array&lt;NetHandle&gt;&gt;
获取所有处于连接状态的网络列表,使用promise方式作为异步方法。
获取所有处于连接状态的网络列表,使用Promise方式作为异步方法。
**需要权限**:ohos.permission.GET_NETWORK_INFO
......@@ -336,7 +336,7 @@ connection.getDefaultNet().then(function (netHandle) {
reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
向网络管理报告网络处于可用状态,调用此接口说明应用程序认为网络的可用性(ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED)与网络管理不一致。
使用promise方式作为异步方法。
使用Promise方式作为异步方法。
**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET
......@@ -351,7 +351,7 @@ reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 以Promise形式返回执行结果。 |
| Promise&lt;void&gt; | 无返回值的Promise对象。 |
**示例:**
......@@ -398,7 +398,7 @@ connection.getDefaultNet().then(function (netHandle) {
reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt;
向网络管理报告网络处于不可用状态,调用此接口说明应用程序认为网络的可用性(ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED)与网络管理不一致。
使用promise方式作为异步方法。
使用Promise方式作为异步方法。
**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET
......@@ -413,7 +413,7 @@ reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 以Promise形式返回执行结果。 |
| Promise&lt;void&gt; | 无返回值的Promise对象。 |
**示例:**
......@@ -522,7 +522,7 @@ enableAirplaneMode(): Promise\<void>
| 类型 | 说明 |
| ------------------------------------------- | ----------------------------- |
| Promise\<void> | 以Promise形式返回结果。 |
| Promise\<void> | 无返回值的Promise对象。 |
**示例:**
......@@ -571,7 +571,7 @@ disableAirplaneMode(): Promise\<void>
| 类型 | 说明 |
| ------------------------------------------- | ----------------------------- |
| Promise\<void> | 以Promise形式返回结果。 |
| Promise\<void> | 无返回值的Promise对象。 |
**示例:**
......@@ -890,7 +890,7 @@ bindSocket(socketParam: TCPSocket \| UDPSocket): Promise\<void>;
| 类型 | 说明 |
| -------------- | ---------------------- |
| Promise\<void> | 以Promise形式返回结果。 |
| Promise\<void> | 无返回值的Promise对象。 |
**示例:**
......
......@@ -312,7 +312,7 @@ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFC
| TNF_UNKNOWN | 0x05 | Unknown。|
| TNF_UNCHANGED | 0x06 | Unchanged (see section 2.3.3)。|
## RtdType<sup>9+</sup>
## NDEF Record RTD类型定义
NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**需要权限**:ohos.permission.NFC_TAG
......@@ -320,8 +320,8 @@ NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规
**系统能力**:SystemCapability.Communication.NFC.Core
| **参数名** | **常量值** | **说明** |
| -------- | -------- | -------- |
| RTD_TEXT | 常量 'T' | 文本类型的NDEF Record。|
| RTD_URI | 常量 'U' | URI类型的NDEF Record。|
| RTD_TEXT<sup>9+</sup> | [0x54] | 文本类型的NDEF Record。|
| RTD_URI<sup>9+</sup> | [0x55] | URI类型的NDEF Record。|
## NfcForumType<sup>9+</sup>
NFC Forum标准里面Tag类型的定义。
......
......@@ -728,9 +728,9 @@ ndef.writeNdef(ndefMessage, (err, data)=> {
### NdefTag.canSetReadOnly<sup>9+</sup>
canSetReadOnly(): Promise\<boolean>
canSetReadOnly(): boolean
检查ndef标签是否可以设置为只读,使用promise方式作为异步方法
检查NDEF标签是否可以设置为只读
**需要权限**:ohos.permission.NFC_TAG
......@@ -740,7 +740,7 @@ canSetReadOnly(): Promise\<boolean>
| **类型** | **说明** |
| ------------------ | --------------------------|
| Promise&lt;boolean&gt; | true: NDEF标签可设置为只读, false: NDEF标签不可设置为只读。 |
| boolean| true: NDEF标签可设置为只读, false: NDEF标签不可设置为只读。 |
**示例:**
......@@ -748,43 +748,8 @@ canSetReadOnly(): Promise\<boolean>
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag', has obtained the 'ndef' correctly.
ndef.canSetReadOnly()
.then((data) => {
console.log("ndef canSetReadOnly data: " + data);
}).catch((err)=> {
console.log("ndef canSetReadOnly err: " + err);
});
```
### NdefTag.canSetReadOnly<sup>9+</sup>
canSetReadOnly(callback: AsyncCallback&lt;boolean&gt;): void;
检查ndef标签是否可以设置为只读,使用callback方式作为异步方法。
**需要权限**:ohos.permission.NFC_TAG
**系统能力**:SystemCapability.Communication.NFC
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 回调函数,NDEF标签可设置为只读,返回true。 |
**示例:**
```js
import tag from '@ohos.nfc.tag';
// see 'tag.TagInfo' at 'js-apis-nfcTag', has obtained the 'ndef' correctly.
ndef.canSetReadOnly((err, data)=> {
if (err) {
console.log("ndef canSetReadOnly err: " + err);
} else {
console.log("ndef canSetReadOnly data: " + data);
}
});
var canSetReadOnly = ndef.canSetReadOnly();
console.log("ndef canSetReadOnly: " + canSetReadOnly);
```
### NdefTag.setReadOnly<sup>9+</sup>
......
......@@ -20,6 +20,11 @@ isScreenLocked(callback: AsyncCallback&lt;boolean&gt;): void
判断屏幕是否锁屏,使用callback作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.isLocked<sup>9+</sup>](#screenlockislocked9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数:**
......@@ -47,6 +52,11 @@ isScreenLocked(): Promise&lt;boolean&gt;
判断屏幕是否锁屏,使用Promise作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.isLocked<sup>9+</sup>](#screenlockislocked9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
......@@ -66,17 +76,40 @@ isScreenLocked(): Promise&lt;boolean&gt;
```
## screenlock.isLocked<sup>9+</sup>
isLocked(): boolean;
判断屏幕是否锁屏,使用同步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true表示当前屏幕已锁定,返回false表示当前屏幕未锁定。 |
**示例**
```js
var isLocked = screenlock.isLocked();
```
## screenlock.isSecureMode
isSecureMode(callback: AsyncCallback&lt;boolean&gt;): void
判断设备是否处于安全模式下,使用callback作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.isSecure<sup>9+</sup>](#screenlockissecure9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
......@@ -102,6 +135,11 @@ isSecureMode(): Promise&lt;boolean&gt;
判断设备是否处于安全模式下,使用Promise作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.isSecure<sup>9+</sup>](#screenlockissecure9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
......@@ -121,17 +159,40 @@ isSecureMode(): Promise&lt;boolean&gt;
```
## screenlock.isSecure<sup>9+</sup>
isSecure(): boolean;
判断设备是否处于安全模式下,使用同步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 |
**示例**
```js
var isSecure = screenlock.isSecure();
```
## screenlock.unlockScreen
unlockScreen(callback: AsyncCallback&lt;void&gt;): void
解锁屏幕,使用callback作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.unlock<sup>9+</sup>](#screenlockunlock9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
......@@ -157,6 +218,11 @@ unlockScreen(): Promise&lt;void&gt;
解锁屏幕,使用Promise作为异步方法。
> **说明:**
> 从API version 9开始废弃。建议使用[screenlock.unlock<sup>9+</sup>](#screenlockunlock9)代替。
>
> 从 API version 7开始支持。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
......@@ -176,14 +242,64 @@ unlockScreen(): Promise&lt;void&gt;
```
## screenlock.lockScreen<sup>9+</sup>
## screenlock.unlock<sup>9+</sup>
unlock(callback: AsyncCallback&lt;boolean&gt;): void
解锁屏幕,使用callback作为异步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。返回true表示屏幕解锁成功,返回false表示屏幕解锁失败。 |
**示例**
```js
screenlock.unlock((err,data) => {
if (err) {
console.error('unlock error -> ${JSON.stringify(err)}');
return;
}
console.info('unlock success data -> ${JSON.stringify(data)}');
});
```
## screenlock.unlock<sup>9+</sup>
lockScreen(callback: AsyncCallback&lt;boolean&gt;): void
unlock(): Promise&lt;boolean&gt;
解锁屏幕,使用Promise作为异步方法。
锁定屏幕,使用callback作为异步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 以Promise形式返回结果。 |
**示例**
```js
screenlock.unlock().then((data) => {
console.log('unlock success');
}).catch((err) => {
console.error('unlock fail, : err->${JSON.stringify(err)}');
});
```
## screenlock.lock<sup>9+</sup>
lock(callback: AsyncCallback&lt;boolean&gt;): void
锁定屏幕,使用callback作为异步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**系统接口**:此接口为系统接口,三方应用不支持调用。
......@@ -192,23 +308,23 @@ lockScreen(callback: AsyncCallback&lt;boolean&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,失败时返回错误信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。返回true表示屏幕锁定成功,返回false表示屏幕锁定失败。 |
**示例**
```js
screenlock.lockScreen((err) => {
screenlock.lock((err) => {
if (err) {
console.error('lockScreen callback error -> ${JSON.stringify(err)}');
console.error('lock callback error -> ${JSON.stringify(err)}');
return;
}
console.info('lockScreen callback success');
console.info('lock callback success');
});
```
## screenlock.lockScreen<sup>9+</sup>
## screenlock.lock<sup>9+</sup>
lockScreen(): Promise&lt;boolean&gt;
lock(): Promise&lt;boolean&gt;
锁定屏幕,使用Promise作为异步方法。
......@@ -225,10 +341,10 @@ lockScreen(): Promise&lt;boolean&gt;
**示例**
```js
screenlock.lockScreen().then(() => {
console.log('lockScreen success');
screenlock.lock().then(() => {
console.log('lock success');
}).catch((err) => {
console.error('lockScreen fail, promise: err->${JSON.stringify(err)}');
console.error('lock fail, promise: err->${JSON.stringify(err)}');
});
```
......
......@@ -52,7 +52,7 @@ getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
异步获取指定卷的总空间大小,以callback方式返回。
......@@ -69,7 +69,7 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):v
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;number&gt; | 是 | 获取指定卷总空间之后的回调 |
| callback | callback: AsyncCallback&lt;number&gt; | 是 | 获取指定卷总空间之后的回调 |
**示例:**
......@@ -121,7 +121,7 @@ getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
异步获取指定卷的可用空间大小,以callback方式返回。
......@@ -138,7 +138,7 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):vo
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;number&gt; | 是 | 获取指定卷可用空间之后的回调 |
| callback | callback: AsyncCallback&lt;number&gt; | 是 | 获取指定卷可用空间之后的回调 |
**示例:**
......@@ -206,7 +206,7 @@ getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | 是 | 应用包名 |
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | 是 | 获取指定卷上的应用存储数据之后的回调 |
| callback | callback: AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | 是 | 获取指定卷上的应用存储数据之后的回调 |
**示例:**
......@@ -251,7 +251,7 @@ getCurrentBundleStats(callback: AsyncCallback&lt;BundleStats&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | 是 | 获取指定卷上的应用存储状态之后的回调 |
| callback | callback: AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | 是 | 获取指定卷上的应用存储状态之后的回调 |
**示例:**
......@@ -323,7 +323,7 @@ getTotalSize(callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback&lt;number&gt; | 是 | 获取内卡的总空间大小之后的回调 |
| callback | callback: AsyncCallback&lt;number&gt; | 是 | 获取内卡的总空间大小之后的回调 |
**示例:**
......@@ -381,7 +381,7 @@ getFreeSize(callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | 是 | 获取内卡的可用空间大小之后的回调 |
| callback | callback: AsyncCallback&lt;number&gt; | 是 | 获取内卡的可用空间大小之后的回调 |
**示例:**
......@@ -424,7 +424,7 @@ getSystemSize(): Promise&lt;number&gt;
## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback:AsyncCallback&lt;number&gt;):void
getSystemSize(callback: AsyncCallback&lt;number&gt;): void
异步获取系统空间大小,以callback方式返回。
......@@ -440,7 +440,7 @@ getSystemSize(callback:AsyncCallback&lt;number&gt;):void
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | 是 | 获取系统空间大小之后的回调 |
| callback | callback: AsyncCallback&lt;number&gt; | 是 | 获取系统空间大小之后的回调 |
**示例:**
......@@ -475,7 +475,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | 返回各类别数据大小 |
| Promise&lt;[StorageStats](#storagestats)&gt; | 返回各类别数据大小 |
**示例:**
......@@ -490,7 +490,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;):void
getUserStorageStats(userId: number, callback: AsyncCallback&lt;StorageStats&gt;): void
异步获取用户各类别数据大小,以callback方式返回。
......@@ -507,7 +507,7 @@ getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;):
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | number | 否 | 用户id <br/>确认当前用户:<br/>-&nbsp;有值:表示指定用户。<br/>-&nbsp;无值:表示当前用户。 |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | 是 | 返回各类别数据大小之后的回调 |
| callback | callback: AsyncCallback&lt;[StorageStats](#storagestats)&gt; | 是 | 返回各类别数据大小之后的回调 |
**示例:**
......
......@@ -25,7 +25,7 @@ URLSearchParams的构造函数。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | 否 | 入参对象。<br/>-&nbsp;string[][]:字符串二维数组<br/>-&nbsp;Record&lt;string,&nbsp;string&gt;:对象列表<br/>-&nbsp;string:字符串<br/>-&nbsp;URLSearchParams:对象 |
| init | string[][] \| Record&lt;string, string&gt; \| string \| URLSearchParams | 否 | 入参对象。<br/>- string[][]:字符串二维数组<br/>- Record&lt;string, string&gt;:对象列表<br/>- string:字符串<br/>- URLSearchParams:对象 |
**示例:**
......@@ -127,7 +127,7 @@ entries(): IterableIterator<[string, string]>
| 类型 | 说明 |
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | 返回一个ES6的迭代器。 |
| IterableIterator&lt;[string, string]&gt; | 返回一个ES6的迭代器。 |
**示例:**
......@@ -191,7 +191,7 @@ get(name: string): string | null
| 类型 | 说明 |
| -------- | -------- |
| string | 返回第一个值。 |
| null | 如果没找到,返回&nbsp;null。 |
| null | 如果没找到,返回 null。 |
**示例:**
......@@ -332,7 +332,7 @@ for (var value of searchParams.values()) {
| 类型 | 说明 |
| -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | 返回一个ES6的迭代器。 |
| IterableIterator&lt;[string, string]&gt; | 返回一个ES6的迭代器。 |
**示例:**
......@@ -403,7 +403,7 @@ URL的构造函数。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| url | string | 是 | 入参对象。 |
| base | string&nbsp;\|&nbsp;URL | 否 | 入参字符串或者对象。<br/>-&nbsp;string:字符串<br/>-&nbsp;URL:字符串或对象 |
| base | string \| URL | 否 | 入参字符串或者对象。<br/>- string:字符串<br/>- URL:字符串或对象 |
**示例:**
......@@ -441,7 +441,7 @@ toString(): string
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
url.toString();
```
......@@ -462,5 +462,5 @@ toJSON(): string
**示例:**
```js
const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON()
url.toJSON();
```
......@@ -37,36 +37,38 @@ constructor()
```js
import userIAM_faceAuth from '@ohos.userIAM.faceAuth';
let faceAuthManager = new userIAM_faceAuth.FaceAuthManager()
let faceAuthManager = new userIAM_faceAuth.FaceAuthManager();
```
### setSurfaceId
setSurfaceId(surfaceId: string): ResultCode;
setSurfaceId(surfaceId: string): void;
设置录入流程中人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID, 返回值表示操作是否成功
设置录入流程中人脸预览界面 [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。
**系统能力:** SystemCapability.UserIAM.UserAuth.FaceAuth
**需要权限:** ohos.permission.MANAGE_USER_IDM
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------- | ---- | -------------------------- |
| surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 |
**返回值:**
| 类型 | 说明 |
| ---------- | ------------------------------------------------------------ |
| [ResultCode](#resultcode) | 表示操作是否成功 |
**示例:**
```js
import userIAM_faceAuth from '@ohos.userIAM.faceAuth';
let faceAuthManager = new userIAM_faceAuth.FaceAuthManager()
faceAuthManager.setSurfaceId("0");
import faceAuth from '@ohos.userIAM.faceAuth';
let surfaceId = "123456";
let manager = new faceAuth.FaceAuthManager();
try {
manager.setSurfaceId(surfaceId);
console.info("set surface id success");
} catch (e) {
console.error("set surface id failed, error = " + e);
}
```
## ResultCode
......@@ -77,5 +79,4 @@ setSurfaceId(surfaceId: string): ResultCode;
| 名称 | 默认值 | 描述 |
| ----------------------- | ------ | -------------------- |
| SUCCESS | 0 | 执行成功。 |
| FAIL | 1 | 执行失败。 |
| FAIL | 12700001 | 执行失败。 |
......@@ -132,27 +132,27 @@
// xxx.js
import prompt from '@system.prompt';
export default {
showDialog(e) {
showDialog() {
this.$element('simpledialog').show()
},
cancelDialog(e) {
cancelDialog() {
prompt.showToast({
message: 'Dialog cancelled'
})
},
cancelSchedule(e) {
cancelSchedule() {
this.$element('simpledialog').close()
prompt.showToast({
message: 'Successfully cancelled'
})
},
setSchedule(e) {
setSchedule() {
this.$element('simpledialog').close()
prompt.showToast({
message: 'Successfully confirmed'
})
},
doubleclick(e){
doubleclick(){
prompt.showToast({
message: 'doubleclick'
})
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册