提交 71c6fac0 编写于 作者: E ester.zhou 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into TR-18192

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
......@@ -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",
......
......@@ -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**.
......
......@@ -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"
}
]
```
......
......@@ -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,
}
]
}
......
......@@ -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%')
}
.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)'
```
# app.js
## Application Lifecycle<sup>4+</sup>
You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows:
......@@ -11,14 +12,76 @@ 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() {
console.info('Application onCreate');
},
onDestroy() {
console.info('Application onDestroy');
},
}
```
## Application Object<sup>10+</sup>
| 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.
......@@ -52,7 +52,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
#include "iremote_broker.h"
//定义消息码
const int TRANS_ID_PING_ABILITY = 5
const int TRANS_ID_PING_ABILITY = 5;
const std::string DESCRIPTOR = "test.ITestAbility";
......@@ -180,138 +180,178 @@ 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"
import rpc from "@ohos.rpc";
// 仅FA模型需要导入@ohos.ability.featureAbility
// import featureAbility from "@ohos.ability.featureAbility";
let proxy = null
let connectId = null
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. 服务端处理客户端请求
服务端被绑定的Ability在onConnect方法里返回继承自rpc.RemoteObject的对象,该对象需要实现onRemoteMessageRequest方法,处理客户端的请求。
```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);
```
......@@ -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便是为了突破这一点。
![IPC&RPC通信机制](figures/075sd302-aeb9-481a-bb8f-e552sdb61ead.PNG)
## 约束与限制
- 单个设备上跨进程通信时,传输的数据量最大约为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对象不能在本设备内进行二次跨进程传递。
## 使用建议
> **说明:**
> 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机制提供远端接口调用与数据传递。
首先,需要编写接口类,接口类中必须定义消息码,供通信双方标识操作,可以有未实现的的方法,因为通信双方均需继承该接口类且双方不能是抽象类,所以此时定义的未实现的方法必须在双方继承时给出实现,这保证了继承双方不是抽象类。然后,需要编写Stub端相关类及其接口,并且实现AsObject方法及OnRemoteRequest方法。同时,也需要编写Proxy端,实现接口类中的方法和AsObject方法,也可以封装一些额外的方法用于调用SendRequest向对端发送数据。以上三者都具备后,便可以向SAMgr注册SA了,此时的注册应该在Stub所在进程完成。最后,在需要的地方从SAMgr中获取Proxy,便可通过Proxy实现与Stub的跨进程通信了。
相关步骤:
## 实现原理
- 实现接口类:需继承IRemoteBroker,需定义消息码,可声明不在此类实现的方法
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表示服务提供方
- 实现服务提供端(Stub):需继承IRemoteStub或者RemoteObject,需重写AsObject方法及OnRemoteRequest方法。
- 实现服务请求端(Proxy):需继承IRemoteProxy或RemoteProxy,需重写AsObject方法,封装所需方法调用SendRequest。
![IPC&RPC通信机制](figures/075sd302-aeb9-481a-bb8f-e552sdb61ead.PNG)
- 注册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
# 远端状态订阅开发实例
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"
......@@ -87,15 +83,51 @@ result = object->RemoveDeathRecipient(deathRecipient); // 移除消亡通知
## JS侧接口
| 接口名 | 返回值类型 | 功能描述 |
| -------------------- | ---------- | ------------------------------------------------------------ |
| addDeathRecippient | boolean | 注册用于接收远程对象消亡通知的回调,增加proxy对象上的消亡通知。 |
| removeDeathRecipient | boolean | 注销用于接收远程对象消亡通知的回调。 |
| ------------------------ | ---------- | ----------------------------------------------------------------- |
| 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的使用)
......
......@@ -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
......@@ -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<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"];
let permissionList: Array<Permissions> = ['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&lt;number&gt;, 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<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"];
let permissionList: Array<Permissions> = ['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&lt;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&lt;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)}`);
```
......
......@@ -65,11 +65,11 @@ createAccount(name: string, callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt;
```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&lt;void&gt;): 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&lt;void&gt;
```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&lt;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&lt;boolean&gt;
```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&lt;
```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&lt;void&gt;
```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&lt;boolean&gt;): 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&lt;boolean&gt;
```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&lt;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&lt;string&gt;
```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&lt;void&gt;
```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&lt;string&gt;):
```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&lt;string&gt;
```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&lt;Array&lt;AppAccountInfo&gt;&gt;): 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&lt;Array&lt;AppAccountInfo&gt;&gt;
```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&lt;Array&lt;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&lt;Array&lt;AppAccountInfo&gt;&gt;
```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&lt;string&gt;, callback: Callback&lt;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&lt;Array&lt;AppAccountInfo&gt;&gt
```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&lt;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&lt;void&gt;
```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&lt;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&lt;Array&lt;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&lt;Array&lt;
```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&lt;Array&lt;string&gt;&gt;
```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&lt;AuthCallback&gt;):
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&lt;AuthCallback&gt;
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&lt;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&lt;AuthenticatorInfo&gt;
```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&lt;string&gt;, 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&lt;string&gt;): 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&lt;void&gt;
```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&lt;Array&lt;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&lt;void&gt;): 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&lt;void&gt;)
**示例:**
```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&lt;void&gt;
**示例:**
```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&lt;void&gt;): 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&lt;void&gt;
**示例:**
```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<sup>(deprecated)</sup>
......@@ -2932,8 +2932,8 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;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&lt;void&gt;
**示例:**
```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&lt;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&lt;void&gt;
**示例:**
```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&lt;boolean&gt;):
**示例:**
```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&lt;boolean&gt;
**示例:**
```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&lt;
**示例:**
```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&lt;void&gt;
**示例:**
```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&lt;void&gt;
**示例:**
```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&lt;void&gt;
**示例:**
```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&lt;Array&lt;AppAccountInfo&gt;&
```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&lt;Array&lt;AppAccountInfo&gt;&gt;
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&lt;Array&lt;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&lt;Array&lt;AppAccountInfo&gt;&gt;
**示例:**
```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&lt;string&gt
**示例:**
```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&lt;string&gt;): 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&lt;string&gt;
**示例:**
```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&lt;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&lt;string&gt;
**示例:**
```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&lt;string&gt;, callback: Callback&lt;Array&lt;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&lt;Array&lt;AppAccountInfo&gt;&gt;): 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&lt;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&lt;void&gt
**示例:**
```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&lt;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&lt;Array&lt;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&lt;Array&lt
**示例:**
```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&lt;Array&lt;string&gt;&gt;
**示例:**
```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&lt;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&lt;AuthenticatorCallback&gt
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&lt;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&lt;AuthenticatorInfo&gt;
**示例:**
```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&lt;AuthenticatorInfo&gt;
| 名称 | 值 | 说明 |
| -------------------------------- | ---------------------- | ----------------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY<sup>(deprecated)</sup> | "addAccountImplicitly" | 表示操作,隐式添加帐号。 |
| ACTION_AUTHENTICATE<sup>(deprecated)</sup> | "authenticate" | 表示操作,鉴权。 |
| ACTION_CREATE_ACCOUNT_IMPLICITLY<sup>9+</sup> | "createAccountImplicitly" | 表示操作,隐式创建帐号。 |
| ACTION_AUTH<sup>9+</sup> | "auth" | 表示操作,鉴权。 |
| ACTION_VERIFY_CREDENTIAL<sup>9+</sup> | "verifyCredential" | 表示操作,验证凭据。 |
| ACTION_SET_AUTHENTICATOR_PROPERTIES<sup>9+</sup> | "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_LABELS<sup>9+</sup> | "requiredLabels" | 表示键名,必需的标签。 |
| KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | 表示键名,布尔返回值。 |
| ACTION_ADD_ACCOUNT_IMPLICITLY<sup>(deprecated)</sup> | 'addAccountImplicitly' | 表示操作,隐式添加帐号。 |
| ACTION_AUTHENTICATE<sup>(deprecated)</sup> | 'authenticate' | 表示操作,鉴权。 |
| ACTION_CREATE_ACCOUNT_IMPLICITLY<sup>9+</sup> | 'createAccountImplicitly' | 表示操作,隐式创建帐号。 |
| ACTION_AUTH<sup>9+</sup> | 'auth' | 表示操作,鉴权。 |
| ACTION_VERIFY_CREDENTIAL<sup>9+</sup> | 'verifyCredential' | 表示操作,验证凭据。 |
| ACTION_SET_AUTHENTICATOR_PROPERTIES<sup>9+</sup> | '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_LABELS<sup>9+</sup> | 'requiredLabels' | 表示键名,必需的标签。 |
| KEY_BOOLEAN_RESULT<sup>9+</sup> | 'booleanResult' | 表示键名,布尔返回值。 |
## ResultCode<sup>(deprecated)</sup>
......@@ -4609,21 +4609,21 @@ onResult: (code: number, result?: AuthResult) =&gt; 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) =&gt; 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?: () =&gt; 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}) =&gt; 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) =&gt; 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?: () =&gt; 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
}
......
......@@ -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;
......
......@@ -45,14 +45,14 @@ createAVPlayer(callback: AsyncCallback\<AVPlayer>): 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}`);
console.error(`createAVPlayer fail, error message:${error.message}`);
}
});
```
......@@ -82,17 +82,17 @@ createAVPlayer(): Promise\<AVPlayer>
**示例:**
```js
let avPlayer
let avPlayer;
media.createAVPlayer().then((video) => {
if (video != null) {
avPlayer = video;
console.info('createAVPlayer success');
} else {
console.info('createAVPlayer fail');
console.error('createAVPlayer fail');
}
}).catch((error) => {
console.info(`AVPlayer catchCallback, error:${error}`);
console.error(`AVPlayer catchCallback, error message:${error.message}`);
});
```
......@@ -122,14 +122,14 @@ createAVRecorder(callback: AsyncCallback\<AVRecorder>): 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}`);
console.error(`createAVRecorder fail, error message:${error.message}`);
}
});
```
......@@ -160,17 +160,17 @@ createAVRecorder(): Promise\<AVRecorder>
**示例:**
```js
let avRecorder
let avRecorder;
media.createAVRecorder().then((recorder) => {
if (recorder != null) {
avRecorder = recorder;
console.info('createAVRecorder success');
} else {
console.info('createAVRecorder fail');
console.error('createAVRecorder fail');
}
}).catch((error) => {
console.info(`createAVRecorder catchCallback, error:${error}`);
console.error(`createAVRecorder catchCallback, error message:${error.message}`);
});
```
......@@ -202,14 +202,14 @@ createVideoRecorder(callback: AsyncCallback\<VideoRecorder>): 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}`);
console.error(`video createVideoRecorder fail, error message:${error.message}`);
}
});
```
......@@ -242,17 +242,17 @@ createVideoRecorder(): Promise\<VideoRecorder>
**示例:**
```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');
console.error('video createVideoRecorder fail');
}
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error message:${error.message}`);
});
```
......@@ -483,8 +483,8 @@ AVPlayer回调的**错误分类**<a name = error_info></a>可以分为以下几
```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)
})
```
......@@ -931,7 +931,7 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void
**示例:**
```js
printfDescription(obj) {
function printfDescription(obj) {
for (let item in obj) {
let property = obj[item];
console.info('audio key is ' + item);
......@@ -977,7 +977,7 @@ getTrackDescription(): Promise\<Array\<MediaDescription>>
```js
let arrayDescription;
printfDescription(obj) {
function printfDescription(obj) {
for (let item in obj) {
let property = obj[item];
console.info('audio key is ' + item);
......@@ -1788,7 +1788,7 @@ avRecorder.prepare(AVRecorderConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('prepare failed and error is ' + err.message);
console.error('prepare failed and error is ' + err.message);
}
})
```
......@@ -1858,7 +1858,7 @@ let AVRecorderConfig = {
avRecorder.prepare(AVRecorderConfig).then(() => {
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);
});
```
......@@ -1901,7 +1901,7 @@ avRecorder.getInputSurface((err, surfaceId) => {
console.info('getInputSurface success');
surfaceID = surfaceId;
} else {
console.info('getInputSurface failed and error is ' + err.message);
console.error('getInputSurface failed and error is ' + err.message);
}
});
......@@ -1944,7 +1944,7 @@ avRecorder.getInputSurface().then((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);
});
```
......@@ -1981,7 +1981,7 @@ avRecorder.start((err) => {
if (err == null) {
console.info('start AVRecorder success');
} else {
console.info('start AVRecorder failed and error is ' + err.message);
console.error('start AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2018,7 +2018,7 @@ start(): Promise\<void>
avRecorder.start().then(() => {
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);
});
```
......@@ -2055,7 +2055,7 @@ avRecorder.pause((err) => {
if (err == null) {
console.info('pause AVRecorder success');
} else {
console.info('pause AVRecorder failed and error is ' + err.message);
console.error('pause AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2092,7 +2092,7 @@ pause(): Promise\<void>
avRecorder.pause().then(() => {
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);
});
```
......@@ -2129,7 +2129,7 @@ avRecorder.resume((err) => {
if (err == null) {
console.info('resume AVRecorder success');
} else {
console.info('resume AVRecorder failed and error is ' + err.message);
console.error('resume AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2166,7 +2166,7 @@ resume(): Promise\<void>
avRecorder.resume().then(() => {
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);
});
```
......@@ -2205,7 +2205,7 @@ avRecorder.stop((err) => {
if (err == null) {
console.info('stop AVRecorder success');
} else {
console.info('stop AVRecorder failed and error is ' + err.message);
console.error('stop AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2244,7 +2244,7 @@ stop(): Promise\<void>
avRecorder.stop().then(() => {
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);
});
```
......@@ -2280,7 +2280,7 @@ avRecorder.reset((err) => {
if (err == null) {
console.info('reset AVRecorder success');
} else {
console.info('reset AVRecorder failed and error is ' + err.message);
console.error('reset AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2316,7 +2316,7 @@ reset(): Promise\<void>
avRecorder.reset().then(() => {
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);
});
```
......@@ -2351,7 +2351,7 @@ avRecorder.release((err) => {
if (err == null) {
console.info('release AVRecorder success');
} else {
console.info('release AVRecorder failed and error is ' + err.message);
console.error('release AVRecorder failed and error is ' + err.message);
}
});
```
......@@ -2386,7 +2386,7 @@ release(): Promise\<void>
avRecorder.release().then(() => {
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);
});
```
......@@ -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);
});
```
......@@ -2670,7 +2670,7 @@ videoRecorder.prepare(videoConfig, (err) => {
if (err == null) {
console.info('prepare success');
} else {
console.info('prepare failed and error is ' + err.message);
console.error('prepare failed and error is ' + err.message);
}
})
```
......@@ -2740,7 +2740,7 @@ let videoConfig = {
videoRecorder.prepare(videoConfig).then(() => {
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);
});
```
......@@ -2784,7 +2784,7 @@ videoRecorder.getInputSurface((err, surfaceId) => {
console.info('getInputSurface success');
surfaceID = surfaceId;
} else {
console.info('getInputSurface failed and error is ' + err.message);
console.error('getInputSurface failed and error is ' + err.message);
}
});
```
......@@ -2828,7 +2828,7 @@ videoRecorder.getInputSurface().then((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);
});
```
......@@ -2868,7 +2868,7 @@ videoRecorder.start((err) => {
if (err == null) {
console.info('start videorecorder success');
} else {
console.info('start videorecorder failed and error is ' + err.message);
console.error('start videorecorder failed and error is ' + err.message);
}
});
```
......@@ -2908,7 +2908,7 @@ start(): Promise\<void>;
videoRecorder.start().then(() => {
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);
});
```
......@@ -2948,7 +2948,7 @@ videoRecorder.pause((err) => {
if (err == null) {
console.info('pause videorecorder success');
} else {
console.info('pause videorecorder failed and error is ' + err.message);
console.error('pause videorecorder failed and error is ' + err.message);
}
});
```
......@@ -2988,7 +2988,7 @@ pause(): Promise\<void>;
videoRecorder.pause().then(() => {
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);
});
```
......@@ -3026,7 +3026,7 @@ videoRecorder.resume((err) => {
if (err == null) {
console.info('resume videorecorder success');
} else {
console.info('resume videorecorder failed and error is ' + err.message);
console.error('resume videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3064,7 +3064,7 @@ resume(): Promise\<void>;
videoRecorder.resume().then(() => {
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);
});
```
......@@ -3104,7 +3104,7 @@ videoRecorder.stop((err) => {
if (err == null) {
console.info('stop videorecorder success');
} else {
console.info('stop videorecorder failed and error is ' + err.message);
console.error('stop videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3144,7 +3144,7 @@ stop(): Promise\<void>;
videoRecorder.stop().then(() => {
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);
});
```
......@@ -3180,7 +3180,7 @@ videoRecorder.release((err) => {
if (err == null) {
console.info('release videorecorder success');
} else {
console.info('release videorecorder failed and error is ' + err.message);
console.error('release videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3216,7 +3216,7 @@ release(): Promise\<void>;
videoRecorder.release().then(() => {
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);
});
```
......@@ -3255,7 +3255,7 @@ videoRecorder.reset((err) => {
if (err == null) {
console.info('reset videorecorder success');
} else {
console.info('reset videorecorder failed and error is ' + err.message);
console.error('reset videorecorder failed and error is ' + err.message);
}
});
```
......@@ -3294,7 +3294,7 @@ reset(): Promise\<void>;
videoRecorder.reset().then(() => {
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,14 +3429,14 @@ createVideoPlayer(callback: AsyncCallback\<VideoPlayer>): 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}`);
console.error(`video createVideoPlayer fail, error:${error}`);
}
});
```
......@@ -3461,17 +3461,17 @@ createVideoPlayer(): Promise\<VideoPlayer>
**示例:**
```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');
console.error('video createVideoPlayer fail');
}
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -3830,7 +3830,7 @@ audioPlayer.on('finish', () => { //设置'finish'事件回调
audioPlayer.stop(); //停止播放,并触发'stop'事件回调
});
audioPlayer.on('error', (error) => { //设置'error'事件回调
console.info(`audio error called, error: ${error}`);
console.error(`audio error called, error: ${error}`);
});
// 用户选择音频设置fd(本地播放)
......@@ -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'事件
```
......@@ -3966,7 +3966,7 @@ videoPlayer.setDisplaySurface(surfaceId, (err) => {
if (err == null) {
console.info('setDisplaySurface success!');
} else {
console.info('setDisplaySurface fail!');
console.error('setDisplaySurface fail!');
}
});
```
......@@ -4000,7 +4000,7 @@ let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId).then(() => {
console.info('setDisplaySurface success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4025,7 +4025,7 @@ videoPlayer.prepare((err) => {
if (err == null) {
console.info('prepare success!');
} else {
console.info('prepare fail!');
console.error('prepare fail!');
}
});
```
......@@ -4050,7 +4050,7 @@ prepare(): Promise\<void>
videoPlayer.prepare().then(() => {
console.info('prepare success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4075,7 +4075,7 @@ videoPlayer.play((err) => {
if (err == null) {
console.info('play success!');
} else {
console.info('play fail!');
console.error('play fail!');
}
});
```
......@@ -4100,7 +4100,7 @@ play(): Promise\<void>;
videoPlayer.play().then(() => {
console.info('play success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4150,7 +4150,7 @@ pause(): Promise\<void>
videoPlayer.pause().then(() => {
console.info('pause success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4175,7 +4175,7 @@ videoPlayer.stop((err) => {
if (err == null) {
console.info('stop success!');
} else {
console.info('stop fail!');
console.error('stop fail!');
}
});
```
......@@ -4200,7 +4200,7 @@ stop(): Promise\<void>
videoPlayer.stop().then(() => {
console.info('stop success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4225,7 +4225,7 @@ videoPlayer.reset((err) => {
if (err == null) {
console.info('reset success!');
} else {
console.info('reset fail!');
console.error('reset fail!');
}
});
```
......@@ -4250,7 +4250,7 @@ reset(): Promise\<void>
videoPlayer.reset().then(() => {
console.info('reset success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4277,7 +4277,7 @@ videoPlayer.seek(seekTime, (err, result) => {
if (err == null) {
console.info('seek success!');
} else {
console.info('seek fail!');
console.error('seek fail!');
}
});
```
......@@ -4307,7 +4307,7 @@ videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => {
if (err == null) {
console.info('seek success!');
} else {
console.info('seek fail!');
console.error('seek fail!');
}
});
```
......@@ -4341,13 +4341,13 @@ let seekTime = 5000;
videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完成后的时间点
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');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4374,7 +4374,7 @@ videoPlayer.setVolume(vol, (err, result) => {
if (err == null) {
console.info('setVolume success!');
} else {
console.info('setVolume fail!');
console.error('setVolume fail!');
}
});
```
......@@ -4406,7 +4406,7 @@ let vol = 0.5;
videoPlayer.setVolume(vol).then(() => {
console.info('setVolume success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4431,7 +4431,7 @@ videoPlayer.release((err) => {
if (err == null) {
console.info('release success!');
} else {
console.info('release fail!');
console.error('release fail!');
}
});
```
......@@ -4456,7 +4456,7 @@ release(): Promise\<void>
videoPlayer.release().then(() => {
console.info('release success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -4561,7 +4561,7 @@ videoPlayer.setSpeed(speed, (err, result) => {
if (err == null) {
console.info('setSpeed success!');
} else {
console.info('setSpeed fail!');
console.error('setSpeed fail!');
}
});
```
......@@ -4595,7 +4595,7 @@ let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed).then(() => {
console.info('setSpeed success');
}).catch((error) => {
console.info(`video catchCallback, error:${error}`);
console.error(`video catchCallback, error:${error}`);
});
```
......@@ -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'事件
```
......@@ -4966,7 +4966,7 @@ let audioRecorderConfig = {
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'事件
```
......
......@@ -86,7 +86,7 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt;
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&lt;boolean&gt;): 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&lt;boolean&gt;)
}
});
} catch (err) {
console.log('checkOsAccountActivated exception:' + JSON.stringify(err));
console.log('checkOsAccountActivated exception: ' + JSON.stringify(err));
}
```
......@@ -300,7 +300,7 @@ checkOsAccountActivated(localId: number): Promise&lt;boolean&gt;
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&lt
```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&lt;boolean&gt;): 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&lt;boolean&gt;
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&lt;boolean&gt;): 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&lt;boolean&gt;):
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&lt;boolean&gt;
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&lt;void&gt;): 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&lt;void&gt;
```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&lt;string&gt;, 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));
}
```
......@@ -790,7 +790,7 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
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&lt;
```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));
}
```
......@@ -889,7 +889,7 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
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&lt;number&gt;): 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&lt;number&gt;
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&lt;number&gt;): 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&lt;number&gt;
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&lt;number&gt;): 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&lt;number&gt;
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&lt;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&lt;number&gt;): void
}
});
} catch (err) {
console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(err));
console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
}
```
......@@ -1282,7 +1282,7 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
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&lt;Array&lt;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));
}
```
......@@ -1371,7 +1371,7 @@ getOsAccountConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
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&lt;Array&lt;OsAccountInfo&gt;&
console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
});
} catch (e) {
console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e));
console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
}
```
......@@ -1448,7 +1448,7 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
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&lt;Array&lt;number&gt;&gt;
}
});
} catch (e) {
console.log('getActivatedOsAccountLocalIds exception:' + JSON.stringify(e));
console.log('getActivatedOsAccountLocalIds exception: ' + JSON.stringify(e));
}
```
......@@ -1520,7 +1520,7 @@ getActivatedOsAccountLocalIds(): Promise&lt;Array&lt;number&gt;&gt;
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));
}
```
......@@ -1614,7 +1614,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
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));
}
```
......@@ -1710,7 +1710,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
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&lt;OsAccountInfo&gt;): void
console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
});
} catch (e) {
console.log('getCurrentOsAccount exception:' + JSON.stringify(e));
console.log('getCurrentOsAccount exception: ' + JSON.stringify(e));
}
```
......@@ -1783,7 +1783,7 @@ getCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
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&lt;OsAccountInfo&gt;
console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
});
} catch (e) {
console.log('queryOsAccountById exception:' + JSON.stringify(e));
console.log('queryOsAccountById exception: ' + JSON.stringify(e));
}
```
......@@ -1873,7 +1873,7 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
console.log('queryOsAccountById err: ' + JSON.stringify(err));
});
} catch (e) {
console.log('queryOsAccountById exception:' + JSON.stringify(e));
console.log('queryOsAccountById exception: ' + JSON.stringify(e));
}
```
......@@ -2057,7 +2057,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;)
console.log('get photo:' + photo + ' by localId: ' + localId);
});
} catch (e) {
console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e));
console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
}
```
......@@ -2105,7 +2105,7 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
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));
}
```
......@@ -2206,7 +2206,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
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));
}
```
......@@ -2326,7 +2326,7 @@ getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback&lt;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));
}
```
......@@ -2370,7 +2370,7 @@ getSerialNumberForOsAccountLocalId(localId: number): Promise&lt;number&gt;
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&lt;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&lt;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&lt;number&gt;): void;
console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId));
});
} catch (e) {
console.info('getBundleIdForUid exception:' + JSON.stringify(e));
console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
}
```
### getBundleIdForUid<sup>9+</sup>
......@@ -2535,7 +2535,7 @@ getBundleIdForUid(uid: number): Promise&lt;number&gt;;
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&lt;boolean&gt;): void;
console.info('isMainOsAccount result:' + JSON.stringify(result));
});
} catch (e) {
console.info('isMainOsAccount exception:' + JSON.stringify(e));
console.info('isMainOsAccount exception: ' + JSON.stringify(e));
}
```
### isMainOsAccount<sup>9+</sup>
......@@ -2611,7 +2611,7 @@ isMainOsAccount(): Promise&lt;boolean&gt;;
console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
});
} catch (e) {
console.info('isMainOsAccount exception:' + JSON.stringify(e));
console.info('isMainOsAccount exception: ' + JSON.stringify(e));
}
```
### getOsAccountConstraintSourceTypes<sup>9+</sup>
......@@ -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&lt;boolean&gt;): 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);
}
});
```
......@@ -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&lt;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&lt;boolean&gt;): 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&lt;boolean&gt;
```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&lt;boolean&gt;): 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&lt;boolean&gt;): 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&lt;boolean&gt;
```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&lt;number&gt;): 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&lt;number&gt;
```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&lt;number&gt;): 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);
}
});
```
......@@ -3230,9 +3230,9 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;):
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&lt;number&gt;
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);
}
});
```
......@@ -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&lt;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&lt;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&lt;boolean&gt;
**示例:**
```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));
}
```
......
......@@ -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&lt;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&lt;Permissions&gt;, 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. |
......
......@@ -4856,7 +4856,7 @@ readException(): void
Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
// 仅FA模型需要导入@ohos.ability.;featureAbility
// 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
let proxy;
......@@ -5450,6 +5450,7 @@ marshalling(dataOut: MessageSequence): boolean
| 类型 | 说明 |
| ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。|
**示例:**
```ts
......@@ -5555,6 +5556,7 @@ marshalling(dataOut: MessageParcel): boolean
| 类型 | 说明 |
| ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。 |
**示例:**
```ts
......@@ -7093,9 +7095,9 @@ MessageOption构造函数。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------------------------------------- |
| syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | -------------------------------------- |
| async | boolean | 否 | 同步调用或异步调用标志。默认同步调用。 |
**示例:**
......@@ -7823,7 +7825,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
| 类型 | 说明 |
| ---------------------------- | --------------------------------------------- |
| Promise&lt;RequestResult&gt; | 返回一个期约,兑现值是sendRequestResult实例。 |
| Promise&lt;RequestResult&gt; | 返回一个期约,兑现值是RequestResult实例。 |
**示例:**
......@@ -9099,6 +9101,7 @@ 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");
......
......@@ -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)
# 电源默认休眠行为定制开发指导
## 概述
### 简介
当前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. 再次开机后等待一段时间。
设备进入黑屏状态。
# 唤醒源定制开发指导
## 概述
### 简介
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册