提交 2fbda1f3 编写于 作者: H HelloCrease

update docs

Signed-off-by: NHelloCrease <lian15@huawei.com>
上级 c4589f0c
...@@ -8,20 +8,20 @@ ...@@ -8,20 +8,20 @@
## 接口说明 ## 接口说明
| 模块 | 接口名 | 描述 | | 模块 | 接口名 | 描述 |
| -------- | -------- | -------- | | ------------- | ---------------------------------------- | ------------------------------- |
| ohos.vibrator | vibrate(duration:&nbsp;number):&nbsp;Promise&lt;void&gt; | 触发马达按照时长振动,Promise型。 | | ohos.vibrator | vibrate(duration:&nbsp;number):&nbsp;Promise&lt;void&gt; | 触发马达按照时长振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(duration:&nbsp;number,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照时长振动,Callback型。 | | ohos.vibrator | vibrate(duration:&nbsp;number,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照时长振动,使用Callback异步回调。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId):&nbsp;Promise&lt;void&gt; | 触发马达按照指定字符串振动,Promise型。 | | ohos.vibrator | vibrate(effectId:&nbsp;EffectId):&nbsp;Promise&lt;void&gt; | 触发马达按照开发者传递效果振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照指定字符串振动,Callback型。 | | ohos.vibrator | vibrate(effectId:&nbsp;EffectId,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照开发者传递效果振动,使用Callback异步回调。 |
| ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode):&nbsp;Promise&lt;void&gt; | 停止振动。 | | ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode):&nbsp;Promise&lt;void&gt; | 停止振动。 |
| ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 停止振动。 | | ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;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&lt;string&gt;): void ...@@ -22,18 +24,18 @@ getOneCfgFile(relPath: string, callback: AsyncCallback&lt;string&gt;): void
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | --------------------------- | ---- | --------------------- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回最高优先级配置文件的路径 | | callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回最高优先级配置文件的路径 |
**示例:** **示例:**
``` ```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&lt;string&gt; ...@@ -48,19 +50,19 @@ getOneCfgFile(relPath: string): Promise&lt;string&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | --------------------- | ------------ |
| Promise&lt;string&gt; | 最高优先级配置文件的路径 | | Promise&lt;string&gt; | 最高优先级配置文件的路径 |
**示例:** **示例:**
``` ```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&lt;Array&lt;string&gt;&gt;) ...@@ -77,18 +79,18 @@ getCfgFiles(relPath: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;)
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ------------- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回文件列表 | | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回文件列表 |
**示例:** **示例:**
``` ```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&lt;Array&lt;string&gt;&gt; ...@@ -103,19 +105,19 @@ getCfgFiles(relPath: string): Promise&lt;Array&lt;string&gt;&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 | | relPath | string | 是 | 配置文件名 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------------- | ---- |
| Promise&lt;Array&lt;string&gt;&gt; | 文件列表 | | Promise&lt;Array&lt;string&gt;&gt; | 文件列表 |
**示例:** **示例:**
``` ```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&lt;Array&lt;string&gt;&gt;): void ...@@ -131,17 +133,17 @@ getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ----------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 | | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 |
**示例:** **示例:**
``` ```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&lt;Array&lt;string&gt;&gt; ...@@ -156,14 +158,14 @@ getCfgDirList(): Promise&lt;Array&lt;string&gt;&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy **系统能力**:SystemCapability.Customization.ConfigPolicy
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ---------------------------------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 | | Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 |
**示例:** **示例:**
``` ```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);
}); });
......
# 企业设备管理 # 企业设备管理
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
``` ```
...@@ -25,16 +26,16 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -25,16 +26,16 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------------- | ----------------------------------- | ---- | ------------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | | type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否激活成功 | | callback | AsyncCallback\<boolean> | 是 | callback方式返回是否激活成功 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -48,7 +49,7 @@ enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDevice ...@@ -48,7 +49,7 @@ enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDevice
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log(result); console.log("result is " + result);
}); });
``` ```
...@@ -66,21 +67,21 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -66,21 +67,21 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------ | | -------------- | ----------------------------------- | ---- | ------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 | | type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | --------------------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 | | Promise\<boolean> | Promise形式返回是否激活成功 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -91,7 +92,7 @@ let enterpriseInfo = { ...@@ -91,7 +92,7 @@ let enterpriseInfo = {
} }
enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL) enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL)
.then((result) => { .then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -111,24 +112,24 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -111,24 +112,24 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | ------------------------------ | | -------- | ----------------------------------- | ---- | ------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 | | callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: elementName.bundleName, bundleName: "bundleName",
abilityName: elementName.abilityName, abilityName: "abilityName",
}; };
enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => { enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log(result); console.log("result is " + result);
}); });
``` ```
...@@ -148,25 +149,25 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -148,25 +149,25 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | ------------------ | | ----- | ----------------------------------- | ---- | --------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | --------------------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 | | Promise\<boolean> | Promise形式返回是否激活成功 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => { enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -183,21 +184,21 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -183,21 +184,21 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------- | ---- | ------------------------------ | | ---------- | ----------------------- | ---- | ------------------- |
| bundleName | String | 是 | 超级设备管理员应用的包名 | | bundleName | String | 是 | 超级设备管理员应用的包名 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 | | callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 |
**示例** **示例**
``` ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => { enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log(result); console.log("result is " + result);
}); });
``` ```
...@@ -212,22 +213,22 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -212,22 +213,22 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------------ | | ---------- | ------ | ---- | ------------ |
| bundleName | String | 是 | 超级设备管理员应用的包名 | | bundleName | String | 是 | 超级设备管理员应用的包名 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | --------------------------- | | ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 | | Promise\<boolean> | Promise形式返回是否激活成功 |
**示例** **示例**
``` ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => { enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -244,24 +245,24 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -244,24 +245,24 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | -------------------------------- | | -------- | ----------------------------------- | ---- | -------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 | | callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: elementName.bundleName, bundleName: "bundleName",
abilityName: elementName.abilityName, abilityName: "abilityName",
}; };
enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => { enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log(result); console.log("result is " + result);
}); });
``` ```
...@@ -278,25 +279,25 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -278,25 +279,25 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | -------------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------- | | ----------------- | ------------------- |
| Promise\<boolean> | Promise形式返回是否处于激活状态 | | Promise\<boolean> | Promise形式返回是否处于激活状态 |
**示例** **示例**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => { enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -313,21 +314,21 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -313,21 +314,21 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------- | ---- | -------------------------------- | | ---------- | ----------------------- | ---- | -------------------- |
| bundleName | String | 是 | 设备管理员应用 | | bundleName | String | 是 | 设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 | | callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 |
**示例** **示例**
``` ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => { enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
} }
console.log(result); console.log("result is " + result);
}); });
``` ```
...@@ -344,22 +345,22 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -344,22 +345,22 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数** **参数**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------ | | ---------- | ------ | ---- | --------- |
| bundleName | String | 是 | 超级设备管理员应用 | | bundleName | String | 是 | 超级设备管理员应用 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ------------------------------- | | ----------------- | ------------------- |
| Promise\<boolean> | Promise形式返回是否处于激活状态 | | Promise\<boolean> | Promise形式返回是否处于激活状态 |
**示例** **示例**
``` ```js
let bundleName = "com.example.myapplication"; let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => { enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -376,13 +377,13 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -376,13 +377,13 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | --------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<DeviceSettingsManager&gt; | 是 | callback方式返回DeviceSettingsManager对象 | | callback | AsyncCallback<DeviceSettingsManager&gt; | 是 | callback方式返回DeviceSettingsManager对象 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
...@@ -414,13 +415,13 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -414,13 +415,13 @@ SystemCapability.Customation.EnterpriseDeviceManager
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | ------------------------------------ | ---------------------------------- |
| Promise&lt;DeviceSettingsManager&gt; | Promise方式返回DeviceSettingsManager对象 | | Promise&lt;DeviceSettingsManager&gt; | Promise方式返回DeviceSettingsManager对象 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
...@@ -447,15 +448,15 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -447,15 +448,15 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------------------ | | -------------- | ----------------------------------- | ---- | ---------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| callback | AsyncCallback\<boolean&gt; | 是 | callback方式返回是否设置企业信息成功 | | callback | AsyncCallback\<boolean&gt; | 是 | callback方式返回是否设置企业信息成功 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -466,7 +467,7 @@ let enterpriseInfo = { ...@@ -466,7 +467,7 @@ let enterpriseInfo = {
} }
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => { .then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -484,20 +485,20 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -484,20 +485,20 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------ | | -------------- | ----------------------------------- | ---- | ------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 | | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | ----------------------------------- | | ------------------ | --------------------- |
| Promise\<boolean>; | Promise方式返回是否设置企业信息成功 | | Promise\<boolean>; | Promise方式返回是否设置企业信息成功 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -508,7 +509,7 @@ let enterpriseInfo = { ...@@ -508,7 +509,7 @@ let enterpriseInfo = {
} }
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => { .then((result) => {
console.log(result); console.log("result is " + result);
}).catch(error => { }).catch(error => {
console.log("error occurs" + error); console.log("error occurs" + error);
}); });
...@@ -525,14 +526,14 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -525,14 +526,14 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| callback | AsyncCallback&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | 是 | callback方式返回设备管理员应用的企业信息 | | callback | AsyncCallback&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | 是 | callback方式返回设备管理员应用的企业信息 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -559,19 +560,19 @@ SystemCapability.Customation.EnterpriseDeviceManager ...@@ -559,19 +560,19 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | -------------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------------------ | ------------------------------------------- | | ---------------------------------------- | ------------------------- |
| Promise&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Promise方式返回设备管理员应用的企业信息对象 | | Promise&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Promise方式返回设备管理员应用的企业信息对象 |
**示例:** **示例:**
``` ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility", abilityName: "com.example.myapplication.MainAbility",
...@@ -590,10 +591,10 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { ...@@ -590,10 +591,10 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
**系统能力:** **系统能力:**
以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager 以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | ------ | ---- | ---------------------------------- | | ----------- | ---- | ------ | ---- | ----------------- |
| name | 只读 | string | 是 | 表示设备管理员应用所属企业的名称。 | | name | 只读 | string | 是 | 表示设备管理员应用所属企业的名称。 |
| description | 只读 | string | 是 | 表示设备管理员应用所属企业的描述。 | | description | 只读 | string | 是 | 表示设备管理员应用所属企业的描述。 |
## AdminType ## AdminType
...@@ -602,7 +603,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { ...@@ -602,7 +603,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
**系统能力:** **系统能力:**
以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager 以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
| -------- | -------- | -------- | | ----------------- | ---- | ----- |
| ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 | | ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 |
| ADMIN_TYPE_SUPER | 0x01 | 超级管理员 | | ADMIN_TYPE_SUPER | 0x01 | 超级管理员 |
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。 输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -25,10 +26,10 @@ on(type: “change”, listener: Callback&lt;DeviceListener&gt;): void ...@@ -25,10 +26,10 @@ on(type: “change”, listener: Callback&lt;DeviceListener&gt;): void
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | ---------- |
| type | string | 是 | 输入设备的事件类型 | | type | string | 是 | 输入设备的事件类型 |
| listener | Callback&lt;[DeviceListener](#devicelistener)&gt; | 是 | 可上报的输入设备事件 | | listener | Callback&lt;[DeviceListener](#devicelistener)&gt; | 是 | 可上报的输入设备事件 |
**示例:** **示例:**
...@@ -60,10 +61,10 @@ off(type: “change”, listener?: Callback&lt;DeviceListener&gt;): void ...@@ -60,10 +61,10 @@ off(type: “change”, listener?: Callback&lt;DeviceListener&gt;): void
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | ---------- |
| type | string | 是 | 输入设备的事件类型 | | type | string | 是 | 输入设备的事件类型 |
| listener | Callback&lt;[DeviceListener](#devicelistener)&gt; | 否 | 可上报的输入设备事件 | | listener | Callback&lt;[DeviceListener](#devicelistener)&gt; | 否 | 可上报的输入设备事件 |
**示例:** **示例:**
...@@ -112,8 +113,8 @@ function getDeviceIds(): Promise&lt;&lt;Array&lt;number&gt;&gt; ...@@ -112,8 +113,8 @@ function getDeviceIds(): Promise&lt;&lt;Array&lt;number&gt;&gt;
**返回值:** **返回值:**
| 参数 | 说明 | | 参数 | 说明 |
| ------------------------- | ----------------------------- | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于异步获取结果 | | Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例:**
...@@ -158,14 +159,14 @@ function getDevice(deviceId: number): Promise&lt;InputDeviceData&gt; ...@@ -158,14 +159,14 @@ function getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- | | -------- | ------ | ---- | ------------ |
| deviceId | number | 是 | 需要获取信息的设备id。 | | deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值:** **返回值:**
| 参数 | 说明 | | 参数 | 说明 |
| -------------------------------------------------- | ----------------------------- | | ---------------------------------------- | ------------------ |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise实例,用于异步获取结果 | | Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例:**
...@@ -187,11 +188,11 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt; ...@@ -187,11 +188,11 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 | | keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 |
**示例:** **示例:**
...@@ -212,15 +213,15 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;b ...@@ -212,15 +213,15 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;b
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 | | keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
**返回值:** **返回值:**
| 参数 | 说明 | | 参数 | 说明 |
| ----------------------------------- | ----------------------------- | | ----------------------------------- | ------------------ |
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise实例,用于异步获取结果 | | Promise&lt;Array&lt;boolean&gt;&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例:**
...@@ -242,10 +243,10 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): ...@@ -242,10 +243,10 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;):
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | 是 | 回调函数,异步返回查询结果。 |
**示例:** **示例:**
...@@ -266,15 +267,15 @@ getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;; ...@@ -266,15 +267,15 @@ getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;;
**返回值:** **返回值:**
| 参数 | 说明 | | 参数 | 说明 |
| -------------------------------------------- | ----------------------------- | | ---------------------------------------- | ------------------ |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise实例,用于异步获取结果 | | Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise实例,用于异步获取结果 |
**示例:** **示例:**
```js ```js
// 示例查询设备id为1的设备键盘类型。 // 示例查询设备id为1的设备键盘类型。
inputDevice.getKeyboardType().then((ret)=>{ inputDevice.getKeyboardType(1).then((ret)=>{
console.log("The keyboard type of the device is: " + ret); console.log("The keyboard type of the device is: " + ret);
}) })
``` ```
...@@ -285,9 +286,9 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -285,9 +286,9 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| -------- | --------------------------- | ------------------------------------------------------------ | | -------- | --------------------------- | --------------------------------- |
| type | [ChangedType](#changedtype) | 表示输入设备插入或者移除。 | | type | [ChangedType](#changedtype) | 表示输入设备插入或者移除。 |
| deviceId | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 | | deviceId | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
## InputDeviceData ## InputDeviceData
...@@ -296,18 +297,18 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -296,18 +297,18 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为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<sup>9+</sup> | number | 输入设备的总线类型。 | | bus<sup>9+</sup> | number | 输入设备的总线类型。 |
| product<sup>9+</sup> | number | 输入设备的产品信息。 | | product<sup>9+</sup> | number | 输入设备的产品信息。 |
| vendor<sup>9+</sup> | number | 输入设备的厂商信息。 | | vendor<sup>9+</sup> | number | 输入设备的厂商信息。 |
| version<sup>9+</sup> | number | 输入设备的版本信息。 | | version<sup>9+</sup> | number | 输入设备的版本信息。 |
| phys<sup>9+</sup> | string | 输入设备的物理地址。 | | phys<sup>9+</sup> | string | 输入设备的物理地址。 |
| uniq<sup>9+</sup> | string | 输入设备的唯一标识。 | | uniq<sup>9+</sup> | string | 输入设备的唯一标识。 |
## AxisType<sup>9+</sup> ## AxisType<sup>9+</sup>
...@@ -315,17 +316,17 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -315,17 +316,17 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ----------- | -------- | ------------------- | | ----------- | ------ | --------------- |
| touchMajor | string | 表示touchMajor轴。 | | touchMajor | string | 表示touchMajor轴。 |
| touchMinor | string | 表示touchMinor轴。 | | touchMinor | string | 表示touchMinor轴。 |
| toolMinor | string | 表示toolMinor轴。 | | toolMinor | string | 表示toolMinor轴。 |
| toolMajor | string | 表示toolMajor轴。 | | toolMajor | string | 表示toolMajor轴。 |
| orientation | string | 表示orientation轴。 | | orientation | string | 表示orientation轴。 |
| pressure | string | 表示pressure轴。 | | pressure | string | 表示pressure轴。 |
| x | string | 表示x轴。 | | x | string | 表示x轴。 |
| y | string | 表示y轴。 | | y | string | 表示y轴。 |
| NULL | string | 无。 | | NULL | string | 无。 |
## AxisRange ## AxisRange
...@@ -333,15 +334,15 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -333,15 +334,15 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ----------------------- | ------------------------- | ---------------- | | ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | 轴的输入源类型。 | | source | [SourceType](#sourcetype) | 轴的输入源类型。 |
| axis | [AxisType](axistype) | 轴的类型。 | | axis | [AxisType](axistype) | 轴的类型。 |
| max | number | 轴的最大值。 | | max | number | 轴的最大值。 |
| min | number | 轴的最小值。 | | min | number | 轴的最小值。 |
| fuzz<sup>9+</sup> | number | 轴的模糊值。 | | fuzz<sup>9+</sup> | number | 轴的模糊值。 |
| flat<sup>9+</sup> | number | 轴的基准值。 | | flat<sup>9+</sup> | number | 轴的基准值。 |
| resolution<sup>9+</sup> | number | 轴的分辨率。 | | resolution<sup>9+</sup> | number | 轴的分辨率。 |
## SourceType ## SourceType
...@@ -364,10 +365,10 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -364,10 +365,10 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 | | 名称 | 参数类型 | 说明 |
| ------ | -------- | ------------------ | | ------ | ------ | --------- |
| add | string | 表示输入设备插入。 | | add | string | 表示输入设备插入。 |
| remove | string | 表示输入设备移除。 | | remove | string | 表示输入设备移除。 |
## KeyboardType<sup>9+</sup> ## KeyboardType<sup>9+</sup>
...@@ -375,11 +376,11 @@ inputDevice.getKeyboardType().then((ret)=>{ ...@@ -375,11 +376,11 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice **系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 值 | 说明 | | 名称 | 参数类型 | 值 | 说明 |
| ------------------- | -------- | ---- | ------------------ | | ------------------- | ------ | ---- | --------- |
| NONE | number | 0 | 表示无按键设备。 | | NONE | number | 0 | 表示无按键设备。 |
| UNKNOWN | number | 1 | 表示未知按键设备。 | | UNKNOWN | number | 1 | 表示未知按键设备。 |
| ALPHABETIC_KEYBOARD | number | 2 | 表示全键盘设备。 | | ALPHABETIC_KEYBOARD | number | 2 | 表示全键盘设备。 |
| DIGITAL_KEYBOARD | number | 3 | 表示小键盘设备。 | | DIGITAL_KEYBOARD | number | 3 | 表示小键盘设备。 |
| HANDWRITING_PEN | number | 4 | 表示手写笔设备。 | | HANDWRITING_PEN | number | 4 | 表示手写笔设备。 |
| REMOTE_CONTROL | number | 5 | 表示遥控器设备。 | | REMOTE_CONTROL | number | 5 | 表示遥控器设备。 |
# 注入按键 # 注入按键
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
> >
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> >
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
## 导入模块 ## 导入模块
``` ```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 sensor from '@ohos.sensor'; import sensor from '@ohos.sensor';
``` ```
...@@ -30,7 +30,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler ...@@ -30,7 +30,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -59,7 +59,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Line ...@@ -59,7 +59,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Line
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -88,7 +88,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback ...@@ -88,7 +88,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -118,7 +118,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons ...@@ -118,7 +118,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -147,7 +147,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes ...@@ -147,7 +147,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -176,7 +176,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G ...@@ -176,7 +176,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -206,7 +206,7 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig ...@@ -206,7 +206,7 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -233,7 +233,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe ...@@ -233,7 +233,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -260,7 +260,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes ...@@ -260,7 +260,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
}, },
...@@ -285,7 +285,7 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambie ...@@ -285,7 +285,7 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambie
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
}, },
...@@ -310,7 +310,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti ...@@ -310,7 +310,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -337,7 +337,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac ...@@ -337,7 +337,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -367,7 +367,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes ...@@ -367,7 +367,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
}, },
...@@ -392,7 +392,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo ...@@ -392,7 +392,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
}, },
...@@ -417,7 +417,7 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes ...@@ -417,7 +417,7 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
}, },
...@@ -442,7 +442,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, ...@@ -442,7 +442,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;,
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
}, },
...@@ -467,7 +467,7 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes ...@@ -467,7 +467,7 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
}, },
...@@ -492,7 +492,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio ...@@ -492,7 +492,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -521,7 +521,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateRe ...@@ -521,7 +521,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateRe
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
}, },
...@@ -545,7 +545,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio ...@@ -545,7 +545,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -573,7 +573,7 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet ...@@ -573,7 +573,7 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
}, },
...@@ -599,7 +599,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele ...@@ -599,7 +599,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -626,7 +626,7 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Li ...@@ -626,7 +626,7 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Li
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -681,7 +681,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo ...@@ -681,7 +681,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -708,7 +708,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR ...@@ -708,7 +708,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -735,7 +735,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l ...@@ -735,7 +735,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -763,7 +763,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si ...@@ -763,7 +763,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -788,7 +788,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P ...@@ -788,7 +788,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -813,7 +813,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR ...@@ -813,7 +813,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
...@@ -836,7 +836,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A ...@@ -836,7 +836,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
...@@ -859,7 +859,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne ...@@ -859,7 +859,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -884,7 +884,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb ...@@ -884,7 +884,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -912,7 +912,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR ...@@ -912,7 +912,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) { if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message); console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
...@@ -939,7 +939,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes ...@@ -939,7 +939,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
...@@ -962,7 +962,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR ...@@ -962,7 +962,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
...@@ -985,7 +985,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt ...@@ -985,7 +985,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
...@@ -1008,7 +1008,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR ...@@ -1008,7 +1008,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
...@@ -1031,7 +1031,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat ...@@ -1031,7 +1031,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1056,7 +1056,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota ...@@ -1056,7 +1056,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRate ...@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRate
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
...@@ -1107,7 +1107,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD ...@@ -1107,7 +1107,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value); console.info("Wear status: "+ data.value);
} }
...@@ -1133,7 +1133,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele ...@@ -1133,7 +1133,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('x-coordinate component: ' + data.x); console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1161,7 +1161,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb ...@@ -1161,7 +1161,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1190,7 +1190,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR ...@@ -1190,7 +1190,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
...@@ -1214,7 +1214,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt; ...@@ -1214,7 +1214,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
...@@ -1238,7 +1238,7 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR ...@@ -1238,7 +1238,7 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
...@@ -1262,7 +1262,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo ...@@ -1262,7 +1262,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1290,7 +1290,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR ...@@ -1290,7 +1290,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1318,7 +1318,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& ...@@ -1318,7 +1318,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1344,7 +1344,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt ...@@ -1344,7 +1344,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
...@@ -1370,7 +1370,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRate ...@@ -1370,7 +1370,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRate
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
...@@ -1396,7 +1396,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes ...@@ -1396,7 +1396,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
...@@ -1422,7 +1422,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt; ...@@ -1422,7 +1422,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1450,7 +1450,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); ...@@ -1450,7 +1450,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1476,7 +1476,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); ...@@ -1476,7 +1476,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1505,7 +1505,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac ...@@ -1505,7 +1505,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1531,7 +1531,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR ...@@ -1531,7 +1531,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
**返回值:** ; **返回值:** ;
``` ```js
function callback(data) { function callback(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
...@@ -1557,7 +1557,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt; ...@@ -1557,7 +1557,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -1581,7 +1581,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR ...@@ -1581,7 +1581,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
} }
...@@ -1605,7 +1605,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota ...@@ -1605,7 +1605,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1632,7 +1632,7 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S ...@@ -1632,7 +1632,7 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -1656,7 +1656,7 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD ...@@ -1656,7 +1656,7 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD
**示例:** **示例:**
``` ```js
function accCallback(data) { function accCallback(data) {
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
} }
...@@ -1681,13 +1681,13 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -1681,13 +1681,13 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
``` ```js
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) { if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return; return;
} }
console.info("Operation successed. Data obtained: " + data.x); console.info("Operation successed. Data obtained: " + data);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
...@@ -1716,8 +1716,8 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -1716,8 +1716,8 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
``` ```js
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => { promise.then((data) => {
console.info("Operation successed."); console.info("Operation successed.");
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
...@@ -1744,8 +1744,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba ...@@ -1744,8 +1744,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 | | callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 |
**示例:** **示例:**
``` ```js
sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) { sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) { if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return; return;
...@@ -1775,8 +1775,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi ...@@ -1775,8 +1775,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 | | Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
**返回值:** **返回值:**
``` ```js
const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000); const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => { promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
...@@ -1804,7 +1804,7 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac ...@@ -1804,7 +1804,7 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.getAltitude(0, 200, function(err, data) { sensor.getAltitude(0, 200, function(err, data) {
if (err) { if (err) {
console.error( console.error(
...@@ -1838,7 +1838,7 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt; ...@@ -1838,7 +1838,7 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
**返回值:** **返回值:**
``` ```js
const promise = sensor.getAltitude(0, 200); const promise = sensor.getAltitude(0, 200);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data); console.info(' sensor_getAltitude_Promise success', data);
...@@ -1865,10 +1865,10 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -1865,10 +1865,10 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -1898,7 +1898,7 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt; ...@@ -1898,7 +1898,7 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
**返回值:** **返回值:**
``` ```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' getGeomagneticDip_promise successed', data); console.info(' getGeomagneticDip_promise successed', data);
...@@ -1925,10 +1925,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -1925,10 +1925,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:** **返回值:**
``` ```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -1963,10 +1963,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -1963,10 +1963,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:** **返回值:**
``` ```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'getAngleModifiy_promise success'); console.info('getAngleModifiy_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
...@@ -1993,10 +1993,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -1993,10 +1993,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -2030,10 +2030,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n ...@@ -2030,10 +2030,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n
**返回值:** **返回值:**
``` ```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise success'); console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
...@@ -2060,10 +2060,10 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt ...@@ -2060,10 +2060,10 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt
**返回值:** **返回值:**
``` ```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -2097,12 +2097,12 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe ...@@ -2097,12 +2097,12 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe
**返回值:** **返回值:**
``` ```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info('createQuaternion_promise successed'); console.info('createQuaternion_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2127,16 +2127,16 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr ...@@ -2127,16 +2127,16 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr
**返回值:** **返回值:**
``` ```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_callback" + data[i]); console.info("sensor_getDirection_callback" + data[i]);
} }
}) })
``` ```
...@@ -2164,12 +2164,12 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt ...@@ -2164,12 +2164,12 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt
**返回值:** **返回值:**
``` ```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data.x); console.info('sensor_getAltitude_Promise success', data.x);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_promise" + data[i]); console.info("sensor_getDirection_promise" + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2195,16 +2195,16 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2195,16 +2195,16 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:** **返回值:**
``` ```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]) console.info("data[" + i + "]: " + data[i])
} }
}) })
``` ```
...@@ -2233,15 +2233,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2233,15 +2233,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:** **返回值:**
``` ```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise successed'); console.info('createRotationMatrix_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info(LABEL + 'promise failed'); console.info('promise failed');
}) })
``` ```
...@@ -2355,11 +2355,11 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2355,11 +2355,11 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ------------------------ | | ----- | ------ | ---- | ---- | ----------------- |
| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | | alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 |
| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | | beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 |
| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | | gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 |
## RotationVectorResponse ## RotationVectorResponse
......
# 振动 # 振动
> ![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.
先完成此消息的编辑!
想要评论请 注册