diff --git a/en/application-dev/application-models/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md
index 4c912d5e58a1b8083ba1037cccf449dd953d245c..688eaefa4bc10723d23f880dfbb4c1502cb42053 100644
--- a/en/application-dev/application-models/accessibilityextensionability.md
+++ b/en/application-dev/application-models/accessibilityextensionability.md
@@ -12,10 +12,13 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca
This document is organized as follows:
-- [Creating an AccessibilityExtAbility File](#creating-an-accessibility-extension-service)
-- [Processing an Accessibility Event](#processing-an-accessibility-event)
-- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
-- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
+- [AccessibilityExtensionAbility Development](#accessibilityextensionability-development)
+ - [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service)
+ - [Creating a Project](#creating-a-project)
+ - [Creating an AccessibilityExtAbility File](#creating-an-accessibilityextability-file)
+ - [Processing an Accessibility Event](#processing-an-accessibility-event)
+ - [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
+ - [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
## Creating an Accessibility Extension Service
@@ -79,13 +82,13 @@ You can also process physical key events in the accessibility extension service.
## Declaring Capabilities of Accessibility Extension Services
-After developing the custom logic for an accessibility extension service, you must add the configuration information of the service to the corresponding module-level **module.json5** file in the project directory. In the file, the **srcEntrance** tag indicates the path to the accessibility extension service. Make sure the value of the **type** tag is fixed at **accessibility**. Otherwise, the connection to the service will fail.
+After developing the custom logic for an accessibility extension service, you must add the configuration information of the service to the corresponding module-level **module.json5** file in the project directory. In the file, the **srcEntry** tag indicates the path to the accessibility extension service. Make sure the value of the **type** tag is fixed at **accessibility**. Otherwise, the connection to the service will fail.
```json
"extensionAbilities": [
{
"name": "AccessibilityExtAbility",
- "srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
+ "srcEntry": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
"label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc",
"type": "accessibility",
diff --git a/en/application-dev/application-models/common-event-static-subscription.md b/en/application-dev/application-models/common-event-static-subscription.md
index 85852f5712df84107c6593160d276ed33557baf9..53e014abe38ac3f8ec89fe8a21dc9280184a280b 100644
--- a/en/application-dev/application-models/common-event-static-subscription.md
+++ b/en/application-dev/application-models/common-event-static-subscription.md
@@ -22,8 +22,6 @@ A static subscriber is started once it receives a target event published by the
You can implement service logic in the **onReceiveEvent** callback.
-
-
2. Project Configuration for a Static Subscriber
After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows:
@@ -35,12 +33,12 @@ A static subscriber is started once it receives a target event published by the
"extensionAbilities": [
{
"name": "StaticSubscriber",
- "srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts",
+ "srcEntry": "./ets/StaticSubscriber/StaticSubscriber.ts",
"description": "$string:StaticSubscriber_desc",
"icon": "$media:icon",
"label": "$string:StaticSubscriber_label",
"type": "staticSubscriber",
- "visible": true,
+ "exported": true,
"metadata": [
{
"name": "ohos.extension.staticSubscriber",
@@ -56,7 +54,7 @@ A static subscriber is started once it receives a target event published by the
Pay attention to the following fields in the JSON file:
- - **srcEntrance**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
+ - **srcEntry**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
- **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**.
diff --git a/en/application-dev/application-models/enterprise-extensionAbility.md b/en/application-dev/application-models/enterprise-extensionAbility.md
index 0038b41e5b4f654d8c7924ec1232bb342dd616cb..1c39325cbe87435189896816a17bcb9537bb80ac 100644
--- a/en/application-dev/application-models/enterprise-extensionAbility.md
+++ b/en/application-dev/application-models/enterprise-extensionAbility.md
@@ -60,15 +60,15 @@ To implement EnterpriseAdminExtensionAbility, you need to activate the device ad
};
```
-4. Register **ServiceExtensionAbility** in the [**module.json5**](../quick-start/module-configuration-file.md) file corresponding to the project module. Set **type** to **enterpriseAdmin** and **srcEntrance** to the path of the ExtensionAbility code.
+4. Register **ServiceExtensionAbility** in the [**module.json5**](../quick-start/module-configuration-file.md) file corresponding to the project module. Set **type** to **enterpriseAdmin** and **srcEntry** to the path of the ExtensionAbility code.
```ts
"extensionAbilities": [
{
"name": "ohos.samples.enterprise_admin_ext_ability",
"type": "enterpriseAdmin",
- "visible": true,
- "srcEntrance": "./ets/enterpriseextability/EnterpriseAdminAbility.ts"
+ "exported": true,
+ "srcEntry": "./ets/enterpriseextability/EnterpriseAdminAbility.ts"
}
]
```
diff --git a/en/application-dev/application-models/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md
index 8a7856f402bf30b1610521e3cf05dda7145c3509..2b3910707ecdb6f964822380a85b14857ec8fd29 100644
--- a/en/application-dev/application-models/inputmethodextentionability.md
+++ b/en/application-dev/application-models/inputmethodextentionability.md
@@ -54,7 +54,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
1. **InputMethodService.ts** file:
- In this file, add the dependency package for importing InputMethodExtensionAbility. Customize a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks.
+ In the **InputMethodService.ts** file, add the dependency package for importing InputMethodExtensionAbility. Customize a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks.
```ts
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
@@ -233,7 +233,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file.
- ```ets
+ ```ts
import { numberSourceListData, sourceListType } from './keyboardKeyData'
@Component
@@ -342,7 +342,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
}
```
- Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntrance** to the code path of the InputMethodExtensionAbility component.
+ Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component.
```ts
{
@@ -353,9 +353,9 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
"description": "inputMethod",
"icon": "$media:icon",
"name": "InputMethodExtAbility",
- "srcEntrance": "./ets/inputmethodextability/InputMethodService.ts",
+ "srcEntry": "./ets/inputmethodextability/InputMethodService.ts",
"type": "inputMethod",
- "visible": true,
+ "exported": true,
}
]
}
diff --git a/en/application-dev/quick-start/atomicService.md b/en/application-dev/quick-start/atomicService.md
index 35aca1e7a3379568cb37af53e3fc614e3d39d519..c1ab0d30f08450cc2a03ff53a4b7a57774ae10b8 100644
--- a/en/application-dev/quick-start/atomicService.md
+++ b/en/application-dev/quick-start/atomicService.md
@@ -44,7 +44,6 @@ Note that you must set the **bundleType** field to **atomicService** in the [app
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
- "distributedNotificationEnabled": true,
"targetAPIVersion": 9
}
}
@@ -78,7 +77,7 @@ Pre-loading is triggered after the first frame of the newly accessed module is r
"module": {
"name": "entry",
"type": "entry",
- "srcEntrance": "./ets/Application/MyAbilityStage.ts",
+ "srcEntry": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
@@ -98,13 +97,13 @@ Pre-loading is triggered after the first frame of the newly accessed module is r
"abilities": [
{
"name": "MainAbility",
- "srcEntrance": "./ets/MainAbility/MainAbility.ts",
+ "srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
- "visible": true,
+ "exported": true,
"skills": [
{
"entities": [
@@ -170,7 +169,7 @@ import router from '@ohos.router';
@Entry
@Component
struct Index {
- @State message: string = 'Hello World'
+ @State message: string = 'Hello World';
build() {
Row() {
@@ -200,19 +199,20 @@ struct Index {
}).catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
})
- }
- .width('100%')
+ })
+ .width('100%')
}
.height('100%')
}
+ }
}
```
The input parameter **url** of the **router.pushUrl** API is as follows:
-```ets
+```ts
'@bundle:com.example.hmservice/library/ets/pages/menu'
```
The **url** content template is as follows:
-```ets
+```ts
'@bundle:bundle name/module name/path/page file name (without the extension .ets)'
```
diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md b/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md
index d22c607252dafd01ef58ddec221372e254ed79a4..17d26d717f801b1be11d1f2d53296c081f972052 100644
--- a/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md
+++ b/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md
@@ -1,5 +1,6 @@
# app.js
+## Application Lifecycle4+
You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows:
@@ -11,7 +12,9 @@ You can implement lifecycle logic specific to your application in the **app.js**
In the following example, logs are printed only in the lifecycle functions.
-```
+
+
+```js
// app.js
export default {
onCreate() {
@@ -22,3 +25,63 @@ export default {
},
}
```
+
+## Application Object10+
+
+| Attribute | Type | Description |
+| ------ | -------- | ---------------------------------------- |
+| getApp | Function | Obtains the data object exposed in **app.js** from the page JS file. This API works globally.|
+
+> **NOTE**
+>
+> The application object is global data and occupies JS memory before the application exits. Although it facilitates data sharing between different pages, exercise caution when using it on small-system devices, whose memory is small. If they are overused, exceptions may occur due to insufficient memory when the application displays complex pages.
+
+The following is an example:
+
+Declare the application object in **app.js**.
+
+```javascript
+// app.js
+export default {
+ data: {
+ test: "by getAPP"
+ },
+ onCreate() {
+ console.info('Application onCreate');
+ },
+ onDestroy() {
+ console.info('Application onDestroy');
+ },
+};
+```
+
+Access the application object on a specific page.
+
+```javascript
+// index.js
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ if (typeof getApp !== 'undefined') {
+ var appData = getApp().data;
+ if (typeof appData !== 'undefined') {
+ this.title = appData.name; // read from app data
+ }
+ }
+ },
+ clickHandler() {
+ if (typeof getApp !== 'undefined') {
+ var appData = getApp().data;
+ if (typeof appData !== 'undefined') {
+ appData.name = this.title; // write to app data
+ }
+ }
+ }
+}
+```
+
+> **NOTE**
+>
+> To ensure that the application can run properly on an earlier version that does not support **getApp**, compatibility processing must be performed in the code. That is, before using **getApp**, check whether it is available.
diff --git a/zh-cn/application-dev/connectivity/ipc-rpc-development-guideline.md b/zh-cn/application-dev/connectivity/ipc-rpc-development-guideline.md
index 47366f9ed55ec3798ea2b465a74ca3e4b18050f0..d82d03c298cae4709b440e7d7a40db53836ee535 100755
--- a/zh-cn/application-dev/connectivity/ipc-rpc-development-guideline.md
+++ b/zh-cn/application-dev/connectivity/ipc-rpc-development-guideline.md
@@ -29,7 +29,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
external_deps = [
"ipc:ipc_single",
]
-
+
#rpc场景
external_deps = [
"ipc:ipc_core",
@@ -50,12 +50,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++
#include "iremote_broker.h"
-
+
//定义消息码
- const int TRANS_ID_PING_ABILITY = 5
-
+ const int TRANS_ID_PING_ABILITY = 5;
+
const std::string DESCRIPTOR = "test.ITestAbility";
-
+
class ITestAbility : public IRemoteBroker {
public:
// DECLARE_INTERFACE_DESCRIPTOR是必需的,入参需使用std::u16string;
@@ -71,13 +71,13 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++
#include "iability_test.h"
#include "iremote_stub.h"
-
+
class TestAbilityStub : public IRemoteStub {
public:
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
int TestPingAbility(const std::u16string &dummy) override;
};
-
+
int TestAbilityStub::OnRemoteRequest(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
@@ -98,12 +98,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++
#include "iability_server_test.h"
-
+
class TestAbility : public TestAbilityStub {
public:
int TestPingAbility(const std::u16string &dummy);
}
-
+
int TestAbility::TestPingAbility(const std::u16string &dummy) {
return 0;
}
@@ -117,7 +117,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
#include "iability_test.h"
#include "iremote_proxy.h"
#include "iremote_object.h"
-
+
class TestAbilityProxy : public IRemoteProxy {
public:
explicit TestAbilityProxy(const sptr &impl);
@@ -125,12 +125,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
private:
static inline BrokerDelegator delegator_; // 方便后续使用iface_cast宏
}
-
+
TestAbilityProxy::TestAbilityProxy(const sptr &impl)
: IRemoteProxy(impl)
{
}
-
+
int TestAbilityProxy::TestPingAbility(const std::u16string &dummy){
MessageOption option;
MessageParcel dataParcel, replyParcel;
@@ -149,7 +149,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
// 注册到本设备内
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
samgr->AddSystemAbility(saId, new TestAbility());
-
+
// 在组网场景下,会被同步到其他设备上
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
ISystemAbilityManager::SAExtraProp saExtra;
@@ -166,10 +166,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr remoteObject = samgr->GetSystemAbility(saId);
sptr testAbility = iface_cast(remoteObject); // 使用iface_cast宏转换成具体类型
-
+
// 获取其他设备注册的SA的proxy
sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
-
+
// networkId是组网场景下对应设备的标识符,可以通过GetLocalNodeDeviceInfo获取
sptr remoteObject = samgr->GetSystemAbility(saId, networkId);
sptr proxy(new TestAbilityProxy(remoteObject)); // 直接构造具体Proxy
@@ -180,59 +180,97 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
1. 添加依赖
```ts
- import rpc from "@ohos.rpc"
- import featureAbility from "@ohos.ability.featureAbility"
+ import rpc from "@ohos.rpc";
+ // 仅FA模型需要导入@ohos.ability.featureAbility
+ // import featureAbility from "@ohos.ability.featureAbility";
```
-
+ Stage模型需要获取context
+
+ ```ts
+ import Ability from "@ohos.app.ability.UIAbility";
+
+ export default class MainAbility extends Ability {
+ onCreate(want, launchParam) {
+ console.log("[Demo] MainAbility onCreate");
+ globalThis.context = this.context;
+ }
+ onDestroy() {
+ console.log("[Demo] MainAbility onDestroy");
+ }
+ onWindowStageCreate(windowStage) {
+ // Main window is created, set main page for this ability
+ console.log("[Demo] MainAbility onWindowStageCreate");
+ }
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ console.log("[Demo] MainAbility onWindowStageDestroy");
+ }
+ onForeground() {
+ // Ability has brought to foreground
+ console.log("[Demo] MainAbility onForeground");
+ }
+ onBackground() {
+ // Ability has back to background
+ console.log("[Demo] MainAbility onBackground");
+ }
+ }
+ ```
2. 绑定Ability
- 首先,构造变量want,指定要绑定的Ability所在应用的包名、组件名,如果是跨设备的场景,还需要绑定目标设备NetworkId(组网场景下对应设备的标识符,可以使用deviceManager获取目标设备的NetworkId);然后,构造变量connect,指定绑定成功、绑定失败、断开连接时的回调函数;最后,使用featureAbility提供的接口绑定Ability。
+ 首先,构造变量want,指定要绑定的Ability所在应用的包名、组件名,如果是跨设备的场景,还需要绑定目标设备NetworkId(组网场景下对应设备的标识符,可以使用deviceManager获取目标设备的NetworkId);然后,构造变量connect,指定绑定成功、绑定失败、断开连接时的回调函数;最后,FA模型使用featureAbility提供的接口绑定Ability,Stage模型通过context获取服务后用提供的接口绑定Ability。
```ts
- import rpc from "@ohos.rpc"
- import featureAbility from "@ohos.ability.featureAbility"
-
- let proxy = null
- let connectId = null
-
+ import rpc from "@ohos.rpc";
+ // 仅FA模型需要导入@ohos.ability.featureAbility
+ // import featureAbility from "@ohos.ability.featureAbility";
+
+ let proxy = null;
+ let connectId = null;
+
// 单个设备绑定Ability
let want = {
// 包名和组件名写实际的值
"bundleName": "ohos.rpc.test.server",
"abilityName": "ohos.rpc.test.server.ServiceAbility",
- }
+ };
let connect = {
onConnect:function(elementName, remote) {
- proxy = remote
+ proxy = remote;
},
onDisconnect:function(elementName) {
},
onFailed:function() {
- proxy = null
+ proxy = null;
}
- }
- connectId = featureAbility.connectAbility(want, connect)
-
+ };
+ // FA模型使用此方法连接服务
+ // connectId = featureAbility.connectAbility(want, connect);
+
+ connectId = globalThis.context.connectServiceExtensionAbility(want,connect);
+
// 如果是跨设备绑定,可以使用deviceManager获取目标设备NetworkId
- import deviceManager from '@ohos.distributedHardware.deviceManager'
+ import deviceManager from '@ohos.distributedHardware.deviceManager';
function deviceManagerCallback(deviceManager) {
- let deviceList = deviceManager.getTrustedDeviceListSync()
- let networkId = deviceList[0].networkId
+ let deviceList = deviceManager.getTrustedDeviceListSync();
+ let networkId = deviceList[0].networkId;
let want = {
"bundleName": "ohos.rpc.test.server",
"abilityName": "ohos.rpc.test.service.ServiceAbility",
"networkId": networkId,
"flags": 256
- }
- connectId = featureAbility.connectAbility(want, connect)
+ };
+ // 建立连接后返回的Id需要保存下来,在断开连接时需要作为参数传入
+ // FA模型使用此方法连接服务
+ // connectId = featureAbility.connectAbility(want, connect);
+
+ connectId = globalThis.context.connectServiceExtensionAbility(want,connect);
}
// 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数
- deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback)
+ deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback);
```
-
3. 服务端处理客户端请求
@@ -240,78 +278,80 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```ts
onConnect(want: Want) {
- var robj:rpc.RemoteObject = new Stub("rpcTestAbility")
- return robj
+ var robj:rpc.RemoteObject = new Stub("rpcTestAbility");
+ return robj;
}
class Stub extends rpc.RemoteObject {
constructor(descriptor) {
- super(descriptor)
+ super(descriptor);
}
onRemoteMessageRequest(code, data, reply, option) {
// 根据code处理客户端的请求
- return true
+ return true;
}
}
```
-
-
4. 客户端处理服务端响应
- 客户端在onConnect回调里接收到代理对象,调用sendRequestAsync方法发起请求,在期约(JavaScript期约:用于表示一个异步操作的最终完成或失败及其结果值)或者回调函数里接收结果。
+ 客户端在onConnect回调里接收到代理对象,调用sendRequest方法发起请求,在期约(JavaScript期约:用于表示一个异步操作的最终完成或失败及其结果值)或者回调函数里接收结果。
```ts
// 使用期约
- let option = new rpc.MessageOption()
- let data = rpc.MessageParcel.create()
- let reply = rpc.MessageParcel.create()
+ let option = new rpc.MessageOption();
+ let data = rpc.MessageParcel.create();
+ let reply = rpc.MessageParcel.create();
// 往data里写入参数
- proxy.sendRequestAsync(1, data, reply, option)
+ proxy.sendRequest(1, data, reply, option)
.then(function(result) {
if (result.errCode != 0) {
- console.error("send request failed, errCode: " + result.errCode)
- return
+ console.error("send request failed, errCode: " + result.errCode);
+ return;
}
// 从result.reply里读取结果
})
.catch(function(e) {
- console.error("send request got exception: " + e)
- }
+ console.error("send request got exception: " + e);
+ })
.finally(() => {
- data.reclaim()
- reply.reclaim()
+ data.reclaim();
+ reply.reclaim();
})
-
+
// 使用回调函数
function sendRequestCallback(result) {
try {
if (result.errCode != 0) {
- console.error("send request failed, errCode: " + result.errCode)
- return
+ console.error("send request failed, errCode: " + result.errCode);
+ return;
}
// 从result.reply里读取结果
} finally {
- result.data.reclaim()
- result.reply.reclaim()
+ result.data.reclaim();
+ result.reply.reclaim();
}
}
- let option = new rpc.MessageOption()
- let data = rpc.MessageParcel.create()
- let reply = rpc.MessageParcel.create()
+ let option = new rpc.MessageOption();
+ let data = rpc.MessageParcel.create();
+ let reply = rpc.MessageParcel.create();
// 往data里写入参数
- proxy.sendRequest(1, data, reply, option, sendRequestCallback)
+ proxy.sendRequest(1, data, reply, option, sendRequestCallback);
```
5. 断开连接
- IPC通信结束后,使用featureAbility的接口断开连接。
+ IPC通信结束后,FA模型使用featureAbility的接口断开连接,Stage模型在获取context后用提供的接口断开连接。
```ts
- import rpc from "@ohos.rpc"
- import featureAbility from "@ohos.ability.featureAbility"
+ import rpc from "@ohos.rpc";
+ // 仅FA模型需要导入@ohos.ability.featureAbility
+ // import featureAbility from "@ohos.ability.featureAbility";
function disconnectCallback() {
- console.info("disconnect ability done")
+ console.info("disconnect ability done");
}
- featureAbility.disconnectAbility(connectId, disconnectCallback)
+ // FA模型使用此方法断开连接
+ // featureAbility.disconnectAbility(connectId, disconnectCallback);
+
+ globalThis.context.disconnectServiceExtensionAbility(connectId);
```
diff --git a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md
index 5dbf04f2d32e2ee7bca088cbd8f0a434d0e277a3..9bae7408831c2dceffce76425c579d265fd39f2a 100755
--- a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md
+++ b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md
@@ -3,35 +3,25 @@
## 基本概念
-IPC(Inter-Process Communication)与RPC(Remote Procedure Call)用于实现跨进程通信,不同的是前者使用Binder驱动,用于设备内的跨进程通信,后者使用软总线驱动,用于跨设备跨进程通信。需要跨进程通信的原因是因为每个进程都有自己独立的资源和内存空间,其他进程不能随意访问不同进程的内存和资源,IPC/RPC便是为了突破这一点。IPC和RPC通常采用客户端-服务器(Client-Server)模型,在使用时,请求服务的(Client)一端进程可获取提供服务(Server)一端所在进程的代理(Proxy),并通过此代理读写数据来实现进程间的数据通信,更具体的讲,首先请求服务的(Client)一端会建立一个服务提供端(Server)的代理对象,这个代理对象具备和服务提供端(Server)一样的功能,若想访问服务提供端(Server)中的某一个方法,只需访问代理对象中对应的方法即可,代理对象会将请求发送给服务提供端(Server);然后服务提供端(Server)处理接受到的请求,处理完之后通过驱动返回处理结果给代理对象;最后代理对象将请求结果进一步返回给请求服务端(Client)。通常,Server会先注册系统能力(System Ability)到系统能力管理者(System Ability Manager,缩写SAMgr)中,SAMgr负责管理这些SA并向Client提供相关的接口。Client要和某个具体的SA通信,必须先从SAMgr中获取该SA的代理,然后使用代理和SA通信。下文直接使用Proxy表示服务请求方,Stub表示服务提供方。
+IPC(Inter-Process Communication)与RPC(Remote Procedure Call)用于实现跨进程通信,不同的是前者使用Binder驱动,用于设备内的跨进程通信,后者使用软总线驱动,用于跨设备跨进程通信。需要跨进程通信的原因是因为每个进程都有自己独立的资源和内存空间,其他进程不能随意访问不同进程的内存和资源,IPC/RPC便是为了突破这一点。
-
-
-
-## 约束与限制
-
-- 单个设备上跨进程通信时,传输的数据量最大约为1MB,过大的数据量请使用[匿名共享内存](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-rpc.md#ashmem8)
-
-- 不支持在RPC中订阅匿名Stub对象(没有向SAMgr注册Stub对象)的死亡通知。
-- 不支持把跨设备的Proxy对象传递回该Proxy对象所指向的Stub对象所在的设备,即指向远端设备Stub的Proxy对象不能在本设备内进行二次跨进程传递。
-
-## 使用建议
-
-首先,需要编写接口类,接口类中必须定义消息码,供通信双方标识操作,可以有未实现的的方法,因为通信双方均需继承该接口类且双方不能是抽象类,所以此时定义的未实现的方法必须在双方继承时给出实现,这保证了继承双方不是抽象类。然后,需要编写Stub端相关类及其接口,并且实现AsObject方法及OnRemoteRequest方法。同时,也需要编写Proxy端,实现接口类中的方法和AsObject方法,也可以封装一些额外的方法用于调用SendRequest向对端发送数据。以上三者都具备后,便可以向SAMgr注册SA了,此时的注册应该在Stub所在进程完成。最后,在需要的地方从SAMgr中获取Proxy,便可通过Proxy实现与Stub的跨进程通信了。
+> **说明:**
+> Stage模型不能直接使用本文介绍的IPC和RPC,需要通过以下能力实现相关业务场景:
+>- IPC典型使用场景为[后台服务](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/application-models/background-services.md),后台服务通过IPC机制提供跨进程的服务调用能力。
+>- RPC典型使用场景为[多端协同](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md),多端协同通过RPC机制提供远端接口调用与数据传递。
-相关步骤:
-- 实现接口类:需继承IRemoteBroker,需定义消息码,可声明不在此类实现的方法。
+## 实现原理
-- 实现服务提供端(Stub):需继承IRemoteStub或者RemoteObject,需重写AsObject方法及OnRemoteRequest方法。
+IPC和RPC通常采用客户端-服务器(Client-Server)模型,在使用时,请求服务的(Client)一端进程可获取提供服务(Server)一端所在进程的代理(Proxy),并通过此代理读写数据来实现进程间的数据通信,更具体的讲,首先请求服务的(Client)一端会建立一个服务提供端(Server)的代理对象,这个代理对象具备和服务提供端(Server)一样的功能,若想访问服务提供端(Server)中的某一个方法,只需访问代理对象中对应的方法即可,代理对象会将请求发送给服务提供端(Server);然后服务提供端(Server)处理接受到的请求,处理完之后通过驱动返回处理结果给代理对象;最后代理对象将请求结果进一步返回给请求服务端(Client)。通常,Server会先注册系统能力(System Ability)到系统能力管理者(System Ability Manager,缩写SAMgr)中,SAMgr负责管理这些SA并向Client提供相关的接口。Client要和某个具体的SA通信,必须先从SAMgr中获取该SA的代理,然后使用代理和SA通信。下文直接使用Proxy表示服务请求方,Stub表示服务提供方。
-- 实现服务请求端(Proxy):需继承IRemoteProxy或RemoteProxy,需重写AsObject方法,封装所需方法调用SendRequest。
+
-- 注册SA:申请SA的唯一ID,向SAMgr注册SA。
-- 获取SA:通过SA的ID和设备ID获取Proxy,使用Proxy与远端通信
+## 约束与限制
+- 单个设备上跨进程通信时,传输的数据量最大约为1MB,过大的数据量请使用[匿名共享内存](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-rpc.md#ashmem8)。
-## 相关模块
+- 不支持在RPC中订阅匿名Stub对象(没有向SAMgr注册Stub对象)的死亡通知。
-[分布式任务调度子系统](https://gitee.com/openharmony/ability_dmsfwk)
+- 不支持把跨设备的Proxy对象传递回该Proxy对象所指向的Stub对象所在的设备,即指向远端设备Stub的Proxy对象不能在本设备内进行二次跨进程传递。
\ No newline at end of file
diff --git a/zh-cn/application-dev/connectivity/subscribe-remote-state.md b/zh-cn/application-dev/connectivity/subscribe-remote-state.md
index a0d062634fde09442e14dbdcb351ab58c7656633..f53964f6908212a3bf04e89a38541fac8962fd01 100755
--- a/zh-cn/application-dev/connectivity/subscribe-remote-state.md
+++ b/zh-cn/application-dev/connectivity/subscribe-remote-state.md
@@ -1,6 +1,6 @@
# 远端状态订阅开发实例
-IPC/RPC提供对远端Stub对象状态的订阅机制, 在远端Stub对象消亡时,可触发消亡通知告诉本地Proxy对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消亡通知接口DeathRecipient并实现onRemoteDied方法清理资源。该方法会在远端Stub对象所在进程消亡或所在设备离开组网时被回调。值得注意的是,调用这些接口有一定的顺序。首先,需要Proxy订阅Stub消亡通知,若在订阅期间Stub状态正常,则在不再需要时取消订阅;若在订阅期间Stub所在进程退出或者所在设备退出组网,则会自动触发Proxy自定义的后续操作。
+IPC/RPC提供对远端Stub对象状态的订阅机制,在远端Stub对象消亡时,可触发消亡通知告诉本地Proxy对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消亡通知接口DeathRecipient并实现onRemoteDied方法清理资源。该方法会在远端Stub对象所在进程消亡或所在设备离开组网时被回调。值得注意的是,调用这些接口有一定的顺序。首先,需要Proxy订阅Stub消亡通知,若在订阅期间Stub状态正常,则在不再需要时取消订阅;若在订阅期间Stub所在进程退出或者所在设备退出组网,则会自动触发Proxy自定义的后续操作。
## 使用场景
@@ -21,7 +21,6 @@ IPC/RPC提供对远端Stub对象状态的订阅机制, 在远端Stub对象消
#include "iremote_broker.h"
#include "iremote_stub.h"
-
//定义消息码
enum {
TRANS_ID_PING_ABILITY = 5,
@@ -61,9 +60,6 @@ int TestServiceProxy::TestPingAbility(const std::u16string &dummy){
}
```
-
-
-
```c++
#include "iremote_object.h"
@@ -86,16 +82,52 @@ result = object->RemoveDeathRecipient(deathRecipient); // 移除消亡通知
## JS侧接口
-| 接口名 | 返回值类型 | 功能描述 |
-| -------------------- | ---------- | ------------------------------------------------------------ |
-| addDeathRecippient | boolean | 注册用于接收远程对象消亡通知的回调,增加proxy对象上的消亡通知。 |
-| removeDeathRecipient | boolean | 注销用于接收远程对象消亡通知的回调。 |
-| onRemoteDied | void | 在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 |
+| 接口名 | 返回值类型 | 功能描述 |
+| ------------------------ | ---------- | ----------------------------------------------------------------- |
+| registerDeathRecipient | void | 注册用于接收远程对象消亡通知的回调,增加 proxy 对象上的消亡通知。 |
+| unregisterDeathRecipient | void | 注销用于接收远程对象消亡通知的回调。 |
+| onRemoteDied | void | 在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 |
+
+### 获取context
+
+Stage模型在连接服务前需要先获取context
+
+```ts
+import Ability from "@ohos.app.ability.UIAbility";
+
+export default class MainAbility extends Ability {
+ onCreate(want, launchParam) {
+ console.log("[Demo] MainAbility onCreate");
+ globalThis.context = this.context;
+ }
+ onDestroy() {
+ console.log("[Demo] MainAbility onDestroy");
+ }
+ onWindowStageCreate(windowStage) {
+ // Main window is created, set main page for this ability
+ console.log("[Demo] MainAbility onWindowStageCreate");
+ }
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ console.log("[Demo] MainAbility onWindowStageDestroy");
+ }
+ onForeground() {
+ // Ability has brought to foreground
+ console.log("[Demo] MainAbility onForeground");
+ }
+ onBackground() {
+ // Ability has back to background
+ console.log("[Demo] MainAbility onBackground");
+ }
+}
+```
### 参考代码
```ts
-import FA from "@ohos.ability.featureAbility";
+// 仅FA模型需要导入@ohos.ability.featureAbility
+// import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -113,15 +145,19 @@ let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-FA.connectAbility(want, connect);
+// FA模型通过此方法连接服务
+// FA.connectAbility(want, connect);
+
+globalThis.context.connectServiceExtensionAbility(want, connect);
+
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
}
}
let deathRecipient = new MyDeathRecipient();
-proxy.addDeathRecippient(deathRecipient, 0);
-proxy.removeDeathRecipient(deathRecipient, 0);
+proxy.registerDeathRecippient(deathRecipient, 0);
+proxy.unregisterDeathRecipient(deathRecipient, 0);
```
## Stub感知Proxy消亡(匿名Stub的使用)
diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md
index ec0d5179d0f51a11ffa3c7564081866c74874355..53f759e0f81872b4f21e6dbb30a938f291fa846c 100644
--- a/zh-cn/application-dev/device/usb-guidelines.md
+++ b/zh-cn/application-dev/device/usb-guidelines.md
@@ -167,4 +167,4 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
针对USB管理开发,有以下相关实例可供参考:
-- [`USBManager`:USB管理(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/DeviceManagement/USBManager)
\ No newline at end of file
+- [`DeviceManagementCollection`:设备管理合集(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/DeviceManagement/DeviceManagementCollection)
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
index 3a68b140fdda82a68efba233440edfe60117d6fd..22e2fd481fed190b88ee82b92d27a9acca1c9b43 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
@@ -73,7 +73,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
try {
- atManager.checkAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
+ atManager.checkAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`checkAccessToken success, data->${JSON.stringify(data)}`);
}).catch((err) => {
console.log(`checkAccessToken fail, err->${JSON.stringify(err)}`);
@@ -117,7 +117,7 @@ verifyAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus
```js
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
-let data = atManager.verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
+let data = atManager.verifyAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`);
```
@@ -168,7 +168,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let permissionFlags = 1;
try {
- atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
+ atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('grantUserGrantedPermission success');
}).catch((err) => {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
@@ -220,7 +220,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let permissionFlags = 1;
try {
- atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
+ atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -279,7 +279,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let permissionFlags = 1;
try {
- atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
+ atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('revokeUserGrantedPermission success');
}).catch((err) => {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
@@ -331,7 +331,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let permissionFlags = 1;
try {
- atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
+ atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -388,7 +388,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
try {
- atManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
+ atManager.getPermissionFlags(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`);
}).catch((err) => {
console.log(`getPermissionFlags fail, err->${JSON.stringify(err)}`);
@@ -466,10 +466,10 @@ import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array = [appInfo.accessTokenId];
-let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
+let permissionList: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try {
atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => {
- console.debug("receive permission state change, data:" + JSON.stringify(data));
+ console.debug('receive permission state change, data:' + JSON.stringify(data));
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
@@ -504,7 +504,7 @@ off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionL
| 错误码ID | 错误信息 |
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. |
-| 12100004 | The interface is not used together with "on". |
+| 12100004 | The interface is not used together with 'on'. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
@@ -517,7 +517,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array = [appInfo.accessTokenId];
-let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
+let permissionList: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try {
atManager.off('permissionStateChange', tokenIDList, permissionList);
} catch(err) {
@@ -557,7 +557,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
-let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
+let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
@@ -598,10 +598,10 @@ requestPermissionsFromUser(context: Context, permissionList: Array<Permission
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
- atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"], (err, data)=>{
- console.info("data:" + JSON.stringify(data));
- console.info("data permissions:" + data.permissions);
- console.info("data authResults:" + data.authResults);
+ atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
+ console.info('data:' + JSON.stringify(data));
+ console.info('data permissions:' + data.permissions);
+ console.info('data authResults:' + data.authResults);
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
@@ -649,12 +649,12 @@ requestPermissionsFromUser(context: Context, permissionList: Array<Permission
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
try {
- atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => {
- console.info("data:" + JSON.stringify(data));
- console.info("data permissions:" + data.permissions);
- console.info("data authResults:" + data.authResults);
+ atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA']).then((data) => {
+ console.info('data:' + JSON.stringify(data));
+ console.info('data permissions:' + data.permissions);
+ console.info('data authResults:' + data.authResults);
}).catch((err) => {
- console.info("data:" + JSON.stringify(err));
+ console.info('data:' + JSON.stringify(err));
})
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
@@ -693,7 +693,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
-let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
+let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
@@ -733,7 +733,7 @@ checkAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus;
```js
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
-let data = atManager.checkAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
+let data = atManager.checkAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`);
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
index 7724c86ea73f651548df234412f36e20f3c33cf2..bab624aa746f57dfa3f19d27702df8d62389d046 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
@@ -65,11 +65,11 @@ createAccount(name: string, callback: AsyncCallback<void>): void;
```js
try {
- appAccountManager.createAccount("WangWu", (err) => {
- console.log("createAccount err: " + JSON.stringify(err));
+ appAccountManager.createAccount('WangWu', (err) => {
+ console.log('createAccount err: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("createAccount err: " + JSON.stringify(err));
+ console.log('createAccount err: ' + JSON.stringify(err));
}
```
@@ -103,19 +103,19 @@ createAccount(name: string, options: CreateAccountOptions, callback: AsyncCallba
```js
let options = {
customData: {
- "age": "10"
+ 'age': '10'
}
}
try {
- appAccountManager.createAccount("LiSi", options, (err) => {
+ appAccountManager.createAccount('LiSi', options, (err) => {
if (err) {
- console.log("createAccount failed, error: " + JSON.stringify(err));
+ console.log('createAccount failed, error: ' + JSON.stringify(err));
} else {
- console.log("createAccount successfully");
+ console.log('createAccount successfully');
}
});
} catch(err) {
- console.log("createAccount exception: " + JSON.stringify(err));
+ console.log('createAccount exception: ' + JSON.stringify(err));
}
```
@@ -154,17 +154,17 @@ createAccount(name: string, options?: CreateAccountOptions): Promise<void>
```js
let options = {
customData: {
- "age": "10"
+ 'age': '10'
}
}
try {
- appAccountManager.createAccount("LiSi", options).then(() => {
- console.log("createAccount successfully");
+ appAccountManager.createAccount('LiSi', options).then(() => {
+ console.log('createAccount successfully');
}).catch((err) => {
- console.log("createAccount failed, error: " + JSON.stringify(err));
+ console.log('createAccount failed, error: ' + JSON.stringify(err));
});
} catch(err) {
- console.log("createAccount exception: " + JSON.stringify(err));
+ console.log('createAccount exception: ' + JSON.stringify(err));
}
```
@@ -198,8 +198,8 @@ createAccountImplicitly(owner: string, callback: AuthCallback): void
```js
function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ console.log('resultCode: ' + code);
+ console.log('result: ' + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
@@ -210,19 +210,19 @@ createAccountImplicitly(owner: string, callback: AuthCallback): void
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
try {
- appAccountManager.createAccountImplicitly("com.example.accountjsdemo", {
+ appAccountManager.createAccountImplicitly('com.example.accountjsdemo', {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
} catch (err) {
- console.log("createAccountImplicitly exception: " + JSON.stringify(err));
+ console.log('createAccountImplicitly exception: ' + JSON.stringify(err));
}
```
@@ -257,8 +257,8 @@ createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions,
```js
function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ console.log('resultCode: ' + code);
+ console.log('result: ' + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
@@ -269,23 +269,23 @@ createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions,
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
let options = {
- authType: "getSocialData",
- requiredLabels: [ "student" ]
+ authType: 'getSocialData',
+ requiredLabels: [ 'student' ]
};
try {
- appAccountManager.createAccountImplicitly("com.example.accountjsdemo", options, {
+ appAccountManager.createAccountImplicitly('com.example.accountjsdemo', options, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
} catch (err) {
- console.log("createAccountImplicitly exception: " + JSON.stringify(err));
+ console.log('createAccountImplicitly exception: ' + JSON.stringify(err));
}
```
@@ -316,15 +316,15 @@ removeAccount(name: string, callback: AsyncCallback<void>): void
```js
try {
- appAccountManager.removeAccount("ZhaoLiu", (err) => {
+ appAccountManager.removeAccount('ZhaoLiu', (err) => {
if (err) {
- console.log("removeAccount failed, error: " + JSON.stringify(err));
+ console.log('removeAccount failed, error: ' + JSON.stringify(err));
} else {
- console.log("removeAccount successfully");
+ console.log('removeAccount successfully');
}
});
} catch(err) {
- console.log("removeAccount exception: " + JSON.stringify(err));
+ console.log('removeAccount exception: ' + JSON.stringify(err));
}
```
@@ -360,13 +360,13 @@ removeAccount(name: string): Promise<void>
```js
try {
- appAccountManager.removeAccount("Lisi").then(() => {
- console.log("removeAccount successfully");
+ appAccountManager.removeAccount('Lisi').then(() => {
+ console.log('removeAccount successfully');
}).catch((err) => {
- console.log("removeAccount failed, error: " + JSON.stringify(err));
+ console.log('removeAccount failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("removeAccount exception: " + JSON.stringify(err));
+ console.log('removeAccount exception: ' + JSON.stringify(err));
}
```
@@ -400,15 +400,15 @@ setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback:
```js
try {
- appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true, (err) => {
+ appAccountManager.setAppAccess('ZhangSan', 'com.example.accountjsdemo', true, (err) => {
if (err) {
- console.log("setAppAccess failed: " + JSON.stringify(err));
+ console.log('setAppAccess failed: ' + JSON.stringify(err));
} else {
- console.log("setAppAccess successfully");
+ console.log('setAppAccess successfully');
}
});
} catch (err) {
- console.log("setAppAccess exception: " + JSON.stringify(err));
+ console.log('setAppAccess exception: ' + JSON.stringify(err));
}
```
@@ -447,13 +447,13 @@ setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise&l
```js
try {
- appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true).then(() => {
- console.log("setAppAccess successfully");
+ appAccountManager.setAppAccess('ZhangSan', 'com.example.accountjsdemo', true).then(() => {
+ console.log('setAppAccess successfully');
}).catch((err) => {
- console.log("setAppAccess failed: " + JSON.stringify(err));
+ console.log('setAppAccess failed: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setAppAccess exception: " + JSON.stringify(err));
+ console.log('setAppAccess exception: ' + JSON.stringify(err));
}
```
@@ -485,15 +485,15 @@ checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<bool
```js
try {
- appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo", (err, isAccessible) => {
+ appAccountManager.checkAppAccess('ZhangSan', 'com.example.accountjsdemo', (err, isAccessible) => {
if (err) {
- console.log("checkAppAccess failed, error: " + JSON.stringify(err));
+ console.log('checkAppAccess failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkAppAccess successfully");
+ console.log('checkAppAccess successfully');
}
});
} catch (err) {
- console.log("checkAppAccess exception: " + JSON.stringify(err));
+ console.log('checkAppAccess exception: ' + JSON.stringify(err));
}
```
@@ -530,13 +530,13 @@ checkAppAccess(name: string, bundleName: string): Promise<boolean>
```js
try {
- appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo").then((isAccessible) => {
- console.log("checkAppAccess successfully, isAccessible: " + isAccessible);
+ appAccountManager.checkAppAccess('ZhangSan', 'com.example.accountjsdemo').then((isAccessible) => {
+ console.log('checkAppAccess successfully, isAccessible: ' + isAccessible);
}).catch((err) => {
- console.log("checkAppAccess failed, error: " + JSON.stringify(err));
+ console.log('checkAppAccess failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("checkAppAccess exception: " + JSON.stringify(err));
+ console.log('checkAppAccess exception: ' + JSON.stringify(err));
}
```
@@ -570,11 +570,11 @@ setDataSyncEnabled(name: string, isEnabled: boolean, callback: AsyncCallback<
```js
try {
- appAccountManager.setDataSyncEnabled("ZhangSan", true, (err) => {
- console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ appAccountManager.setDataSyncEnabled('ZhangSan', true, (err) => {
+ console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
}
```
@@ -613,13 +613,13 @@ setDataSyncEnabled(name: string, isEnabled: boolean): Promise<void>
```js
try {
- appAccountManager .setDataSyncEnabled("ZhangSan", true).then(() => {
+ appAccountManager .setDataSyncEnabled('ZhangSan', true).then(() => {
console.log('setDataSyncEnabled Success');
}).catch((err) => {
- console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
}
```
@@ -652,15 +652,15 @@ checkDataSyncEnabled(name: string, callback: AsyncCallback<boolean>): void
```js
try {
- appAccountManager.checkDataSyncEnabled("ZhangSan", (err, isEnabled) => {
+ appAccountManager.checkDataSyncEnabled('ZhangSan', (err, isEnabled) => {
if (err) {
- console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err));
+ console.log('checkDataSyncEnabled failed, err: ' + JSON.stringify(err));
} else {
console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled);
}
});
} catch (err) {
- console.log("checkDataSyncEnabled err: " + JSON.stringify(err));
+ console.log('checkDataSyncEnabled err: ' + JSON.stringify(err));
}
```
@@ -698,13 +698,13 @@ checkDataSyncEnabled(name: string): Promise<boolean>
```js
try {
- appAccountManager.checkDataSyncEnabled("ZhangSan").then((isEnabled) => {
- console.log("checkDataSyncEnabled successfully, isEnabled: " + isEnabled);
+ appAccountManager.checkDataSyncEnabled('ZhangSan').then((isEnabled) => {
+ console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => {
- console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err));
+ console.log('checkDataSyncEnabled failed, err: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("checkDataSyncEnabled err: " + JSON.stringify(err));
+ console.log('checkDataSyncEnabled err: ' + JSON.stringify(err));
}
```
@@ -737,15 +737,15 @@ setCredential(name: string, credentialType: string, credential: string,callback:
```js
try {
- appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx", (err) => {
+ appAccountManager.setCredential('ZhangSan', 'PIN_SIX', 'xxxxxx', (err) => {
if (err) {
- console.log("setCredential failed, error: " + JSON.stringify(err));
+ console.log('setCredential failed, error: ' + JSON.stringify(err));
} else {
- console.log("setCredential successfully");
+ console.log('setCredential successfully');
}
});
} catch (err) {
- console.log("setCredential exception: " + JSON.stringify(err));
+ console.log('setCredential exception: ' + JSON.stringify(err));
}
```
@@ -783,13 +783,13 @@ setCredential(name: string, credentialType: string, credential: string): Promise
```js
try {
- appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx").then(() => {
- console.log("setCredential successfully");
+ appAccountManager.setCredential('ZhangSan', 'PIN_SIX', 'xxxxxx').then(() => {
+ console.log('setCredential successfully');
}).catch((err) => {
- console.log("setCredential failed, error: " + JSON.stringify(err));
+ console.log('setCredential failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setCredential exception: " + JSON.stringify(err));
+ console.log('setCredential exception: ' + JSON.stringify(err));
}
```
@@ -822,15 +822,15 @@ getCredential(name: string, credentialType: string, callback: AsyncCallback<s
```js
try {
- appAccountManager.getCredential("ZhangSan", "PIN_SIX", (err, result) => {
+ appAccountManager.getCredential('ZhangSan', 'PIN_SIX', (err, result) => {
if (err) {
- console.log("getCredential failed, error: " + JSON.stringify(err));
+ console.log('getCredential failed, error: ' + JSON.stringify(err));
} else {
console.log('getCredential successfully, result: ' + result);
}
});
} catch (err) {
- console.log("getCredential err: " + JSON.stringify(err));
+ console.log('getCredential err: ' + JSON.stringify(err));
}
```
@@ -868,13 +868,13 @@ getCredential(name: string, credentialType: string): Promise<string>
```js
try {
- appAccountManager.getCredential("ZhangSan", "PIN_SIX").then((credential) => {
- console.log("getCredential successfully, credential: " + credential);
+ appAccountManager.getCredential('ZhangSan', 'PIN_SIX').then((credential) => {
+ console.log('getCredential successfully, credential: ' + credential);
}).catch((err) => {
- console.log("getCredential failed, error: " + JSON.stringify(err));
+ console.log('getCredential failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getCredential exception: " + JSON.stringify(err));
+ console.log('getCredential exception: ' + JSON.stringify(err));
}
```
@@ -908,15 +908,15 @@ setCustomData(name: string, key: string, value: string, callback: AsyncCallback&
```js
try {
- appAccountManager.setCustomData("ZhangSan", "age", "12", (err) => {
+ appAccountManager.setCustomData('ZhangSan', 'age', '12', (err) => {
if (err) {
- console.log("setCustomData failed, error: " + JSON.stringify(err));
+ console.log('setCustomData failed, error: ' + JSON.stringify(err));
} else {
- console.log("setCustomData successfully");
+ console.log('setCustomData successfully');
}
});
} catch (err) {
- console.log("setCustomData exception: " + JSON.stringify(err));
+ console.log('setCustomData exception: ' + JSON.stringify(err));
}
```
@@ -955,13 +955,13 @@ setCustomData(name: string, key: string, value: string): Promise<void>
```js
try {
- appAccountManager.setCustomData("ZhangSan", "age", "12").then(() => {
- console.log("setCustomData successfully");
+ appAccountManager.setCustomData('ZhangSan', 'age', '12').then(() => {
+ console.log('setCustomData successfully');
}).catch((err) => {
- console.log("setCustomData failed, error: " + JSON.stringify(err));
+ console.log('setCustomData failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setCustomData exception: " + JSON.stringify(err));
+ console.log('setCustomData exception: ' + JSON.stringify(err));
}
```
@@ -994,15 +994,15 @@ getCustomData(name: string, key: string, callback: AsyncCallback<string>):
```js
try {
- appAccountManager.getCustomData("ZhangSan", "age", (err, data) => {
+ appAccountManager.getCustomData('ZhangSan', 'age', (err, data) => {
if (err) {
console.log('getCustomData failed, error: ' + err);
} else {
- console.log("getCustomData successfully, data: " + data);
+ console.log('getCustomData successfully, data: ' + data);
}
});
} catch (err) {
- console.log("getCustomData exception: " + JSON.stringify(err));
+ console.log('getCustomData exception: ' + JSON.stringify(err));
}
```
@@ -1040,13 +1040,13 @@ getCustomData(name: string, key: string): Promise<string>
```js
try {
- appAccountManager.getCustomData("ZhangSan", "age").then((data) => {
- console.log("getCustomData successfully, data: " + data);
+ appAccountManager.getCustomData('ZhangSan', 'age').then((data) => {
+ console.log('getCustomData successfully, data: ' + data);
}).catch((err) => {
- console.log("getCustomData failed, error: " + JSON.stringify(err));
+ console.log('getCustomData failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getCustomData exception: " + JSON.stringify(err));
+ console.log('getCustomData exception: ' + JSON.stringify(err));
}
```
@@ -1084,10 +1084,10 @@ getCustomDataSync(name: string, key: string): string;
```js
try {
- let value = appAccountManager.getCustomDataSync("ZhangSan", "age");
- console.info("getCustomDataSync successfully, vaue:" + value);
+ let value = appAccountManager.getCustomDataSync('ZhangSan', 'age');
+ console.info('getCustomDataSync successfully, vaue: ' + value);
} catch (err) {
- console.error("getCustomDataSync failed, error: " + JSON.stringify(err));
+ console.error('getCustomDataSync failed, error: ' + JSON.stringify(err));
}
```
@@ -1117,13 +1117,13 @@ getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
try {
appAccountManager.getAllAccounts((err, data) => {
if (err) {
- console.debug("getAllAccounts failed, error:" + JSON.stringify(err));
+ console.debug('getAllAccounts failed, error: ' + JSON.stringify(err));
} else {
- console.debug("getAllAccounts successfully");
+ console.debug('getAllAccounts successfully');
}
});
} catch (err) {
- console.debug("getAllAccounts exception: " + JSON.stringify(err));
+ console.debug('getAllAccounts exception: ' + JSON.stringify(err));
}
```
@@ -1152,12 +1152,12 @@ getAllAccounts(): Promise<Array<AppAccountInfo>>
```js
try {
appAccountManager.getAllAccounts().then((data) => {
- console.debug("getAllAccounts successfully");
+ console.debug('getAllAccounts successfully');
}).catch((err) => {
- console.debug("getAllAccounts failed, error:" + JSON.stringify(err));
+ console.debug('getAllAccounts failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.debug("getAllAccounts exception: " + JSON.stringify(err));
+ console.debug('getAllAccounts exception: ' + JSON.stringify(err));
}
```
@@ -1188,15 +1188,15 @@ getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccount
```js
try {
- appAccountManager.getAccountsByOwner("com.example.accountjsdemo2", (err, data) => {
+ appAccountManager.getAccountsByOwner('com.example.accountjsdemo2', (err, data) => {
if (err) {
- console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err));
+ console.debug('getAccountsByOwner failed, error:' + JSON.stringify(err));
} else {
- console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data));
+ console.debug('getAccountsByOwner successfully, data:' + JSON.stringify(data));
}
});
} catch (err) {
- console.debug("getAccountsByOwner exception:" + JSON.stringify(err));
+ console.debug('getAccountsByOwner exception:' + JSON.stringify(err));
}
```
@@ -1232,13 +1232,13 @@ getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>>
```js
try {
- appAccountManager.getAccountsByOwner("com.example.accountjsdemo2").then((data) => {
- console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data));
+ appAccountManager.getAccountsByOwner('com.example.accountjsdemo2').then((data) => {
+ console.debug('getAccountsByOwner successfully, data: ' + JSON.stringify(data));
}).catch((err) => {
- console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err));
+ console.debug('getAccountsByOwner failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.debug("getAccountsByOwner exception:" + JSON.stringify(err));
+ console.debug('getAccountsByOwner exception: ' + JSON.stringify(err));
}
```
@@ -1270,12 +1270,12 @@ on(type: 'accountChange', owners: Array<string>, callback: Callback<Arr
```js
function changeOnCallback(data){
- console.log("receive change data:" + JSON.stringify(data));
+ console.log('receive change data:' + JSON.stringify(data));
}
try{
- appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback);
+ appAccountManager.on('accountChange', ['com.example.actsaccounttest'], changeOnCallback);
} catch(err) {
- console.error("on accountChange failed, error:" + JSON.stringify(err));
+ console.error('on accountChange failed, error:' + JSON.stringify(err));
}
```
@@ -1305,18 +1305,18 @@ off(type: 'accountChange', callback?: Callback<Array<AppAccountInfo>>
```js
function changeOnCallback(data) {
- console.log("receive change data:" + JSON.stringify(data));
+ console.log('receive change data:' + JSON.stringify(data));
}
try{
- appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback);
+ appAccountManager.on('accountChange', ['com.example.actsaccounttest'], changeOnCallback);
} catch(err) {
- console.error("on accountChange failed, error:" + JSON.stringify(err));
+ console.error('on accountChange failed, error:' + JSON.stringify(err));
}
try{
appAccountManager.off('accountChange', changeOnCallback);
}
catch(err){
- console.error("off accountChange failed, error:" + JSON.stringify(err));
+ console.error('off accountChange failed, error:' + JSON.stringify(err));
}
```
@@ -1354,8 +1354,8 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi
function onResultCallback(code, authResult) {
- console.log("resultCode: " + code);
- console.log("authResult: " + JSON.stringify(authResult));
+ console.log('resultCode: ' + code);
+ console.log('authResult: ' + JSON.stringify(authResult));
}
function onRequestRedirectedCallback(request) {
@@ -1366,19 +1366,19 @@ auth(name: string, owner: string, authType: string, callback: AuthCallback): voi
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
try {
- appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", {
+ appAccountManager.auth('LiSi', 'com.example.accountjsdemo', 'getSocialData', {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
} catch (err) {
- console.log("auth exception: " + JSON.stringify(err));
+ console.log('auth exception: ' + JSON.stringify(err));
}
```
@@ -1417,8 +1417,8 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj
function onResultCallback(code, authResult) {
- console.log("resultCode: " + code);
- console.log("authResult: " + JSON.stringify(authResult));
+ console.log('resultCode: ' + code);
+ console.log('authResult: ' + JSON.stringify(authResult));
}
function onRequestRedirectedCallback(request) {
@@ -1429,22 +1429,22 @@ auth(name: string, owner: string, authType: string, options: {[key: string]: Obj
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
let options = {
- "password": "xxxx",
+ 'password': 'xxxx',
};
try {
- appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", options, {
+ appAccountManager.auth('LiSi', 'com.example.accountjsdemo', 'getSocialData', options, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
} catch (err) {
- console.log("auth exception: " + JSON.stringify(err));
+ console.log('auth exception: ' + JSON.stringify(err));
}
```
@@ -1478,15 +1478,15 @@ getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallb
```js
try {
- appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, token) => {
+ appAccountManager.getAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', (err, token) => {
if (err) {
- console.log("getAuthToken failed, error: " + JSON.stringify(err));
+ console.log('getAuthToken failed, error: ' + JSON.stringify(err));
} else {
- console.log("getAuthToken successfully, token: " + token);
+ console.log('getAuthToken successfully, token: ' + token);
}
});
} catch (err) {
- console.log("getAuthToken exception: " + JSON.stringify(err));
+ console.log('getAuthToken exception: ' + JSON.stringify(err));
}
```
@@ -1525,13 +1525,13 @@ getAuthToken(name: string, owner: string, authType: string): Promise<string&g
```js
try {
- appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((token) => {
- console.log("getAuthToken successfully, token: " + token);
+ appAccountManager.getAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData').then((token) => {
+ console.log('getAuthToken successfully, token: ' + token);
}).catch((err) => {
- console.log("getAuthToken failed, error: " + JSON.stringify(err));
+ console.log('getAuthToken failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getAuthToken exception: " + JSON.stringify(err));
+ console.log('getAuthToken exception: ' + JSON.stringify(err));
}
```
@@ -1565,11 +1565,11 @@ setAuthToken(name: string, authType: string, token: string, callback: AsyncCallb
```js
try {
- appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
+ appAccountManager.setAuthToken('LiSi', 'getSocialData', 'xxxx', (err) => {
if (err) {
- console.log("setAuthToken failed, error: " + JSON.stringify(err));
+ console.log('setAuthToken failed, error: ' + JSON.stringify(err));
} else {
- console.log("setAuthToken successfully");
+ console.log('setAuthToken successfully');
}
});
} catch (err) {
@@ -1612,13 +1612,13 @@ setAuthToken(name: string, authType: string, token: string): Promise<void>
```js
try {
- appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
- console.log("setAuthToken successfully");
+ appAccountManager.setAuthToken('LiSi', 'getSocialData', 'xxxx').then(() => {
+ console.log('setAuthToken successfully');
}).catch((err) => {
- console.log("setAuthToken failed, error: " + JSON.stringify(err));
+ console.log('setAuthToken failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setAuthToken exception: " + JSON.stringify(err));
+ console.log('setAuthToken exception: ' + JSON.stringify(err));
}
```
@@ -1653,11 +1653,11 @@ deleteAuthToken(name: string, owner: string, authType: string, token: string, ca
```js
try {
- appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => {
+ appAccountManager.deleteAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx', (err) => {
if (err) {
console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
} else {
- console.log("deleteAuthToken successfully");
+ console.log('deleteAuthToken successfully');
}
});
} catch (err) {
@@ -1701,8 +1701,8 @@ deleteAuthToken(name: string, owner: string, authType: string, token: string): P
```js
try {
- appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => {
- console.log("deleteAuthToken successfully");
+ appAccountManager.deleteAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx').then(() => {
+ console.log('deleteAuthToken successfully');
}).catch((err) => {
console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
});
@@ -1744,15 +1744,15 @@ setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVis
```js
try {
- appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => {
+ appAccountManager.setAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true, (err) => {
if (err) {
- console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ console.log('setAuthTokenVisibility failed, error: ' + JSON.stringify(err));
} else {
- console.log("setAuthTokenVisibility successfully");
+ console.log('setAuthTokenVisibility successfully');
}
});
} catch (err) {
- console.log("setAuthTokenVisibility exception: " + JSON.stringify(err));
+ console.log('setAuthTokenVisibility exception: ' + JSON.stringify(err));
}
```
@@ -1794,13 +1794,13 @@ setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVis
```js
try {
- appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => {
- console.log("setAuthTokenVisibility successfully");
+ appAccountManager.setAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true).then(() => {
+ console.log('setAuthTokenVisibility successfully');
}).catch((err) => {
- console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ console.log('setAuthTokenVisibility failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("setAuthTokenVisibility exception: " + JSON.stringify(err));
+ console.log('setAuthTokenVisibility exception: ' + JSON.stringify(err));
}
```
@@ -1834,15 +1834,15 @@ checkAuthTokenVisibility(name: string, authType: string, bundleName: string, cal
```js
try {
- appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, isVisible) => {
+ appAccountManager.checkAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', (err, isVisible) => {
if (err) {
- console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ console.log('checkAuthTokenVisibility failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible);
+ console.log('checkAuthTokenVisibility successfully, isVisible: ' + isVisible);
}
});
} catch (err) {
- console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err));
+ console.log('checkAuthTokenVisibility exception: ' + JSON.stringify(err));
}
```
@@ -1881,13 +1881,13 @@ checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Pr
```js
try {
- appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((isVisible) => {
- console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible);
+ appAccountManager.checkAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo').then((isVisible) => {
+ console.log('checkAuthTokenVisibility successfully, isVisible: ' + isVisible);
}).catch((err) => {
- console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ console.log('checkAuthTokenVisibility failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err));
+ console.log('checkAuthTokenVisibility exception: ' + JSON.stringify(err));
}
```
@@ -1919,15 +1919,15 @@ getAllAuthTokens(name: string, owner: string, callback: AsyncCallback<Array&l
```js
try {
- appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo", (err, tokenArr) => {
+ appAccountManager.getAllAuthTokens('LiSi', 'com.example.accountjsdemo', (err, tokenArr) => {
if (err) {
- console.log("getAllAuthTokens failed, error: " + JSON.stringify(err));
+ console.log('getAllAuthTokens failed, error: ' + JSON.stringify(err));
} else {
console.log('getAllAuthTokens successfully, tokenArr: ' + tokenArr);
}
});
} catch (err) {
- console.log("getAllAuthTokens exception: " + JSON.stringify(err));
+ console.log('getAllAuthTokens exception: ' + JSON.stringify(err));
}
```
@@ -1964,13 +1964,13 @@ getAllAuthTokens(name: string, owner: string): Promise<Array<AuthTokenInfo
```js
try {
- appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo").then((tokenArr) => {
+ appAccountManager.getAllAuthTokens('LiSi', 'com.example.accountjsdemo').then((tokenArr) => {
console.log('getAllAuthTokens successfully, tokenArr: ' + JSON.stringify(tokenArr));
}).catch((err) => {
- console.log("getAllAuthTokens failed, error: " + JSON.stringify(err));
+ console.log('getAllAuthTokens failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getAllAuthTokens exception: " + JSON.stringify(err));
+ console.log('getAllAuthTokens exception: ' + JSON.stringify(err));
}
```
@@ -2003,11 +2003,11 @@ getAuthList(name: string, authType: string, callback: AsyncCallback<Array<
```js
try {
- appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData", (err, authList) => {
+ appAccountManager.getAuthList('LiSi', 'getSocialData', (err, authList) => {
if (err) {
- console.log("getAuthList failed, error: " + JSON.stringify(err));
+ console.log('getAuthList failed, error: ' + JSON.stringify(err));
} else {
- console.log("getAuthList successfully, authList: " + authList);
+ console.log('getAuthList successfully, authList: ' + authList);
}
});
} catch (err) {
@@ -2049,13 +2049,13 @@ getAuthList(name: string, authType: string): Promise<Array<string>>
```js
try {
- appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData").then((authList) => {
- console.log("getAuthList successfully, authList: " + authList);
+ appAccountManager.getAuthList('LiSi', 'getSocialData').then((authList) => {
+ console.log('getAuthList successfully, authList: ' + authList);
}).catch((err) => {
- console.log("getAuthList failed, error: " + JSON.stringify(err));
+ console.log('getAuthList failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getAuthList exception: " + JSON.stringify(err));
+ console.log('getAuthList exception: ' + JSON.stringify(err));
}
```
@@ -2093,23 +2093,23 @@ getAuthCallback(sessionId: string, callback: AsyncCallback<AuthCallback>):
try {
appAccountManager.getAuthCallback(sessionId, (err, callback) => {
if (err != null) {
- console.log("getAuthCallback err: " + JSON.stringify(err));
+ console.log('getAuthCallback err: ' + JSON.stringify(err));
return;
}
var result = {
accountInfo: {
- name: "Lisi",
- owner: "com.example.accountjsdemo",
+ name: 'Lisi',
+ owner: 'com.example.accountjsdemo',
},
tokenInfo: {
- token: "xxxxxx",
- authType: "getSocialData"
+ token: 'xxxxxx',
+ authType: 'getSocialData'
}
};
callback.onResult(0, result);
});
} catch (err) {
- console.log("getAuthCallback exception: " + JSON.stringify(err));
+ console.log('getAuthCallback exception: ' + JSON.stringify(err));
}
}
}
@@ -2155,20 +2155,20 @@ getAuthCallback(sessionId: string): Promise<AuthCallback>
appAccountManager.getAuthCallback(sessionId).then((callback) => {
var result = {
accountInfo: {
- name: "Lisi",
- owner: "com.example.accountjsdemo",
+ name: 'Lisi',
+ owner: 'com.example.accountjsdemo',
},
tokenInfo: {
- token: "xxxxxx",
- authType: "getSocialData"
+ token: 'xxxxxx',
+ authType: 'getSocialData'
}
};
callback.onResult(0, result);
}).catch((err) => {
- console.log("getAuthCallback err: " + JSON.stringify(err));
+ console.log('getAuthCallback err: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getAuthCallback exception: " + JSON.stringify(err));
+ console.log('getAuthCallback exception: ' + JSON.stringify(err));
}
}
}
@@ -2201,15 +2201,15 @@ queryAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorIn
```js
try {
- appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo", (err, info) => {
+ appAccountManager.queryAuthenticatorInfo('com.example.accountjsdemo', (err, info) => {
if (err) {
- console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err));
+ console.log('queryAuthenticatorInfo failed, error: ' + JSON.stringify(err));
} else {
console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info));
}
});
} catch (err) {
- console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err));
+ console.log('queryAuthenticatorInfo exception: ' + JSON.stringify(err));
}
```
@@ -2245,13 +2245,13 @@ queryAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
```js
try {
- appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo").then((info) => {
- console.log("queryAuthenticatorInfo successfully, info: " + JSON.stringify(info));
+ appAccountManager.queryAuthenticatorInfo('com.example.accountjsdemo').then((info) => {
+ console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info));
}).catch((err) => {
- console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err));
+ console.log('queryAuthenticatorInfo failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err));
+ console.log('queryAuthenticatorInfo exception: ' + JSON.stringify(err));
}
```
@@ -2286,17 +2286,17 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>, cal
**示例:**
```js
- let labels = ["student"];
+ let labels = ['student'];
try {
- appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels, (err, hasAllLabels) => {
+ appAccountManager.checkAccountLabels('zhangsan', 'com.example.accountjsdemo', labels, (err, hasAllLabels) => {
if (err) {
- console.log("checkAccountLabels failed, error: " + JSON.stringify(err));
+ console.log('checkAccountLabels failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkAccountLabels successfully, hasAllLabels: " + hasAllLabels);
+ console.log('checkAccountLabels successfully, hasAllLabels: ' + hasAllLabels);
}
});
} catch (err) {
- console.log("checkAccountLabels exception: " + JSON.stringify(err));
+ console.log('checkAccountLabels exception: ' + JSON.stringify(err));
}
```
@@ -2336,15 +2336,15 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>): Pr
**示例:**
```js
- let labels = ["student"];
+ let labels = ['student'];
try {
- appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels).then((hasAllLabels) => {
+ appAccountManager.checkAccountLabels('zhangsan', 'com.example.accountjsdemo', labels).then((hasAllLabels) => {
console.log('checkAccountLabels successfully: ' + hasAllLabels);
}).catch((err) => {
- console.log("checkAccountLabels failed, error: " + JSON.stringify(err));
+ console.log('checkAccountLabels failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("checkAccountLabels exception: " + JSON.stringify(err));
+ console.log('checkAccountLabels exception: ' + JSON.stringify(err));
}
```
@@ -2377,15 +2377,15 @@ deleteCredential(name: string, credentialType: string, callback: AsyncCallback&l
```js
try {
- appAccountManager.deleteCredential("zhangsan", "PIN_SIX", (err) => {
+ appAccountManager.deleteCredential('zhangsan', 'PIN_SIX', (err) => {
if (err) {
- console.log("deleteCredential failed, error: " + JSON.stringify(err));
+ console.log('deleteCredential failed, error: ' + JSON.stringify(err));
} else {
- console.log("deleteCredential successfully");
+ console.log('deleteCredential successfully');
}
});
} catch (err) {
- console.log("deleteCredential exception: " + JSON.stringify(err));
+ console.log('deleteCredential exception: ' + JSON.stringify(err));
}
```
@@ -2423,13 +2423,13 @@ deleteCredential(name: string, credentialType: string): Promise<void>
```js
try {
- appAccountManager.deleteCredential("zhangsan", "PIN_SIX").then(() => {
- console.log("deleteCredential successfully");
+ appAccountManager.deleteCredential('zhangsan', 'PIN_SIX').then(() => {
+ console.log('deleteCredential successfully');
}).catch((err) => {
- console.log("deleteCredential failed, error: " + JSON.stringify(err));
+ console.log('deleteCredential failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("deleteCredential exception: " + JSON.stringify(err));
+ console.log('deleteCredential exception: ' + JSON.stringify(err));
}
```
@@ -2461,19 +2461,19 @@ selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback&
```js
let options = {
- allowedOwners: [ "com.example.accountjsdemo" ],
- requiredLabels: [ "student" ]
+ allowedOwners: [ 'com.example.accountjsdemo' ],
+ requiredLabels: [ 'student' ]
};
try {
appAccountManager.selectAccountsByOptions(options, (err, accountArr) => {
if (err) {
- console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err));
+ console.log('selectAccountsByOptions failed, error: ' + JSON.stringify(err));
} else {
- console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr));
+ console.log('selectAccountsByOptions successfully, accountArr: ' + JSON.stringify(accountArr));
}
});
} catch (err) {
- console.log("selectAccountsByOptions exception: " + JSON.stringify(err));
+ console.log('selectAccountsByOptions exception: ' + JSON.stringify(err));
}
```
@@ -2510,16 +2510,16 @@ selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<App
```js
let options = {
- allowedOwners: ["com.example.accountjsdemo"]
+ allowedOwners: ['com.example.accountjsdemo']
};
try {
appAccountManager.selectAccountsByOptions(options).then((accountArr) => {
- console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr));
+ console.log('selectAccountsByOptions successfully, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => {
- console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err));
+ console.log('selectAccountsByOptions failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("selectAccountsByOptions exception: " + JSON.stringify(err));
+ console.log('selectAccountsByOptions exception: ' + JSON.stringify(err));
}
```
@@ -2554,17 +2554,17 @@ verifyCredential(name: string, owner: string, callback: AuthCallback): void;
```js
try {
- appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", {
+ appAccountManager.verifyCredential('zhangsan', 'com.example.accountjsdemo', {
onResult: (resultCode, result) => {
- console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ console.log('verifyCredential onResult, resultCode: ' + JSON.stringify(resultCode));
+ console.log('verifyCredential onResult, result: ' + JSON.stringify(result));
},
onRequestRedirected: (request) => {
- console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ console.log('verifyCredential onRequestRedirected, request: ' + JSON.stringify(request));
}
});
} catch (err) {
- console.log("verifyCredential err: " + JSON.stringify(err));
+ console.log('verifyCredential err: ' + JSON.stringify(err));
}
```
@@ -2600,21 +2600,21 @@ verifyCredential(name: string, owner: string, options: VerifyCredentialOptions,
```js
let options = {
- credentialType: "pin",
- credential: "123456"
+ credentialType: 'pin',
+ credential: '123456'
};
try {
- appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", options, {
+ appAccountManager.verifyCredential('zhangsan', 'com.example.accountjsdemo', options, {
onResult: (resultCode, result) => {
- console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ console.log('verifyCredential onResult, resultCode: ' + JSON.stringify(resultCode));
+ console.log('verifyCredential onResult, result: ' + JSON.stringify(result));
},
onRequestRedirected: (request) => {
- console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ console.log('verifyCredential onRequestRedirected, request: ' + JSON.stringify(request));
}
});
} catch (err) {
- console.log("verifyCredential err: " + JSON.stringify(err));
+ console.log('verifyCredential err: ' + JSON.stringify(err));
}
```
@@ -2647,17 +2647,17 @@ setAuthenticatorProperties(owner: string, callback: AuthCallback): void;
```js
try {
- appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", {
+ appAccountManager.setAuthenticatorProperties('com.example.accountjsdemo', {
onResult: (resultCode, result) => {
- console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ console.log('setAuthenticatorProperties onResult, resultCode: ' + JSON.stringify(resultCode));
+ console.log('setAuthenticatorProperties onResult, result: ' + JSON.stringify(result));
},
onRequestRedirected: (request) => {
- console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ console.log('setAuthenticatorProperties onRequestRedirected, request: ' + JSON.stringify(request));
}
});
} catch (err) {
- console.log("setAuthenticatorProperties err: " + JSON.stringify(err));
+ console.log('setAuthenticatorProperties err: ' + JSON.stringify(err));
}
```
@@ -2691,20 +2691,20 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac
```js
let options = {
- properties: {"prop1": "value1"}
+ properties: {'prop1': 'value1'}
};
try {
- appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", options, {
+ appAccountManager.setAuthenticatorProperties('com.example.accountjsdemo', options, {
onResult: (resultCode, result) => {
- console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ console.log('setAuthenticatorProperties onResult, resultCode: ' + JSON.stringify(resultCode));
+ console.log('setAuthenticatorProperties onResult, result: ' + JSON.stringify(result));
},
onRequestRedirected: (request) => {
- console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ console.log('setAuthenticatorProperties onRequestRedirected, request: ' + JSON.stringify(request));
}
});
} catch (err) {
- console.log("setAuthenticatorProperties err: " + JSON.stringify(err));
+ console.log('setAuthenticatorProperties err: ' + JSON.stringify(err));
}
```
@@ -2732,8 +2732,8 @@ addAccount(name: string, callback: AsyncCallback<void>): void
**示例:**
```js
- appAccountManager.addAccount("WangWu", (err) => {
- console.log("addAccount err: " + JSON.stringify(err));
+ appAccountManager.addAccount('WangWu', (err) => {
+ console.log('addAccount err: ' + JSON.stringify(err));
});
```
@@ -2759,8 +2759,8 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>)
**示例:**
```js
- appAccountManager.addAccount("LiSi", "token101", (err) => {
- console.log("addAccount err: " + JSON.stringify(err));
+ appAccountManager.addAccount('LiSi', 'token101', (err) => {
+ console.log('addAccount err: ' + JSON.stringify(err));
});
```
@@ -2791,10 +2791,10 @@ addAccount(name: string, extraInfo?: string): Promise<void>
**示例:**
```js
- appAccountManager.addAccount("LiSi", "token101").then(()=> {
+ appAccountManager.addAccount('LiSi', 'token101').then(()=> {
console.log('addAccount Success');
}).catch((err) => {
- console.log("addAccount err: " + JSON.stringify(err));
+ console.log('addAccount err: ' + JSON.stringify(err));
});
```
@@ -2825,8 +2825,8 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ console.log('resultCode: ' + code);
+ console.log('result: ' + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
@@ -2837,13 +2837,13 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
- appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, {
+ appAccountManager.addAccountImplicitly('com.example.accountjsdemo', 'getSocialData', {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
@@ -2871,8 +2871,8 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void
**示例:**
```js
- appAccountManager.deleteAccount("ZhaoLiu", (err) => {
- console.log("deleteAccount err: " + JSON.stringify(err));
+ appAccountManager.deleteAccount('ZhaoLiu', (err) => {
+ console.log('deleteAccount err: ' + JSON.stringify(err));
});
```
@@ -2903,10 +2903,10 @@ deleteAccount(name: string): Promise<void>
**示例:**
```js
- appAccountManager.deleteAccount("ZhaoLiu").then(() => {
+ appAccountManager.deleteAccount('ZhaoLiu').then(() => {
console.log('deleteAccount Success');
}).catch((err) => {
- console.log("deleteAccount err: " + JSON.stringify(err));
+ console.log('deleteAccount err: ' + JSON.stringify(err));
});
```
### disableAppAccess(deprecated)
@@ -2932,8 +2932,8 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo
**示例:**
```js
- appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => {
- console.log("disableAppAccess err: " + JSON.stringify(err));
+ appAccountManager.disableAppAccess('ZhangSan', 'com.example.accountjsdemo', (err) => {
+ console.log('disableAppAccess err: ' + JSON.stringify(err));
});
```
@@ -2965,10 +2965,10 @@ disableAppAccess(name: string, bundleName: string): Promise<void>
**示例:**
```js
- appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => {
+ appAccountManager.disableAppAccess('ZhangSan', 'com.example.accountjsdemo').then(() => {
console.log('disableAppAccess Success');
}).catch((err) => {
- console.log("disableAppAccess err: " + JSON.stringify(err));
+ console.log('disableAppAccess err: ' + JSON.stringify(err));
});
```
@@ -2995,8 +2995,8 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi
**示例:**
```js
- appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => {
- console.log("enableAppAccess: " + JSON.stringify(err));
+ appAccountManager.enableAppAccess('ZhangSan', 'com.example.accountjsdemo', (err) => {
+ console.log('enableAppAccess: ' + JSON.stringify(err));
});
```
@@ -3028,10 +3028,10 @@ enableAppAccess(name: string, bundleName: string): Promise<void>
**示例:**
```js
- appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => {
+ appAccountManager.enableAppAccess('ZhangSan', 'com.example.accountjsdemo').then(() => {
console.log('enableAppAccess Success');
}).catch((err) => {
- console.log("enableAppAccess err: " + JSON.stringify(err));
+ console.log('enableAppAccess err: ' + JSON.stringify(err));
});
```
@@ -3059,8 +3059,8 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>):
**示例:**
```js
- appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
- console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
+ appAccountManager.checkAppAccountSyncEnable('ZhangSan', (err, result) => {
+ console.log('checkAppAccountSyncEnable err: ' + JSON.stringify(err));
console.log('checkAppAccountSyncEnable result: ' + result);
});
```
@@ -3094,10 +3094,10 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>
**示例:**
```js
- appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
+ appAccountManager.checkAppAccountSyncEnable('ZhangSan').then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data);
}).catch((err) => {
- console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
+ console.log('checkAppAccountSyncEnable err: ' + JSON.stringify(err));
});
```
@@ -3125,8 +3125,8 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca
**示例:**
```js
- appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
- console.log("setAccountCredential err: " + JSON.stringify(err));
+ appAccountManager.setAccountCredential('ZhangSan', 'credentialType001', 'credential001', (err) => {
+ console.log('setAccountCredential err: ' + JSON.stringify(err));
});
```
@@ -3159,10 +3159,10 @@ setAccountCredential(name: string, credentialType: string, credential: string):
**示例:**
```js
- appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
+ appAccountManager.setAccountCredential('ZhangSan', 'credentialType001', 'credential001').then(() => {
console.log('setAccountCredential Success');
}).catch((err) => {
- console.log("setAccountCredential err: " + JSON.stringify(err));
+ console.log('setAccountCredential err: ' + JSON.stringify(err));
});
```
@@ -3190,8 +3190,8 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<
**示例:**
```js
- appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
- console.log("setAccountExtraInfo err: " + JSON.stringify(err));
+ appAccountManager.setAccountExtraInfo('ZhangSan', 'Tk002', (err) => {
+ console.log('setAccountExtraInfo err: ' + JSON.stringify(err));
});
```
@@ -3224,10 +3224,10 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void>
**示例:**
```js
- appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
+ appAccountManager.setAccountExtraInfo('ZhangSan', 'Tk002').then(() => {
console.log('setAccountExtraInfo Success');
}).catch((err) => {
- console.log("setAccountExtraInfo err: " + JSON.stringify(err));
+ console.log('setAccountExtraInfo err: ' + JSON.stringify(err));
});
```
@@ -3256,8 +3256,8 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
**示例:**
```js
- appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
- console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
+ appAccountManager.setAppAccountSyncEnable('ZhangSan', true, (err) => {
+ console.log('setAppAccountSyncEnable err: ' + JSON.stringify(err));
});
```
@@ -3291,10 +3291,10 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
**示例:**
```js
- appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
+ appAccountManager .setAppAccountSyncEnable('ZhangSan', true).then(() => {
console.log('setAppAccountSyncEnable Success');
}).catch((err) => {
- console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
+ console.log('setAppAccountSyncEnable err: ' + JSON.stringify(err));
});
```
@@ -3323,8 +3323,8 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
**示例:**
```js
- appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
- console.log("setAssociatedData err: " + JSON.stringify(err));
+ appAccountManager.setAssociatedData('ZhangSan', 'k001', 'v001', (err) => {
+ console.log('setAssociatedData err: ' + JSON.stringify(err));
});
```
@@ -3358,10 +3358,10 @@ setAssociatedData(name: string, key: string, value: string): Promise<void>
**示例:**
```js
- appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
+ appAccountManager.setAssociatedData('ZhangSan', 'k001', 'v001').then(() => {
console.log('setAssociatedData Success');
}).catch((err) => {
- console.log("setAssociatedData err: " + JSON.stringify(err));
+ console.log('setAssociatedData err: ' + JSON.stringify(err));
});
```
@@ -3389,8 +3389,8 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>&
```js
appAccountManager.getAllAccessibleAccounts((err, data)=>{
- console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
- console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data));
+ console.debug('getAllAccessibleAccounts err: ' + JSON.stringify(err));
+ console.debug('getAllAccessibleAccounts data: ' + JSON.stringify(data));
});
```
@@ -3420,7 +3420,7 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>
appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data);
}).catch((err) => {
- console.log("getAllAccessibleAccounts err: " + JSON.stringify(err));
+ console.log('getAllAccessibleAccounts err: ' + JSON.stringify(err));
});
```
@@ -3448,10 +3448,10 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo
**示例:**
```js
- const selfBundle = "com.example.actsgetallaaccounts";
+ const selfBundle = 'com.example.actsgetallaaccounts';
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
- console.debug("getAllAccounts err:" + JSON.stringify(err));
- console.debug("getAllAccounts data:" + JSON.stringify(data));
+ console.debug('getAllAccounts err: ' + JSON.stringify(err));
+ console.debug('getAllAccounts data:' + JSON.stringify(data));
});
```
@@ -3484,11 +3484,11 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>
**示例:**
```js
- const selfBundle = "com.example.actsgetallaaccounts";
+ const selfBundle = 'com.example.actsgetallaaccounts';
appAccountManager.getAllAccounts(selfBundle).then((data) => {
console.log('getAllAccounts: ' + data);
}).catch((err) => {
- console.log("getAllAccounts err: " + JSON.stringify(err));
+ console.log('getAllAccounts err: ' + JSON.stringify(err));
});
```
@@ -3515,8 +3515,8 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba
**示例:**
```js
- appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
- console.log("getAccountCredential err: " + JSON.stringify(err));
+ appAccountManager.getAccountCredential('ZhangSan', 'credentialType001', (err, result) => {
+ console.log('getAccountCredential err: ' + JSON.stringify(err));
console.log('getAccountCredential result: ' + result);
});
```
@@ -3549,10 +3549,10 @@ getAccountCredential(name: string, credentialType: string): Promise<string>
**示例:**
```js
- appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
+ appAccountManager.getAccountCredential('ZhangSan', 'credentialType001').then((data) => {
console.log('getAccountCredential, result: ' + data);
}).catch((err) => {
- console.log("getAccountCredential err: " + JSON.stringify(err));
+ console.log('getAccountCredential err: ' + JSON.stringify(err));
});
```
@@ -3578,8 +3578,8 @@ getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void
**示例:**
```js
- appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
- console.log("getAccountExtraInfo err: " + JSON.stringify(err));
+ appAccountManager.getAccountExtraInfo('ZhangSan', (err, result) => {
+ console.log('getAccountExtraInfo err: ' + JSON.stringify(err));
console.log('getAccountExtraInfo result: ' + result);
});
```
@@ -3611,10 +3611,10 @@ getAccountExtraInfo(name: string): Promise<string>
**示例:**
```js
- appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
+ appAccountManager.getAccountExtraInfo('ZhangSan').then((data) => {
console.log('getAccountExtraInfo, result: ' + data);
}).catch((err) => {
- console.log("getAccountExtraInfo err: " + JSON.stringify(err));
+ console.log('getAccountExtraInfo err: ' + JSON.stringify(err));
});
```
@@ -3641,8 +3641,8 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback<string&g
**示例:**
```js
- appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
- console.log("getAssociatedData err: " + JSON.stringify(err));
+ appAccountManager.getAssociatedData('ZhangSan', 'k001', (err, result) => {
+ console.log('getAssociatedData err: ' + JSON.stringify(err));
console.log('getAssociatedData result: ' + result);
});
```
@@ -3675,10 +3675,10 @@ getAssociatedData(name: string, key: string): Promise<string>
**示例:**
```js
- appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
+ appAccountManager.getAssociatedData('ZhangSan', 'k001').then((data) => {
console.log('getAssociatedData: ' + data);
}).catch((err) => {
- console.log("getAssociatedData err: " + JSON.stringify(err));
+ console.log('getAssociatedData err: ' + JSON.stringify(err));
});
```
@@ -3706,13 +3706,13 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A
```js
function changeOnCallback(data){
- console.debug("receive change data:" + JSON.stringify(data));
+ console.debug('receive change data:' + JSON.stringify(data));
}
try{
- appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
+ appAccountManager.on('change', ['com.example.actsaccounttest'], changeOnCallback);
}
catch(err){
- console.error("on accountOnOffDemo err:" + JSON.stringify(err));
+ console.error('on accountOnOffDemo err:' + JSON.stringify(err));
}
```
@@ -3739,16 +3739,16 @@ off(type: 'change', callback?: Callback<Array<AppAccountInfo>>): voi
```js
function changeOnCallback(data){
- console.debug("receive change data:" + JSON.stringify(data));
+ console.debug('receive change data: ' + JSON.stringify(data));
appAccountManager.off('change', function(){
- console.debug("off finish");
+ console.debug('off finish');
})
}
try{
- appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
+ appAccountManager.on('change', ['com.example.actsaccounttest'], changeOnCallback);
}
catch(err){
- console.error("on accountOnOffDemo err:" + JSON.stringify(err));
+ console.error('on accountOnOffDemo err: ' + JSON.stringify(err));
}
```
@@ -3778,8 +3778,8 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
```js
function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ console.log('resultCode: ' + code);
+ console.log('result: ' + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
@@ -3790,13 +3790,13 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
entities: ['entity.system.default'],
}
this.context.startAbility(wantInfo).then(() => {
- console.log("startAbility successfully");
+ console.log('startAbility successfully');
}).catch((err) => {
- console.log("startAbility err: " + JSON.stringify(err));
+ console.log('startAbility err: ' + JSON.stringify(err));
})
}
- appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, {
+ appAccountManager.authenticate('LiSi', 'com.example.accountjsdemo', 'getSocialData', {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
@@ -3826,7 +3826,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
**示例:**
```js
- appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, data) => {
+ appAccountManager.getOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err));
console.log('getOAuthToken token: ' + data);
});
@@ -3861,10 +3861,10 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string&
**示例:**
```js
- appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((data) => {
+ appAccountManager.getOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData').then((data) => {
console.log('getOAuthToken token: ' + data);
}).catch((err) => {
- console.log("getOAuthToken err: " + JSON.stringify(err));
+ console.log('getOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -3892,7 +3892,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
**示例:**
```js
- appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
+ appAccountManager.setOAuthToken('LiSi', 'getSocialData', 'xxxx', (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -3926,7 +3926,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void>
**示例:**
```js
- appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
+ appAccountManager.setOAuthToken('LiSi', 'getSocialData', 'xxxx').then(() => {
console.log('setOAuthToken successfully');
}).catch((err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
@@ -3958,7 +3958,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
**示例:**
```js
- appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => {
+ appAccountManager.deleteOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx', (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -3993,10 +3993,10 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
**示例:**
```js
- appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => {
+ appAccountManager.deleteOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx').then(() => {
console.log('deleteOAuthToken successfully');
}).catch((err) => {
- console.log("deleteOAuthToken err: " + JSON.stringify(err));
+ console.log('deleteOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -4025,7 +4025,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:**
```js
- appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => {
+ appAccountManager.setOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
});
```
@@ -4060,7 +4060,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**示例:**
```js
- appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => {
+ appAccountManager.setOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true).then(() => {
console.log('setOAuthTokenVisibility successfully');
}).catch((err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
@@ -4091,7 +4091,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
**示例:**
```js
- appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, data) => {
+ appAccountManager.checkOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
console.log('checkOAuthTokenVisibility isVisible: ' + data);
});
@@ -4126,7 +4126,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
**示例:**
```js
- appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((data) => {
+ appAccountManager.checkOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo').then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data);
}).catch((err) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
@@ -4156,8 +4156,8 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array&
**示例:**
```js
- appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo", (err, data) => {
- console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ appAccountManager.getAllOAuthTokens('LiSi', 'com.example.accountjsdemo', (err, data) => {
+ console.log('getAllOAuthTokens err: ' + JSON.stringify(err));
console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
});
```
@@ -4190,10 +4190,10 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn
**示例:**
```js
- appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo").then((data) => {
+ appAccountManager.getAllOAuthTokens('LiSi', 'com.example.accountjsdemo').then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => {
- console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ console.log('getAllOAuthTokens err: ' + JSON.stringify(err));
});
```
@@ -4220,7 +4220,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<
**示例:**
```js
- appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData", (err, data) => {
+ appAccountManager.getOAuthList('LiSi', 'getSocialData', (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err));
console.log('getOAuthList data: ' + JSON.stringify(data));
});
@@ -4254,10 +4254,10 @@ getOAuthList(name: string, authType: string): Promise<Array<string>>
**示例:**
```js
- appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData").then((data) => {
+ appAccountManager.getOAuthList('LiSi', 'getSocialData').then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data));
}).catch((err) => {
- console.log("getOAuthList err: " + JSON.stringify(err));
+ console.log('getOAuthList err: ' + JSON.stringify(err));
});
```
@@ -4290,13 +4290,13 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
if (err.code != account_appAccount.ResultCode.SUCCESS) {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
return;
}
- var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
+ [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
+ [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
});
}
@@ -4336,13 +4336,13 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
onCreate(want, param) {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
+ [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
+ [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
});
}
}
@@ -4370,8 +4370,8 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo
**示例:**
```js
- appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo", (err, data) => {
- console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ appAccountManager.getAuthenticatorInfo('com.example.accountjsdemo', (err, data) => {
+ console.log('getAuthenticatorInfo err: ' + JSON.stringify(err));
console.log('getAuthenticatorInfo data: ' + JSON.stringify(data));
});
```
@@ -4403,10 +4403,10 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
**示例:**
```js
- appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo").then((data) => {
+ appAccountManager.getAuthenticatorInfo('com.example.accountjsdemo').then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
}).catch((err) => {
- console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ console.log('getAuthenticatorInfo err: ' + JSON.stringify(err));
});
```
@@ -4537,23 +4537,23 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
| 名称 | 值 | 说明 |
| -------------------------------- | ---------------------- | ----------------------- |
-| ACTION_ADD_ACCOUNT_IMPLICITLY(deprecated) | "addAccountImplicitly" | 表示操作,隐式添加帐号。 |
-| ACTION_AUTHENTICATE(deprecated) | "authenticate" | 表示操作,鉴权。 |
-| ACTION_CREATE_ACCOUNT_IMPLICITLY9+ | "createAccountImplicitly" | 表示操作,隐式创建帐号。 |
-| ACTION_AUTH9+ | "auth" | 表示操作,鉴权。 |
-| ACTION_VERIFY_CREDENTIAL9+ | "verifyCredential" | 表示操作,验证凭据。 |
-| ACTION_SET_AUTHENTICATOR_PROPERTIES9+ | "setAuthenticatorProperties" | 表示操作,设置认证器属性。 |
-| KEY_NAME | "name" | 表示键名,应用帐号的名称。 |
-| KEY_OWNER | "owner" | 表示键名,应用帐号所有者。|
-| KEY_TOKEN | "token" | 表示键名,令牌。 |
-| KEY_ACTION | "action" | 表示键名,操作。 |
-| KEY_AUTH_TYPE | "authType" | 表示键名,鉴权类型。 |
-| KEY_SESSION_ID | "sessionId" | 表示键名,会话标识。 |
-| KEY_CALLER_PID | "callerPid" | 表示键名,调用方PID。 |
-| KEY_CALLER_UID | "callerUid" | 表示键名,调用方UID。 |
-| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键名,调用方包名。 |
-| KEY_REQUIRED_LABELS9+ | "requiredLabels" | 表示键名,必需的标签。 |
-| KEY_BOOLEAN_RESULT9+ | "booleanResult" | 表示键名,布尔返回值。 |
+| ACTION_ADD_ACCOUNT_IMPLICITLY(deprecated) | 'addAccountImplicitly' | 表示操作,隐式添加帐号。 |
+| ACTION_AUTHENTICATE(deprecated) | 'authenticate' | 表示操作,鉴权。 |
+| ACTION_CREATE_ACCOUNT_IMPLICITLY9+ | 'createAccountImplicitly' | 表示操作,隐式创建帐号。 |
+| ACTION_AUTH9+ | 'auth' | 表示操作,鉴权。 |
+| ACTION_VERIFY_CREDENTIAL9+ | 'verifyCredential' | 表示操作,验证凭据。 |
+| ACTION_SET_AUTHENTICATOR_PROPERTIES9+ | 'setAuthenticatorProperties' | 表示操作,设置认证器属性。 |
+| KEY_NAME | 'name' | 表示键名,应用帐号的名称。 |
+| KEY_OWNER | 'owner' | 表示键名,应用帐号所有者。|
+| KEY_TOKEN | 'token' | 表示键名,令牌。 |
+| KEY_ACTION | 'action' | 表示键名,操作。 |
+| KEY_AUTH_TYPE | 'authType' | 表示键名,鉴权类型。 |
+| KEY_SESSION_ID | 'sessionId' | 表示键名,会话标识。 |
+| KEY_CALLER_PID | 'callerPid' | 表示键名,调用方PID。 |
+| KEY_CALLER_UID | 'callerUid' | 表示键名,调用方UID。 |
+| KEY_CALLER_BUNDLE_NAME | 'callerBundleName' | 表示键名,调用方包名。 |
+| KEY_REQUIRED_LABELS9+ | 'requiredLabels' | 表示键名,必需的标签。 |
+| KEY_BOOLEAN_RESULT9+ | 'booleanResult' | 表示键名,布尔返回值。 |
## ResultCode(deprecated)
@@ -4609,21 +4609,21 @@ onResult: (code: number, result?: AuthResult) => void
```js
let appAccountManager = account_appAccount.createAppAccountManager();
- var sessionId = "1234";
+ var sessionId = '1234';
appAccountManager.getAuthCallback(sessionId).then((callback) => {
var result = {
accountInfo: {
- name: "Lisi",
- owner: "com.example.accountjsdemo",
+ name: 'Lisi',
+ owner: 'com.example.accountjsdemo',
},
tokenInfo: {
- token: "xxxxxx",
- authType: "getSocialData"
+ token: 'xxxxxx',
+ authType: 'getSocialData'
}
};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
- console.log("getAuthCallback err: " + JSON.stringify(err));
+ console.log('getAuthCallback err: ' + JSON.stringify(err));
});
```
@@ -4647,20 +4647,20 @@ onRequestRedirected: (request: Want) => void
class MyAuthenticator extends account_appAccount.Authenticator {
createAccountImplicitly(options, callback) {
callback.onRequestRedirected({
- bundleName: "com.example.accountjsdemo",
- abilityName: "com.example.accountjsdemo.LoginAbility",
+ bundleName: 'com.example.accountjsdemo',
+ abilityName: 'com.example.accountjsdemo.LoginAbility',
});
}
auth(name, authType, options, callback) {
var result = {
accountInfo: {
- name: "Lisi",
- owner: "com.example.accountjsdemo",
+ name: 'Lisi',
+ owner: 'com.example.accountjsdemo',
},
tokenInfo: {
- token: "xxxxxx",
- authType: "getSocialData"
+ token: 'xxxxxx',
+ authType: 'getSocialData'
}
};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
@@ -4680,11 +4680,11 @@ onRequestContinued?: () => void
```js
let appAccountManager = account_appAccount.createAppAccountManager();
- var sessionId = "1234";
+ var sessionId = '1234';
appAccountManager.getAuthCallback(sessionId).then((callback) => {
callback.onRequestContinued();
}).catch((err) => {
- console.log("getAuthCallback err: " + JSON.stringify(err));
+ console.log('getAuthCallback err: ' + JSON.stringify(err));
});
```
@@ -4715,15 +4715,15 @@ onResult: (code: number, result: {[key: string]: any}) => void
```js
let appAccountManager = account_appAccount.createAppAccountManager();
- var sessionId = "1234";
+ var sessionId = '1234';
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
+ [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
+ [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
});
```
@@ -4747,15 +4747,15 @@ onRequestRedirected: (request: Want) => void
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
- bundleName: "com.example.accountjsdemo",
- abilityName: "com.example.accountjsdemo.LoginAbility",
+ bundleName: 'com.example.accountjsdemo',
+ abilityName: 'com.example.accountjsdemo.LoginAbility',
});
}
authenticate(name, authType, callerBundleName, options, callback) {
var result = {[account_appAccount.Constants.KEY_NAME]: name,
[account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
}
@@ -4773,11 +4773,11 @@ onRequestContinued?: () => void
```js
let appAccountManager = account_appAccount.createAppAccountManager();
- var sessionId = "1234";
+ var sessionId = '1234';
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.onRequestContinued();
}).catch((err) => {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
});
```
@@ -4937,22 +4937,22 @@ getRemoteObject(): rpc.RemoteObject;
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
- bundleName: "com.example.accountjsdemo",
- abilityName: "com.example.accountjsdemo.LoginAbility",
+ bundleName: 'com.example.accountjsdemo',
+ abilityName: 'com.example.accountjsdemo.LoginAbility',
});
}
authenticate(name, authType, callerBundleName, options, callback) {
var result = {[account_appAccount.Constants.KEY_NAME]: name,
[account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
verifyCredential(name, options, callback) {
callback.onRequestRedirected({
- bundleName: "com.example.accountjsdemo",
- abilityName: "com.example.accountjsdemo.VerifyAbility",
+ bundleName: 'com.example.accountjsdemo',
+ abilityName: 'com.example.accountjsdemo.VerifyAbility',
parameters: {
name: name
}
diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md
index 9a04bf1a637f946b66b86b054b007a8612bdecc7..0a79d69ce73bcdc75b03d89f3ccd6036199be201 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md
@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
try {
- data_preferences.deletePreferences(context, 'mystore', function (err, val) {
+ data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return;
@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
try {
- data_preferences.deletePreferences(this.context, 'mystore', function (err, val) {
+ data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return;
@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
try {
- data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) {
+ data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return;
@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
try {
- data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err, val) {
+ data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return;
diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md
index 5bb8c62c3a321382460e1f158055f506561cc9df..d9e5b6de48fcada343bb882eea768a284484978b 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-media.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-media.md
@@ -45,15 +45,15 @@ createAVPlayer(callback: AsyncCallback\): void
**示例:**
```js
-let avPlayer
+let avPlayer;
media.createAVPlayer((error, video) => {
- if (video != null) {
- avPlayer = video;
- console.info('createAVPlayer success');
- } else {
- console.info(`createAVPlayer fail, error:${error}`);
- }
+ if (video != null) {
+ avPlayer = video;
+ console.info('createAVPlayer success');
+ } else {
+ console.error(`createAVPlayer fail, error message:${error.message}`);
+ }
});
```
@@ -82,17 +82,17 @@ createAVPlayer(): Promise\
**示例:**
```js
-let avPlayer
+let avPlayer;
media.createAVPlayer().then((video) => {
- if (video != null) {
- avPlayer = video;
- console.info('createAVPlayer success');
- } else {
- console.info('createAVPlayer fail');
- }
+ if (video != null) {
+ avPlayer = video;
+ console.info('createAVPlayer success');
+ } else {
+ console.error('createAVPlayer fail');
+ }
}).catch((error) => {
- console.info(`AVPlayer catchCallback, error:${error}`);
+ console.error(`AVPlayer catchCallback, error message:${error.message}`);
});
```
@@ -122,15 +122,15 @@ createAVRecorder(callback: AsyncCallback\): void
**示例:**
```js
-let avRecorder
+let avRecorder;
media.createAVRecorder((error, recorder) => {
- if (recorder != null) {
- avRecorder = recorder;
- console.info('createAVRecorder success');
- } else {
- console.info(`createAVRecorder fail, error:${error}`);
- }
+ if (recorder != null) {
+ avRecorder = recorder;
+ console.info('createAVRecorder success');
+ } else {
+ console.error(`createAVRecorder fail, error message:${error.message}`);
+ }
});
```
@@ -160,17 +160,17 @@ createAVRecorder(): Promise\
**示例:**
```js
-let avRecorder
+let avRecorder;
media.createAVRecorder().then((recorder) => {
- if (recorder != null) {
- avRecorder = recorder;
- console.info('createAVRecorder success');
- } else {
- console.info('createAVRecorder fail');
- }
+ if (recorder != null) {
+ avRecorder = recorder;
+ console.info('createAVRecorder success');
+ } else {
+ console.error('createAVRecorder fail');
+ }
}).catch((error) => {
- console.info(`createAVRecorder catchCallback, error:${error}`);
+ console.error(`createAVRecorder catchCallback, error message:${error.message}`);
});
```
@@ -202,15 +202,15 @@ createVideoRecorder(callback: AsyncCallback\): void
**示例:**
```js
-let videoRecorder
+let videoRecorder;
media.createVideoRecorder((error, video) => {
- if (video != null) {
- videoRecorder = video;
- console.info('video createVideoRecorder success');
- } else {
- console.info(`video createVideoRecorder fail, error:${error}`);
- }
+ if (video != null) {
+ videoRecorder = video;
+ console.info('video createVideoRecorder success');
+ } else {
+ console.error(`video createVideoRecorder fail, error message:${error.message}`);
+ }
});
```
@@ -242,17 +242,17 @@ createVideoRecorder(): Promise\
**示例:**
```js
-let videoRecorder
+let videoRecorder;
media.createVideoRecorder().then((video) => {
- if (video != null) {
- videoRecorder = video;
- console.info('video createVideoRecorder success');
- } else {
- console.info('video createVideoRecorder fail');
- }
+ if (video != null) {
+ videoRecorder = video;
+ console.info('video createVideoRecorder success');
+ } else {
+ console.error('video createVideoRecorder fail');
+ }
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error message:${error.message}`);
});
```
@@ -395,38 +395,38 @@ on(type: 'stateChange', callback: (state: AVPlayerState, reason: StateChangeReas
```js
avPlayer.on('stateChange', async (state, reason) => {
- switch (state) {
- case 'idle':
- console.info('state idle called')
- break;
- case 'initialized':
- console.info('initialized prepared called')
- break;
- case 'prepared':
- console.info('state prepared called')
- break;
- case 'playing':
- console.info('state playing called')
- break;
- case 'paused':
- console.info('state paused called')
- break;
- case 'completed':
- console.info('state completed called')
- break;
- case 'stopped':
- console.info('state stopped called')
- break;
- case 'released':
- console.info('state released called')
- break;
- case 'error':
- console.info('state error called')
- break;
- default:
- console.info('unkown state :' + state)
- break;
- }
+ switch (state) {
+ case 'idle':
+ console.info('state idle called')
+ break;
+ case 'initialized':
+ console.info('initialized prepared called')
+ break;
+ case 'prepared':
+ console.info('state prepared called')
+ break;
+ case 'playing':
+ console.info('state playing called')
+ break;
+ case 'paused':
+ console.info('state paused called')
+ break;
+ case 'completed':
+ console.info('state completed called')
+ break;
+ case 'stopped':
+ console.info('state stopped called')
+ break;
+ case 'released':
+ console.info('state released called')
+ break;
+ case 'error':
+ console.info('state error called')
+ break;
+ default:
+ console.info('unkown state :' + state)
+ break;
+ }
})
```
@@ -483,8 +483,8 @@ AVPlayer回调的**错误分类**可以分为以下几
```js
avPlayer.on('error', (error) => {
- console.info('error happened,and error message is :' + error.message)
- console.info('error happened,and error code is :' + error.code)
+ console.error('error happened,and error message is :' + error.message)
+ console.error('error happened,and error code is :' + error.code)
})
```
@@ -535,11 +535,11 @@ prepare(callback: AsyncCallback\): void
```js
avPlayer.prepare((err) => {
- if (err == null) {
- console.info('prepare success');
- } else {
- console.error('prepare filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('prepare success');
+ } else {
+ console.error('prepare filed,error message is :' + err.message)
+ }
})
```
@@ -570,9 +570,9 @@ prepare(): Promise\
```js
avPlayer.prepare().then(() => {
- console.info('prepare success');
+ console.info('prepare success');
}, (err) => {
- console.error('prepare filed,error message is :' + err.message)
+ console.error('prepare filed,error message is :' + err.message)
})
```
@@ -602,11 +602,11 @@ play(callback: AsyncCallback\): void
```js
avPlayer.play((err) => {
- if (err == null) {
- console.info('play success');
- } else {
- console.error('play filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('play success');
+ } else {
+ console.error('play filed,error message is :' + err.message)
+ }
})
```
@@ -636,9 +636,9 @@ play(): Promise\
```js
avPlayer.play().then(() => {
- console.info('play success');
+ console.info('play success');
}, (err) => {
- console.error('play filed,error message is :' + err.message)
+ console.error('play filed,error message is :' + err.message)
})
```
@@ -668,11 +668,11 @@ pause(callback: AsyncCallback\): void
```js
avPlayer.pause((err) => {
- if (err == null) {
- console.info('pause success');
- } else {
- console.error('pause filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('pause success');
+ } else {
+ console.error('pause filed,error message is :' + err.message)
+ }
})
```
@@ -702,9 +702,9 @@ pause(): Promise\
```js
avPlayer.pause().then(() => {
- console.info('pause success');
+ console.info('pause success');
}, (err) => {
- console.error('pause filed,error message is :' + err.message)
+ console.error('pause filed,error message is :' + err.message)
})
```
@@ -734,11 +734,11 @@ stop(callback: AsyncCallback\): void
```js
avPlayer.stop((err) => {
- if (err == null) {
- console.info('stop success');
- } else {
- console.error('stop filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('stop success');
+ } else {
+ console.error('stop filed,error message is :' + err.message)
+ }
})
```
@@ -768,9 +768,9 @@ stop(): Promise\
```js
avPlayer.stop().then(() => {
- console.info('stop success');
+ console.info('stop success');
}, (err) => {
- console.error('stop filed,error message is :' + err.message)
+ console.error('stop filed,error message is :' + err.message)
})
```
@@ -800,11 +800,11 @@ reset(callback: AsyncCallback\): void
```js
avPlayer.reset((err) => {
- if (err == null) {
- console.info('reset success');
- } else {
- console.error('reset filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('reset success');
+ } else {
+ console.error('reset filed,error message is :' + err.message)
+ }
})
```
@@ -834,9 +834,9 @@ reset(): Promise\
```js
avPlayer.reset().then(() => {
- console.info('reset success');
+ console.info('reset success');
}, (err) => {
- console.error('reset filed,error message is :' + err.message)
+ console.error('reset filed,error message is :' + err.message)
})
```
@@ -866,11 +866,11 @@ release(callback: AsyncCallback\): void
```js
avPlayer.release((err) => {
- if (err == null) {
- console.info('reset success');
- } else {
- console.error('release filed,error message is :' + err.message)
- }
+ if (err == null) {
+ console.info('reset success');
+ } else {
+ console.error('release filed,error message is :' + err.message)
+ }
})
```
@@ -900,9 +900,9 @@ release(): Promise\
```js
avPlayer.release().then(() => {
- console.info('release success');
+ console.info('release success');
}, (err) => {
- console.error('release filed,error message is :' + err.message)
+ console.error('release filed,error message is :' + err.message)
})
```
@@ -931,22 +931,22 @@ getTrackDescription(callback: AsyncCallback\>): void
**示例:**
```js
-printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('audio key is ' + item);
- console.info('audio value is ' + property);
- }
+function printfDescription(obj) {
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('audio key is ' + item);
+ console.info('audio value is ' + property);
+ }
}
avPlayer.getTrackDescription((error, arrList) => {
- if ((arrList) != null) {
- for (let i = 0; i < arrList.length; i++) {
- printfDescription(arrList[i]);
- }
- } else {
- console.log(`video getTrackDescription fail, error:${error}`);
+ if ((arrList) != null) {
+ for (let i = 0; i < arrList.length; i++) {
+ printfDescription(arrList[i]);
}
+ } else {
+ console.log(`video getTrackDescription fail, error:${error}`);
+ }
});
```
@@ -977,24 +977,24 @@ getTrackDescription(): Promise\>
```js
let arrayDescription;
-printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('audio key is ' + item);
- console.info('audio value is ' + property);
- }
+function printfDescription(obj) {
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('audio key is ' + item);
+ console.info('audio value is ' + property);
+ }
}
avPlayer.getTrackDescription().then((arrList) => {
- if (arrList != null) {
- arrayDescription = arrList;
- } else {
- console.log('video getTrackDescription fail');
- }
+ if (arrList != null) {
+ arrayDescription = arrList;
+ } else {
+ console.log('video getTrackDescription fail');
+ }
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.info(`video catchCallback, error:${error}`);
});
for (let i = 0; i < arrayDescription.length; i++) {
- printfDescription(arrayDescription[i]);
+ printfDescription(arrayDescription[i]);
}
```
@@ -1040,7 +1040,7 @@ on(type: 'seekDone', callback: Callback\): void
```js
avPlayer.on('seekDone', (seekDoneTime:number) => {
- console.info('seekDone success,and seek time is:' + seekDoneTime)
+ console.info('seekDone success,and seek time is:' + seekDoneTime)
})
```
@@ -1104,7 +1104,7 @@ on(type: 'speedDone', callback: Callback\): void
```js
avPlayer.on('speedDone', (speed:number) => {
- console.info('speedDone success,and speed value is:' + speed)
+ console.info('speedDone success,and speed value is:' + speed)
})
```
@@ -1168,7 +1168,7 @@ on(type: 'bitrateDone', callback: Callback\): void
```js
avPlayer.on('bitrateDone', (bitrate:number) => {
- console.info('bitrateDone success,and bitrate value is:' + bitrate)
+ console.info('bitrateDone success,and bitrate value is:' + bitrate)
})
```
@@ -1211,7 +1211,7 @@ on(type: 'availableBitrates', callback: (bitrates: Array\) => void): voi
```js
avPlayer.on('availableBitrates', (bitrates: Array) => {
- console.info('availableBitrates success,and availableBitrates length is:' + bitrates.length)
+ console.info('availableBitrates success,and availableBitrates length is:' + bitrates.length)
})
```
@@ -1275,7 +1275,7 @@ on(type: 'volumeChange', callback: Callback\): void
```js
avPlayer.on('volumeChange', (vol:number) => {
- console.info('volumeChange success,and new volume is :' + vol)
+ console.info('volumeChange success,and new volume is :' + vol)
})
```
@@ -1318,7 +1318,7 @@ on(type: 'endOfStream', callback: Callback\): void
```js
avPlayer.on('endOfStream', () => {
- console.info('endOfStream success')
+ console.info('endOfStream success')
})
```
@@ -1362,7 +1362,7 @@ on(type: 'timeUpdate', callback: Callback\): void
```js
avPlayer.on('timeUpdate', (time:number) => {
- console.info('timeUpdate success,and new time is :' + time)
+ console.info('timeUpdate success,and new time is :' + time)
})
```
@@ -1406,7 +1406,7 @@ on(type: 'durationUpdate', callback: Callback\): void
```js
avPlayer.on('durationUpdate', (duration) => {
- console.info('durationUpdate success,new duration is :' + duration)
+ console.info('durationUpdate success,new duration is :' + duration)
})
```
@@ -1449,7 +1449,7 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js
avPlayer.on('bufferingUpdate', (infoType: media.BufferingInfoType, value: number) => {
- console.info('bufferingUpdate success,and infoType value is:' + infoType + ', value is :' + value)
+ console.info('bufferingUpdate success,and infoType value is:' + infoType + ', value is :' + value)
})
```
@@ -1492,7 +1492,7 @@ on(type: 'startRenderFrame', callback: Callback\): void
```js
avPlayer.on('startRenderFrame', () => {
- console.info('startRenderFrame success')
+ console.info('startRenderFrame success')
})
```
@@ -1535,7 +1535,7 @@ on(type: 'videoSizeChange', callback: (width: number, height: number) => void):
```js
avPlayer.on('videoSizeChange', (width: number, height: number) => {
- console.info('videoSizeChange success,and width is:' + width + ', height is :' + height)
+ console.info('videoSizeChange success,and width is:' + width + ', height is :' + height)
})
```
@@ -1580,7 +1580,7 @@ on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void
import audio from '@ohos.multimedia.audio';
avPlayer.on('audioInterrupt', (info: audio.InterruptEvent) => {
- console.info('audioInterrupt success,and InterruptEvent info is:' + info)
+ console.info('audioInterrupt success,and InterruptEvent info is:' + info)
})
```
@@ -1693,19 +1693,19 @@ avPlayer.off('audioInterrupt')
```js
import media from '@ohos.multimedia.media'
function printfItemDescription(obj, key) {
- let property = obj[key];
- console.info('audio key is ' + key); // 通过key值获取对应的value。key值具体可见[MediaDescriptionKey]
- console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey]
+ let property = obj[key];
+ console.info('audio key is ' + key); // 通过key值获取对应的value。key值具体可见[MediaDescriptionKey]
+ console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey]
}
let audioPlayer = media.createAudioPlayer();
audioPlayer.getTrackDescription((error, arrList) => {
- if (arrList != null) {
- for (let i = 0; i < arrList.length; i++) {
- printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
- }
- } else {
- console.log(`audio getTrackDescription fail, error:${error}`);
+ if (arrList != null) {
+ for (let i = 0; i < arrList.length; i++) {
+ printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
}
+ } else {
+ console.log(`audio getTrackDescription fail, error:${error}`);
+ }
});
```
@@ -1764,32 +1764,32 @@ prepare(config: AVRecorderConfig, callback: AsyncCallback\): void
```js
// 配置参数以实际硬件设备支持的范围为准
let AVRecorderProfile = {
- audioBitrate : 48000,
- audioChannels : 2,
- audioCodec : media.CodecMimeType.AUDIO_AAC,
- audioSampleRate : 48000,
- fileFormat : media.ContainerFormatType.CFT_MPEG_4,
- videoBitrate : 2000000,
- videoCodec : media.CodecMimeType.VIDEO_AVC,
- videoFrameWidth : 640,
- videoFrameHeight : 480,
- videoFrameRate : 30
+ audioBitrate : 48000,
+ audioChannels : 2,
+ audioCodec : media.CodecMimeType.AUDIO_AAC,
+ audioSampleRate : 48000,
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
+ videoBitrate : 2000000,
+ videoCodec : media.CodecMimeType.VIDEO_AVC,
+ videoFrameWidth : 640,
+ videoFrameHeight : 480,
+ videoFrameRate : 30
}
let AVRecorderConfig = {
- audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
- videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
- profile : AVRecorderProfile,
- url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
- rotation : 0, // 合理值0、90、180、270,非合理值prepare接口将报错
- location : { latitude : 30, longitude : 130 }
+ audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
+ profile : AVRecorderProfile,
+ url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
+ rotation : 0, // 合理值0、90、180、270,非合理值prepare接口将报错
+ location : { latitude : 30, longitude : 130 }
}
avRecorder.prepare(AVRecorderConfig, (err) => {
- if (err == null) {
- console.info('prepare success');
- } else {
- console.info('prepare failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('prepare success');
+ } else {
+ console.error('prepare failed and error is ' + err.message);
+ }
})
```
@@ -1835,30 +1835,30 @@ prepare(config: AVRecorderConfig): Promise\
```js
// 配置参数以实际硬件设备支持的范围为准
let AVRecorderProfile = {
- audioBitrate : 48000,
- audioChannels : 2,
- audioCodec : media.CodecMimeType.AUDIO_AAC,
- audioSampleRate : 48000,
- fileFormat : media.ContainerFormatType.CFT_MPEG_4,
- videoBitrate : 2000000,
- videoCodec : media.CodecMimeType.VIDEO_AVC,
- videoFrameWidth : 640,
- videoFrameHeight : 480,
- videoFrameRate : 30
+ audioBitrate : 48000,
+ audioChannels : 2,
+ audioCodec : media.CodecMimeType.AUDIO_AAC,
+ audioSampleRate : 48000,
+ fileFormat : media.ContainerFormatType.CFT_MPEG_4,
+ videoBitrate : 2000000,
+ videoCodec : media.CodecMimeType.VIDEO_AVC,
+ videoFrameWidth : 640,
+ videoFrameHeight : 480,
+ videoFrameRate : 30
}
let AVRecorderConfig = {
- audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
- videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
- profile : AVRecorderProfile,
- url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
- rotation : 0, // 合理值0、90、180、270,非合理值prepare接口报错
- location : { latitude : 30, longitude : 130 }
+ audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
+ videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
+ profile : AVRecorderProfile,
+ url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
+ rotation : 0, // 合理值0、90、180、270,非合理值prepare接口报错
+ location : { latitude : 30, longitude : 130 }
}
avRecorder.prepare(AVRecorderConfig).then(() => {
- console.info('prepare success');
+ console.info('prepare success');
}).catch((err) => {
- console.info('prepare failed and catch error is ' + err.message);
+ console.error('prepare failed and catch error is ' + err.message);
});
```
@@ -1897,12 +1897,12 @@ getInputSurface(callback: AsyncCallback\): void
let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput
avRecorder.getInputSurface((err, surfaceId) => {
- if (err == null) {
- console.info('getInputSurface success');
- surfaceID = surfaceId;
- } else {
- console.info('getInputSurface failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('getInputSurface success');
+ surfaceID = surfaceId;
+ } else {
+ console.error('getInputSurface failed and error is ' + err.message);
+ }
});
```
@@ -1941,10 +1941,10 @@ getInputSurface(): Promise\
let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput
avRecorder.getInputSurface().then((surfaceId) => {
- console.info('getInputSurface success');
- surfaceID = surfaceId;
+ console.info('getInputSurface success');
+ surfaceID = surfaceId;
}).catch((err) => {
- console.info('getInputSurface failed and catch error is ' + err.message);
+ console.error('getInputSurface failed and catch error is ' + err.message);
});
```
@@ -1978,11 +1978,11 @@ start(callback: AsyncCallback\): void
```js
avRecorder.start((err) => {
- if (err == null) {
- console.info('start AVRecorder success');
- } else {
- console.info('start AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('start AVRecorder success');
+ } else {
+ console.error('start AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2016,9 +2016,9 @@ start(): Promise\
```js
avRecorder.start().then(() => {
- console.info('start AVRecorder success');
+ console.info('start AVRecorder success');
}).catch((err) => {
- console.info('start AVRecorder failed and catch error is ' + err.message);
+ console.error('start AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2052,11 +2052,11 @@ pause(callback: AsyncCallback\): void
```js
avRecorder.pause((err) => {
- if (err == null) {
- console.info('pause AVRecorder success');
- } else {
- console.info('pause AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('pause AVRecorder success');
+ } else {
+ console.error('pause AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2090,9 +2090,9 @@ pause(): Promise\
```js
avRecorder.pause().then(() => {
- console.info('pause AVRecorder success');
+ console.info('pause AVRecorder success');
}).catch((err) => {
- console.info('pause AVRecorder failed and catch error is ' + err.message);
+ console.error('pause AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2126,11 +2126,11 @@ resume(callback: AsyncCallback\): void
```js
avRecorder.resume((err) => {
- if (err == null) {
- console.info('resume AVRecorder success');
- } else {
- console.info('resume AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('resume AVRecorder success');
+ } else {
+ console.error('resume AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2164,9 +2164,9 @@ resume(): Promise\
```js
avRecorder.resume().then(() => {
- console.info('resume AVRecorder success');
+ console.info('resume AVRecorder success');
}).catch((err) => {
- console.info('resume AVRecorder failed and catch error is ' + err.message);
+ console.error('resume AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2202,11 +2202,11 @@ stop(callback: AsyncCallback\): void
```js
avRecorder.stop((err) => {
- if (err == null) {
- console.info('stop AVRecorder success');
- } else {
- console.info('stop AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('stop AVRecorder success');
+ } else {
+ console.error('stop AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2242,9 +2242,9 @@ stop(): Promise\
```js
avRecorder.stop().then(() => {
- console.info('stop AVRecorder success');
+ console.info('stop AVRecorder success');
}).catch((err) => {
- console.info('stop AVRecorder failed and catch error is ' + err.message);
+ console.error('stop AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2277,11 +2277,11 @@ reset(callback: AsyncCallback\): void
```js
avRecorder.reset((err) => {
- if (err == null) {
- console.info('reset AVRecorder success');
- } else {
- console.info('reset AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('reset AVRecorder success');
+ } else {
+ console.error('reset AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2314,9 +2314,9 @@ reset(): Promise\
```js
avRecorder.reset().then(() => {
- console.info('reset AVRecorder success');
+ console.info('reset AVRecorder success');
}).catch((err) => {
- console.info('reset AVRecorder failed and catch error is ' + err.message);
+ console.error('reset AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2348,11 +2348,11 @@ release(callback: AsyncCallback\): void
```js
avRecorder.release((err) => {
- if (err == null) {
- console.info('release AVRecorder success');
- } else {
- console.info('release AVRecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('release AVRecorder success');
+ } else {
+ console.error('release AVRecorder failed and error is ' + err.message);
+ }
});
```
@@ -2384,9 +2384,9 @@ release(): Promise\
```js
avRecorder.release().then(() => {
- console.info('release AVRecorder success');
+ console.info('release AVRecorder success');
}).catch((err) => {
- console.info('release AVRecorder failed and catch error is ' + err.message);
+ console.error('release AVRecorder failed and catch error is ' + err.message);
});
```
@@ -2409,7 +2409,7 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe
```js
avRecorder.on('stateChange', async (state, reason) => {
- console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason);
+ console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason);
});
```
@@ -2463,7 +2463,7 @@ on(type: 'error', callback: ErrorCallback): void
```js
avRecorder.on('error', (err) => {
- console.info('case avRecorder.on(error) called, errMessage is ' + err.message);
+ console.error('case avRecorder.on(error) called, errMessage is ' + err.message);
});
```
@@ -2644,34 +2644,34 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void;
```js
// 配置参数以实际硬件设备支持的范围为准
let videoProfile = {
- audioBitrate : 48000,
- audioChannels : 2,
- audioCodec : 'audio/mp4a-latm',
- audioSampleRate : 48000,
- fileFormat : 'mp4',
- videoBitrate : 2000000,
- videoCodec : 'video/avc',
- videoFrameWidth : 640,
- videoFrameHeight : 480,
- videoFrameRate : 30
+ audioBitrate : 48000,
+ audioChannels : 2,
+ audioCodec : 'audio/mp4a-latm',
+ audioSampleRate : 48000,
+ fileFormat : 'mp4',
+ videoBitrate : 2000000,
+ videoCodec : 'video/avc',
+ videoFrameWidth : 640,
+ videoFrameHeight : 480,
+ videoFrameRate : 30
}
let videoConfig = {
- audioSourceType : 1,
- videoSourceType : 0,
- profile : videoProfile,
- url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
- orientationHint : 0,
- location : { latitude : 30, longitude : 130 },
+ audioSourceType : 1,
+ videoSourceType : 0,
+ profile : videoProfile,
+ url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
+ orientationHint : 0,
+ location : { latitude : 30, longitude : 130 },
}
// asyncallback
videoRecorder.prepare(videoConfig, (err) => {
- if (err == null) {
- console.info('prepare success');
- } else {
- console.info('prepare failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('prepare success');
+ } else {
+ console.error('prepare failed and error is ' + err.message);
+ }
})
```
@@ -2715,32 +2715,32 @@ prepare(config: VideoRecorderConfig): Promise\;
```js
// 配置参数以实际硬件设备支持的范围为准
let videoProfile = {
- audioBitrate : 48000,
- audioChannels : 2,
- audioCodec : 'audio/mp4a-latm',
- audioSampleRate : 48000,
- fileFormat : 'mp4',
- videoBitrate : 2000000,
- videoCodec : 'video/avc',
- videoFrameWidth : 640,
- videoFrameHeight : 480,
- videoFrameRate : 30
+ audioBitrate : 48000,
+ audioChannels : 2,
+ audioCodec : 'audio/mp4a-latm',
+ audioSampleRate : 48000,
+ fileFormat : 'mp4',
+ videoBitrate : 2000000,
+ videoCodec : 'video/avc',
+ videoFrameWidth : 640,
+ videoFrameHeight : 480,
+ videoFrameRate : 30
}
let videoConfig = {
- audioSourceType : 1,
- videoSourceType : 0,
- profile : videoProfile,
- url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
- orientationHint : 0,
- location : { latitude : 30, longitude : 130 },
+ audioSourceType : 1,
+ videoSourceType : 0,
+ profile : videoProfile,
+ url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
+ orientationHint : 0,
+ location : { latitude : 30, longitude : 130 },
}
// promise
videoRecorder.prepare(videoConfig).then(() => {
- console.info('prepare success');
+ console.info('prepare success');
}).catch((err) => {
- console.info('prepare failed and catch error is ' + err.message);
+ console.error('prepare failed and catch error is ' + err.message);
});
```
@@ -2780,12 +2780,12 @@ getInputSurface(callback: AsyncCallback\): void;
// asyncallback
let surfaceID = null; // 传递给外界的surfaceID
videoRecorder.getInputSurface((err, surfaceId) => {
- if (err == null) {
- console.info('getInputSurface success');
- surfaceID = surfaceId;
- } else {
- console.info('getInputSurface failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('getInputSurface success');
+ surfaceID = surfaceId;
+ } else {
+ console.error('getInputSurface failed and error is ' + err.message);
+ }
});
```
@@ -2825,10 +2825,10 @@ getInputSurface(): Promise\;
// promise
let surfaceID = null; // 传递给外界的surfaceID
videoRecorder.getInputSurface().then((surfaceId) => {
- console.info('getInputSurface success');
- surfaceID = surfaceId;
+ console.info('getInputSurface success');
+ surfaceID = surfaceId;
}).catch((err) => {
- console.info('getInputSurface failed and catch error is ' + err.message);
+ console.error('getInputSurface failed and catch error is ' + err.message);
});
```
@@ -2865,11 +2865,11 @@ start(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.start((err) => {
- if (err == null) {
- console.info('start videorecorder success');
- } else {
- console.info('start videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('start videorecorder success');
+ } else {
+ console.error('start videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -2906,9 +2906,9 @@ start(): Promise\;
```js
// promise
videoRecorder.start().then(() => {
- console.info('start videorecorder success');
+ console.info('start videorecorder success');
}).catch((err) => {
- console.info('start videorecorder failed and catch error is ' + err.message);
+ console.error('start videorecorder failed and catch error is ' + err.message);
});
```
@@ -2945,11 +2945,11 @@ pause(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.pause((err) => {
- if (err == null) {
- console.info('pause videorecorder success');
- } else {
- console.info('pause videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('pause videorecorder success');
+ } else {
+ console.error('pause videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -2986,9 +2986,9 @@ pause(): Promise\;
```js
// promise
videoRecorder.pause().then(() => {
- console.info('pause videorecorder success');
+ console.info('pause videorecorder success');
}).catch((err) => {
- console.info('pause videorecorder failed and catch error is ' + err.message);
+ console.error('pause videorecorder failed and catch error is ' + err.message);
});
```
@@ -3023,11 +3023,11 @@ resume(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.resume((err) => {
- if (err == null) {
- console.info('resume videorecorder success');
- } else {
- console.info('resume videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('resume videorecorder success');
+ } else {
+ console.error('resume videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -3062,9 +3062,9 @@ resume(): Promise\;
```js
// promise
videoRecorder.resume().then(() => {
- console.info('resume videorecorder success');
+ console.info('resume videorecorder success');
}).catch((err) => {
- console.info('resume videorecorder failed and catch error is ' + err.message);
+ console.error('resume videorecorder failed and catch error is ' + err.message);
});
```
@@ -3101,11 +3101,11 @@ stop(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.stop((err) => {
- if (err == null) {
- console.info('stop videorecorder success');
- } else {
- console.info('stop videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('stop videorecorder success');
+ } else {
+ console.error('stop videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -3142,9 +3142,9 @@ stop(): Promise\;
```js
// promise
videoRecorder.stop().then(() => {
- console.info('stop videorecorder success');
+ console.info('stop videorecorder success');
}).catch((err) => {
- console.info('stop videorecorder failed and catch error is ' + err.message);
+ console.error('stop videorecorder failed and catch error is ' + err.message);
});
```
@@ -3177,11 +3177,11 @@ release(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.release((err) => {
- if (err == null) {
- console.info('release videorecorder success');
- } else {
- console.info('release videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('release videorecorder success');
+ } else {
+ console.error('release videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -3214,9 +3214,9 @@ release(): Promise\;
```js
// promise
videoRecorder.release().then(() => {
- console.info('release videorecorder success');
+ console.info('release videorecorder success');
}).catch((err) => {
- console.info('release videorecorder failed and catch error is ' + err.message);
+ console.error('release videorecorder failed and catch error is ' + err.message);
});
```
@@ -3252,11 +3252,11 @@ reset(callback: AsyncCallback\): void;
```js
// asyncallback
videoRecorder.reset((err) => {
- if (err == null) {
- console.info('reset videorecorder success');
- } else {
- console.info('reset videorecorder failed and error is ' + err.message);
- }
+ if (err == null) {
+ console.info('reset videorecorder success');
+ } else {
+ console.error('reset videorecorder failed and error is ' + err.message);
+ }
});
```
@@ -3292,9 +3292,9 @@ reset(): Promise\;
```js
// promise
videoRecorder.reset().then(() => {
- console.info('reset videorecorder success');
+ console.info('reset videorecorder success');
}).catch((err) => {
- console.info('reset videorecorder failed and catch error is ' + err.message);
+ console.error('reset videorecorder failed and catch error is ' + err.message);
});
```
@@ -3327,7 +3327,7 @@ on(type: 'error', callback: ErrorCallback): void
```js
// 当获取videoRecordState接口出错时通过此订阅事件上报
videoRecorder.on('error', (error) => { // 设置'error'事件回调
- console.info(`audio error called, error: ${error}`);
+ console.error(`audio error called, error: ${error}`);
})
```
@@ -3429,15 +3429,15 @@ createVideoPlayer(callback: AsyncCallback\): void
**示例:**
```js
-let videoPlayer
+let videoPlayer;
media.createVideoPlayer((error, video) => {
- if (video != null) {
- videoPlayer = video;
- console.info('video createVideoPlayer success');
- } else {
- console.info(`video createVideoPlayer fail, error:${error}`);
- }
+ if (video != null) {
+ videoPlayer = video;
+ console.info('video createVideoPlayer success');
+ } else {
+ console.error(`video createVideoPlayer fail, error:${error}`);
+ }
});
```
@@ -3461,17 +3461,17 @@ createVideoPlayer(): Promise\
**示例:**
```js
-let videoPlayer
+let videoPlayer;
media.createVideoPlayer().then((video) => {
- if (video != null) {
- videoPlayer = video;
- console.info('video createVideoPlayer success');
- } else {
- console.info('video createVideoPlayer fail');
- }
+ if (video != null) {
+ videoPlayer = video;
+ console.info('video createVideoPlayer success');
+ } else {
+ console.error('video createVideoPlayer fail');
+ }
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -3554,7 +3554,7 @@ play(): void
```js
audioPlayer.on('play', () => { //设置'play'事件回调
- console.log('audio play success');
+ console.log('audio play success');
});
audioPlayer.play();
```
@@ -3571,7 +3571,7 @@ pause(): void
```js
audioPlayer.on('pause', () => { //设置'pause'事件回调
- console.log('audio pause success');
+ console.log('audio pause success');
});
audioPlayer.pause();
```
@@ -3588,7 +3588,7 @@ stop(): void
```js
audioPlayer.on('stop', () => { //设置'stop'事件回调
- console.log('audio stop success');
+ console.log('audio stop success');
});
audioPlayer.stop();
```
@@ -3605,7 +3605,7 @@ reset(): void
```js
audioPlayer.on('reset', () => { //设置'reset'事件回调
- console.log('audio reset success');
+ console.log('audio reset success');
});
audioPlayer.reset();
```
@@ -3628,11 +3628,11 @@ seek(timeMs: number): void
```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
- if (seekDoneTime == null) {
- console.info('audio seek fail');
- return;
- }
- console.log('audio seek success. seekDoneTime: ' + seekDoneTime);
+ if (seekDoneTime == null) {
+ console.info('audio seek fail');
+ return;
+ }
+ console.log('audio seek success. seekDoneTime: ' + seekDoneTime);
});
audioPlayer.seek(30000); //seek到30000ms的位置
```
@@ -3655,7 +3655,7 @@ setVolume(vol: number): void
```js
audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调
- console.log('audio volumeChange success');
+ console.log('audio volumeChange success');
});
audioPlayer.setVolume(1); //设置音量到100%
```
@@ -3693,21 +3693,21 @@ getTrackDescription(callback: AsyncCallback\>): void
```js
function printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('audio key is ' + item);
- console.info('audio value is ' + property);
- }
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('audio key is ' + item);
+ console.info('audio value is ' + property);
+ }
}
audioPlayer.getTrackDescription((error, arrList) => {
- if (arrList != null) {
- for (let i = 0; i < arrList.length; i++) {
- printfDescription(arrList[i]);
- }
- } else {
- console.log(`audio getTrackDescription fail, error:${error}`);
+ if (arrList != null) {
+ for (let i = 0; i < arrList.length; i++) {
+ printfDescription(arrList[i]);
}
+ } else {
+ console.log(`audio getTrackDescription fail, error:${error}`);
+ }
});
```
@@ -3729,25 +3729,25 @@ getTrackDescription(): Promise\>
```js
function printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('audio key is ' + item);
- console.info('audio value is ' + property);
- }
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('audio key is ' + item);
+ console.info('audio value is ' + property);
+ }
}
let arrayDescription = null
audioPlayer.getTrackDescription().then((arrList) => {
- if (arrList != null) {
- arrayDescription = arrList;
- } else {
- console.log('audio getTrackDescription fail');
- }
+ if (arrList != null) {
+ arrayDescription = arrList;
+ } else {
+ console.log('audio getTrackDescription fail');
+ }
}).catch((error) => {
- console.info(`audio catchCallback, error:${error}`);
+ console.info(`audio catchCallback, error:${error}`);
});
for (let i = 0; i < arrayDescription.length; i++) {
- printfDescription(arrayDescription[i]);
+ printfDescription(arrayDescription[i]);
}
```
@@ -3770,8 +3770,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js
audioPlayer.on('bufferingUpdate', (infoType, value) => {
- console.log('audio bufferingInfo type: ' + infoType);
- console.log('audio bufferingInfo value: ' + value);
+ console.log('audio bufferingInfo type: ' + infoType);
+ console.log('audio bufferingInfo value: ' + value);
});
```
@@ -3797,40 +3797,40 @@ import fs from '@ohos.file.fs';
let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例
audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调
- console.info('audio set source success');
- audioPlayer.play(); //开始播放,并触发'play'事件回调
+ console.info('audio set source success');
+ audioPlayer.play(); //开始播放,并触发'play'事件回调
});
audioPlayer.on('play', () => { //设置'play'事件回调
- console.info('audio play success');
- audioPlayer.seek(30000); //调用seek方法,并触发'timeUpdate'事件回调
+ console.info('audio play success');
+ audioPlayer.seek(30000); //调用seek方法,并触发'timeUpdate'事件回调
});
audioPlayer.on('pause', () => { //设置'pause'事件回调
- console.info('audio pause success');
- audioPlayer.stop(); //停止播放,并触发'stop'事件回调
+ console.info('audio pause success');
+ audioPlayer.stop(); //停止播放,并触发'stop'事件回调
});
audioPlayer.on('reset', () => { //设置'reset'事件回调
- console.info('audio reset success');
- audioPlayer.release(); //释放播放实例资源
- audioPlayer = undefined;
+ console.info('audio reset success');
+ audioPlayer.release(); //释放播放实例资源
+ audioPlayer = undefined;
});
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
- if (seekDoneTime == null) {
- console.info('audio seek fail');
- return;
- }
- console.info('audio seek success, and seek time is ' + seekDoneTime);
- audioPlayer.setVolume(0.5); //设置音量为50%,并触发'volumeChange'事件回调
+ if (seekDoneTime == null) {
+ console.info('audio seek fail');
+ return;
+ }
+ console.info('audio seek success, and seek time is ' + seekDoneTime);
+ audioPlayer.setVolume(0.5); //设置音量为50%,并触发'volumeChange'事件回调
});
audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调
- console.info('audio volumeChange success');
- audioPlayer.pause(); //暂停播放,并触发'pause'事件回调
+ console.info('audio volumeChange success');
+ audioPlayer.pause(); //暂停播放,并触发'pause'事件回调
});
audioPlayer.on('finish', () => { //设置'finish'事件回调
- console.info('audio play finish');
- audioPlayer.stop(); //停止播放,并触发'stop'事件回调
+ console.info('audio play finish');
+ audioPlayer.stop(); //停止播放,并触发'stop'事件回调
});
audioPlayer.on('error', (error) => { //设置'error'事件回调
- console.info(`audio error called, error: ${error}`);
+ console.error(`audio error called, error: ${error}`);
});
// 用户选择音频设置fd(本地播放)
@@ -3838,13 +3838,13 @@ let fdPath = 'fd://';
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" 命令,将其推送到设备上
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
fs.open(path).then((file) => {
- fdPath = fdPath + '' + file.fd;
- console.info('open fd success fd is' + fdPath);
- audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调
+ fdPath = fdPath + '' + file.fd;
+ console.info('open fd success fd is' + fdPath);
+ audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调
}, (err) => {
- console.info('open fd failed err is' + err);
+ console.info('open fd failed err is' + err);
}).catch((err) => {
- console.info('open fd failed err is' + err);
+ console.info('open fd failed err is' + err);
});
```
@@ -3867,11 +3867,11 @@ on(type: 'timeUpdate', callback: Callback\): void
```js
audioPlayer.on('timeUpdate', (newTime) => { //设置'timeUpdate'事件回调
- if (newTime == null) {
- console.info('audio timeUpadate fail');
- return;
- }
- console.log('audio timeUpadate success. seekDoneTime: ' + newTime);
+ if (newTime == null) {
+ console.info('audio timeUpadate fail');
+ return;
+ }
+ console.log('audio timeUpadate success. seekDoneTime: ' + newTime);
});
audioPlayer.play(); //开始播放后,自动触发时间戳更新事件
```
@@ -3895,7 +3895,7 @@ on(type: 'error', callback: ErrorCallback): void
```js
audioPlayer.on('error', (error) => { //设置'error'事件回调
- console.info(`audio error called, error: ${error}`);
+ console.error(`audio error called, error: ${error}`);
});
audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件
```
@@ -3963,11 +3963,11 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\): void
```js
let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId, (err) => {
- if (err == null) {
- console.info('setDisplaySurface success!');
- } else {
- console.info('setDisplaySurface fail!');
- }
+ if (err == null) {
+ console.info('setDisplaySurface success!');
+ } else {
+ console.error('setDisplaySurface fail!');
+ }
});
```
@@ -3998,9 +3998,9 @@ setDisplaySurface(surfaceId: string): Promise\
```js
let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId).then(() => {
- console.info('setDisplaySurface success');
+ console.info('setDisplaySurface success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4022,11 +4022,11 @@ prepare(callback: AsyncCallback\): void
```js
videoPlayer.prepare((err) => {
- if (err == null) {
- console.info('prepare success!');
- } else {
- console.info('prepare fail!');
- }
+ if (err == null) {
+ console.info('prepare success!');
+ } else {
+ console.error('prepare fail!');
+ }
});
```
@@ -4048,9 +4048,9 @@ prepare(): Promise\
```js
videoPlayer.prepare().then(() => {
- console.info('prepare success');
+ console.info('prepare success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4072,11 +4072,11 @@ play(callback: AsyncCallback\): void;
```js
videoPlayer.play((err) => {
- if (err == null) {
- console.info('play success!');
- } else {
- console.info('play fail!');
- }
+ if (err == null) {
+ console.info('play success!');
+ } else {
+ console.error('play fail!');
+ }
});
```
@@ -4098,9 +4098,9 @@ play(): Promise\;
```js
videoPlayer.play().then(() => {
- console.info('play success');
+ console.info('play success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4122,11 +4122,11 @@ pause(callback: AsyncCallback\): void
```js
videoPlayer.pause((err) => {
- if (err == null) {
- console.info('pause success!');
- } else {
- console.info('pause fail!');
- }
+ if (err == null) {
+ console.info('pause success!');
+ } else {
+ console.info('pause fail!');
+ }
});
```
@@ -4148,9 +4148,9 @@ pause(): Promise\
```js
videoPlayer.pause().then(() => {
- console.info('pause success');
+ console.info('pause success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4172,11 +4172,11 @@ stop(callback: AsyncCallback\): void
```js
videoPlayer.stop((err) => {
- if (err == null) {
- console.info('stop success!');
- } else {
- console.info('stop fail!');
- }
+ if (err == null) {
+ console.info('stop success!');
+ } else {
+ console.error('stop fail!');
+ }
});
```
@@ -4198,9 +4198,9 @@ stop(): Promise\
```js
videoPlayer.stop().then(() => {
- console.info('stop success');
+ console.info('stop success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4222,11 +4222,11 @@ reset(callback: AsyncCallback\): void
```js
videoPlayer.reset((err) => {
- if (err == null) {
- console.info('reset success!');
- } else {
- console.info('reset fail!');
- }
+ if (err == null) {
+ console.info('reset success!');
+ } else {
+ console.error('reset fail!');
+ }
});
```
@@ -4248,9 +4248,9 @@ reset(): Promise\
```js
videoPlayer.reset().then(() => {
- console.info('reset success');
+ console.info('reset success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4274,11 +4274,11 @@ seek(timeMs: number, callback: AsyncCallback\): void
```js
let seekTime = 5000;
videoPlayer.seek(seekTime, (err, result) => {
- if (err == null) {
- console.info('seek success!');
- } else {
- console.info('seek fail!');
- }
+ if (err == null) {
+ console.info('seek success!');
+ } else {
+ console.error('seek fail!');
+ }
});
```
@@ -4304,11 +4304,11 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\): void
import media from '@ohos.multimedia.media'
let seekTime = 5000;
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => {
- if (err == null) {
- console.info('seek success!');
- } else {
- console.info('seek fail!');
- }
+ if (err == null) {
+ console.info('seek success!');
+ } else {
+ console.error('seek fail!');
+ }
});
```
@@ -4339,15 +4339,15 @@ seek(timeMs: number, mode?:SeekMode): Promise\
import media from '@ohos.multimedia.media'
let seekTime = 5000;
videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完成后的时间点
- console.info('seek success');
+ console.info('seek success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
- console.info('seek success');
+ console.info('seek success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4371,11 +4371,11 @@ setVolume(vol: number, callback: AsyncCallback\): void
```js
let vol = 0.5;
videoPlayer.setVolume(vol, (err, result) => {
- if (err == null) {
- console.info('setVolume success!');
- } else {
- console.info('setVolume fail!');
- }
+ if (err == null) {
+ console.info('setVolume success!');
+ } else {
+ console.error('setVolume fail!');
+ }
});
```
@@ -4404,9 +4404,9 @@ setVolume(vol: number): Promise\
```js
let vol = 0.5;
videoPlayer.setVolume(vol).then(() => {
- console.info('setVolume success');
+ console.info('setVolume success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4428,11 +4428,11 @@ release(callback: AsyncCallback\): void
```js
videoPlayer.release((err) => {
- if (err == null) {
- console.info('release success!');
- } else {
- console.info('release fail!');
- }
+ if (err == null) {
+ console.info('release success!');
+ } else {
+ console.error('release fail!');
+ }
});
```
@@ -4454,9 +4454,9 @@ release(): Promise\
```js
videoPlayer.release().then(() => {
- console.info('release success');
+ console.info('release success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4478,21 +4478,21 @@ getTrackDescription(callback: AsyncCallback\>): void
```js
function printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('video key is ' + item);
- console.info('video value is ' + property);
- }
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('video key is ' + item);
+ console.info('video value is ' + property);
+ }
}
videoPlayer.getTrackDescription((error, arrList) => {
- if ((arrList) != null) {
- for (let i = 0; i < arrList.length; i++) {
- printfDescription(arrList[i]);
- }
- } else {
- console.log(`video getTrackDescription fail, error:${error}`);
+ if ((arrList) != null) {
+ for (let i = 0; i < arrList.length; i++) {
+ printfDescription(arrList[i]);
}
+ } else {
+ console.log(`video getTrackDescription fail, error:${error}`);
+ }
});
```
@@ -4514,25 +4514,25 @@ getTrackDescription(): Promise\>
```js
function printfDescription(obj) {
- for (let item in obj) {
- let property = obj[item];
- console.info('video key is ' + item);
- console.info('video value is ' + property);
- }
+ for (let item in obj) {
+ let property = obj[item];
+ console.info('video key is ' + item);
+ console.info('video value is ' + property);
+ }
}
let arrayDescription;
videoPlayer.getTrackDescription().then((arrList) => {
- if (arrList != null) {
- arrayDescription = arrList;
- } else {
- console.log('video getTrackDescription fail');
- }
+ if (arrList != null) {
+ arrayDescription = arrList;
+ } else {
+ console.log('video getTrackDescription fail');
+ }
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.info(`video catchCallback, error:${error}`);
});
for (let i = 0; i < arrayDescription.length; i++) {
- printfDescription(arrayDescription[i]);
+ printfDescription(arrayDescription[i]);
}
```
@@ -4558,11 +4558,11 @@ import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed, (err, result) => {
- if (err == null) {
- console.info('setSpeed success!');
- } else {
- console.info('setSpeed fail!');
- }
+ if (err == null) {
+ console.info('setSpeed success!');
+ } else {
+ console.error('setSpeed fail!');
+ }
});
```
@@ -4593,9 +4593,9 @@ import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed).then(() => {
- console.info('setSpeed success');
+ console.info('setSpeed success');
}).catch((error) => {
- console.info(`video catchCallback, error:${error}`);
+ console.error(`video catchCallback, error:${error}`);
});
```
@@ -4618,7 +4618,7 @@ on(type: 'playbackCompleted', callback: Callback\): void
```js
videoPlayer.on('playbackCompleted', () => {
- console.info('playbackCompleted success!');
+ console.info('playbackCompleted success!');
});
```
@@ -4641,8 +4641,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js
videoPlayer.on('bufferingUpdate', (infoType, value) => {
- console.log('video bufferingInfo type: ' + infoType);
- console.log('video bufferingInfo value: ' + value);
+ console.log('video bufferingInfo type: ' + infoType);
+ console.log('video bufferingInfo value: ' + value);
});
```
@@ -4665,7 +4665,7 @@ on(type: 'startRenderFrame', callback: Callback\): void
```js
videoPlayer.on('startRenderFrame', () => {
- console.info('startRenderFrame success!');
+ console.info('startRenderFrame success!');
});
```
@@ -4688,8 +4688,8 @@ on(type: 'videoSizeChanged', callback: (width: number, height: number) => void):
```js
videoPlayer.on('videoSizeChanged', (width, height) => {
- console.log('video width is: ' + width);
- console.log('video height is: ' + height);
+ console.log('video width is: ' + width);
+ console.log('video height is: ' + height);
});
```
@@ -4712,7 +4712,7 @@ on(type: 'error', callback: ErrorCallback): void
```js
videoPlayer.on('error', (error) => { // 设置'error'事件回调
- console.info(`video error called, error: ${error}`);
+ console.error(`video error called, error: ${error}`);
});
videoPlayer.url = 'fd://error'; //设置错误的播放地址,触发'error'事件
```
@@ -4762,16 +4762,16 @@ prepare(config: AudioRecorderConfig): void
```js
let audioRecorderConfig = {
- audioEncoder : media.AudioEncoder.AAC_LC,
- audioEncodeBitRate : 22050,
- audioSampleRate : 22050,
- numberOfChannels : 2,
- format : media.AudioOutputFormat.AAC_ADTS,
- uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限
- location : { latitude : 30, longitude : 130},
+ audioEncoder : media.AudioEncoder.AAC_LC,
+ audioEncodeBitRate : 22050,
+ audioSampleRate : 22050,
+ numberOfChannels : 2,
+ format : media.AudioOutputFormat.AAC_ADTS,
+ uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限
+ location : { latitude : 30, longitude : 130},
}
audioRecorder.on('prepare', () => { //设置'prepare'事件回调
- console.log('prepare success');
+ console.log('prepare success');
});
audioRecorder.prepare(audioRecorderConfig);
```
@@ -4789,7 +4789,7 @@ start(): void
```js
audioRecorder.on('start', () => { //设置'start'事件回调
- console.log('audio recorder start success');
+ console.log('audio recorder start success');
});
audioRecorder.start();
```
@@ -4806,7 +4806,7 @@ pause():void
```js
audioRecorder.on('pause', () => { //设置'pause'事件回调
- console.log('audio recorder pause success');
+ console.log('audio recorder pause success');
});
audioRecorder.pause();
```
@@ -4823,7 +4823,7 @@ resume():void
```js
audioRecorder.on('resume', () => { //设置'resume'事件回调
- console.log('audio recorder resume success');
+ console.log('audio recorder resume success');
});
audioRecorder.resume();
```
@@ -4840,7 +4840,7 @@ stop(): void
```js
audioRecorder.on('stop', () => { //设置'stop'事件回调
- console.log('audio recorder stop success');
+ console.log('audio recorder stop success');
});
audioRecorder.stop();
```
@@ -4857,7 +4857,7 @@ release(): void
```js
audioRecorder.on('release', () => { //设置'release'事件回调
- console.log('audio recorder release success');
+ console.log('audio recorder release success');
});
audioRecorder.release();
audioRecorder = undefined;
@@ -4877,7 +4877,7 @@ reset(): void
```js
audioRecorder.on('reset', () => { //设置'reset'事件回调
- console.log('audio recorder reset success');
+ console.log('audio recorder reset success');
});
audioRecorder.reset();
```
@@ -4902,38 +4902,38 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset'
```js
let audioRecorder = media.createAudioRecorder(); // 创建一个音频录制实例
let audioRecorderConfig = {
- audioEncoder : media.AudioEncoder.AAC_LC,
- audioEncodeBitRate : 22050,
- audioSampleRate : 22050,
- numberOfChannels : 2,
- format : media.AudioOutputFormat.AAC_ADTS,
- uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
- location : { latitude : 30, longitude : 130},
+ audioEncoder : media.AudioEncoder.AAC_LC,
+ audioEncodeBitRate : 22050,
+ audioSampleRate : 22050,
+ numberOfChannels : 2,
+ format : media.AudioOutputFormat.AAC_ADTS,
+ uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
+ location : { latitude : 30, longitude : 130},
}
audioRecorder.on('error', (error) => { // 设置'error'事件回调
- console.info(`audio error called, error: ${error}`);
+ console.info(`audio error called, error: ${error}`);
});
audioRecorder.on('prepare', () => { // 设置'prepare'事件回调
- console.log('prepare success');
- audioRecorder.start(); // 开始录制,并触发'start'事件回调
+ console.log('prepare success');
+ audioRecorder.start(); // 开始录制,并触发'start'事件回调
});
audioRecorder.on('start', () => { // 设置'start'事件回调
- console.log('audio recorder start success');
+ console.log('audio recorder start success');
});
audioRecorder.on('pause', () => { // 设置'pause'事件回调
- console.log('audio recorder pause success');
+ console.log('audio recorder pause success');
});
audioRecorder.on('resume', () => { // 设置'resume'事件回调
- console.log('audio recorder resume success');
+ console.log('audio recorder resume success');
});
audioRecorder.on('stop', () => { // 设置'stop'事件回调
- console.log('audio recorder stop success');
+ console.log('audio recorder stop success');
});
audioRecorder.on('release', () => { // 设置'release'事件回调
- console.log('audio recorder release success');
+ console.log('audio recorder release success');
});
audioRecorder.on('reset', () => { // 设置'reset'事件回调
- console.log('audio recorder reset success');
+ console.log('audio recorder reset success');
});
audioRecorder.prepare(audioRecorderConfig) // 设置录制参数 ,并触发'prepare'事件回调
```
@@ -4957,16 +4957,16 @@ on(type: 'error', callback: ErrorCallback): void
```js
let audioRecorderConfig = {
- audioEncoder : media.AudioEncoder.AAC_LC,
- audioEncodeBitRate : 22050,
- audioSampleRate : 22050,
- numberOfChannels : 2,
- format : media.AudioOutputFormat.AAC_ADTS,
- uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
- location : { latitude : 30, longitude : 130},
+ audioEncoder : media.AudioEncoder.AAC_LC,
+ audioEncodeBitRate : 22050,
+ audioSampleRate : 22050,
+ numberOfChannels : 2,
+ format : media.AudioOutputFormat.AAC_ADTS,
+ uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
+ location : { latitude : 30, longitude : 130},
}
audioRecorder.on('error', (error) => { // 设置'error'事件回调
- console.info(`audio error called, error: ${error}`);
+ console.error(`audio error called, error: ${error}`);
});
audioRecorder.prepare(audioRecorderConfig); // prepare不设置参数,触发'error'事件
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
index 9689fd14e9f575eacb96e4cf4cfdde00bb06831c..f93daebe1e05919950f81b6c18146a2ee771928a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md
@@ -86,7 +86,7 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
if (err) {
console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`);
} else {
- console.log("activateOsAccount successfully");
+ console.log('activateOsAccount successfully');
}
});
} catch (err) {
@@ -139,7 +139,7 @@ activateOsAccount(localId: number): Promise<void>
console.log('activateOsAccount failed, err:' + JSON.stringify(err));
});
} catch (e) {
- console.log('activateOsAccount exception:' + JSON.stringify(e));
+ console.log('activateOsAccount exception: ' + JSON.stringify(e));
}
```
@@ -172,7 +172,7 @@ checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void
if (err) {
console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
} else {
- console.log("checkMultiOsAccountEnabled successfully, isEnabled: " + isEnabled);
+ console.log('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
}
});
} catch (err) {
@@ -254,7 +254,7 @@ checkOsAccountActivated(localId: number, callback: AsyncCallback<boolean>)
}
});
} catch (err) {
- console.log('checkOsAccountActivated exception:' + JSON.stringify(err));
+ console.log('checkOsAccountActivated exception: ' + JSON.stringify(err));
}
```
@@ -297,10 +297,10 @@ checkOsAccountActivated(localId: number): Promise<boolean>
accountManager.checkOsAccountActivated(localId).then((isActivated) => {
console.log('checkOsAccountActivated successfully, isActivated: ' + isActivated);
}).catch((err) => {
- console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err));
+ console.log('checkOsAccountActivated failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log('checkOsAccountActivated exception:' + JSON.stringify(err));
+ console.log('checkOsAccountActivated exception: ' + JSON.stringify(err));
}
```
@@ -335,17 +335,17 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: A
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let constraint = "constraint.wifi";
+ let constraint = 'constraint.wifi';
try {
accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err, isEnabled)=>{
if (err) {
- console.log("checkOsAccountConstraintEnabled failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkOsAccountConstraintEnabled successfully, isEnabled: " + isEnabled);
+ console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
}
});
} catch (err) {
- console.log("checkOsAccountConstraintEnabled exception: " + JSON.stringify(err));
+ console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
}
```
@@ -385,15 +385,15 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise<
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let constraint = "constraint.wifi";
+ let constraint = 'constraint.wifi';
try {
accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled) => {
- console.log("checkOsAccountConstraintEnabled successfully, isEnabled: " + isEnabled);
+ console.log('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => {
- console.log("checkOsAccountConstraintEnabled failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("checkOsAccountConstraintEnabled exception: " + JSON.stringify(err));
+ console.log('checkOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
}
```
@@ -424,13 +424,13 @@ checkOsAccountTestable(callback: AsyncCallback<boolean>): void
try {
accountManager.checkOsAccountTestable((err, isTestable) => {
if (err) {
- console.log("checkOsAccountTestable failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkOsAccountTestable successfully, isTestable: " + isTestable);
+ console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable);
}
});
} catch (err) {
- console.log("checkOsAccountTestable error: " + JSON.stringify(err));
+ console.log('checkOsAccountTestable error: ' + JSON.stringify(err));
}
```
@@ -460,9 +460,9 @@ checkOsAccountTestable(): Promise<boolean>
let accountManager = account_osAccount.getAccountManager();
try {
accountManager.checkOsAccountTestable().then((isTestable) => {
- console.log("checkOsAccountTestable successfully, isTestable: " + isTestable);
+ console.log('checkOsAccountTestable successfully, isTestable: ' + isTestable);
}).catch((err) => {
- console.log("checkOsAccountTestable failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountTestable failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('checkOsAccountTestable exception: ' + JSON.stringify(err));
@@ -496,13 +496,13 @@ checkOsAccountVerified(callback: AsyncCallback<boolean>): void
try {
accountManager.checkOsAccountVerified((err, isVerified) => {
if (err) {
- console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}
});
} catch (err) {
- console.log("checkOsAccountVerified exception: " + JSON.stringify(err));
+ console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
}
```
@@ -539,13 +539,13 @@ checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>):
try {
accountManager.checkOsAccountVerified(localId, (err, isVerified) => {
if (err) {
- console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
} else {
- console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}
});
} catch (err) {
- console.log("checkOsAccountVerified exception: " + err);
+ console.log('checkOsAccountVerified exception: ' + err);
}
```
@@ -586,9 +586,9 @@ checkOsAccountVerified(localId: number): Promise<boolean>
let localId = 100;
try {
accountManager.checkOsAccountVerified(localId).then((isVerified) => {
- console.log("checkOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => {
- console.log("checkOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
@@ -627,19 +627,19 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void
```js
let accountManager = account_osAccount.getAccountManager();
- let accountName = "testAccountName";
+ let accountName = 'testAccountName';
try {
accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => {
accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{
if (err) {
- console.log("removeOsAccount failed, error: " + JSON.stringify(err));
+ console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
} else {
- console.log("removeOsAccount successfully");
+ console.log('removeOsAccount successfully');
}
});
});
} catch (err) {
- console.log('removeOsAccount exception:' + JSON.stringify(err));
+ console.log('removeOsAccount exception: ' + JSON.stringify(err));
}
```
@@ -680,17 +680,17 @@ removeOsAccount(localId: number): Promise<void>
```js
let accountManager = account_osAccount.getAccountManager();
- let accountName = "testAccountName";
+ let accountName = 'testAccountName';
try {
accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
- console.log("removeOsAccount successfully");
+ console.log('removeOsAccount successfully');
}).catch((err) => {
- console.log("removeOsAccount failed, error: " + JSON.stringify(err));
+ console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
});
});
} catch (err) {
- console.log("removeOsAccount exception: " + JSON.stringify(err));
+ console.log('removeOsAccount exception: ' + JSON.stringify(err));
}
```
@@ -729,17 +729,17 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let constraint = "constraint.wifi";
+ let constraint = 'constraint.wifi';
try {
accountManager.setOsAccountConstraints(localId, [constraint], true, (err) => {
if (err) {
- console.log("setOsAccountConstraints failed, error:" + JSON.stringify(err));
+ console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
} else {
- console.log("setOsAccountConstraints successfully");
+ console.log('setOsAccountConstraints successfully');
}
});
} catch (err) {
- console.log("setOsAccountConstraints exception: " + JSON.stringify(err));
+ console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
}
```
@@ -787,10 +787,10 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
console.log('setOsAccountConstraints succsuccessfully');
}).catch((err) => {
- console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
+ console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log('setOsAccountConstraints exception:' + JSON.stringify(err));
+ console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
}
```
@@ -828,17 +828,17 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback<
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let name = "demoName";
+ let name = 'demoName';
try {
accountManager.setOsAccountName(localId, name, (err) => {
if (err) {
- console.log("setOsAccountName failed, error: " + JSON.stringify(err));
+ console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
} else {
- console.log("setOsAccountName successfully");
+ console.log('setOsAccountName successfully');
}
});
} catch (err) {
- console.log('setOsAccountName exception:' + JSON.stringify(err));
+ console.log('setOsAccountName exception: ' + JSON.stringify(err));
}
```
@@ -886,10 +886,10 @@ setOsAccountName(localId: number, localName: string): Promise<void>
accountManager.setOsAccountName(localId, name).then(() => {
console.log('setOsAccountName successfully');
}).catch((err) => {
- console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
+ console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log('setOsAccountName exception:' + JSON.stringify(err));
+ console.log('setOsAccountName exception: ' + JSON.stringify(err));
}
```
@@ -922,13 +922,13 @@ getOsAccountCount(callback: AsyncCallback<number>): void
try {
accountManager.getOsAccountCount((err, count) => {
if (err) {
- console.log("getOsAccountCount failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountCount successfully, count: " + count);
+ console.log('getOsAccountCount successfully, count: ' + count);
}
});
} catch (err) {
- console.log("getOsAccountCount exception: " + JSON.stringify(err));
+ console.log('getOsAccountCount exception: ' + JSON.stringify(err));
}
```
@@ -960,12 +960,12 @@ getOsAccountCount(): Promise<number>
let accountManager = account_osAccount.getAccountManager();
try {
accountManager.getOsAccountCount().then((count) => {
- console.log("getOsAccountCount successfully, count: " + count);
+ console.log('getOsAccountCount successfully, count: ' + count);
}).catch((err) => {
- console.log("getOsAccountCount failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountCount failed, error: ' + JSON.stringify(err));
});
} catch(err) {
- console.log('getOsAccountCount exception:' + JSON.stringify(err));
+ console.log('getOsAccountCount exception: ' + JSON.stringify(err));
}
```
@@ -996,13 +996,13 @@ getOsAccountLocalId(callback: AsyncCallback<number>): void
try {
accountManager.getOsAccountLocalId((err, localId) => {
if (err) {
- console.log("getOsAccountLocalId failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountLocalId successfully, localId: " + localId);
+ console.log('getOsAccountLocalId successfully, localId: ' + localId);
}
});
} catch (err) {
- console.log("getOsAccountLocalId exception: " + JSON.stringify(err));
+ console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
}
```
@@ -1032,9 +1032,9 @@ getOsAccountLocalId(): Promise<number>
let accountManager = account_osAccount.getAccountManager();
try {
accountManager.getOsAccountLocalId().then((localId) => {
- console.log("getOsAccountLocalId successfully, localId: " + localId);
+ console.log('getOsAccountLocalId successfully, localId: ' + localId);
}).catch((err) => {
- console.log("getOsAccountLocalId failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalId failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('getOsAccountLocalId exception: ' + JSON.stringify(err));
@@ -1071,12 +1071,12 @@ getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): v
try {
accountManager.getOsAccountLocalIdForUid(uid, (err, localId) => {
if (err) {
- console.log("getOsAccountLocalIdForUid failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
}
- console.log("getOsAccountLocalIdForUid successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
});
} catch (err) {
- console.log("getOsAccountLocalIdForUid exception: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
}
```
@@ -1114,9 +1114,9 @@ getOsAccountLocalIdForUid(uid: number): Promise<number>
let uid = 12345678;
try {
accountManager.getOsAccountLocalIdForUid(uid).then((localId) => {
- console.log("getOsAccountLocalIdForUid successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdForUid successfully, localId: ' + localId);
}).catch((err) => {
- console.log("getOsAccountLocalIdForUid failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForUid failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('getOsAccountLocalIdForUid exception: ' + JSON.stringify(err));
@@ -1155,9 +1155,9 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallb
try {
accountManager.getOsAccountLocalIdForDomain(domainInfo, (err, localId) => {
if (err) {
- console.log("getOsAccountLocalIdForDomain failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountLocalIdForDomain successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
}
});
} catch (err) {
@@ -1201,12 +1201,12 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number&g
let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'};
try {
accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId) => {
- console.log("getOsAccountLocalIdForDomain successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
}).catch((err) => {
- console.log("getOsAccountLocalIdForDomain failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForDomain failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log("getOsAccountLocalIdForDomain exception: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForDomain exception: ' + JSON.stringify(err));
}
```
@@ -1245,7 +1245,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
}
});
} catch (err) {
- console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(err));
+ console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
}
```
@@ -1279,10 +1279,10 @@ queryMaxOsAccountNumber(): Promise<number>
accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt);
}).catch((err) => {
- console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
+ console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
});
} catch (err) {
- console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(err));
+ console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
}
```
@@ -1319,13 +1319,13 @@ getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<str
try {
accountManager.getOsAccountConstraints(localId, (err, constraints) => {
if (err) {
- console.log("getOsAccountConstraints failed, err: " + JSON.stringify(err));
+ console.log('getOsAccountConstraints failed, err: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountConstraints successfully, constraints: " + JSON.stringify(constraints));
+ console.log('getOsAccountConstraints successfully, constraints: ' + JSON.stringify(constraints));
}
});
} catch (err) {
- console.log('getOsAccountConstraints exception:' + JSON.stringify(err));
+ console.log('getOsAccountConstraints exception: ' + JSON.stringify(err));
}
```
@@ -1368,10 +1368,10 @@ getOsAccountConstraints(localId: number): Promise<Array<string>>
accountManager.getOsAccountConstraints(localId).then((constraints) => {
console.log('getOsAccountConstraints, constraints: ' + constraints);
}).catch((err) => {
- console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
+ console.log('getOsAccountConstraints err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getOsAccountConstraints exception:' + JSON.stringify(e));
+ console.log('getOsAccountConstraints exception: ' + JSON.stringify(e));
}
```
@@ -1409,7 +1409,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>&
console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
});
} catch (e) {
- console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
+ console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
}
```
@@ -1445,10 +1445,10 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => {
- console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
+ console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
+ console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
}
```
@@ -1485,7 +1485,7 @@ getActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>>
}
});
} catch (e) {
- console.log('getActivatedOsAccountLocalIds exception:' + JSON.stringify(e));
+ console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
}
```
@@ -1517,10 +1517,10 @@ getActivatedOsAccountLocalIds(): Promise<Array<number>>
accountManager.getActivatedOsAccountLocalIds().then((idArray) => {
console.log('getActivatedOsAccountLocalIds, idArray: ' + idArray);
}).catch((err) => {
- console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err));
+ console.log('getActivatedOsAccountLocalIds err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getActivatedOsAccountLocalIds exception:' + JSON.stringify(e));
+ console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
}
```
@@ -1564,7 +1564,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
});
} catch (e) {
- console.log('createOsAccount exception:' + JSON.stringify(e));
+ console.log('createOsAccount exception: ' + JSON.stringify(e));
}
```
@@ -1611,10 +1611,10 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf
accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('createOsAccount err: ' + JSON.stringify(err));
+ console.log('createOsAccount err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('createOsAccount exception:' + JSON.stringify(e));
+ console.log('createOsAccount exception: ' + JSON.stringify(e));
}
```
@@ -1659,7 +1659,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
});
} catch (e) {
- console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
}
```
@@ -1707,10 +1707,10 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
+ console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('createOsAccountForDomain exception:' + JSON.stringify(e));
+ console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
}
```
@@ -1746,7 +1746,7 @@ getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
});
} catch (e) {
- console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
+ console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
}
```
@@ -1780,10 +1780,10 @@ getCurrentOsAccount(): Promise<OsAccountInfo>
accountManager.getCurrentOsAccount().then((accountInfo) => {
console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
+ console.log('getCurrentOsAccount err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
+ console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
}
```
@@ -1825,7 +1825,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>
console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
});
} catch (e) {
- console.log('queryOsAccountById exception:' + JSON.stringify(e));
+ console.log('queryOsAccountById exception: ' + JSON.stringify(e));
}
```
@@ -1870,10 +1870,10 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo>
accountManager.queryOsAccountById(localId).then((accountInfo) => {
console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('queryOsAccountById err: ' + JSON.stringify(err));
+ console.log('queryOsAccountById err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('queryOsAccountById exception:' + JSON.stringify(e));
+ console.log('queryOsAccountById exception: ' + JSON.stringify(e));
}
```
@@ -1939,7 +1939,7 @@ getOsAccountType(): Promise<OsAccountType>
accountManager.getOsAccountType().then((accountType) => {
console.log('getOsAccountType, accountType: ' + accountType);
}).catch((err) => {
- console.log('getOsAccountType err: ' + JSON.stringify(err));
+ console.log('getOsAccountType err: ' + JSON.stringify(err));
});
} catch (e) {
console.log('getOsAccountType exception: ' + JSON.stringify(e));
@@ -2012,7 +2012,7 @@ queryDistributedVirtualDeviceId(): Promise<string>
accountManager.queryDistributedVirtualDeviceId().then((virtualID) => {
console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err) => {
- console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err));
});
} catch (e) {
console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e));
@@ -2057,7 +2057,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>)
console.log('get photo:' + photo + ' by localId: ' + localId);
});
} catch (e) {
- console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
+ console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
}
```
@@ -2102,10 +2102,10 @@ getOsAccountProfilePhoto(localId: number): Promise<string>
accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
console.log('getOsAccountProfilePhoto: ' + photo);
}).catch((err) => {
- console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
+ console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
+ console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
}
```
@@ -2152,7 +2152,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
});
} catch (e) {
- console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
+ console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
}
```
@@ -2203,10 +2203,10 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
console.log('setOsAccountProfilePhoto success');
}).catch((err) => {
- console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
+ console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e));
+ console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
}
```
@@ -2244,7 +2244,7 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback
console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber);
});
} catch (e) {
- console.log('ger localId exception:' + JSON.stringify(e));
+ console.log('ger localId exception: ' + JSON.stringify(e));
}
```
@@ -2285,10 +2285,10 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number>
accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId) => {
console.log('getOsAccountLocalIdForSerialNumber localId: ' + localId);
}).catch((err) => {
- console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err));
+ console.log('getOsAccountLocalIdForSerialNumber err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getOsAccountLocalIdForSerialNumber exception: ' + JSON.stringify(e));
+ console.log('getOsAccountLocalIdForSerialNumber exception: ' + JSON.stringify(e));
}
```
@@ -2326,7 +2326,7 @@ getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<n
console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId);
});
} catch (e) {
- console.log('ger serialNumber exception:' + JSON.stringify(e));
+ console.log('ger serialNumber exception: ' + JSON.stringify(e));
}
```
@@ -2367,10 +2367,10 @@ getSerialNumberForOsAccountLocalId(localId: number): Promise<number>
accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber) => {
console.log('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err) => {
- console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err));
+ console.log('getSerialNumberForOsAccountLocalId err: ' + JSON.stringify(err));
});
} catch (e) {
- console.log('getSerialNumberForOsAccountLocalId exception:' + JSON.stringify(e));
+ console.log('getSerialNumberForOsAccountLocalId exception: ' + JSON.stringify(e));
}
```
@@ -2411,7 +2411,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g
try {
accountManager.on('activating', 'osAccountOnOffNameA', onCallback);
} catch (e) {
- console.log('receive localId exception:' + JSON.stringify(e));
+ console.log('receive localId exception: ' + JSON.stringify(e));
}
```
@@ -2452,7 +2452,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number
try {
accountManager.off('activating', 'osAccountOnOffNameA', offCallback);
} catch (e) {
- console.log('off exception:' + JSON.stringify(e));
+ console.log('off exception: ' + JSON.stringify(e));
}
```
@@ -2491,7 +2491,7 @@ getBundleIdForUid(uid: number, callback: AsyncCallback<number>): void;
console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId));
});
} catch (e) {
- console.info('getBundleIdForUid exception:' + JSON.stringify(e));
+ console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
}
```
### getBundleIdForUid9+
@@ -2535,7 +2535,7 @@ getBundleIdForUid(uid: number): Promise<number>;
console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
});
} catch (e) {
- console.info('getBundleIdForUid exception:' + JSON.stringify(e));
+ console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
}
```
@@ -2573,7 +2573,7 @@ isMainOsAccount(callback: AsyncCallback<boolean>): void;
console.info('isMainOsAccount result:' + JSON.stringify(result));
});
} catch (e) {
- console.info('isMainOsAccount exception:' + JSON.stringify(e));
+ console.info('isMainOsAccount exception: ' + JSON.stringify(e));
}
```
### isMainOsAccount9+
@@ -2611,7 +2611,7 @@ isMainOsAccount(): Promise<boolean>;
console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
});
} catch (e) {
- console.info('isMainOsAccount exception:' + JSON.stringify(e));
+ console.info('isMainOsAccount exception: ' + JSON.stringify(e));
}
```
### getOsAccountConstraintSourceTypes9+
@@ -2652,7 +2652,7 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback:
console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
});
} catch (e) {
- console.info('getOsAccountConstraintSourceTypes exception:' + JSON.stringify(e));
+ console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
}
```
@@ -2700,7 +2700,7 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise&
console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
});
} catch (e) {
- console.info('getOsAccountConstraintSourceTypes exception:' + JSON.stringify(e));
+ console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
}
```
@@ -2728,9 +2728,9 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
let accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => {
if (err) {
- console.log("isMultiOsAccountEnable failed, error: " + JSON.stringify(err));
+ console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
} else {
- console.log("isMultiOsAccountEnable successfully, isEnabled: " + isEnabled);
+ console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
}
});
```
@@ -2760,7 +2760,7 @@ isMultiOsAccountEnable(): Promise<boolean>
accountManager.isMultiOsAccountEnable().then((isEnabled) => {
console.log('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
}).catch((err) => {
- console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
+ console.log('isMultiOsAccountEnable failed, error: ' + JSON.stringify(err));
});
```
@@ -2834,7 +2834,7 @@ isOsAccountActived(localId: number): Promise<boolean>
accountManager.isOsAccountActived(localId).then((isActived) => {
console.log('isOsAccountActived successfully, isActived: ' + isActived);
}).catch((err) => {
- console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
+ console.log('isOsAccountActived failed, error: ' + JSON.stringify(err));
});
```
@@ -2865,12 +2865,12 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let constraint = "constraint.wifi";
+ let constraint = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint, (err, isEnabled) => {
if (err) {
- console.log("isOsAccountConstraintEnable failed, error:" + JSON.stringify(err));
+ console.log('isOsAccountConstraintEnable failed, error: ' + JSON.stringify(err));
} else {
- console.log("isOsAccountConstraintEnable successfully, isEnabled:" + isEnabled);
+ console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
}
});
```
@@ -2907,11 +2907,11 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo
```js
let accountManager = account_osAccount.getAccountManager();
let localId = 100;
- let constraint = "constraint.wifi";
+ let constraint = 'constraint.wifi';
accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled) => {
- console.log("isOsAccountConstraintEnable successfully, isEnabled: " + isEnabled);
+ console.log('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
}).catch((err) => {
- console.log("isOsAccountConstraintEnable err: " + JSON.stringify(err));
+ console.log('isOsAccountConstraintEnable err: ' + JSON.stringify(err));
});
```
@@ -2939,9 +2939,9 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void
let accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTestable) => {
if (err) {
- console.log("isTestOsAccount failed, error: " + JSON.stringify(err));
+ console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
} else {
- console.log("isTestOsAccount successfully, isTestable: " + isTestable);
+ console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
}
});
```
@@ -2969,9 +2969,9 @@ isTestOsAccount(): Promise<boolean>
```js
let accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTestable) => {
- console.log("isTestOsAccount successfully, isTestable: " + isTestable);
+ console.log('isTestOsAccount successfully, isTestable: ' + isTestable);
}).catch((err) => {
- console.log("isTestOsAccount failed, error: " + JSON.stringify(err));
+ console.log('isTestOsAccount failed, error: ' + JSON.stringify(err));
});
```
@@ -3001,9 +3001,9 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void
let accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => {
if (err) {
- console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
} else {
- console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}
});
```
@@ -3036,9 +3036,9 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo
let localId = 100;
accountManager.isOsAccountVerified(localId, (err, isVerified) => {
if (err) {
- console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
} else {
- console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}
});
```
@@ -3074,9 +3074,9 @@ isOsAccountVerified(localId?: number): Promise<boolean>
```js
let accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified(localId).then((isVerified) => {
- console.log("isOsAccountVerified successfully, isVerified: " + isVerified);
+ console.log('isOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => {
- console.log("isOsAccountVerified failed, error: " + JSON.stringify(err));
+ console.log('isOsAccountVerified failed, error: ' + JSON.stringify(err));
});
```
@@ -3106,9 +3106,9 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
let accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, count)=>{
if (err) {
- console.log("getCreatedOsAccountsCount failed, error: " + JSON.stringify(err));
+ console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
} else {
- console.log("getCreatedOsAccountsCount successfully, count: " + count);
+ console.log('getCreatedOsAccountsCount successfully, count: ' + count);
}
});
```
@@ -3138,9 +3138,9 @@ getCreatedOsAccountsCount(): Promise<number>
```js
let accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((count) => {
- console.log("getCreatedOsAccountsCount successfully, count: " + count);
+ console.log('getCreatedOsAccountsCount successfully, count: ' + count);
}).catch((err) => {
- console.log("getCreatedOsAccountsCount failed, error: " + JSON.stringify(err));
+ console.log('getCreatedOsAccountsCount failed, error: ' + JSON.stringify(err));
});
```
@@ -3168,9 +3168,9 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, localId) => {
if (err) {
- console.log("getOsAccountLocalIdFromProcess failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountLocalIdFromProcess successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdFromProcess failed, error: ' + localId);
}
});
```
@@ -3200,7 +3200,7 @@ getOsAccountLocalIdFromProcess(): Promise<number>
accountManager.getOsAccountLocalIdFromProcess().then((localId) => {
console.log('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
}).catch((err) => {
- console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromProcess failed, error: ' + JSON.stringify(err));
});
```
@@ -3230,9 +3230,9 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>):
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, localId) => {
if (err) {
- console.log("getOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountLocalIdFromUid successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
}
});
```
@@ -3267,9 +3267,9 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number>
let accountManager = account_osAccount.getAccountManager();
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((localId) => {
- console.log("getOsAccountLocalIdFromUid successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
}).catch((err) => {
- console.log("getOsAccountLocalIdFromUid failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromUid failed, error: ' + JSON.stringify(err));
});
```
@@ -3301,9 +3301,9 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
let accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, localId) => {
if (err) {
- console.log("getOsAccountLocalIdFromDomain failed, error: " + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
} else {
- console.log("getOsAccountLocalIdFromDomain successfully, localId: " + localId);
+ console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
}
});
```
@@ -3342,7 +3342,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number&
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId) => {
console.log('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
}).catch((err) => {
- console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
+ console.log('getOsAccountLocalIdFromDomain failed, error: ' + JSON.stringify(err));
});
```
@@ -3412,7 +3412,7 @@ getOsAccountAllConstraints(localId: number): Promise<Array<string>>
accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
console.log('getOsAccountAllConstraints, constraints: ' + constraints);
}).catch((err) => {
- console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
+ console.log('getOsAccountAllConstraints err: ' + JSON.stringify(err));
});
```
@@ -3472,7 +3472,7 @@ queryActivatedOsAccountIds(): Promise<Array<number>>
accountManager.queryActivatedOsAccountIds().then((idArray) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
}).catch((err) => {
- console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
+ console.log('queryActivatedOsAccountIds err: ' + JSON.stringify(err));
});
```
@@ -3533,7 +3533,7 @@ queryCurrentOsAccount(): Promise<OsAccountInfo>
accountManager.queryCurrentOsAccount().then((accountInfo) => {
console.log('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
}).catch((err) => {
- console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
+ console.log('queryCurrentOsAccount err: ' + JSON.stringify(err));
});
```
@@ -3590,7 +3590,7 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType>
accountManager.getOsAccountTypeFromProcess().then((accountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
}).catch((err) => {
- console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
+ console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err));
});
```
@@ -3651,7 +3651,7 @@ getDistributedVirtualDeviceId(): Promise<string>
accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err) => {
- console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
+ console.log('getDistributedVirtualDeviceId err: ' + JSON.stringify(err));
});
```
@@ -3717,7 +3717,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
console.log('getOsAccountLocalIdBySerialNumber localId: ' + localId);
}).catch((err) => {
- console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
+ console.log('getOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err));
});
```
@@ -3783,7 +3783,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
console.log('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
}).catch((err) => {
- console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
+ console.log('getSerialNumberByOsAccountLocalId err: ' + JSON.stringify(err));
});
```
@@ -4396,7 +4396,7 @@ static unregisterInputer(authType: AuthType): void
account_osAccount.InputerManager.unregisterInputer(authType);
console.log('unregisterInputer success.');
} catch(err) {
- console.log("unregisterInputer err:" + JSON.stringify(err));
+ console.log('unregisterInputer err:' + JSON.stringify(err));
}
```
@@ -4577,7 +4577,7 @@ getAccountInfo(domain: string, accountName: string, callback: AsyncCallback<D
}, {
domain: domain,
accountName: accountName,
- accountId: "xxxx"
+ accountId: 'xxxx'
})
},
getAuthStatusInfo: (domainAccountInfo, callback) => {},
@@ -4823,7 +4823,7 @@ static registerPlugin(plugin: DomainPlugin): void
account_osAccount.DomainAccountManager.registerPlugin(plugin);
console.log('registerPlugin success.');
} catch(err) {
- console.log("registerPlugin err:" + JSON.stringify(err));
+ console.log('registerPlugin err:' + JSON.stringify(err));
}
```
@@ -4845,7 +4845,7 @@ static unregisterPlugin(): void
account_osAccount.DomainAccountManager.unregisterPlugin();
console.log('unregisterPlugin success.');
} catch(err) {
- console.log("unregisterPlugin err:" + JSON.stringify(err));
+ console.log('unregisterPlugin err:' + JSON.stringify(err));
}
```
@@ -4888,8 +4888,8 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
**示例:**
```js
let domainAccountInfo = {
- domain: "CHINA",
- accountName: "zhangsan"
+ domain: 'CHINA',
+ accountName: 'zhangsan'
}
let credential = new Uint8Array([0])
try {
@@ -5030,15 +5030,15 @@ hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<bool
**示例:**
```js
let domainAccountInfo = {
- domain: "CHINA",
- accountName: "zhangsan"
+ domain: 'CHINA',
+ accountName: 'zhangsan'
}
try {
account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err, result) => {
if (err) {
- console.log("call hasAccount failed, error: " + JSON.stringify(err));
+ console.log('call hasAccount failed, error: ' + JSON.stringify(err));
} else {
- console.log("hasAccount result: " + result);
+ console.log('hasAccount result: ' + result);
}
});
} catch (err) {
@@ -5081,14 +5081,14 @@ hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean>
**示例:**
```js
let domainAccountInfo = {
- domain: "CHINA",
- accountName: "zhangsan"
+ domain: 'CHINA',
+ accountName: 'zhangsan'
}
try {
account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result) => {
- console.log("hasAccount result: " + result);
+ console.log('hasAccount result: ' + result);
}).catch((err) => {
- console.log("call hasAccount failed, error: " + JSON.stringify(err));
+ console.log('call hasAccount failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('hasAccount exception = ' + JSON.stringify(err));
@@ -5126,17 +5126,17 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, call
**示例:**
```js
let domainAccountInfo = {
- domain: "CHINA",
- accountName: "zhangsan",
- accountId: "123456"
+ domain: 'CHINA',
+ accountName: 'zhangsan',
+ accountId: '123456'
}
let token = new Uint8Array([0])
try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err) => {
if (err != null) {
- console.log("updateAccountToken failed, error: " + JSON.stringify(err));
+ console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
} else {
- console.log("updateAccountToken successfully");
+ console.log('updateAccountToken successfully');
}
})
} catch (err) {
@@ -5180,16 +5180,16 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Pro
**示例:**
```js
let domainAccountInfo = {
- domain: "CHINA",
- accountName: "zhangsan",
- accountId: "123456"
+ domain: 'CHINA',
+ accountName: 'zhangsan',
+ accountId: '123456'
}
let token = new Uint8Array([0])
try {
account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => {
- console.log("updateAccountToken successfully");
+ console.log('updateAccountToken successfully');
}).catch((err) => {
- console.log("updateAccountToken failed, error: " + JSON.stringify(err));
+ console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('updateAccountToken exception = ' + JSON.stringify(err));
@@ -5465,7 +5465,7 @@ cancel(challenge: Uint8Array): void;
try {
userIDM.cancel(challenge);
} catch(err) {
- console.log("cancel err:" + JSON.stringify(err));
+ console.log('cancel err:' + JSON.stringify(err));
}
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
index 585dd679ca6634077f2726a7c063c08d83f538e6..d7ff5598a78d4d713a33c6172c06f94d65a94d90 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
@@ -58,7 +58,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0).then(() => {
+ privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.PERMISSION_USED_STATS', 1, 0).then(() => {
console.log('addPermissionUsedRecord success');
}).catch((err) => {
console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
@@ -108,7 +108,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0, (err, data) => {
+ privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.PERMISSION_USED_STATS', 1, 0, (err, data) => {
if (err) {
console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
} else {
@@ -160,14 +160,14 @@ getPermissionUsedRecord(request: PermissionUsedRequest): Promise<PermissionUs
import privacyManager from '@ohos.privacyManager';
let request = {
- "tokenId": 1,
- "isRemote": false,
- "deviceId": "device",
- "bundleName": "bundle",
- "permissionNames": [],
- "beginTime": 0,
- "endTime": 1,
- "flag":privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
+ 'tokenId': 1,
+ 'isRemote': false,
+ 'deviceId': 'device',
+ 'bundleName': 'bundle',
+ 'permissionNames': [],
+ 'beginTime': 0,
+ 'endTime': 1,
+ 'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
};
try {
privacyManager.getPermissionUsedRecord(request).then((data) => {
@@ -215,14 +215,14 @@ getPermissionUsedRecord(request: PermissionUsedRequest, callback: AsyncCallback&
import privacyManager from '@ohos.privacyManager';
let request = {
- "tokenId": 1,
- "isRemote": false,
- "deviceId": "device",
- "bundleName": "bundle",
- "permissionNames": [],
- "beginTime": 0,
- "endTime": 1,
- "flag":privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
+ 'tokenId': 1,
+ 'isRemote': false,
+ 'deviceId': 'device',
+ 'bundleName': 'bundle',
+ 'permissionNames': [],
+ 'beginTime': 0,
+ 'endTime': 1,
+ 'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
};
try {
privacyManager.getPermissionUsedRecord(request, (err, data) => {
@@ -280,7 +280,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.startUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS").then(() => {
+ privacyManager.startUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS').then(() => {
console.log('startUsingPermission success');
}).catch((err) => {
console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`);
@@ -328,7 +328,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.startUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS", (err, data) => {
+ privacyManager.startUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS', (err, data) => {
if (err) {
console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -383,7 +383,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.stopUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS").then(() => {
+ privacyManager.stopUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS').then(() => {
console.log('stopUsingPermission success');
}).catch((err) => {
console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
@@ -431,7 +431,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId
try {
- privacyManager.stopUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS", (err, data) => {
+ privacyManager.stopUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS', (err, data) => {
if (err) {
console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -481,7 +481,7 @@ import privacyManager from '@ohos.privacyManager';
let permissionList = [];
try {
privacyManager.on('activeStateChange', permissionList, (data) => {
- console.debug("receive permission state change, data:" + JSON.stringify(data));
+ console.debug('receive permission state change, data:' + JSON.stringify(data));
});
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
@@ -513,7 +513,7 @@ off(type: 'activeStateChange', permissionList: Array<Permissions>, callbac
| 错误码ID | 错误信息 |
| -------- | -------- |
| 12100001 | The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. |
-| 12100004 | The interface is not used together with "on"|
+| 12100004 | The interface is not used together with 'on'|
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md
index b5e1808f23bee943f177affcdf7d733e883975a9..e00729e7e1c8b3f57a20337b28e4cfd17d212475 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md
@@ -2396,7 +2396,7 @@ readException(): void
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -2414,10 +2414,10 @@ readException(): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -4856,9 +4856,9 @@ readException(): void
Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- // 仅FA模型需要导入@ohos.ability.;featureAbility
+ // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -4876,10 +4876,10 @@ readException(): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -5450,6 +5450,7 @@ marshalling(dataOut: MessageSequence): boolean
| 类型 | 说明 |
| ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。|
+
**示例:**
```ts
@@ -5555,6 +5556,7 @@ marshalling(dataOut: MessageParcel): boolean
| 类型 | 说明 |
| ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。 |
+
**示例:**
```ts
@@ -5671,7 +5673,7 @@ asObject(): IRemoteObject
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -5689,10 +5691,10 @@ asObject(): IRemoteObject
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6115,7 +6117,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6133,10 +6135,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6191,7 +6193,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6209,10 +6211,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6275,7 +6277,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6293,10 +6295,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6352,7 +6354,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6383,10 +6385,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
result.data.reclaim();
result.reply.reclaim();
}
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6433,7 +6435,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6464,10 +6466,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
result.data.reclaim();
result.reply.reclaim();
}
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6517,7 +6519,7 @@ getLocalInterface(interface: string): IRemoteBroker
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6535,10 +6537,10 @@ getLocalInterface(interface: string): IRemoteBroker
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6583,7 +6585,7 @@ queryLocalInterface(interface: string): IRemoteBroker
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6601,10 +6603,10 @@ queryLocalInterface(interface: string): IRemoteBroker
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6645,7 +6647,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6663,10 +6665,10 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6717,7 +6719,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6735,10 +6737,10 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6784,7 +6786,7 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6802,10 +6804,10 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6857,7 +6859,7 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6875,10 +6877,10 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -6925,7 +6927,7 @@ getDescriptor(): string
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6943,10 +6945,10 @@ getDescriptor(): string
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getDescriptor接口方法获取对象的接口描述符
@@ -6984,7 +6986,7 @@ getInterfaceDescriptor(): string
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -7002,10 +7004,10 @@ getInterfaceDescriptor(): string
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -7037,7 +7039,7 @@ isObjectDead(): boolean
```ts
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
-
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -7055,10 +7057,10 @@ isObjectDead(): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
-
+
// FA模型使用此方法连接服务
// FA.connectAbility(want,connect);
-
+
globalThis.context.connectServiceExtensionAbility(want, connect);
```
@@ -7093,9 +7095,9 @@ MessageOption构造函数。
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | --------- | ------ | ---- | -------------------------------------- |
- | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------- | ---- | -------------------------------------- |
+| async | boolean | 否 | 同步调用或异步调用标志。默认同步调用。 |
**示例:**
@@ -7823,7 +7825,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
| 类型 | 说明 |
| ---------------------------- | --------------------------------------------- |
- | Promise<RequestResult> | 返回一个期约,兑现值是sendRequestResult实例。 |
+ | Promise<RequestResult> | 返回一个期约,兑现值是RequestResult实例。 |
**示例:**
@@ -9099,30 +9101,31 @@ readFromAshmem(size: number, offset: number): number[]
```ts
import Ability from '@ohos.app.ability.UIAbility';
+
export default class MainAbility extends Ability {
- onCreate(want, launchParam) {
- console.log("[Demo] MainAbility onCreate");
- globalThis.context = this.context;
- }
- onDestroy() {
- console.log("[Demo] MainAbility onDestroy");
- }
- onWindowStageCreate(windowStage) {
- // Main window is created, set main page for this ability
- console.log("[Demo] MainAbility onWindowStageCreate");
- }
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- console.log("[Demo] MainAbility onWindowStageDestroy");
- }
- onForeground() {
- // Ability has brought to foreground
- console.log("[Demo] MainAbility onForeground");
- }
- onBackground() {
- // Ability has back to background
- console.log("[Demo] MainAbility onBackground");
- }
+ onCreate(want, launchParam) {
+ console.log("[Demo] MainAbility onCreate");
+ globalThis.context = this.context;
+ }
+ onDestroy() {
+ console.log("[Demo] MainAbility onDestroy");
+ }
+ onWindowStageCreate(windowStage) {
+ // Main window is created, set main page for this ability
+ console.log("[Demo] MainAbility onWindowStageCreate");
+ }
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ console.log("[Demo] MainAbility onWindowStageDestroy");
+ }
+ onForeground() {
+ // Ability has brought to foreground
+ console.log("[Demo] MainAbility onForeground");
+ }
+ onBackground() {
+ // Ability has back to background
+ console.log("[Demo] MainAbility onBackground");
+ }
};
```
diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md
index 0043c09e41e49e8ff649595c84637a84bce104c2..d0e55e4c73a6f17fba89c356fbae45e88e5b37d9 100644
--- a/zh-cn/device-dev/subsystems/Readme-CN.md
+++ b/zh-cn/device-dev/subsystems/Readme-CN.md
@@ -127,3 +127,5 @@
- [热场景定制开发指导](subsys-thermal_scene.md)
- 电源管理
- [电源模式定制开发指导](subsys-power-mode-customization.md)
+ - [电源默认休眠行为定制开发指导](subsys-power-default-sleep-behavior-customization.md)
+ - [唤醒源定制开发指导](subsys-power-wakeup-source-customization.md)
diff --git a/zh-cn/device-dev/subsystems/subsys-power-default-sleep-behavior-customization.md b/zh-cn/device-dev/subsystems/subsys-power-default-sleep-behavior-customization.md
new file mode 100644
index 0000000000000000000000000000000000000000..08612ccc2456eefc2547f40c05e38848947f3fd5
--- /dev/null
+++ b/zh-cn/device-dev/subsystems/subsys-power-default-sleep-behavior-customization.md
@@ -0,0 +1,161 @@
+# 电源默认休眠行为定制开发指导
+
+## 概述
+
+### 简介
+
+当前OpenHarmony灭屏后会启动运行锁循环检测线程,然后默认进入休眠状态。不同设备的灭屏方式不相同,可能为合盖灭屏、超时灭屏或是按电源键灭屏等;灭屏后的默认行为也不相同,可能为无动作、将屏幕下电,或是进入休眠状态等。为此,OpenHarmony提供电源默认休眠行为的定制方式,产品可以根据具体的设计规格来定制此特性。
+
+### 约束与限制
+
+配置策略:
+产品定制的配置路径,需要根据[配置策略](https://gitee.com/openharmony/customization_config_policy)决定。本开发指导中的定制路径以`/vendor`进行举例,请开发者根据具体的产品配置策略,修改定制路径。
+
+## 开发指导
+
+### 搭建环境
+
+设备要求:
+
+标准系统开发板,如DAYU200/Hi3516DV300开源套件。
+
+环境要求:
+
+Linux调测环境,相关要求和配置可参考《[快速入门](../quick-start/quickstart-overview.md)》
+
+### 开发步骤
+
+本文以[DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568)为例介绍电源默认休眠行为的定制方法。
+
+1. 在产品目录`/vendor/hihope/rk3568`下创建power_manager文件夹。
+
+2. 参考电源管理服务组件中的[电源默认休眠行为配置文件夹](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile)创建目标文件夹,并安装到`/vendor/hihope/rk3568/power_manager`目录下,文件格式如下:
+
+ ```text
+ profile
+ ├── BUILD.gn
+ ├── power_suspend.json
+ ```
+
+3. 编写定制的power_suspend.json,定制后的电源默认休眠行为示例如下:
+
+ ```json
+ {
+ "powerkey": {
+ "action": 1,
+ "delayMs": 0
+ },
+ "timeout": {
+ "action": 1,
+ "delayMs": 0
+ },
+ "lid": {
+ "action": 1,
+ "delayMs": 0
+ },
+ "switch": {
+ "action": 1,
+ "delayMs": 0
+ }
+ }
+ ```
+
+ **表1** 休眠源说明
+
+ | 休眠源 | 描述 |
+ | -------- | -------- |
+ | powerkey | 电源键灭屏 |
+ | timeout | 超时灭屏 |
+ | lid | 皮套灭屏 |
+ | switch | 合盖灭屏 |
+
+ **表2** 休眠源配置说明
+
+ | 配置项 | 描述 |
+ | -------- | -------- |
+ | action | 执行动作,需配置具体枚举值数字,详细说明见下表。 |
+ | delayMs | 延迟时间,单位毫秒。 |
+
+ **表3** action说明
+
+ | action | 取值 | 描述 |
+ | -------- | -------- | -------- |
+ | ACTION_NONE | 0 | 无动作 |
+ | ACTION_AUTO_SUSPEND | 1 | 自动进入睡眠 |
+ | ACTION_FORCE_SUSPEND | 2 | 强制进入睡眠 |
+ | ACTION_HIBERNATE | 3 | 进入休眠 |
+ | ACTION_SHUTDOWN | 4 | 关机 |
+
+4. 参考[电源默认休眠行为的配置文件夹中的BUILD.gn](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/BUILD.gn)编写BUILD.gn文件,将power_suspend.json打包到`/vendor/etc/power_config`目录下,配置如下:
+
+ ```shell
+ import("//build/ohos.gni") #引用build/ohos.gni
+
+ ohos_prebuilt_etc("suspend_config") {
+ source = "power_suspend.json"
+ relative_install_dir = "power_config"
+ install_images = [ chipset_base_dir ] #安装到vendor目录下的必要配置
+ part_name = "product_rk3568" #part_name为product_rk3568,以实现后续编译
+ }
+ ```
+
+5. 将编译目标添加到`/vendor/hihope/rk3568`目录下[ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build)的"module_list"中,例如:
+
+ ```json
+ {
+ "parts": {
+ "product_rk3568": {
+ "module_list": [
+ "//vendor/hihope/rk3568/default_app_config:default_app_config",
+ "//vendor/hihope/rk3568/image_conf:custom_image_conf",
+ "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
+ "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
+ "//vendor/hihope/rk3568/etc:product_etc_conf",
+ "//vendor/hihope/rk3568/power_manager/profile:suspend_config" //添加suspend_config的编译
+ ]
+ }
+ },
+ "subsystem": "product_hihope"
+ }
+ ```
+ “//vendor/hihope/rk3568/power_manager/”为文件夹路径,“profile”为创建的文件夹名字,“suspend_config”为编译目标。
+
+6. 参考《[快速入门](../quick-start/quickstart-overview.md)》编译定制版本,编译命令如下:
+
+ ```shell
+ ./build.sh --product-name rk3568 --ccache
+ ```
+
+7. 将定制版本烧录到DAYU200开发板中。
+
+### 调测验证
+
+1. 以新的休眠源配置文件为例,更改之后:
+ ```json
+ {
+ "powerkey": {
+ "action": 4,
+ "delayMs": 0
+ },
+ "timeout": {
+ "action": 1,
+ "delayMs": 0
+ },
+ "lid": {
+ "action": 1,
+ "delayMs": 0
+ },
+ "switch": {
+ "action": 1,
+ "delayMs": 0
+ }
+ }
+ ```
+
+2. 开机后,点击电源按键。
+
+ 设备进入关机状态。
+
+3. 再次开机后等待一段时间。
+
+ 设备进入黑屏状态。
diff --git a/zh-cn/device-dev/subsystems/subsys-power-wakeup-source-customization.md b/zh-cn/device-dev/subsystems/subsys-power-wakeup-source-customization.md
new file mode 100644
index 0000000000000000000000000000000000000000..b936244d2226a6baba18be6b1cae33126408c611
--- /dev/null
+++ b/zh-cn/device-dev/subsystems/subsys-power-wakeup-source-customization.md
@@ -0,0 +1,178 @@
+# 唤醒源定制开发指导
+
+## 概述
+
+### 简介
+
+OpenHarmony支持多种唤醒源,如电源键、键盘、鼠标等,并提供了定制开启和关闭的方式。当设备进入休眠状态后,用户可以通过按电源键、按键盘、鼠标事件等,来点亮屏幕并唤醒设备。但不同的产品可能支持不同的外设,比如无手写笔、无皮套等。为此,OpenHarmony提供唤醒源的定制方式,产品可以根据具体的设计规格来定制此特性。
+
+### 约束与限制
+
+配置策略:
+产品定制的配置路径,需要根据[配置策略](https://gitee.com/openharmony/customization_config_policy)决定。本开发指导中的定制路径以`/vendor`进行举例,请开发者根据具体的产品配置策略,修改定制路径。
+
+## 开发指导
+
+### 搭建环境
+
+设备要求:
+
+标准系统开发板,如DAYU200/Hi3516DV300开源套件。
+
+环境要求:
+
+Linux调测环境,相关要求和配置可参考《[快速入门](../quick-start/quickstart-overview.md)》
+
+### 开发步骤
+
+本文以[DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568)为例介绍唤醒源的定制方法。
+
+1. 在产品目录`/vendor/hihope/rk3568`下创建power_manager文件夹。
+
+2. 参考[唤醒源文件夹](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile)创建目标文件夹,并安装到`/vendor/hihope/rk3568/power_manager`目录下,文件格式如下:
+
+ ```text
+ profile
+ ├── BUILD.gn
+ ├── power_wakeup.json
+ ```
+
+3. 编写定制的power_wakeup.json,包含定制后的唤醒源如下:
+
+ ```json
+ {
+ "powerkey": {
+ "enable": true
+ },
+ "keyborad": {
+ "enable": true
+ },
+ "mouse": {
+ "enable": true
+ },
+ "touchscreen": {
+ "enable": true,
+ "click": 2
+ },
+ "touchpad": {
+ "enable": true
+ },
+ "pen": {
+ "enable": true
+ },
+ "lid": {
+ "enable": true
+ },
+ "switch": {
+ "enable": true
+ }
+ }
+ ```
+
+ **表1** 唤醒源说明
+
+ | 休眠源 | 描述 |
+ | -------- | -------- |
+ | powerkey | 电源键唤醒 |
+ | keyborad | 键盘唤醒 |
+ | mouse | 鼠标唤醒 |
+ | touchscreen | 触摸屏幕唤醒 |
+ | touchpad | 触摸板唤醒 |
+ | pen | 手写笔唤醒 |
+ | lid | 皮套唤醒 |
+ | switch | 盖子唤醒 |
+
+ **表2** 唤醒源配置说明
+
+ | 配置项 | 类型 | 描述 |
+ | -------- | -------- | -------- |
+ | enable | bool | 是否开启唤醒监听 |
+ | click | int | 点击次数 |
+
+
+4. 参考[唤醒源的配置文件夹中的BUILD.gn](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/BUILD.gn)编写BUILD.gn文件,将power_wakeup.json打包到`/vendor/etc/power_config`目录下,配置如下:
+
+ ```shell
+ import("//build/ohos.gni") #引用build/ohos.gni
+
+ ohos_prebuilt_etc("wakeup_config") {
+ source = "power_wakeup.json"
+ relative_install_dir = "power_config"
+ install_images = [ chipset_base_dir ] #安装到vendor目录下的必要配置
+ part_name = "product_rk3568" #part_name为product_rk3568,以实现后续编译
+ }
+ ```
+
+5. 将编译目标添加到`/vendor/hihope/rk3568`目录下[ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build)的"module_list"中,例如:
+
+ ```json
+ {
+ "parts": {
+ "product_rk3568": {
+ "module_list": [
+ "//vendor/hihope/rk3568/default_app_config:default_app_config",
+ "//vendor/hihope/rk3568/image_conf:custom_image_conf",
+ "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
+ "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
+ "//vendor/hihope/rk3568/etc:product_etc_conf",
+ "//vendor/hihope/rk3568/power_manager/profile:wakeup_config" //添加wakeup_config的编译
+ ]
+ }
+ },
+ "subsystem": "product_hihope"
+ }
+ ```
+ “//vendor/hihope/rk3568/power_manager/”为文件夹路径,“profile”为创建的文件夹名字,“wakeup_config”为编译目标。
+
+6. 参考《[快速入门](../quick-start/quickstart-overview.md)》编译定制版本,编译命令如下:
+
+ ```shell
+ ./build.sh --product-name rk3568 --ccache
+ ```
+
+7. 将定制版本烧录到DAYU200开发板中。
+
+### 调测验证
+
+1. 以新的唤醒源配置文件为例,更改之后:
+ ```json
+ {
+ "powerkey": {
+ "enable": true
+ },
+ "keyborad": {
+ "enable": true
+ },
+ "mouse": {
+ "enable": true
+ },
+ "touchscreen": {
+ "enable": false,
+ "click": 2
+ },
+ "touchpad": {
+ "enable": false
+ },
+ "pen": {
+ "enable": false
+ },
+ "lid": {
+ "enable": false
+ },
+ "switch": {
+ "enable": false
+ }
+ }
+ ```
+
+2. 开机后,点击电源键使设备进入休眠状态,再次点击电源键。
+
+ 设备屏幕点亮,设备被唤醒。
+
+3. 点击电源键使设备进入休眠状态,按下键盘。
+
+ 设备屏幕点亮,设备被唤醒。
+
+4. 点击电源键使设备进入休眠状态,滑动鼠标。
+
+ 设备屏幕点亮,设备被唤醒。
\ No newline at end of file