提交 5beae124 编写于 作者: W wusongqing

updated docs against 5150

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 9024154a
# Configuration Policy # Configuration Policy
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **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 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 configuration policy provides the capability of obtaining the custom configuration directory and file path based on the predefined custom configuration level. The configuration policy provides the capability of obtaining the custom configuration directory and file path based on the predefined custom configuration level.
## Modules to Import ## Modules to Import
``` ```js
import configPolicy from '@ohos.configPolicy'; import configPolicy from '@ohos.configPolicy';
``` ```
...@@ -22,18 +24,18 @@ For example, if the **config.xml** file is stored in **/system/etc/config.xml** ...@@ -22,18 +24,18 @@ For example, if the **config.xml** file is stored in **/system/etc/config.xml**
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| relPath | string | Yes| Name of the configuration file.| | relPath | string | Yes| Name of the configuration file.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the path of the configuration file.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the path of the configuration file.|
**Example** **Example**
``` ```js
configPolicy.getOneCfgFile('config.xml', (error, value) => { configPolicy.getOneCfgFile('config.xml', (error, value) => {
if (error == undefined) { if (error == undefined) {
console.log(value); console.log("value is " + value);
} else { } else {
console.log(error); console.log("error occurs "+ error);
} }
}); });
``` ```
...@@ -48,19 +50,19 @@ Obtains the path of a configuration file with the specified name and highest pri ...@@ -48,19 +50,19 @@ Obtains the path of a configuration file with the specified name and highest pri
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| relPath | string | Yes| Name of the configuration file.| | relPath | string | Yes| Name of the configuration file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the path of the configuration file.| | Promise&lt;string&gt; | Promise used to return the path of the configuration file.|
**Example** **Example**
``` ```js
configPolicy.getOneCfgFile('config.xml').then(value => { configPolicy.getOneCfgFile('config.xml').then(value => {
console.log(value); console.log("value is " + value);
}).catch(error => { }).catch(error => {
console.log("getOneCfgFile promise " + error); console.log("getOneCfgFile promise " + error);
}); });
...@@ -77,18 +79,18 @@ and **/sys-pod/etc/config.xml**, then **/system/etc/config.xml, /sys-pod/etc/con ...@@ -77,18 +79,18 @@ and **/sys-pod/etc/config.xml**, then **/system/etc/config.xml, /sys-pod/etc/con
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| relPath | string | Yes| Name of the configuration file.| | relPath | string | Yes| Name of the configuration file.|
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes| Callback used to return the file list.| | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes| Callback used to return the file list.|
**Example** **Example**
``` ```js
configPolicy.getCfgFiles('config.xml', (error, value) => { configPolicy.getCfgFiles('config.xml', (error, value) => {
if (error == undefined) { if (error == undefined) {
console.log(value); console.log("value is " + value);
} else { } else {
console.log(error); console.log("error occurs "+ error);
} }
}); });
``` ```
...@@ -103,19 +105,19 @@ Obtains all configuration files with the specified name and lists them in ascend ...@@ -103,19 +105,19 @@ Obtains all configuration files with the specified name and lists them in ascend
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| relPath | string | Yes| Name of the configuration file.| | relPath | string | Yes| Name of the configuration file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the file list.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the file list.|
**Example** **Example**
``` ```js
configPolicy.getCfgFiles('config.xml').then(value => { configPolicy.getCfgFiles('config.xml').then(value => {
console.log(value); console.log("value is " + value);
}).catch(error => { }).catch(error => {
console.log("getCfgFiles promise " + error); console.log("getCfgFiles promise " + error);
}); });
...@@ -131,17 +133,17 @@ Obtains the configuration level directory list. This API uses an asynchronous ca ...@@ -131,17 +133,17 @@ Obtains the configuration level directory list. This API uses an asynchronous ca
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes| Callback used to return the configuration level directory list.| | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes| Callback used to return the configuration level directory list.|
**Example** **Example**
``` ```js
configPolicy.getCfgDirList((error, value) => { configPolicy.getCfgDirList((error, value) => {
if (error == undefined) { if (error == undefined) {
console.log(value); console.log("value is " + value);
} else { } else {
console.log(error); console.log("error occurs "+ error);
} }
}); });
``` ```
...@@ -156,14 +158,14 @@ Obtains the configuration level directory list. This API uses a promise to retur ...@@ -156,14 +158,14 @@ Obtains the configuration level directory list. This API uses a promise to retur
**System capability**: SystemCapability.Customization.ConfigPolicy **System capability**: SystemCapability.Customization.ConfigPolicy
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the configuration level directory list.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the configuration level directory list.|
**Example** **Example**
``` ```js
configPolicy.getCfgDirList().then(value => { configPolicy.getCfgDirList().then(value => {
console.log(value); console.log("value is " + value);
}).catch(error => { }).catch(error => {
console.log("getCfgDirList promise " + error); console.log("getCfgDirList promise " + error);
}); });
......
# Vibrator # Vibrator
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > **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 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.
## Modules to Import ## Modules to Import
``` ```js
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
...@@ -25,16 +26,16 @@ Triggers vibration with a specific duration. This API uses a promise to return t ...@@ -25,16 +26,16 @@ Triggers vibration with a specific duration. This API uses a promise to return t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------ | | -------- | ------ | ---- | ------------ |
| duration | number | Yes | Vibration duration.| | duration | number | Yes | Vibration duration. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```js
vibrator.vibrate(1000).then(()=>{ vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -57,10 +58,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb ...@@ -57,10 +58,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- | | -------- | ------------------------- | ---- | ----------------------- |
| duration | number | Yes | Vibration duration. | | duration | number | Yes | Vibration duration. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```js
vibrator.vibrate(1000,function(error){ vibrator.vibrate(1000,function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
...@@ -84,15 +85,15 @@ Triggers vibration with a specific effect. This API uses a promise to return the ...@@ -84,15 +85,15 @@ Triggers vibration with a specific effect. This API uses a promise to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | ------------- | | -------- | --------------------- | ---- | ------------- |
| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect.| | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -115,10 +116,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac ...@@ -115,10 +116,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ----------------------- | | -------- | ------------------------- | ---- | ----------------------- |
| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is triggered successfully. |
**Example** **Example**
``` ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
...@@ -142,15 +143,15 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise ...@@ -142,15 +143,15 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | --------------- | | -------- | ------------------------------------- | ---- | --------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.| | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------- | | ------------------- | ----------- |
| Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully.| | Promise&lt;void&gt; | Promise used to indicate whether the vibration is stopped successfully. |
**Example** **Example**
``` ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -173,15 +174,15 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch ...@@ -173,15 +174,15 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | ----------------------- | | -------- | ------------------------------------- | ---- | ----------------------- |
| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. |
| callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully.| | callback | AsyncCallback&lt;void&gt; | No | Callback used to indicate whether the vibration is stopped successfully. |
**Example** **Example**
``` ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
}else{ }else{
console.log("Callback returned to indicate a successful stop."); console.log("Callback returned to indicate successful.");
} }
}) })
``` ```
...@@ -194,8 +195,8 @@ Describes the vibration effect. ...@@ -194,8 +195,8 @@ Describes the vibration effect.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------------ | -------------------- | --------------- | | ------------------ | -------------------- | --------------------------------------------------------------- |
| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer. |
## VibratorStopMode ## VibratorStopMode
...@@ -206,5 +207,5 @@ Describes the vibration mode to stop. ...@@ -206,5 +207,5 @@ Describes the vibration mode to stop.
| 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_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.| | 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. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册