未验证 提交 3902cc6c 编写于 作者: O openharmony_ci 提交者: Gitee

!5150 issue修改+示例代码修改+语言标记

Merge pull request !5150 from LiAn/OpenHarmony-3.1-Release
...@@ -8,20 +8,20 @@ ...@@ -8,20 +8,20 @@
## 接口说明 ## 接口说明
| 模块 | 接口名 | 描述 | | 模块 | 接口名 | 描述 |
| -------- | -------- | -------- | | ------------- | ---------------------------------------- | ------------------------------- |
| ohos.vibrator | vibrate(duration: number): Promise<void> | 触发马达按照时长振动,Promise型。 | | ohos.vibrator | vibrate(duration: number): Promise<void> | 触发马达按照时长振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | 触发马达按照时长振动,Callback型。 | | ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | 触发马达按照时长振动,使用Callback异步回调。 |
| ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | 触发马达按照指定字符串振动,Promise型。 | | ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | 触发马达按照开发者传递效果振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | 触发马达按照指定字符串振动,Callback型。 | | ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | 触发马达按照开发者传递效果振动,使用Callback异步回调。 |
| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | 停止振动。 | | ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | 停止振动。 |
| ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | 停止振动。 | | ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | 停止振动。 |
## 开发步骤 ## 开发步骤
1. 控制设备上的振动器,需要在“config.json”里面进行配置请求权限。具体如下: 1. 控制设备上的振动器,需要在“config.json”里面进行配置请求权限。具体如下:
``` ```
”reqPermissions“:[ ”reqPermissions“:[
{ {
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
``` ```
2. 触发设备振动。 2. 触发设备振动。
``` ```
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.vibrate(1000).then((error)=>{ vibrator.vibrate(1000).then((error)=>{
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
``` ```
3. 停止设备振动。 3. 停止设备振动。
``` ```
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{
......
...@@ -26,7 +26,7 @@ createAppAccountManager(): AppAccountManager ...@@ -26,7 +26,7 @@ createAppAccountManager(): AppAccountManager
**示例:** **示例:**
```js ```js
var appAccountManager = account.createAppAccountManager(); var appAccountManager = account_appAccount.createAppAccountManager();
``` ```
## AppAccountManager ## AppAccountManager
......
# 配置策略 # 配置策略
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 >
> - 本模块接口均为系统接口,三方应用不支持调用。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口均为系统接口,三方应用不支持调用。
配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。 配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
## 导入模块 ## 导入模块
``` ```js
import configPolicy from '@ohos.configPolicy'; import configPolicy from '@ohos.configPolicy';
``` ```
...@@ -22,18 +24,18 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void ...@@ -22,18 +24,18 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | --------------------------- | ---- | --------------------- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback<string> | 是 | 异步回调,用于返回最高优先级配置文件的路径 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回最高优先级配置文件的路径 |
**示例:** **示例:**
``` ```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 @@ getOneCfgFile(relPath: string): Promise<string> ...@@ -48,19 +50,19 @@ getOneCfgFile(relPath: string): Promise<string>
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | --------------------- | ------------ |
| Promise<string> | 最高优先级配置文件的路径 | | Promise<string> | 最高优先级配置文件的路径 |
**示例:** **示例:**
``` ```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 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) ...@@ -77,18 +79,18 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ------------- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回文件列表 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回文件列表 |
**示例:** **示例:**
``` ```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 @@ getCfgFiles(relPath: string): Promise<Array<string>> ...@@ -103,19 +105,19 @@ getCfgFiles(relPath: string): Promise<Array<string>>
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------------- | ---- |
| Promise<Array<string>> | 文件列表 | | Promise<Array<string>> | 文件列表 |
**示例:** **示例:**
``` ```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 @@ getCfgDirList(callback: AsyncCallback<Array<string>>): void ...@@ -131,17 +133,17 @@ getCfgDirList(callback: AsyncCallback<Array<string>>): void
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ----------------- |
| callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回配置层级目录列表 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回配置层级目录列表 |
**示例:** **示例:**
``` ```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 @@ getCfgDirList(): Promise<Array<string>> ...@@ -156,14 +158,14 @@ getCfgDirList(): Promise<Array<string>>
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------------- | -------- |
| Promise<Array<string>> | 配置层级目录列表 | | Promise<Array<string>> | 配置层级目录列表 |
**示例:** **示例:**
``` ```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);
}); });
......
...@@ -4,14 +4,15 @@ ...@@ -4,14 +4,15 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。 输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import inputDevice from '@ohos.multimodalInput.inputDevice'; import inputDevice from '@ohos.multimodalInput.inputDevice';
``` ```
...@@ -33,7 +34,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void ...@@ -33,7 +34,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
**示例:** **示例:**
``` ```js
export default { export default {
data: { data: {
deviceIds: Array, deviceIds: Array,
...@@ -65,7 +66,7 @@ function getDeviceIds(): Promise<Array<number>> ...@@ -65,7 +66,7 @@ function getDeviceIds(): Promise<Array<number>>
**示例:** **示例:**
``` ```js
export default { export default {
testGetDeviceIds: function () { testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds"); console.info("InputDeviceJsTest---start---testGetDeviceIds");
...@@ -100,7 +101,7 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi ...@@ -100,7 +101,7 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi
**示例:** **示例:**
``` ```js
export default { export default {
InputDeviceData: { InputDeviceData: {
deviceId : 0, deviceId : 0,
...@@ -136,7 +137,7 @@ function getDevice(deviceId: number): Promise<InputDeviceData> ...@@ -136,7 +137,7 @@ function getDevice(deviceId: number): Promise<InputDeviceData>
**示例:** **示例:**
``` ```js
export default { export default {
InputDeviceData: { InputDeviceData: {
deviceId : 0, deviceId : 0,
...@@ -165,18 +166,18 @@ export default { ...@@ -165,18 +166,18 @@ export default {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ---------- | -------------------------------------- | ------------------------------------------------------------ | | ---------- | -------------------------------------- | ---------------------------------------- |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| name | string | 输入设备的名字。 | | name | string | 输入设备的名字。 |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 | | sources | Array&lt;[SourceType](#sourcetype)&gt; | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
| axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | 输入设备的轴信息。 | | axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | 输入设备的轴信息。 |
| bus | number | 输入设备的总线类型。 | | bus | number | 输入设备的总线类型。 |
| product | number | 输入设备的产品信息。 | | product | number | 输入设备的产品信息。 |
| vendor | number | 输入设备的厂商信息。 | | vendor | number | 输入设备的厂商信息。 |
| version | number | 输入设备的版本信息。 | | version | number | 输入设备的版本信息。 |
| phys | string | 输入设备的物理地址。 | | phys | string | 输入设备的物理地址。 |
| uniq | string | 输入设备的唯一标识。 | | uniq | string | 输入设备的唯一标识。 |
## AxisType ## AxisType
......
# 注入按键 # 注入按键
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
> >
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> >
> - 本模块接口均为系统接口,三方应用不支持调用。 > 本模块接口均为系统接口,三方应用不支持调用。
## 导入模块 ## 导入模块
``` ```js
import inputEventClient from '@ohos.multimodalInput.inputEventClient'; import inputEventClient from '@ohos.multimodalInput.inputEventClient';
``` ```
...@@ -26,20 +26,20 @@ injectEvent({KeyEvent: KeyEvent}): void ...@@ -26,20 +26,20 @@ injectEvent({KeyEvent: KeyEvent}): void
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | --------------------- | ---- | --------- |
| KeyEvent | [KeyEvent](#keyevent) | 是 | 注入按键的描述信息 | | KeyEvent | [KeyEvent](#keyevent) | 是 | 注入按键的描述信息 |
**示例:** **示例:**
``` ```js
let keyEvent = { let keyEvent = {
isPressed: true, isPressed: true,
keyCode: 2, keyCode: 2,
keyDownDuration: 0, keyDownDuration: 0,
isIntercepted: false isIntercepted: false
} }
res = inputEventClient.injectEvent({KeyEvent: keyEvent}); let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
``` ```
...@@ -49,9 +49,9 @@ res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ...@@ -49,9 +49,9 @@ res = inputEventClient.injectEvent({KeyEvent: keyEvent});
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | --------------- | ------- | ---- | --------- |
| isPressed | boolean | 是 | 按键是否按下 | | isPressed | boolean | 是 | 按键是否按下 |
| keyCode | Number | 是 | 按键键值 | | keyCode | Number | 是 | 按键键值 |
| keyDownDuration | boolean | 是 | 按键按下持续时间 | | keyDownDuration | boolean | 是 | 按键按下持续时间 |
| isIntercepted | Number | 是 | 按键是否可以被拦截 | | isIntercepted | Number | 是 | 按键是否可以被拦截 |
# 振动 # 振动
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
...@@ -34,7 +35,7 @@ vibrate(duration: number): Promise&lt;void&gt; ...@@ -34,7 +35,7 @@ vibrate(duration: number): Promise&lt;void&gt;
**示例:** **示例:**
``` ```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)=>{
...@@ -60,7 +61,7 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void ...@@ -60,7 +61,7 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:** **示例:**
``` ```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);
...@@ -92,7 +93,7 @@ vibrate(effectId: EffectId): Promise&lt;void&gt; ...@@ -92,7 +93,7 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示触发振动是否成功。 | | Promise&lt;void&gt; | 指示触发振动是否成功。 |
**示例:** **示例:**
``` ```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)=>{
...@@ -118,7 +119,7 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void ...@@ -118,7 +119,7 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:** **示例:**
``` ```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);
...@@ -150,7 +151,7 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -150,7 +151,7 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示停止振动是否成功。 | | Promise&lt;void&gt; | 指示停止振动是否成功。 |
**示例:** **示例:**
``` ```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)=>{
...@@ -176,7 +177,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void; ...@@ -176,7 +177,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
| callback | AsyncCallback&lt;void&gt; | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 |
**示例:** **示例:**
``` ```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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册