提交 dd589186 编写于 作者: X xieqiongyang 提交者: Gitee

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

Signed-off-by: Nxieqiongyang <xieqiongyang@huawei.com>

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
...@@ -397,7 +397,7 @@ zh-cn/application-dev/reference/apis/js-apis-notification.md @jayleehw @RayShih ...@@ -397,7 +397,7 @@ zh-cn/application-dev/reference/apis/js-apis-notification.md @jayleehw @RayShih
zh-cn/application-dev/reference/apis/js-apis-observer.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-observer.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-osAccount.md @nianCode @zengyawen @JiDong-CS @murphy1984 zh-cn/application-dev/reference/apis/js-apis-osAccount.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @feng-aiwen @ge-yafang @gong-a-shi @logic42 zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yafang @logic42
zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208 zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- master:最新开发版本。 - master:最新开发版本。
- OpenHarmony 3.2 Beta5版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta5.md)了解版本详情。 - OpenHarmony 3.2 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-release.md)了解版本详情。
- OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。 - OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## IDL Overview ## IDL Overview
To ensure successful communications between the client and server, interfaces recognized by both parties must be defined. The OpenHarmony Interface Definition Language (IDL) is a tool for defining such interfaces. OpenHarmony IDL decomposes objects to be transferred into primitives that can be understood by the operating system and encapsulates cross-boundary objects based on developers' requirements. To ensure successful communications between the client and server, interfaces recognized by both parties must be defined. The OpenHarmony Interface Definition Language (IDL) is a tool for defining such interfaces. OpenHarmony IDL decomposes objects to be transferred into primitives that can be understood by the operating system and encapsulates cross-boundary objects based on developers' requirements.
**Figure 1** IDL interface description **Figure 1** IDL interface description
![IDL-interface-description](./figures/IDL-interface-description.png) ![IDL-interface-description](./figures/IDL-interface-description.png)
...@@ -156,11 +156,13 @@ On DevEco Studio, choose **Tools > SDK Manager** to view the local installation ...@@ -156,11 +156,13 @@ On DevEco Studio, choose **Tools > SDK Manager** to view the local installation
Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder named after the version number), and check whether the executable file of IDL exists. Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder named after the version number), and check whether the executable file of IDL exists.
> **NOTE**: Use the SDK of the latest version. The use of an earlier version may cause errors in some statements. > **NOTE**
>
> Use the SDK of the latest version. The use of an earlier version may cause errors in some statements.
If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses the [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md#acquiring-source-code-from-mirrors) as an example. If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md) as an example.
For details about how to replace the SDK package, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md). For details about how to replace the SDK package, see [Full SDK Compilation Guide](../quick-start/full-sdk-compile-guide.md).
After obtaining the executable file, perform subsequent development steps based on your scenario. After obtaining the executable file, perform subsequent development steps based on your scenario.
...@@ -176,6 +178,8 @@ You can use TS to create IDL files. ...@@ -176,6 +178,8 @@ You can use TS to create IDL files.
interface OHOS.IIdlTestService { interface OHOS.IIdlTestService {
int TestIntTransaction([in] int data); int TestIntTransaction([in] int data);
void TestStringTransaction([in] String data); void TestStringTransaction([in] String data);
void TestMapTransaction([in] Map<int, int> data);
int TestArrayTransaction([in] String[] data);
} }
``` ```
...@@ -183,7 +187,9 @@ Run the **idl -gen-ts -d *dir* -c dir/IIdlTestService.idl** command in the folde ...@@ -183,7 +187,9 @@ Run the **idl -gen-ts -d *dir* -c dir/IIdlTestService.idl** command in the folde
-*dir* next to **d** is the target output folder. For example, if the target output folder is **IIdlTestServiceTs**, run the **idl -gen-ts -d IIdlTestServiceTs -c IIdlTestServiceTs/IIdlTestService.idl** command in the folder where the executable file is located. The interface file, stub file, and proxy file are generated in the *dir* directory (**IIdlTestServiceTs** directory in this example) in the execution environment. -*dir* next to **d** is the target output folder. For example, if the target output folder is **IIdlTestServiceTs**, run the **idl -gen-ts -d IIdlTestServiceTs -c IIdlTestServiceTs/IIdlTestService.idl** command in the folder where the executable file is located. The interface file, stub file, and proxy file are generated in the *dir* directory (**IIdlTestServiceTs** directory in this example) in the execution environment.
> **NOTE**: The generated interface class file name must be the same as that of the .idl file. Otherwise, an error occurs during code generation. > **NOTE**
>
> The generated interface class file name must be the same as that of the .idl file. Otherwise, an error occurs during code generation.
For example, for an .idl file named **IIdlTestService.idl** and target output directory named **IIdlTestServiceTs**, the directory structure is similar to the following: For example, for an .idl file named **IIdlTestService.idl** and target output directory named **IIdlTestServiceTs**, the directory structure is similar to the following:
...@@ -203,6 +209,8 @@ The stub class generated by IDL is an abstract implementation of the interface c ...@@ -203,6 +209,8 @@ The stub class generated by IDL is an abstract implementation of the interface c
```ts ```ts
import {testIntTransactionCallback} from "./i_idl_test_service"; import {testIntTransactionCallback} from "./i_idl_test_service";
import {testStringTransactionCallback} from "./i_idl_test_service"; import {testStringTransactionCallback} from "./i_idl_test_service";
import {testMapTransactionCallback} from "./i_idl_test_service";
import {testArrayTransactionCallback} from "./i_idl_test_service";
import IIdlTestService from "./i_idl_test_service"; import IIdlTestService from "./i_idl_test_service";
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
...@@ -211,8 +219,8 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl ...@@ -211,8 +219,8 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
super(des); super(des);
} }
async onRemoteRequestEx(code: number, data, reply, option): Promise<boolean> { async onRemoteMessageRequest(code: number, data, reply, option): Promise<boolean> {
console.log("onRemoteRequestEx called, code = " + code); console.log("onRemoteMessageRequest called, code = " + code);
switch(code) { switch(code) {
case IdlTestServiceStub.COMMAND_TEST_INT_TRANSACTION: { case IdlTestServiceStub.COMMAND_TEST_INT_TRANSACTION: {
let _data = data.readInt(); let _data = data.readInt();
...@@ -231,6 +239,29 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl ...@@ -231,6 +239,29 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
}); });
return true; return true;
} }
case IdlTestServiceStub.COMMAND_TEST_MAP_TRANSACTION: {
let _data = new Map();
let _dataSize = data.readInt();
for (let i = 0; i < _dataSize; ++i) {
let key = data.readInt();
let value = data.readInt();
_data.set(key, value);
}
this.testMapTransaction(_data, (errCode) => {
reply.writeInt(errCode);
});
return true;
}
case IdlTestServiceStub.COMMAND_TEST_ARRAY_TRANSACTION: {
let _data = data.readStringArray();
this.testArrayTransaction(_data, (errCode, returnValue) => {
reply.writeInt(errCode);
if (errCode == 0) {
reply.writeInt(returnValue);
}
});
return true;
}
default: { default: {
console.log("invalid request code" + code); console.log("invalid request code" + code);
break; break;
...@@ -241,17 +272,23 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl ...@@ -241,17 +272,23 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
testIntTransaction(data: number, callback: testIntTransactionCallback): void{} testIntTransaction(data: number, callback: testIntTransactionCallback): void{}
testStringTransaction(data: string, callback: testStringTransactionCallback): void{} testStringTransaction(data: string, callback: testStringTransactionCallback): void{}
testMapTransaction(data: Map<number, number>, callback: testMapTransactionCallback): void{}
testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void{}
static readonly COMMAND_TEST_INT_TRANSACTION = 1; static readonly COMMAND_TEST_INT_TRANSACTION = 1;
static readonly COMMAND_TEST_STRING_TRANSACTION = 2; static readonly COMMAND_TEST_STRING_TRANSACTION = 2;
static readonly COMMAND_TEST_MAP_TRANSACTION = 3;
static readonly COMMAND_TEST_ARRAY_TRANSACTION = 4;
} }
``` ```
You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction** and **testStringTransaction** methods. You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction**, **testStringTransaction**, **testMapTransaction**, and **testArrayTransaction** methods.
```ts ```ts
import {testIntTransactionCallback} from "./i_idl_test_service" import {testIntTransactionCallback} from "./i_idl_test_service"
import {testStringTransactionCallback} from "./i_idl_test_service" import {testStringTransactionCallback} from "./i_idl_test_service"
import {testMapTransactionCallback} from "./i_idl_test_service";
import {testArrayTransactionCallback} from "./i_idl_test_service";
import IdlTestServiceStub from "./idl_test_service_stub" import IdlTestServiceStub from "./idl_test_service_stub"
...@@ -265,6 +302,14 @@ class IdlTestImp extends IdlTestServiceStub { ...@@ -265,6 +302,14 @@ class IdlTestImp extends IdlTestServiceStub {
{ {
callback(0); callback(0);
} }
testMapTransaction(data: Map<number, number>, callback: testMapTransactionCallback): void
{
callback(0);
}
testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void
{
callback(0, 1);
}
} }
``` ```
...@@ -320,11 +365,28 @@ function callbackTestStringTransaction(result: number): void { ...@@ -320,11 +365,28 @@ function callbackTestStringTransaction(result: number): void {
} }
} }
function callbackTestMapTransaction(result: number): void {
if (result == 0) {
console.log('case 3 success');
}
}
function callbackTestArrayTransaction(result: number, ret: number): void {
if (result == 0 && ret == 124) {
console.log('case 4 success');
}
}
var onAbilityConnectDone = { var onAbilityConnectDone = {
onConnect:function (elementName, proxy) { onConnect:function (elementName, proxy) {
let testProxy = new IdlTestServiceProxy(proxy); let testProxy = new IdlTestServiceProxy(proxy);
let testMap = new Map();
testMap.set(1, 1);
testMap.set(1, 2);
testProxy.testIntTransaction(123, callbackTestIntTransaction); testProxy.testIntTransaction(123, callbackTestIntTransaction);
testProxy.testStringTransaction('hello', callbackTestStringTransaction); testProxy.testStringTransaction('hello', callbackTestStringTransaction);
testProxy.testMapTransaction(testMap, callbackTestMapTransaction);
testProxy.testArrayTransaction(['1','2'], callbackTestMapTransaction);
}, },
onDisconnect:function (elementName) { onDisconnect:function (elementName) {
console.log('onDisconnectService onDisconnect'); console.log('onDisconnectService onDisconnect');
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
- ExtensionAbility Component - ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md) - [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md) - [ServiceExtensionAbility](serviceextensionability.md)
- [DataShareExtensionAbility (for System Applications Only)](datashareextensionability.md)
- [FormExtensionAbility (Widget)](widget-development-stage.md) - [FormExtensionAbility (Widget)](widget-development-stage.md)
- [AccessibilityExtensionAbility](accessibilityextensionability.md) - [AccessibilityExtensionAbility](accessibilityextensionability.md)
- [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md) - [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md)
...@@ -46,7 +45,7 @@ ...@@ -46,7 +45,7 @@
- [Common Event Subscription Overview](common-event-subscription-overview.md) - [Common Event Subscription Overview](common-event-subscription-overview.md)
- [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md) - [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md)
- [Subscribing to Common Events in Static Mode (for System Applications Only)](common-event-static-subscription.md) - [Subscribing to Common Events in Static Mode (for System Applications Only)](common-event-static-subscription.md)
- [Unsubscribing from Common Events](common-event-unsubscription.md) - [Unsubscribing from Common Events](common-event-unsubscription.md)
- [Publishing Common Events](common-event-publish.md) - [Publishing Common Events](common-event-publish.md)
- [Background Services](background-services.md) - [Background Services](background-services.md)
- Inter-Thread Communication - Inter-Thread Communication
......
...@@ -27,8 +27,7 @@ This section uses the operation of using a browser to open a website as an examp ...@@ -27,8 +27,7 @@ This section uses the operation of using a browser to open a website as an examp
"host": "www.test.com", "host": "www.test.com",
"port": "8080", "port": "8080",
// Prefix matching is used. // Prefix matching is used.
"pathStartWith": "query", "pathStartWith": "query"
"type": "text/*"
}, },
{ {
"scheme": "http", "scheme": "http",
...@@ -53,12 +52,11 @@ function implicitStartAbility() { ...@@ -53,12 +52,11 @@ function implicitStartAbility() {
let context = getContext(this) as common.UIAbilityContext; let context = getContext(this) as common.UIAbilityContext;
let wantInfo = { let wantInfo = {
// Uncomment the line below if you want to implicitly query data only in the specific bundle. // Uncomment the line below if you want to implicitly query data only in the specific bundle.
// bundleName: "com.example.myapplication", // bundleName: 'com.example.myapplication',
"action": "ohos.want.action.viewData", 'action': 'ohos.want.action.viewData',
// entities can be omitted. // entities can be omitted.
"entities": ["entity.system.browsable"], 'entities': ['entity.system.browsable'],
"uri": "https://www.test.com:8080/query/student", 'uri': 'https://www.test.com:8080/query/student'
"type": "text/plain"
} }
context.startAbility(wantInfo).then(() => { context.startAbility(wantInfo).then(() => {
// ... // ...
...@@ -75,6 +73,6 @@ The matching process is as follows: ...@@ -75,6 +73,6 @@ The matching process is as follows:
3. If **uri** in the passed **want** parameter is included in **uris** under **skills** of the ability to match, which is concatenated into https://www.test.com:8080/query* (where * is a wildcard), the matching is successful. 3. If **uri** in the passed **want** parameter is included in **uris** under **skills** of the ability to match, which is concatenated into https://www.test.com:8080/query* (where * is a wildcard), the matching is successful.
4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills** of the ability to match, the matching is successful. 4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills** of the ability to match, the matching is successful.
When there are multiple matching applications, a dialog box is displayed for you to select one of them. The following figure shows an example. If there are multiple matching applications, the system displays a dialog box for you to select one of them. The following figure shows an example.
![](figures/ability-startup-with-implicit-want1.png) ![](figures/ability-startup-with-implicit-want1.png)
\ No newline at end of file
...@@ -30,7 +30,7 @@ In view of this, OpenHarmony formulates a set of component startup rules, as fol ...@@ -30,7 +30,7 @@ In view of this, OpenHarmony formulates a set of component startup rules, as fol
- An application is considered as a foreground application only when the application process gains focus or its UIAbility component is running in the foreground. - An application is considered as a foreground application only when the application process gains focus or its UIAbility component is running in the foreground.
- Verify the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. - Verify the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- **When the startAbilityByCall() method is used, verify the call permission.** For details, see [Using Ability Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction) and [Using Cross-Device Ability Call](hop-multi-device-collaboration.md#using-cross-device-ability-call). - **When the startAbilityByCall() method is used, verify the call permission.** For details, see [Using Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-call-to-implement-uiability-interaction) and [Using Cross-Device Call](hop-multi-device-collaboration.md#using-cross-device-call).
- Verify the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** permission. - Verify the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** permission.
......
...@@ -76,22 +76,22 @@ In the FA model, you can call **getContext** of **featureAbility** to obtain the ...@@ -76,22 +76,22 @@ In the FA model, you can call **getContext** of **featureAbility** to obtain the
The following code snippet shows how to use **getContext()** to obtain the application context and distributed directory: The following code snippet shows how to use **getContext()** to obtain the application context and distributed directory:
```ts ```ts
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility';
import fileIo from '@ohos.fileio' import fs from '@ohos.file.fs';
(async () => { (async () => {
let dir: string let dir: string;
try { try {
console.info('Begin to getOrCreateDistributedDir') console.info('Begin to getOrCreateDistributedDir');
dir = await featureAbility.getContext().getOrCreateDistributedDir() dir = await featureAbility.getContext().getOrCreateDistributedDir();
console.info('distribute dir is ' + dir) console.info('distribute dir is ' + dir)
} catch (error) { } catch (error) {
console.error('getOrCreateDistributedDir failed with ' + error) console.error('getOrCreateDistributedDir failed with ' + error);
} }
let fd: number; let fd: number;
let path = dir + "/a.txt"; let path = dir + "/a.txt";
fd = fileIo.openSync(path, 0o2 | 0o100, 0o666); fd = fs.openSync(path, fs.OpenMode.READ_WRITE).fd;
fileIo.close(fd); fs.close(fd);
})() })()
``` ```
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
Users often need to share data (such as a text or an image) from one application to another. The following uses PDF file sharing as an example to describe how to use Want to share data between applications. Users often need to share data (such as a text or an image) from one application to another. The following uses PDF file sharing as an example to describe how to use Want to share data between applications.
Data sharing requires two UIAbility components (one for the sharing party and the other for the shared party) and one system component (used as the application selector). When the sharing party initiates data sharing by calling **startAbility()**, the system implicitly matches and displays all applications that support the type of data to share. After the user selects an application, the system starts the application to complete data sharing. Data sharing requires two UIAbility components (one for the sharing party and the other for the shared party) and one system component (used as the application sharing box). When the sharing party initiates data sharing by calling **startAbility()**, the system implicitly matches and displays all applications that support the type of data to share. After the user selects an application, the system starts the application to complete data sharing.
In this section, data sharing is triggered by touching a button. You can use other ways to trigger data sharing during application development. This section focuses on how to configure Want to implement data sharing. In this section, data sharing is triggered by touching a button. You can use other ways to trigger data sharing during application development. This section focuses on how to configure Want to implement data sharing.
The following actions are involved for data sharing: The following actions are involved for data sharing:
- **ohos.want.action.select**: action of starting the application selector. - **ohos.want.action.select**: action of starting the application sharing box.
- **ohos.want.action.sendData**: action of sending a single data record, that is, transferring data to the shared party. - **ohos.want.action.sendData**: action of sending a single data record, that is, transferring data to the shared party.
## Sharing Party ## Sharing Party
The sharing party starts an application selector and transfers the data to the shared party. Therefore, Want of the sharing party must be nested at two layers. In the first layer, implicit Want is used together with the **ohos.want.action.select** action to display the application selector. In the second layer, the data to share is declared The sharing party starts an application sharing box and transfers the data to the shared party. Therefore, Want of the sharing party must be nested at two layers. In the first layer, implicit Want is used together with the **ohos.want.action.select** action to display the application sharing box. In the second layer, the data to share is declared
in the custom field **parameters**, and then the Want that includes the **ohos.want.action.sendData** action and the **parameters** field is transferred to the application selector. The shared party obtains the shared data from **parameters**. in the custom field **parameters**, and then the Want that includes the **ohos.want.action.sendData** action and the **parameters** field is transferred to the application sharing box. The shared party obtains the shared data from **parameters**.
```ts ```ts
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
...@@ -28,21 +28,21 @@ let fileSize; // Obtain the size of the file to share. ...@@ -28,21 +28,21 @@ let fileSize; // Obtain the size of the file to share.
function implicitStartAbility() { function implicitStartAbility() {
let context = getContext(this) as common.UIAbilityContext; let context = getContext(this) as common.UIAbilityContext;
let wantInfo = { let wantInfo = {
/ This action is used to implicitly match the application selector. / This action is used to implicitly match the application sharing box.
action: 'ohos.want.action.select', action: 'ohos.want.action.select',
// This is the custom parameter in the first layer of Want, // This is the custom parameter in the first layer of Want,
/ which is intended to add information to the application selector. / which is intended to add information to the application sharing box.
parameters: { parameters: {
// MIME type of PDF. // MIME type of PDF.
"ability.picker.type": fileType, 'ability.picker.type': fileType,
"ability.picker.fileNames": [fileName], 'ability.picker.fileNames': [fileName],
"ability.picker.fileSizes": [fileSize], 'ability.picker.fileSizes': [fileSize],
// This is nested Want ,which will be directly sent to the selected application. // This is nested Want ,which will be directly sent to the selected application.
"ability.want.params.INTENT": { 'ability.want.params.INTENT': {
"action": "ohos.want.action.sendData", 'action': 'ohos.want.action.sendData',
"type": "application/pdf", 'type': 'application/pdf',
"parameters": { 'parameters': {
"keyFd": { "type": "FD", "value": fileFd } 'keyFd': { 'type': 'FD', 'value': fileFd }
} }
} }
} }
...@@ -59,14 +59,15 @@ function implicitStartAbility() { ...@@ -59,14 +59,15 @@ function implicitStartAbility() {
> >
> Data sharing can be implemented only in FD format. For details about how to obtain the FD and file name, see [File Management](../reference/apis/js-apis-file-fs.md). > Data sharing can be implemented only in FD format. For details about how to obtain the FD and file name, see [File Management](../reference/apis/js-apis-file-fs.md).
In the preceding code, under the custom field **parameters**, the following **ability.picker.*** fields are used to pass the information to be displayed on the application selector: In the preceding code, under the custom field **parameters**, the following **ability.picker.*** fields are used to pass the information to be displayed on the application sharing box:
- **ability.picker.type**: file type icon. - **ability.picker.type**: file type icon.
- **ability.picker.fileNames**: file name. - **ability.picker.fileNames**: file name.
- **ability.picker.fileSizes**: file size, in bytes. - **ability.picker.fileSizes**: file size, in bytes.
- **ability.picker.fileNames** and **ability.picker.fileSizes** are arrays and have a one-to-one mapping. - **ability.picker.fileNames** and **ability.picker.fileSizes** are arrays and have a one-to-one mapping.
The following figure shows an example. The following figure shows an example.
![](figures/ability-startup-with-implicit-want2.png) ![](figures/ability-startup-with-implicit-want2.png)
## Shared Party ## Shared Party
......
...@@ -62,7 +62,7 @@ The system matches the **action** attribute in the **want** parameter passed by ...@@ -62,7 +62,7 @@ The system matches the **action** attribute in the **want** parameter passed by
**Figure 1** Matching rules of action in the want parameter **Figure 1** Matching rules of action in the want parameter
![want-action](figures/want-action.png) ![want-action](figures/want-action.png)
### Matching Rules of entities in the want Parameter ### Matching Rules of entities in the want Parameter
...@@ -79,19 +79,15 @@ The system matches the **entities** attribute in the **want** parameter passed b ...@@ -79,19 +79,15 @@ The system matches the **entities** attribute in the **want** parameter passed b
- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified but does not contain **entities** in the passed **want** parameter, the matching fails. - If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
Figure 2 Matching rule of entities in the want parameter **Figure 2** Matching rule of entities in the want parameter
![want-entities](figures/want-entities.png) ![want-entities](figures/want-entities.png)
### Matching Rules of uri and type in the want Parameter ### Matching Rules of uri and type in the want Parameter
When the **uri** and **type** parameters are specified in the **want** parameter to initiate a component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the abilities one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful. When the **uri** and **type** parameters are specified in the **want** parameter to initiate a component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the abilities one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful.
Figure 3 Matching rules when uri and type are specified in the want parameter
![want-uri-type1](figures/want-uri-type1.png)
There are four combinations of **uri** and **type** settings. The matching rules are as follows: There are four combinations of **uri** and **type** settings. The matching rules are as follows:
- Neither **uri** or **type** is specified in the **want** parameter. - Neither **uri** or **type** is specified in the **want** parameter.
...@@ -111,11 +107,17 @@ There are four combinations of **uri** and **type** settings. The matching rules ...@@ -111,11 +107,17 @@ There are four combinations of **uri** and **type** settings. The matching rules
- If the **uris** array under **skills** of an ability is unspecified, the matching fails. - If the **uris** array under **skills** of an ability is unspecified, the matching fails.
- If the **uris** array under **skills** of an ability contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails. - If the **uris** array under **skills** of an ability contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
Leftmost URI matching: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the **uris** array under **skills** of the ability,
the matching is successful only if the leftmost URI in the passed **want** parameter matches **scheme**, the combination of **scheme** and **host**, or the combination of **scheme**, **host**, and **port**.
To simplify the description, **uri** and **type** passed in the **want** parameter are called **w_uri** and **w_type**, respectively; the **uris** array under **skills** of an ability to match is called **s_uris**; each element in the array is called **s_uri**. Matching is performed from top to bottom. **Figure 3** Matching rules when uri and type are specified in the want parameter
![want-uri-type1](figures/want-uri-type1.png)
To simplify the description, **uri** and **type** passed in the **want** parameter are called **w_uri** and **w_type**, respectively; the **uris** array under **skills** of an ability to match is called **s_uris**; each element in the array is called **s_uri**. Matching is performed from top to bottom.
Figure 4 Matching rules of uri and type in the want parameter **Figure 4** Matching rules of uri and type in the want parameter
![want-uri-type2](figures/want-uri-type2.png) ![want-uri-type2](figures/want-uri-type2.png)
...@@ -128,7 +130,9 @@ To simplify the description, **uri** in the passed **want** parameter is called ...@@ -128,7 +130,9 @@ To simplify the description, **uri** in the passed **want** parameter is called
- If **host** of **s_uri** is unspecified and **scheme** of **w_uri** and **scheme** of **s_uri** are the same, the matching is successful. Otherwise, the matching fails. - If **host** of **s_uri** is unspecified and **scheme** of **w_uri** and **scheme** of **s_uri** are the same, the matching is successful. Otherwise, the matching fails.
- If **path**, **pathStartWith**, and **pathRegex** of **s_uri** are unspecified and **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching fails. - If **port** of **s_uri** is unspecified and the combination of **scheme** and **host** of **w_uri** is the same as the combination of **scheme** and **host** of **s_uri**, the matching is successful. Otherwise, the matching fails.
- If **path**, **pathStartWith**, and **pathRegex** of **s_uri** are unspecified and the combination of **scheme**, **host**, and **port** of **w_uri** is the same as the combination of **scheme**, **host**, and **port** of **s_uri**, the matching is successful. Otherwise, the matching fails.
- If **path** of **s_uri** is specified and the **full path expressions** of **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching of **pathStartWith** continues. - If **path** of **s_uri** is specified and the **full path expressions** of **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching of **pathStartWith** continues.
...@@ -139,12 +143,17 @@ To simplify the description, **uri** in the passed **want** parameter is called ...@@ -139,12 +143,17 @@ To simplify the description, **uri** in the passed **want** parameter is called
> **NOTE** > **NOTE**
> >
> The **scheme**, **host**, **port**, **path**, **pathStartWith**, and **pathRegex** attributes of **uris** under **skills** of an ability are concatenated. If **path**, **pathStartWith**, and **pathRegex** are declared in sequence, **uris** can be concatenated into the following expressions: > The **scheme**, **host**, **port**, **path**, **pathStartWith**, and **pathRegex** attributes of **uris** under **skills** of an ability are concatenated. If **path**, **pathStartWith**, and **pathRegex** are declared in sequence, **uris** can be concatenated into the following expressions:
> >
> - **Full path expression**: `scheme://host:port/path` > - **Full path expression**: `scheme://host:port/path`
> >
> - **Prefix expression**: `scheme://host:port/pathStartWith` > - **Prefix expression**: `scheme://host:port/pathStartWith`
> >
> - **Regular expression**: `scheme://host:port/pathRegex` > - **Regular expression**: `scheme://host:port/pathRegex`
>
> - **Prefix URI expression**: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the configuration file, the matching is successful if a URI prefixed with the configuration file is passed in.
> * `scheme://`
> * `scheme://host`
> * `scheme://host:port`
### Matching Rules of type ### Matching Rules of type
......
...@@ -25,6 +25,12 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab ...@@ -25,6 +25,12 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [EnterpriseAdminExtensionAbility](../reference/apis/js-apis-EnterpriseAdminExtensionAbility.md): ExtensionAbility component of the enterprise_admin type, which provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts. - [EnterpriseAdminExtensionAbility](../reference/apis/js-apis-EnterpriseAdminExtensionAbility.md): ExtensionAbility component of the enterprise_admin type, which provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.
> **NOTE**<br>
> 1. Third-party applications cannot implement ServiceExtensionAbility, DataShareExtensionAbility, StaticSubscriberExtensionAbility, or WindowExtensionAbility.
>
> 2. To implement transaction processing in the background for a third-party application, use background tasks rather than ServiceExtensionAbility. For details, see [Background Task](../task-management/background-task-overview.md).
>
> 3. Third-party applications can use other types of ExtensionAbility components that have been defined.
## Using ExtensionAbility of the Specified Type ## Using ExtensionAbility of the Specified Type
......
# Cross-Device Migration (for System Applications Only)] # Cross-Device Migration (for System Applications Only)
## When to Use ## When to Use
...@@ -47,25 +47,16 @@ The table below describes the main APIs used for cross-device migration. For det ...@@ -47,25 +47,16 @@ The table below describes the main APIs used for cross-device migration. For det
## How to Develop ## How to Develop
1. Configure the data synchronization permission in the **module.json5** file. The sample code is as follows: 1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
```json
{
"module": {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
}
]
}
}
```
2. Configure the fields related to cross-device migration in the configuration file. 2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
- Configure the application to support migration.
Set the **continuable** field in the **module.json5** file to **true**. The default value is **false**. If this parameter is set to **false**, the application cannot be continued on the target device. 3. Configure the fields related to cross-device migration in the configuration file.
Configure the application to support migration.
Set the **continuable** field in the **module.json5** file to **true**. The default value is **false**. If this parameter is set to **false**, the application cannot be continued on the target device.
```json ```json
{ {
"module": { "module": {
...@@ -80,47 +71,31 @@ The table below describes the main APIs used for cross-device migration. For det ...@@ -80,47 +71,31 @@ The table below describes the main APIs used for cross-device migration. For det
} }
``` ```
- Configure the application launch type. For details, see [UIAbility Component Launch Type](uiability-launch-type.md). Configure the application launch type. For details, see [UIAbility Component Launch Type](uiability-launch-type.md).
3. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
```ts
requestPermission() {
let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => {
console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => {
console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
})
}
```
4. Implement [onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) in the UIAbility of the initiator. 4. Implement [onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) in the UIAbility of the initiator.
[onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) is called on the initiator. You can save the data in this method to implement application compatibility check and migration decision. [onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) is called on the initiator. You can save the data in this method to implement application compatibility check and migration decision.
- Saving migrated data: You can save the data to be migrated in key-value pairs in **wantParam**. - Saving migrated data: You can save the data to be migrated in key-value pairs in **wantParam**.
- Checking application compatibility: You can obtain the version number of the target application from **wantParam** and check the compatibility between the target application and the current application. - Checking application compatibility: You can obtain the version number of the target application from **wantParam** and check the compatibility between the target application and the current application.
- Making a migration decision: You can determine whether to support the migration based on the return value of **onContinue()**. For details about the return value, see [Available APIs](#available-apis). - Making a migration decision: You can determine whether to support the migration based on the return value of **onContinue()**. For details about the return value, see [Available APIs](#available-apis).
The sample code is as follows: The sample code is as follows:
```ts ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
onContinue(wantParam : {[key: string]: any}) { onContinue(wantParam : {[key: string]: any}) {
console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`) console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
let workInput = AppStorage.Get<string>('ContinueWork'); let workInput = AppStorage.Get<string>('ContinueWork');
// Set the user input data into wantParam. // Set the user input data into wantParam.
wantParam["work"] = workInput // set user input data into want params wantParam["work"] = workInput // set user input data into want params
console.info(`onContinue input = ${wantParam["input"]}`); console.info(`onContinue input = ${wantParam["input"]}`);
return AbilityConstant.OnContinueResult.AGREE return AbilityConstant.OnContinueResult.AGREE
} }
``` ```
5. Implement **onCreate()** and **onNewWant()** in the UIAbility of the target application to implement data restoration. 5. Implement **onCreate()** and **onNewWant()** in the UIAbility of the target application to implement data restoration.
- Implementation example of **onCreate** in the multi-instance scenario - Implementation example of **onCreate** in the multi-instance scenario
......
...@@ -30,102 +30,100 @@ Missions are managed by system applications (such as home screen), rather than t ...@@ -30,102 +30,100 @@ Missions are managed by system applications (such as home screen), rather than t
A UIAbility instance corresponds to an independent mission. Therefore, when an application calls [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start a UIAbility, a mission is created. A UIAbility instance corresponds to an independent mission. Therefore, when an application calls [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start a UIAbility, a mission is created.
To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions.
You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions. The sample code is as follows: ```ts
import missionManager from '@ohos.app.ability.missionManager'
let listener = {
```ts // Listen for mission creation.
import missionManager from '@ohos.app.ability.missionManager' onMissionCreated: function (mission) {
console.info("--------onMissionCreated-------")
let listener = { },
// Listen for mission creation. // Listen for mission destruction.
onMissionCreated: function (mission) { onMissionDestroyed: function (mission) {
console.info("--------onMissionCreated-------") console.info("--------onMissionDestroyed-------")
}, },
// Listen for mission destruction. // Listen for mission snapshot changes.
onMissionDestroyed: function (mission) { onMissionSnapshotChanged: function (mission) {
console.info("--------onMissionDestroyed-------") console.info("--------onMissionSnapshotChanged-------")
}, },
// Listen for mission snapshot changes. // Listen for switching the mission to the foreground.
onMissionSnapshotChanged: function (mission) { onMissionMovedToFront: function (mission) {
console.info("--------onMissionSnapshotChanged-------") console.info("--------onMissionMovedToFront-------")
}, },
// Listen for switching the mission to the foreground. // Listen for mission icon changes.
onMissionMovedToFront: function (mission) { onMissionIconUpdated: function (mission, icon) {
console.info("--------onMissionMovedToFront-------") console.info("--------onMissionIconUpdated-------")
}, },
// Listen for mission icon changes. // Listen for mission name changes.
onMissionIconUpdated: function (mission, icon) { onMissionLabelUpdated: function (mission) {
console.info("--------onMissionIconUpdated-------") console.info("--------onMissionLabelUpdated-------")
}, },
// Listen for mission name changes. // Listen for mission closure events.
onMissionLabelUpdated: function (mission) { onMissionClosed: function (mission) {
console.info("--------onMissionLabelUpdated-------") console.info("--------onMissionClosed-------")
}, }
// Listen for mission closure events. };
onMissionClosed: function (mission) {
console.info("--------onMissionClosed-------") // 1. Register a mission change listener.
} let listenerId = missionManager.on('mission', listener);
};
// 2. Obtain the latest 20 missions in the system.
// 1. Register a mission change listener. missionManager.getMissionInfos("", 20, (error, missions) => {
let listenerId = missionManager.on('mission', listener); console.info("getMissionInfos is called, error.code = " + error.code);
console.info("size = " + missions.length);
// 2. Obtain the latest 20 missions in the system. console.info("missions = " + JSON.stringify(missions));
missionManager.getMissionInfos("", 20, (error, missions) => { });
console.info("getMissionInfos is called, error.code = " + error.code);
console.info("size = " + missions.length); // 3. Obtain the detailed information about a mission.
console.info("missions = " + JSON.stringify(missions)); let missionId = 11; // The mission ID 11 is only an example.
}); let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
console.info(err);
// 3. Obtain the detailed information about a mission. });
let missionId = 11; // The mission ID 11 is only an example.
let mission = missionManager.getMissionInfo("", missionId).catch(function (err) { // 4. Obtain the mission snapshot.
console.info(err); missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
}); console.info("getMissionSnapShot is called, error.code = " + error.code);
console.info("bundleName = " + snapshot.ability.bundleName);
// 4. Obtain the mission snapshot. })
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
console.info("getMissionSnapShot is called, error.code = " + error.code); // 5. Obtain the low-resolution mission snapshot.
console.info("bundleName = " + snapshot.ability.bundleName); missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
}) console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
console.info("bundleName = " + snapshot.ability.bundleName);
// 5. Obtain the low-resolution mission snapshot. })
missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code); // 6. Lock or unlock the mission.
console.info("bundleName = " + snapshot.ability.bundleName); missionManager.lockMission(missionId).then(() => {
}) console.info("lockMission is called ");
});
// 6. Lock or unlock the mission.
missionManager.lockMission(missionId).then(() => { missionManager.unlockMission(missionId).then(() => {
console.info("lockMission is called "); console.info("unlockMission is called ");
}); });
missionManager.unlockMission(missionId).then(() => { // 7. Switch the mission to the foreground.
console.info("unlockMission is called "); missionManager.moveMissionToFront(missionId).then(() => {
}); console.info("moveMissionToFront is called ");
});
// 7. Switch the mission to the foreground.
missionManager.moveMissionToFront(missionId).then(() => { // 8. Clear a single mission.
console.info("moveMissionToFront is called "); missionManager.clearMission(missionId).then(() => {
}); console.info("clearMission is called ");
});
// 8. Clear a single mission.
missionManager.clearMission(missionId).then(() => { // 9. Clear all missions.
console.info("clearMission is called "); missionManager.clearAllMissions().catch(function (err) {
}); console.info(err);
});
// 9. Clear all missions.
missionManager.clearAllMissions().catch(function (err) { // 10. Deregister the mission change listener.
console.info(err); missionManager.off('mission', listenerId, (error) => {
}); console.info("unregisterMissionListener");
})
// 10. Deregister the mission change listener. ```
missionManager.off('mission', listenerId, (error) => {
console.info("unregisterMissionListener");
})
```
...@@ -9,37 +9,7 @@ During application development, you must declare the required permission in the ...@@ -9,37 +9,7 @@ During application development, you must declare the required permission in the
To declare a permission in **config.json**, add **reqPermissions** under **module** and list the permission. To declare a permission in **config.json**, add **reqPermissions** under **module** and list the permission.
For example, to request the permission to access the calendar, perform the following steps:
For example, to declare the permission to access the calendar, request the **ohos.permission.READ_CALENDAR** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). 1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
The sample code in the **config.json** file is as follows:
```json
{
"module": {
// ...
"reqPermissions": [
{
"name": "ohos.permission.READ_CALENDAR"
// ...
}
]
}
}
```
Request the permission from uses in the form of a dialog box:
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let permissions: Array<string> = ['ohos.permission.READ_CALENDAR']
context.requestPermissionsFromUser(permissions, 1).then((data) => {
console.info("Succeed to request permission from user with data: " + JSON.stringify(data))
}).catch((error) => {
console.info("Failed to request permission from user with error: " + JSON.stringify(error))
})
```
...@@ -10,7 +10,7 @@ The following figure shows the basic concepts used in the stage model. ...@@ -10,7 +10,7 @@ The following figure shows the basic concepts used in the stage model.
- [UIAbility component](uiability-overview.md) and [ExtensionAbility component](extensionability-overview.md) - [UIAbility component](uiability-overview.md) and [ExtensionAbility component](extensionability-overview.md)
The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development. They are the specific implementation of the abstract ability concept on the stage model. They are also units scheduled by the Ability Manager Service (AMS), which schedules their lifecycles as well. The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development.
- UIAbility has the UI and is mainly used for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the creation, destruction, foreground, and background states. Display-related states are exposed through WindowStage events. - UIAbility has the UI and is mainly used for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the creation, destruction, foreground, and background states. Display-related states are exposed through WindowStage events.
...@@ -22,6 +22,7 @@ The following figure shows the basic concepts used in the stage model. ...@@ -22,6 +22,7 @@ The following figure shows the basic concepts used in the stage model.
- [Context](application-context-stage.md) - [Context](application-context-stage.md)
In the stage model, Context and its derived classes provide a variety of resources and capabilities that can be called during the runtime. The UIAbility component and ExtensionAbility derived classes have different Context classes. These classes, which all inherit from the base class Context, provide different capabilities. In the stage model, Context and its derived classes provide a variety of resources and capabilities that can be called during the runtime. The UIAbility component and ExtensionAbility derived classes have different Context classes. These classes, which all inherit from the base class Context, provide different capabilities.
- [AbilityStage](abilitystage.md) - [AbilityStage](abilitystage.md)
Each HAP of the Entry or Feature type has an AbilityStage class instance during the runtime. When the code in the HAP is loaded to the process for the first time, the system creates an AbilityStage class instance first. Each UIAbility class defined in the HAP is associated with this class instance after instantiation. Through this class instance, you can obtain the runtime information of the UIAbility instances in the HAP. Each HAP of the Entry or Feature type has an AbilityStage class instance during the runtime. When the code in the HAP is loaded to the process for the first time, the system creates an AbilityStage class instance first. Each UIAbility class defined in the HAP is associated with this class instance after instantiation. Through this class instance, you can obtain the runtime information of the UIAbility instances in the HAP.
......
...@@ -80,7 +80,7 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub** ...@@ -80,7 +80,7 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub**
4. After **event1** is used, you can call [eventHub.off()](../reference/apis/js-apis-inner-application-eventHub.md#eventhuboff) to unsubscribe from the event. 4. After **event1** is used, you can call [eventHub.off()](../reference/apis/js-apis-inner-application-eventHub.md#eventhuboff) to unsubscribe from the event.
```ts ```ts
// context is the ability-level context of the UIAbility instance. // context is the AbilityContext of the UIAbility instance.
this.context.eventHub.off('event1'); this.context.eventHub.off('event1');
``` ```
...@@ -240,10 +240,6 @@ The following provides an example to describe the object overwritten problem in ...@@ -240,10 +240,6 @@ The following provides an example to describe the object overwritten problem in
struct Index { struct Index {
onPageShow() { onPageShow() {
let ctx = globalThis.context; // Obtain the context from globalThis and use it. let ctx = globalThis.context; // Obtain the context from globalThis and use it.
let permissions = ['com.example.permission']
ctx.requestPermissionsFromUser(permissions,(result) => {
// ...
});
} }
// Page display. // Page display.
build() { build() {
...@@ -251,7 +247,7 @@ The following provides an example to describe the object overwritten problem in ...@@ -251,7 +247,7 @@ The following provides an example to describe the object overwritten problem in
} }
} }
``` ```
3. In the UIAbilityB file, [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md) is stored in **globalThis** and has the same name as that in the UIAbilityA file. 3. In the UIAbilityB file, [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md) is stored in **globalThis** and has the same name as that in the UIAbilityA file.
```ts ```ts
...@@ -274,10 +270,6 @@ The following provides an example to describe the object overwritten problem in ...@@ -274,10 +270,6 @@ The following provides an example to describe the object overwritten problem in
struct Index { struct Index {
onPageShow() { onPageShow() {
let ctx = globalThis.context; // Obtain the context from globalThis and use it. let ctx = globalThis.context; // Obtain the context from globalThis and use it.
let permissions = ['com.example.permission']
ctx.requestPermissionsFromUser(permissions,(result) => {
console.info('requestPermissionsFromUser result:' + JSON.stringify(result));
});
} }
// Page display. // Page display.
build() { build() {
...@@ -285,7 +277,7 @@ The following provides an example to describe the object overwritten problem in ...@@ -285,7 +277,7 @@ The following provides an example to describe the object overwritten problem in
} }
} }
``` ```
5. Switch the UIAbilityB instance to the background and switch the UIAbilityA instance to the foreground. In this case, UIAbilityA will not enter the **onCreate()** lifecycle again. 5. Switch the UIAbilityB instance to the background and switch the UIAbilityA instance to the foreground. In this case, UIAbilityA will not enter the **onCreate()** lifecycle again.
```ts ```ts
...@@ -307,10 +299,6 @@ The following provides an example to describe the object overwritten problem in ...@@ -307,10 +299,6 @@ The following provides an example to describe the object overwritten problem in
struct Index { struct Index {
onPageShow() { onPageShow() {
let ctx = globalThis.context; // The context in globalThis is the context of UIAbilityB. let ctx = globalThis.context; // The context in globalThis is the context of UIAbilityB.
let permissions=['com.example.permission'];
ctx.requestPermissionsFromUser(permissions,(result) => { // Using this object causes a process breakdown.
console.info('requestPermissionsFromUser result:' + JSON.stringify(result));
});
} }
// Page display. // Page display.
build() { build() {
......
...@@ -17,10 +17,13 @@ The launch type of the UIAbility component refers to the state of the UIAbility ...@@ -17,10 +17,13 @@ The launch type of the UIAbility component refers to the state of the UIAbility
Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, if a UIAbility instance of this type already exists in the application process, the instance is reused. Therefore, only one UIAbility instance of this type exists in the system, that is, displayed in **Recents**. Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, if a UIAbility instance of this type already exists in the application process, the instance is reused. Therefore, only one UIAbility instance of this type exists in the system, that is, displayed in **Recents**.
**Figure 1** Demonstration effect in singleton mode **Figure 1** Demonstration effect in singleton mode
![uiability-launch-type1](figures/uiability-launch-type1.png) ![uiability-launch-type1](figures/uiability-launch-type1.png)
> **NOTE**<br>Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **singleton**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the UIAbility instance, the original UIAbility instance is started, and no new UIAbility instance is created. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback is invoked, but the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks are not. > **NOTE**
>
> Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **singleton**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the UIAbility instance, the original UIAbility instance is started, and no new UIAbility instance is created. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback is invoked, but the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks are not.
To use the singleton mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **singleton**. To use the singleton mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **singleton**.
...@@ -44,7 +47,8 @@ To use the singleton mode, set **launchType** in the [module.json5 configuration ...@@ -44,7 +47,8 @@ To use the singleton mode, set **launchType** in the [module.json5 configuration
In standard mode, each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a new UIAbility instance of this type is created in the application process. Multiple UIAbility instances of this type are displayed in **Recents**. In standard mode, each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a new UIAbility instance of this type is created in the application process. Multiple UIAbility instances of this type are displayed in **Recents**.
**Figure 2** Demonstration effect in standard mode **Figure 2** Demonstration effect in standard mode
![standard-mode](figures/standard-mode.png) ![standard-mode](figures/standard-mode.png)
To use the standard mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **standard**. To use the standard mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **standard**.
...@@ -69,7 +73,8 @@ To use the standard mode, set **launchType** in the [module.json5 configuration ...@@ -69,7 +73,8 @@ To use the standard mode, set **launchType** in the [module.json5 configuration
The **specified** mode is used in some special scenarios. For example, in a document application, you want a document instance to be created each time you create a document, but you want to use the same document instance when you repeatedly open an existing document. The **specified** mode is used in some special scenarios. For example, in a document application, you want a document instance to be created each time you create a document, but you want to use the same document instance when you repeatedly open an existing document.
**Figure 3** Demonstration effect in specified mode **Figure 3** Demonstration effect in specified mode
![uiability-launch-type2](figures/uiability-launch-type2.png) ![uiability-launch-type2](figures/uiability-launch-type2.png)
For example, there are two UIAbility components: EntryAbility and SpecifiedAbility (with the launch type **specified**). You are required to start SpecifiedAbility from EntryAbility. For example, there are two UIAbility components: EntryAbility and SpecifiedAbility (with the launch type **specified**). You are required to start SpecifiedAbility from EntryAbility.
...@@ -108,7 +113,7 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili ...@@ -108,7 +113,7 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
instanceKey: getInstance(), instanceKey: getInstance(),
}, },
} }
// context is the ability-level context of the initiator UIAbility. // context is the UIAbilityContext of the initiator UIAbility.
this.context.startAbility(want).then(() => { this.context.startAbility(want).then(() => {
// ... // ...
}).catch((err) => { }).catch((err) => {
...@@ -137,7 +142,7 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili ...@@ -137,7 +142,7 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
} }
``` ```
> **NOTE**<br> > **NOTE**
> >
> 1. Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **specified**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the UIAbility instance, and the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) matches a created UIAbility instance, the original UIAbility instance is started, and no new UIAbility instance is created. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback is invoked, but the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks are not. > 1. Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **specified**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the UIAbility instance, and the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) matches a created UIAbility instance, the original UIAbility instance is started, and no new UIAbility instance is created. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback is invoked, but the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks are not.
> 2. AbilityStage is not automatically generated in the default project of DevEco Studio. For details about how to create an AbilityStage file, see [AbilityStage Component Container](abilitystage.md). > 2. AbilityStage is not automatically generated in the default project of DevEco Studio. For details about how to create an AbilityStage file, see [AbilityStage Component Container](abilitystage.md).
......
...@@ -5,10 +5,25 @@ ...@@ -5,10 +5,25 @@
UIAbility is a type of application component that provides the UI for user interaction. UIAbility is a type of application component that provides the UI for user interaction.
UIAbility is the basic unit scheduled by the system and provides a window for applications to draw UIs. An application can contain one or more UIAbility components. For example, for a payment application, you can use two UIAbility components to carry the entry and payment functionalities. You are advised to use one UIAbility component to carry the same functional module, with multiple pages (if necessary). The following design philosophy is behind UIAbility:
1. Native support for [cross-device migration](hop-cross-device-migration.md) and [multi-device collaboration](hop-multi-device-collaboration.md) at the application component level
2. Support for multiple device types and window forms
For details, see [Interpretation of the Application Model](application-model-description.md).
The UIAbility division principles and suggestions are as follows:
UIAbility is the basic unit scheduled by the system and provides a window for applications to draw UIs. An application can contain one or more UIAbility components. For example, for a payment application, you can use two UIAbility components to carry the entry and payment functionalities.
Each UIAbility component instance is displayed as a mission in Recents. Each UIAbility component instance is displayed as a mission in Recents.
You can develop a single UIAbility or multiple UIAbilities for your application based on service requirements.
- If you want only one mission to be displayed in Recents, use one UIAbility and multiple pages.
- If you want multiple missions to be displayed in Recents or multiple windows to be opened simultaneously, use multiple UIAbilities.
## Privacy Statement Configuration ## Privacy Statement Configuration
......
# Native APIs # Native APIs
Native APIs are a set of native development interfaces and tools provided by the OHOS SDK. It enables the use of C or C++ code to implement key application functionalities. Native APIs provide part of basic underlying capabilities of OHOS, such as libc, graphics library, window system, multimedia, and compression library. They do not provide complete OHOS platform capabilities as JS APIs do. Native APIs are compiled into a dynamic library before being packed into the application.
## Native API Composition
### Native API Directory Structure
Native APIs are stored in the **$(SDK_ROOT)/native** directory of the SDK. They consist of the following parts:
|Directory|Description|
|--|--|
|build|Used to build the toolchain.cmake script of the dynamic library in the application. The **ohos.toolchain.cmake** file in this directory defines OHOS cross compilation options.|
|build-tools|Stores build tools, such as CMake.|
|docs|Stores Native API reference documents, which is extracted from the header files using Doxgen.|
|llvm|Stores LLVM, a cross compiler that supports OHOS ABIs.|
|sysroot|Stores dependent files of build links, including header files and dynamic libraries.|
### Native APIs
|Category|Function|Introduced In|
|--|--|--|
|C standard library|C standard library interfaces based on musl. Currently, more than 1500 interfaces are provided.|API version 8|
|C++ standard library|C++ runtime library libc++_shared. This library must be packed or statically linked to the application during packing.|API version 8|
|Log|HiLog interfaces for printing logs to the system|API version 8|
|napi|A group of Node-APIs provided by ArkUI to facilitate access to the JS application environment during application development. Node-APIs are part of native APIs.|API version 8|
|XComponent|Provides surface and touchscreen event interfaces for developing high-performance graphics applications.|API version 8|
|libuv|Third-party asynchronous I/O library integrated by ArkUI.|API version 8|
|libz|zlib library that provides basic compression and decompression interfaces.|API version 8|
|Drawing|2D graphics library that can be used for drawing on the surface.|API version 8|
|OpenGL|OpenGL 3.0 interfaces.|API version 8|
|Rawfile|Application resource access interfaces that can be used to read various resources packed in the application.|API version 8|
|OpenSLES|Interface library used for 2D and 3D audio acceleration.|API version 8|
|Mindspore|AI model interface library.|API version 9|
|Bundle management|Bundle service interfaces that can be used to query bundle information of the application.|API version 8|
Some native APIs use open source standards. For details, see [Native Standard Libraries Supported by OpenHarmony](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_libc/musl.md/) and [Node_API](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_napi/napi.md/).
## Usage Guidelines
### Scenarios Where Native APIs Are Recommended
You can use native APIs when you want to:
1. Develop performance-sensitive code in computing-intensive scenarios such as gaming and physical simulation.
2. Reuse the existing C or C++ library.
3. Customize libraries related to CPU features, such as neon acceleration.
### Scenarios Where Native APIs Are Not Recommended
You do not need to use native APIs when you want to:
1. Write a native OHOS application.
2. Develop an application compatible on as many OHOS devices as possible.
# Native API References
- [Native API hello world]()
This sample shows how to develop a hello native API library, which can display strings obtained from the hello library on the TS page.
- [Using Native APIs in Application Projects](napi-guidelines.md) - [Using Native APIs in Application Projects](napi-guidelines.md)
This document describes how to use native APIs to interact with modules, interfaces, and asynchronous tasks in JS.
- [Drawing Development](drawing-guidelines.md) - [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md) - [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md) - [Native Window Development](native-window-guidelines.md)
......
...@@ -232,3 +232,26 @@ struct Child { ...@@ -232,3 +232,26 @@ struct Child {
} }
} }
``` ```
## Restrictions on Naming Custom Components, Classes, and Functions
The name of a custom component, class, or function cannot be the same as any system component name.
Example:
```
// Rect.ets
export class Rect {
constructor(){}
}
// Index.ets
// ERROR: The module name 'Rect' can not be the same as the inner component name.
import { Rect } from './Rect';
@Entry
@Component
struct Index {
build() {
}
}
```
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
- [@ohos.promptAction (Prompt)](js-apis-promptAction.md) - [@ohos.promptAction (Prompt)](js-apis-promptAction.md)
- [@ohos.router (Page Routing)](js-apis-router.md) - [@ohos.router (Page Routing)](js-apis-router.md)
- [@ohos.measure (Text Measurement)](js-apis-measure.md) - [@ohos.measure (Text Measurement)](js-apis-measure.md)
- [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md)
- Graphics - Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md) - [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
...@@ -227,7 +228,7 @@ ...@@ -227,7 +228,7 @@
- [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md) - [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md) - [@ohos.data.preferences (User Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md) - [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
...@@ -266,6 +267,7 @@ ...@@ -266,6 +267,7 @@
- [@ohos.request (Upload and Download)](js-apis-request.md) - [@ohos.request (Upload and Download)](js-apis-request.md)
- Connectivity - Connectivity
- [@ohos.bluetooth (Bluetooth)(To Be Deprecated Soon)](js-apis-bluetooth.md)
- [@ohos.bluetoothManager (Bluetooth)(js-apis-bluetoothManager.md) - [@ohos.bluetoothManager (Bluetooth)(js-apis-bluetoothManager.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md) - [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md) - [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md)
...@@ -274,8 +276,8 @@ ...@@ -274,8 +276,8 @@
- [@ohos.rpc (RPC)](js-apis-rpc.md) - [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md) - [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md) - [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md)
- [@ohos.wifi (To Be Deprecated Soon)](js-apis-wifi.md) - [@ohos.wifi (WLAN)(To Be Deprecated Soon)](js-apis-wifi.md)
- [@ohos.wifiext (To Be Deprecated Soon)](js-apis-wifiext.md) - [@ohos.wifiext (WLAN Extension)(To Be Deprecated Soon)](js-apis-wifiext.md)
- tag - tag
- [nfctech (Standard NFC Technologies)](js-apis-nfctech.md) - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
...@@ -340,7 +342,7 @@ ...@@ -340,7 +342,7 @@
- [@ohos.systemParameterEnhance (System Parameter)](js-apis-system-parameterEnhance.md) - [@ohos.systemParameterEnhance (System Parameter)](js-apis-system-parameterEnhance.md)
- [@ohos.thermal (Thermal Management)](js-apis-thermal.md) - [@ohos.thermal (Thermal Management)](js-apis-thermal.md)
- [@ohos.update (Update)](js-apis-update.md) - [@ohos.update (Update)](js-apis-update.md)
- [@ohos.usbManager (USB Management)](js-apis-usbManager.md) - [@ohos.usbManager (USB Manager)](js-apis-usbManager.md)
- [@ohos.vibrator (Vibrator)](js-apis-vibrator.md) - [@ohos.vibrator (Vibrator)](js-apis-vibrator.md)
- Account Management - Account Management
...@@ -390,7 +392,6 @@ ...@@ -390,7 +392,6 @@
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md)
- [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
- [@ohos.bundle (Bundle)](js-apis-Bundle.md) - [@ohos.bundle (Bundle)](js-apis-Bundle.md)
- [@ohos.bundle.innerBundleManager (innerBundleManager)](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundle.innerBundleManager (innerBundleManager)](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState (Device Usage Statistics)](js-apis-deviceUsageStatistics.md) - [@ohos.bundleState (Device Usage Statistics)](js-apis-deviceUsageStatistics.md)
......
...@@ -65,11 +65,13 @@ Indicates that the device's thermal level has changed. ...@@ -65,11 +65,13 @@ Indicates that the device's thermal level has changed.
- Required subscriber permissions: none - Required subscriber permissions: none
## COMMON_EVENT_USER_PRESENT ## COMMON_EVENT_USER_PRESENT<sup>(deprecated)</sup>
(Reserved, not supported yet) Indicates that the user unlocks the device. (Reserved, not supported yet) Indicates that the user unlocks the device.
- Value: **usual.event.USER_PRESENT** - Value: **usual.event.USER_PRESENT**
- Required subscriber permissions: none - Required subscriber permissions: none
> NOTE
>
> This API is deprecated since API version 10.
## COMMON_EVENT_TIME_TICK ## COMMON_EVENT_TIME_TICK
Indicates that the system time has changed as time ticks by. Indicates that the system time has changed as time ticks by.
...@@ -929,3 +931,116 @@ Indicates the result of applying a quick fix to the application. ...@@ -929,3 +931,116 @@ Indicates the result of applying a quick fix to the application.
Indicates that the HTTP proxy configuration has changed. Indicates that the HTTP proxy configuration has changed.
- Value: **usual.event.HTTP_PROXY_CHANGE** - Value: **usual.event.HTTP_PROXY_CHANGE**
- Required subscriber permissions: none - Required subscriber permissions: none
## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup>
Indicates that the SIM card state has changed.
- Value: **usual.event.SIM_STATE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SMS_RECEIVED_COMPLETED<sup>10+<sup>
Indicates that the SMS message is received.
- Value: **usual.event.SMS_RECEIVED_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVE_SMS
## COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED<sup>10+<sup>
Indicates that an emergency cell broadcast message is received.
- Value: **usual.event.SMS_EMERGENCY_CB_RECEIVE_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVE_SMS
## COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED<sup>10+<sup>
Indicates that a cell broadcast message is received.
- Value: **usual.event.SMS_CB_RECEIVE_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVE_SMS
## COMMON_EVENT_STK_COMMAND<sup>10+<sup>
(Reserved, not supported yet) Indicates the STK command.
- Value: **usual.event.STK_COMMAND**
- Required subscriber permissions: none
## COMMON_EVENT_STK_SESSION_END<sup>10+<sup>
(Reserved, not supported yet) Indicates that an STK session ends.
- Value: **usual.event.STK_SESSION_END**
- Required subscriber permissions: none
## COMMON_EVENT_STK_CARD_STATE_CHANGED<sup>10+<sup>
(Reserved, not supported yet) Indicates that the STK card state has changed.
- Value: **usual.event.STK_CARD_STATE_CHANGED**
- Required subscriber permissions: ohos.permission
## COMMON_EVENT_STK_ALPHA_IDENTIFIER<sup>10+<sup>
(Reserved, not supported yet) Indicates the STK alpha indicator.
- Value: **usual.event.STK_ALPHA_IDENTIFIER**
- Required subscriber permissions: none
## COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED<sup>10+<sup>
Indicates that a WAP push message is received.
- Value: **usual.event.SMS_WAPPUSH_RECEIVE_COMPLETED**
- Required subscriber permissions: ohos.permission.RECEIVE_SMS
## COMMON_EVENT_OPERATOR_CONFIG_CHANGED<sup>10+<sup>
Indicates that the carrier configuration has been updated.
- Value: **usual.event.OPERATOR_CONFIG_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIM_CARD_DEFAULT_SMS_SUBSCRIPTION_CHANGED<sup>10+<sup>
Indicates that the default SIM card for the SMS service has changed.
- Value: **usual.event.DEFAULT_SMS_SUBSCRIPTION_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIM_CARD_DEFAULT_DATA_SUBSCRIPTION_CHANGED<sup>10+<sup>
Indicates that the default SIM card for the mobile data service has changed.
- Value: **usual.event.DEFAULT_DATA_SUBSCRIPTION_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIM_CARD_DEFAULT_MAIN_SUBSCRIPTION_CHANGED<sup>10+<sup>
Indicates that the default primary SIM card has changed.
- Value: **usual.event.SIM.DEFAULT_MAIN_SUBSCRIPTION_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIM_CARD_DEFAULT_VOICE_SUBSCRIPTION_CHANGED<sup>10+<sup>
Indicates that the default SIM card for the voice service has changed.
- Value: **usual.event.DEFAULT_VOICE_SUBSCRIPTION_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_CALL_STATE_CHANGED<sup>10+<sup>
Indicates that the call state has changed.
- Value: **usual.event.CALL_STATE_CHANGED**
- Required subscriber permissions: ohos.permission.GET_TELEPHONY_STATE
## COMMON_EVENT_CELLULAR_DATA_STATE_CHANGED<sup>10+<sup>
Indicates that the cellular data state has changed.
- Value: **usual.event.CELLULAR_DATA_STATE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_NETWORK_STATE_CHANGED<sup>10+<sup>
Indicates that the network state has changed.
- Value: **usual.event.NETWORK_STATE_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_SIGNAL_INFO_CHANGED<sup>10+<sup>
Indicates that the signal information is updated.
- Value: **usual.event.SIGNAL_INFO_CHANGED**
- Required subscriber permissions: none
## COMMON_EVENT_INCOMING_CALL_MISSED<sup>10+<sup>
Indicates a missed call.
- Value: **usual.event.INCOMING_CALL_MISSED**
- Required subscriber permissions: ohos.permission.GET_TELEPHONY_STATE
## COMMON_EVENT_RADIO_STATE_CHANGE<sup>10+<sup>
Indicates that the power-on and power-off status of the modem has changed.
- Value: **usual.event.RADIO_STATE_CHANGE**
## COMMON_EVENT_SCREEN_LOCKED <sup>10+<sup>
Indicates that the screen is locked.
- Value: **usual.event.SCREEN_LOCKED**
- Required subscriber permissions: none
## COMMON_EVENT_SCREEN_UNLOCKED<sup>10+<sup>
Indicates that the screen is unlocked.
- Value: **usual.event.SCREEN_UNLOCKED**
- Required subscriber permissions: none
...@@ -79,7 +79,7 @@ try { ...@@ -79,7 +79,7 @@ try {
} }
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -135,7 +135,7 @@ try { ...@@ -135,7 +135,7 @@ try {
console.error('updateConfiguration fail, err: ${JSON.stringify(err)}'); console.error('updateConfiguration fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -177,7 +177,7 @@ try { ...@@ -177,7 +177,7 @@ try {
} }
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -217,7 +217,7 @@ try { ...@@ -217,7 +217,7 @@ try {
console.error('getAbilityRunningInfos fail, err: ${JSON.stringify(err)}'); console.error('getAbilityRunningInfos fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -262,7 +262,7 @@ try { ...@@ -262,7 +262,7 @@ try {
} }
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -310,7 +310,7 @@ try { ...@@ -310,7 +310,7 @@ try {
console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}'); console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
......
...@@ -306,7 +306,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -306,7 +306,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
missionManager.getMissionInfo('', testMissionId, (error, mission) => { missionManager.getMissionInfo('', testMissionId, (error, mission) => {
if (error) { if (error) {
console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
} else { } else {
console.log('mission.missionId = ${mission.missionId}'); console.log('mission.missionId = ${mission.missionId}');
console.log('mission.runningState = ${mission.runningState}'); console.log('mission.runningState = ${mission.runningState}');
...@@ -392,7 +392,7 @@ Obtains information about all missions. This API uses an asynchronous callback t ...@@ -392,7 +392,7 @@ Obtains information about all missions. This API uses an asynchronous callback t
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error) { if (error) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
} else { } else {
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
console.log('missions = ${JSON.stringify(missions)}'); console.log('missions = ${JSON.stringify(missions)}');
......
...@@ -33,7 +33,7 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -33,7 +33,7 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
......
...@@ -375,10 +375,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -375,10 +375,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
console.log('Caller call() called'); console.log('Caller call() called');
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.call catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}'); console.log('Caller.call catch error, error.code: ${callErr.code}, error.message: ${callErr.message}');
}); });
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -456,10 +456,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -456,10 +456,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
data.readParcelable(retmsg); data.readParcelable(retmsg);
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.callWithResult catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}'); console.log('Caller.callWithResult catch error, error.code: ${callErr.code}, error.message: ${callErr.message}');
}); });
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -498,10 +498,10 @@ Releases the caller interface of the target ability. ...@@ -498,10 +498,10 @@ Releases the caller interface of the target ability.
try { try {
caller.release(); caller.release();
} catch (releaseErr) { } catch (releaseErr) {
console.log('Caller.release catch error, error.code: ${JSON.stringify(releaseErr.code)}, error.message: ${JSON.stringify(releaseErr.message)}'); console.log('Caller.release catch error, error.code: ${releaseErr.code}, error.message: ${releaseErr.message}');
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -538,10 +538,10 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -538,10 +538,10 @@ Registers a callback that is invoked when the stub on the target ability is disc
console.log(' Caller OnRelease CallBack is called ${str}'); console.log(' Caller OnRelease CallBack is called ${str}');
}); });
} catch (error) { } catch (error) {
console.log('Caller.onRelease catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('Caller.onRelease catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -587,10 +587,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -587,10 +587,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
console.log(' Caller OnRelease CallBack is called ${str}'); console.log(' Caller OnRelease CallBack is called ${str}');
}); });
} catch (error) { } catch (error) {
console.log('Caller.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('Caller.on catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -637,10 +637,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). ...@@ -637,10 +637,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
caller.on('release', onReleaseCallBack); caller.on('release', onReleaseCallBack);
caller.off('release', onReleaseCallBack); caller.off('release', onReleaseCallBack);
} catch (error) { } catch (error) {
console.log('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('Caller.on or Caller.off catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
}).catch((err) => { }).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -686,10 +686,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). ...@@ -686,10 +686,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
caller.on('release', onReleaseCallBack); caller.on('release', onReleaseCallBack);
caller.off('release'); caller.off('release');
} catch (error) { } catch (error) {
console.error('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('Caller.on or Caller.off catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
}).catch((err) => { }).catch((err) => {
console.error('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); console.error('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
}); });
} }
} }
...@@ -759,7 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -759,7 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try { try {
this.callee.on(method, funcCallBack); this.callee.on(method, funcCallBack);
} catch (error) { } catch (error) {
console.log('Callee.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('Callee.on catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
} }
} }
...@@ -798,7 +798,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -798,7 +798,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try { try {
this.callee.off(method); this.callee.off(method);
} catch (error) { } catch (error) {
console.log('Callee.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('Callee.off catch error, error.code: ${error.code}, error.message: ${error.message}');
} }
} }
} }
......
...@@ -186,10 +186,10 @@ try { ...@@ -186,10 +186,10 @@ try {
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
wantAgent = data; wantAgent = data;
}).catch((err) => { }).catch((err) => {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
}); });
} catch (err) { } catch (err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -280,7 +280,7 @@ function getWantAgentCallback(err, data) { ...@@ -280,7 +280,7 @@ function getWantAgentCallback(err, data) {
// getBundleName callback // getBundleName callback
function getBundleNameCallback(err, data) { function getBundleNameCallback(err, data) {
if(err) { if(err) {
console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${err.code} ${err.message}');
} else { } else {
console.info('getBundleName ok! ${JSON.stringify(data)}'); console.info('getBundleName ok! ${JSON.stringify(data)}');
} }
...@@ -288,13 +288,13 @@ function getWantAgentCallback(err, data) { ...@@ -288,13 +288,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getBundleName(wantAgent, getBundleNameCallback); WantAgent.getBundleName(wantAgent, getBundleNameCallback);
} catch(err) { } catch(err) {
console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -391,16 +391,16 @@ function getWantAgentCallback(err, data) { ...@@ -391,16 +391,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getBundleName(wantAgent).then((data)=>{ WantAgent.getBundleName(wantAgent).then((data)=>{
console.info('getBundleName ok! ${JSON.stringify(data)}'); console.info('getBundleName ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${err.code} ${err.message}');
}); });
} catch(err){ } catch(err){
console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -492,7 +492,7 @@ function getWantAgentCallback(err, data) { ...@@ -492,7 +492,7 @@ function getWantAgentCallback(err, data) {
// getUid callback // getUid callback
function getUidCallback(err, data) { function getUidCallback(err, data) {
if(err) { if(err) {
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} else { } else {
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
} }
...@@ -500,13 +500,13 @@ function getWantAgentCallback(err, data) { ...@@ -500,13 +500,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getUid(wantAgent, getUidCallback); WantAgent.getUid(wantAgent, getUidCallback);
} catch(err) { } catch(err) {
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -603,16 +603,16 @@ function getWantAgentCallback(err, data) { ...@@ -603,16 +603,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getUid(wantAgent).then((data)=>{ WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
}); });
} catch(err){ } catch(err){
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -704,7 +704,7 @@ function getWantAgentCallback(err, data) { ...@@ -704,7 +704,7 @@ function getWantAgentCallback(err, data) {
// getWant callback // getWant callback
function getWantCallback(err, data) { function getWantCallback(err, data) {
if(err) { if(err) {
console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWant failed! ${err.code} ${err.message}');
} else { } else {
console.info('getWant ok! ${JSON.stringify(data)}'); console.info('getWant ok! ${JSON.stringify(data)}');
} }
...@@ -712,13 +712,13 @@ function getWantAgentCallback(err, data) { ...@@ -712,13 +712,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getWant(wantAgent, getWantCallback); WantAgent.getWant(wantAgent, getWantCallback);
} catch(err) { } catch(err) {
console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWant failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -817,16 +817,16 @@ function getWantAgentCallback(err, data) { ...@@ -817,16 +817,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getUid(wantAgent).then((data)=>{ WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
}); });
} catch(err){ } catch(err){
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -917,7 +917,7 @@ function getWantAgentCallback(err, data) { ...@@ -917,7 +917,7 @@ function getWantAgentCallback(err, data) {
// cancel callback // cancel callback
function cancelCallback(err, data) { function cancelCallback(err, data) {
if(err) { if(err) {
console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${err.code} ${err.message}');
} else { } else {
console.info('cancel ok!'); console.info('cancel ok!');
} }
...@@ -925,13 +925,13 @@ function getWantAgentCallback(err, data) { ...@@ -925,13 +925,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.cancel(wantAgent, cancelCallback); WantAgent.cancel(wantAgent, cancelCallback);
} catch(err) { } catch(err) {
console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1028,16 +1028,16 @@ function getWantAgentCallback(err, data) { ...@@ -1028,16 +1028,16 @@ function getWantAgentCallback(err, data) {
WantAgent.cancel(wantAgent).then((data)=>{ WantAgent.cancel(wantAgent).then((data)=>{
console.info('cancel ok!'); console.info('cancel ok!');
}).catch((err)=>{ }).catch((err)=>{
console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${err.code} ${err.message}');
}); });
} catch(err){ } catch(err){
console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1131,7 +1131,7 @@ function getWantAgentCallback(err, data) { ...@@ -1131,7 +1131,7 @@ function getWantAgentCallback(err, data) {
// trigger callback // trigger callback
function triggerCallback(err, data) { function triggerCallback(err, data) {
if(err) { if(err) {
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} else { } else {
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
} }
...@@ -1139,13 +1139,13 @@ function getWantAgentCallback(err, data) { ...@@ -1139,13 +1139,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.trigger(wantAgent, triggerInfo, triggerCallback); WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
} catch(err) { } catch(err) {
console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1239,7 +1239,7 @@ function getWantAgentCallback(err, data) { ...@@ -1239,7 +1239,7 @@ function getWantAgentCallback(err, data) {
// equal callback // equal callback
function equalCallback(err, data) { function equalCallback(err, data) {
if(err) { if(err) {
console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${err.code} ${err.message}');
} else { } else {
console.info('equal ok! ${JSON.stringify(data)}'); console.info('equal ok! ${JSON.stringify(data)}');
} }
...@@ -1247,13 +1247,13 @@ function getWantAgentCallback(err, data) { ...@@ -1247,13 +1247,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.equal(wantAgent1,wantAgent2,equalCallback); WantAgent.equal(wantAgent1,wantAgent2,equalCallback);
} catch(err) { } catch(err) {
console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1353,16 +1353,16 @@ function getWantAgentCallback(err, data) { ...@@ -1353,16 +1353,16 @@ function getWantAgentCallback(err, data) {
WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{ WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{
console.info('equal ok! ${JSON.stringify(data)}'); console.info('equal ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${err.code} ${err.message}');
}) })
} catch(err){ } catch(err){
console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1451,7 +1451,7 @@ function getWantAgentCallback(err, data) { ...@@ -1451,7 +1451,7 @@ function getWantAgentCallback(err, data) {
// getOperationTypeCallback callback // getOperationTypeCallback callback
function getOperationTypeCallback(err, data) { function getOperationTypeCallback(err, data) {
if(err) { if(err) {
console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${err.code} ${err.message}');
} else { } else {
console.info('getOperationType ok! ${JSON.stringify(data)}'); console.info('getOperationType ok! ${JSON.stringify(data)}');
} }
...@@ -1459,13 +1459,13 @@ function getWantAgentCallback(err, data) { ...@@ -1459,13 +1459,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback); WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback);
} catch(err) { } catch(err) {
console.error('getOperationTypeCallback failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationTypeCallback failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
...@@ -1560,16 +1560,16 @@ function getWantAgentCallback(err, data) { ...@@ -1560,16 +1560,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getOperationType(wantAgent).then((data)=>{ WantAgent.getOperationType(wantAgent).then((data)=>{
console.info('getOperationType ok! ${JSON.stringify(data)}'); console.info('getOperationType ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${err.code} ${err.message}');
}); });
} catch(err){ } catch(err){
console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${err.code} ${err.message}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${err.code} ${err.message}');
} }
``` ```
......
...@@ -170,7 +170,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -170,7 +170,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);}); let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => { missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => {
if (error.code) { if (error.code) {
console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
...@@ -247,7 +247,7 @@ Obtains information about all missions. This API uses an asynchronous callback t ...@@ -247,7 +247,7 @@ Obtains information about all missions. This API uses an asynchronous callback t
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -319,7 +319,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback ...@@ -319,7 +319,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -328,7 +328,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback ...@@ -328,7 +328,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionSnapShot('', id, (error, snapshot) => { missionManager.getMissionSnapShot('', id, (error, snapshot) => {
if (error.code) { if (error.code) {
console.error('getMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionSnapShot failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('bundleName = ${snapshot.ability.bundleName}'); console.log('bundleName = ${snapshot.ability.bundleName}');
...@@ -408,7 +408,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu ...@@ -408,7 +408,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -492,7 +492,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re ...@@ -492,7 +492,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -580,7 +580,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy ...@@ -580,7 +580,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -716,7 +716,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba ...@@ -716,7 +716,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -757,7 +757,7 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -757,7 +757,7 @@ Switches a given mission to the foreground, with the startup parameters for the
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
......
...@@ -547,7 +547,7 @@ startBluetoothDiscovery(): void ...@@ -547,7 +547,7 @@ startBluetoothDiscovery(): void
Starts Bluetooth scan to discover remote devices. Starts Bluetooth scan to discover remote devices.
**Rquired permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
...@@ -652,6 +652,98 @@ try { ...@@ -652,6 +652,98 @@ try {
``` ```
## bluetoothManager.setDevicePinCode<sup>10+</sup><a name="setDevicePinCode"></a>
setDevicePinCode(device: string, code: string, callback: AsyncCallback&lt;void&gt;): void
Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**.
**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| code | string | Yes | PIN to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900099 | Operation failed. |
**Example**
```js
//callback
try {
bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345', (err, data) => {
console.info('setDevicePinCode,device name err:' + JSON.stringify(err) + ',device name:' + JSON.stringify(data));
});
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
}
```
## bluetoothManager.setDevicePinCode<sup>10+</sup><a name="setDevicePinCode"></a>
setDevicePinCode(device: string, code: string): Promise&lt;void&gt;
Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| code | string | Yes | PIN to set. |
**Return value**
| Type | Description |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900099 | Operation failed. |
**Example**
```js
//promise
try {
bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345').then(() => {
console.info('setDevicePinCode');
}, error => {
console.info('setDevicePinCode: errCode:' + error.code + ',errMessage' + error.message);
})
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
}
```
## bluetoothManager.on('bluetoothDeviceFind') ## bluetoothManager.on('bluetoothDeviceFind')
on(type: "bluetoothDeviceFind", callback: Callback&lt;Array&lt;string&gt;&gt;): void on(type: "bluetoothDeviceFind", callback: Callback&lt;Array&lt;string&gt;&gt;): void
...@@ -1385,7 +1477,7 @@ Creates a **GattServer** instance. ...@@ -1385,7 +1477,7 @@ Creates a **GattServer** instance.
| Type | Description | | Type | Description |
| ------------------------- | ------------------------------------ | | ------------------------- | ------------------------------------ |
| [GattServer](#gattserver) | **GattServer** instance created. Before using an API of the server, you must create a **GattSever** instance.| | [GattServer](#gattserver) | **GattServer** instance created. Before using an API of this class, you must create a **GattSever** instance.|
**Example** **Example**
...@@ -2333,17 +2425,6 @@ Obtains the network sharing status. ...@@ -2333,17 +2425,6 @@ Obtains the network sharing status.
| --------------------- | --------------------------------- | | --------------------- | --------------------------------- |
| boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.| | boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.|
**Error codes**
For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
| ID| Error Message|
| -------- | ---------------------------- |
|2900001 | Service stopped. |
|2900003 | Bluetooth switch is off. |
|2900004 | Profile is not supported. |
|2900099 | Operation failed. |
**Example** **Example**
```js ```js
...@@ -3258,7 +3339,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3258,7 +3339,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3327,7 +3408,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3327,7 +3408,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3382,7 +3463,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3382,7 +3463,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3444,7 +3525,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3444,7 +3525,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901000 | Read forbidden. | |2901000 | Read forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3491,7 +3572,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3491,7 +3572,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901001 | Write forbidden. | |2901001 | Write forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -3545,7 +3626,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ...@@ -3545,7 +3626,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------- | | -------- | ---------------------------- |
|2900001 | Service stopped. | |2900001 | Service stopped. |
|2901001 | Write forbidden. | |2901001 | Write forbidden. |
|2900099 | Operation failed. | |2900099 | Operation failed. |
**Example** **Example**
...@@ -4016,17 +4097,18 @@ Defines the characteristic API parameters. ...@@ -4016,17 +4097,18 @@ Defines the characteristic API parameters.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | | ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.| | serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.| | characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. | | characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
| descriptors | Array&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Yes | List of descriptors of the characteristic. | | descriptors | Array&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Yes | List of descriptors of the characteristic. |
| properties<sup>10+</sup> | [GattProperties](#gattproperties10) | Yes | Yes | Properties of the characteristic. |
## BLEDescriptor ## BLEDescriptor
Defines the descriptor API parameters. Defines the BLE descriptor.
**System capability**: SystemCapability.Communication.Bluetooth.Core **System capability**: SystemCapability.Communication.Bluetooth.Core
...@@ -4229,6 +4311,7 @@ Defines the scan result. ...@@ -4229,6 +4311,7 @@ Defines the scan result.
| deviceId | string | Yes | No | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.| | deviceId | string | Yes | No | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
| rssi | number | Yes | No | RSSI of the device. | | rssi | number | Yes | No | RSSI of the device. |
| data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. | | data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. |
| deviceName<sup>10+</sup> | string | Yes | No | Name of the device detected. |
## BluetoothState ## BluetoothState
...@@ -4308,6 +4391,7 @@ Defines the pairing request parameters. ...@@ -4308,6 +4391,7 @@ Defines the pairing request parameters.
| -------- | ------ | ---- | ---- | ----------- | | -------- | ------ | ---- | ---- | ----------- |
| deviceId | string | Yes | No | ID of the device to pair.| | deviceId | string | Yes | No | ID of the device to pair.|
| pinCode | string | Yes | No | Key for the device pairing. | | pinCode | string | Yes | No | Key for the device pairing. |
| pinType<sup>10+</sup> | [PinType](#pintype10) | Yes | No | Type of the device to pair. |
## BondStateParam<a name="BondStateParam"></a> ## BondStateParam<a name="BondStateParam"></a>
...@@ -4334,6 +4418,21 @@ Defines the profile state change parameters. ...@@ -4334,6 +4418,21 @@ Defines the profile state change parameters.
| state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.| | state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.|
## GattProperties<sup>10+</sup><a name="GattProperties"></a>
Defines the properties of a GATT characteristic.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Read-only | Mandatory | Description |
| -------- | ------ | ---- | ---- | ----------- |
| write<sup>10+</sup> | boolean | Yes | Yes | Permits writes of the characteristic value (with a response).|
| writeNoResponse<sup>10+</sup> | boolean | Yes | Yes | Permits writes of the characteristic value (without a response).|
| read<sup>10+</sup> | boolean | Yes | Yes | Permits reads of the characteristic value.|
| notify<sup>10+</sup> | boolean | Yes | Yes | Permits notifications of the characteristic value.|
| indicate<sup>10+</sup> | boolean | Yes | Yes | Permits notifications of the characteristic value without acknowledgement.|
## DeviceClass<a name="DeviceClass"></a> ## DeviceClass<a name="DeviceClass"></a>
Defines the class of a Bluetooth device. Defines the class of a Bluetooth device.
...@@ -4347,7 +4446,6 @@ Defines the class of a Bluetooth device. ...@@ -4347,7 +4446,6 @@ Defines the class of a Bluetooth device.
| classOfDevice | number | Yes | No | Class of the device. | | classOfDevice | number | Yes | No | Class of the device. |
## MajorClass<a name="MajorClass"></a> ## MajorClass<a name="MajorClass"></a>
Enumerates the major classes of Bluetooth devices. Enumerates the major classes of Bluetooth devices.
...@@ -4489,3 +4587,21 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS ...@@ -4489,3 +4587,21 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. | | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
| PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. | | PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. |
| PROFILE_PAN_NETWORK | 7 | PAN profile. | | PROFILE_PAN_NETWORK | 7 | PAN profile. |
## PinType<sup>10+</sup><a name="PinType"></a>
Enumerates the Bluetooth pairing types.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
| -------------------------------- | ------ | --------------- |
| PIN_TYPE_ENTER_PIN_CODE<sup>10+</sup> | 0 | The user needs to enter the PIN displayed on the peer device.|
| PIN_TYPE_ENTER_PASSKEY<sup>10+</sup> | 1 | The user needs to enter the PASSKEY displayed on the peer device. |
| PIN_TYPE_CONFIRM_PASSKEY<sup>10+</sup> | 2 | The user needs to confirm the PASSKEY displayed on the local device. |
| PIN_TYPE_NO_PASSKEY_CONSENT<sup>10+</sup> | 3 | There is no PASSKEY, and the user needs to accept or reject the pairing request. |
| PIN_TYPE_NOTIFY_PASSKEY<sup>10+</sup> | 4 | The user needs to enter the PASSKEY displayed on the local device on the peer device. |
| PIN_TYPE_DISPLAY_PIN_CODE<sup>10+</sup> | 5 | The user needs to enter the PIN displayed on the peer device for Bluetooth 2.0 devices. |
| PIN_TYPE_OOB_CONSENT<sup>10+</sup> | 6 | The user needs to accept or reject the out of band (OOB) pairing request. |
| PIN_TYPE_PIN_16_DIGITS<sup>10+</sup> | 7 | The user needs to enter the 16-digit PIN displayed on the peer device. |
...@@ -5,6 +5,8 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th ...@@ -5,6 +5,8 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## BundlePackInfo ## BundlePackInfo
...@@ -63,10 +65,10 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th ...@@ -63,10 +65,10 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- | | ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
| mainAbility | string | Yes| No| Name of the main ability.| | mainAbility | string | Yes| No| Name of the main ability.|
| apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. | | apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. |
| deviceType | Array\<string> | Yes | No | Device types supported by the module. | | deviceTypes | Array\<string> | Yes | No | Device types supported by the module. |
| distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. | | distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. |
| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. | | abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. |
| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | Yes | No | ExtensionAbility information of the module.| | extensionAbilities | Array\<[ExtensionAbility](#extensionability)> | Yes | No | ExtensionAbility information of the module.|
## ModuleDistroInfo ## ModuleDistroInfo
...@@ -123,7 +125,7 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th ...@@ -123,7 +125,7 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
## ApiVersion ## ApiVersion
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall **System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
......
...@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app ...@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app
| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | | appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. | | appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. | | systemApp | boolean | Yes | No | Whether the application is a system application. |
| bundleType |[BundleType](js-apis-bundleManager.md#bundletype) | Yes | No | Bundle type, which can be **APP** (common application) or **ATOMIC_SERVICE** (atomic service). |
...@@ -26,3 +26,28 @@ The **HapModuleInfo** module defines the HAP module information. A system applic ...@@ -26,3 +26,28 @@ The **HapModuleInfo** module defines the HAP module information. A system applic
| deviceTypes | Array\<string> | Yes | No | Types of devices where the module can run. | | deviceTypes | Array\<string> | Yes | No | Types of devices where the module can run. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. | | installationFree | boolean | Yes | No | Whether installation-free is supported. |
| hashValue | string | Yes | No | Hash value of the module. | | hashValue | string | Yes | No | Hash value of the module. |
| moduleType | [ModuleType](js-apis-bundleManager.md#moduletype) | Yes | No | Type of the module. |
| preloads | Array\<[PreloadItem](#preloaditem)> | Yes | No | Preloaded modules in the atomic service.|
| dependencies | Array\<[Dependency](#dependency)> | Yes | No | Dynamic shared libraries on which the module depends. |
## PreloadItem
Describes the preloaded module information in the atomic service.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Type | Readable| Writable| Description |
| --------- | -------------- | ---- | ---- | --------------------------- |
|moduleName | string | Yes | No | Name of the module automatically preloaded by the system.|
## Dependency
Describes the information about the dynamic shared library on which the module depends.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Type | Readable| Writable| Description |
| ----------- | ------ | ---- | ---- | ---------------------- |
| bundleName | string | Yes | No | Name of the shared bundle on which the current module depends. |
| moduleName | string | Yes | No | Module name of the shared bundle on which the current module depends.|
| versionCode | number | Yes | No | Version number of the shared bundle. |
...@@ -49,7 +49,7 @@ Enumerates the application flags, which indicate the type of application informa ...@@ -49,7 +49,7 @@ Enumerates the application flags, which indicate the type of application informa
**System capability**: SystemCapability.BundleManager.BundleFramework.Core **System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
| Name | Value | Description | | Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
...@@ -64,7 +64,7 @@ Enumerates the ability flags, which indicate the type of ability information to ...@@ -64,7 +64,7 @@ Enumerates the ability flags, which indicate the type of ability information to
**System capability**: SystemCapability.BundleManager.BundleFramework.Core **System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
| Name | Value | Description | | Name | Value | Description |
| --------------------------------- | ---------- | ------------------------------------------------------------ | | --------------------------------- | ---------- | ------------------------------------------------------------ |
...@@ -81,7 +81,7 @@ Enumerates the Extension ability flags, which indicate the type of Extension abi ...@@ -81,7 +81,7 @@ Enumerates the Extension ability flags, which indicate the type of Extension abi
**System capability**: SystemCapability.BundleManager.BundleFramework.Core **System capability**: SystemCapability.BundleManager.BundleFramework.Core
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API.
| Name | Value | Description | | Name | Value | Description |
| ------------------------------------------- | ---------- | ------------------------------------------------------------ | | ------------------------------------------- | ---------- | ------------------------------------------------------------ |
...@@ -187,6 +187,39 @@ Enumerates the display orientations of the ability. This attribute applies only ...@@ -187,6 +187,39 @@ Enumerates the display orientations of the ability. This attribute applies only
| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.| | AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.|
| LOCKED |12|Locked.| | LOCKED |12|Locked.|
### CompatiblePolicy
Defines the version compatibility type of the shared library.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| ---------------------- | ---- | -------------------------------- |
| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.|
### ModuleType
Enumerates the module types.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| ------- | ---- | -------------------- |
| ENTRY | 1 | Main module of the application. |
| FEATURE | 2 | Dynamic feature module of the application.|
| SHARED | 3 | Dynamic shared library module of the application. |
### BundleType
Enumerates the bundle types.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| -------------- | ---- | --------------- |
| APP | 0 | The bundle is a common application. |
| ATOMIC_SERVICE | 1 | The bundle is an atomic service.|
## APIs ## APIs
### bundleManager.getBundleInfoForSelf ### bundleManager.getBundleInfoForSelf
...@@ -1077,7 +1110,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -1077,7 +1110,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------------- | | -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. | | 17700001 | The specified bundleName is not found. |
| 17700003 | The specified extensionAbility is not found. | | 17700003 | The specified ability is not found. |
| 17700004 | The specified userId is invalid. | | 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. | | 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. | | 17700029 | The specified ability is disabled. |
...@@ -3036,47 +3069,3 @@ try { ...@@ -3036,47 +3069,3 @@ try {
hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
} }
``` ```
## CompatiblePolicy
Defines the version compatibility type of the shared library.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| ---------------------- | ---- | -------------------------------- |
| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.|
## ModuleType
Enumerates the module types.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| ------- | ---- | -------------------- |
| ENTRY | 1 | Main module of the application. |
| FEATURE | 2 | Dynamic feature module of the application.|
| SHARED | 3 | Dynamic shared library module of the application. |
## BundleType
Enumerates the bundle types.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| -------------- | ---- | --------------- |
| APP | 0 | The bundle is a common application. |
| ATOMIC_SERVICE | 1 | The bundle is an atomic service.|
## AtomicServiceModuleType
Enumerates the module types of an atomic service.
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Value | Description |
| ------ | ---- | --------------------------- |
| NORMAL | 0 | Page package in the atomic service. |
| MAIN | 1 | Landing page package in the atomic service.|
...@@ -35,7 +35,6 @@ Implements initialization for the interpolation curve, which is used to create a ...@@ -35,7 +35,6 @@ Implements initialization for the interpolation curve, which is used to create a
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve) | Interpolation curve.| | [ICurve](#icurve) | Interpolation curve.|
**Example** **Example**
```ts ```ts
...@@ -57,7 +56,7 @@ Creates a step curve. ...@@ -57,7 +56,7 @@ Creates a step curve.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ----| ------------------------------------------------------------ | | ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | Yes | Number of steps. The value must be a positive integer. | | count | number | Yes | Number of steps. The value must be a positive integer.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.|
| end | boolean | Yes | Whether jumping occurs when the interpolation ends.<br>- **true**: Jumping occurs when the interpolation ends.<br>- **false**: Jumping occurs when the interpolation starts.| | end | boolean | Yes | Whether jumping occurs when the interpolation ends.<br>- **true**: Jumping occurs when the interpolation ends.<br>- **false**: Jumping occurs when the interpolation starts.|
**Return value** **Return value**
...@@ -66,7 +65,6 @@ Creates a step curve. ...@@ -66,7 +65,6 @@ Creates a step curve.
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve) | Interpolation curve.| | [ICurve](#icurve) | Interpolation curve.|
**Example** **Example**
```ts ```ts
...@@ -85,12 +83,13 @@ Creates a cubic Bezier curve. The curve values must be between 0 and 1. ...@@ -85,12 +83,13 @@ Creates a cubic Bezier curve. The curve values must be between 0 and 1.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | -------------- | | Name| Type | Mandatory| Description |
| x1 | number | Yes | X coordinate of the first point on the Bezier curve.| | ------ | ------ | ---- | ------------------------------------------------------------ |
| y1 | number | Yes | Y coordinate of the first point on the Bezier curve.| | x1 | number | Yes | X coordinate of the first point on the Bezier curve.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.|
| x2 | number | Yes | X coordinate of the second point on the Bezier curve.| | y1 | number | Yes | Y coordinate of the first point on the Bezier curve.<br>Value range: (-∞, +∞) |
| y2 | number | Yes | Y coordinate of the second point on the Bezier curve.| | x2 | number | Yes | X coordinate of the second point on the Bezier curve.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.|
| y2 | number | Yes | Y coordinate of the second point on the Bezier curve.<br>Value range: (-∞, +∞) |
**Return value** **Return value**
...@@ -112,17 +111,17 @@ Curves.cubicBezierCurve(0.1, 0.0, 0.1, 1.0) // Create a cubic Bezier curve. ...@@ -112,17 +111,17 @@ Curves.cubicBezierCurve(0.1, 0.0, 0.1, 1.0) // Create a cubic Bezier curve.
springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve
Creates a spring curve. Creates a spring curve. The curve shape is subject to the spring parameters, and the animation duration is subject to the **duration** parameter in **animation** and **animateTo**.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ------------------------------------------------------------ |
| velocity | number | Yes | Initial velocity. It is applied by external factors to the elastic animation. It aims to help ensure the smooth transition from the previous motion state to the elastic animation.| | velocity | number | Yes | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state.<br>Value range: (-∞, +∞)|
| mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.| | mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
| stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.| | stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
| damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.| | damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
**Return value** **Return value**
...@@ -149,18 +148,19 @@ Creates a spring animation curve. If multiple spring animations are applied to t ...@@ -149,18 +148,19 @@ Creates a spring animation curve. If multiple spring animations are applied to t
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | Duration of one complete oscillation, in seconds.<br>Default value: **0.55**| | response | number | No | Duration of one complete oscillation,<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**| | dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.<br> Default value: **0**| | overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.<br><br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in **[animation](../arkui-ts/ts-animatorproperty.md)** or **[animateTo](../arkui-ts/ts-explicit-animation.md)**. The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>Note: The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.| | [ICurve](#icurve)| Curve.<br>**NOTE**<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.|
**Example** **Example**
...@@ -182,17 +182,18 @@ Creates a responsive spring animation curve. It is a special case of [springMoti ...@@ -182,17 +182,18 @@ Creates a responsive spring animation curve. It is a special case of [springMoti
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | See **response** in **springMotion**. Default value: **0.15**| | response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.|
| dampingFraction | number | No | See **dampingFraction** in **springMotion**. Default value: **0.86**| | dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.|
| overlapDuration | number | No | See **overlapDuration** in **springMotion**. Default value: **0.25**| | overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **[animation](../arkui-ts/ts-animatorproperty.md)** or **[animateTo](../arkui-ts/ts-explicit-animation.md)**. In addition, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.| | [ICurve](#icurve)| Curve.<br>**NOTE**<br>1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the **interpolate** function of the curve.|
**Example** **Example**
...@@ -202,6 +203,39 @@ Curves.responsiveSpringMotion() // Create a responsive spring animation curve wi ...@@ -202,6 +203,39 @@ Curves.responsiveSpringMotion() // Create a responsive spring animation curve wi
``` ```
## Curves.interpolatingSpringCurve<sup>10+</sup>
interpolatingSpring(velocity: number, mass: number, stiffness: number, damping: number): ICurve
Creates an interpolating spring curve animated from 0 to 1. The actual animation value is calculated based on the curve. The animation duration is subject to the curve parameters, rather than the **duration** parameter in **animation** or **animateTo**.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- |
| velocity | number | Yes | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the animation attribute change value.|
| mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.|
| stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.|
| damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.|
**Return value**
| Type | Description |
| ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Interpolation curve.|
**Example**
```ts
import Curves from '@ohos.curves'
Curves.interpolatingSpring(100, 1, 228, 30) // Create an interpolating spring curve whose duration is subject to spring parameters.
```
## ICurve ## ICurve
...@@ -217,9 +251,9 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -217,9 +251,9 @@ Since API version 9, this API is supported in ArkTS widgets.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | -------------------------------------------- | | -------- | ------ | ---- | ------------------------------------------------------------ |
| fraction | number | Yes | Current normalized time. The value ranges from 0 to 1.| | fraction | number | Yes | Current normalized time.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.|
**Return value** **Return value**
...@@ -300,7 +334,7 @@ Creates a spring curve. This API is deprecated since API version 9. You are advi ...@@ -300,7 +334,7 @@ Creates a spring curve. This API is deprecated since API version 9. You are advi
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| velocity | number | Yes | Initial velocity. It is applied by external factors to the elastic animation. It aims to help ensure the smooth transition from the previous motion state to the elastic animation.| | velocity | number | Yes | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state.|
| mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.| | mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.|
| stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.| | stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.|
| damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.| | damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.|
......
...@@ -299,7 +299,7 @@ try { ...@@ -299,7 +299,7 @@ try {
getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\<BundlePackInfo>; getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\<BundlePackInfo>;
Obtains **bundlePackInfo** based on **bundleName** and **bundleFlag**. This API uses a promise to return the result. Obtains **bundlePackInfo** based on **bundleName** and **BundlePackFlag**. This API uses a promise to return the result.
**System API**: This is a system API. **System API**: This is a system API.
......
...@@ -20,7 +20,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -20,7 +20,7 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundAppInfos() { function getForegroundAppInfos() {
appManager.getForegroundApplications((error, data) => { appManager.getForegroundApplications((error, data) => {
if (error && error.code) { if (error && error.code) {
console.log('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.log('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
} }
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册