提交 ba3ef9cb 编写于 作者: X xuzhidan 提交者: Gitee

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

Signed-off-by: Nxuzhidan <xuzhidan1@huawei.com>
...@@ -85,6 +85,7 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin ...@@ -85,6 +85,7 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-huks-guide.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23
...@@ -348,4 +349,6 @@ zh-cn/application-dev/napi/napi-guidelines.md @RayShih ...@@ -348,4 +349,6 @@ zh-cn/application-dev/napi/napi-guidelines.md @RayShih
zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang
zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease
\ No newline at end of file zh-cn/application-dev/website.md @zengyawen
zh-cn/application-dev/faqs/ @zengyawen
\ No newline at end of file
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#!/bin/bash
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
docker build -t openharmony-docker:1.0.0 .
...@@ -590,7 +590,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { ...@@ -590,7 +590,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
testIntTransaction(data: number, callback: testIntTransactionCallback): void testIntTransaction(data: number, callback: testIntTransactionCallback): void
{ {
let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); let _option = new rpc.MessageOption();
let _data = new rpc.MessageParcel(); let _data = new rpc.MessageParcel();
let _reply = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel();
_data.writeInt(data); _data.writeInt(data);
...@@ -612,7 +612,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { ...@@ -612,7 +612,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
testStringTransaction(data: string, callback: testStringTransactionCallback): void testStringTransaction(data: string, callback: testStringTransactionCallback): void
{ {
let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); let _option = new rpc.MessageOption();
let _data = new rpc.MessageParcel(); let _data = new rpc.MessageParcel();
let _reply = new rpc.MessageParcel(); let _reply = new rpc.MessageParcel();
_data.writeString(data); _data.writeString(data);
......
...@@ -19,7 +19,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r ...@@ -19,7 +19,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r
|API|Description| |API|Description|
|:------|:------| |:------|:------|
|startAbilityByCall(want: Want): Promise\<Caller>|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| |startAbilityByCall(want: Want): Promise\<Caller>|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
|on(method: string, callback: CaleeCallBack): void|Callback invoked when the callee registers a method.| |on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee registers a method.|
|off(method: string): void|Callback invoked when the callee deregisters a method.| |off(method: string): void|Callback invoked when the callee deregisters a method.|
|call(method: string, data: rpc.Sequenceable): Promise\<void>|Sends agreed sequenceable data to the callee.| |call(method: string, data: rpc.Sequenceable): Promise\<void>|Sends agreed sequenceable data to the callee.|
|callWithResult(method: string, data: rpc.Sequenceable): Promise\<rpc.MessageParcel>|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.| |callWithResult(method: string, data: rpc.Sequenceable): Promise\<rpc.MessageParcel>|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
...@@ -28,7 +28,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r ...@@ -28,7 +28,7 @@ The table below describes the ability call APIs. For details, see [Ability](../r
## How to Develop ## How to Develop
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. For details about the complete project code, see [Samples](#samples). > The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently.
### Creating a Callee ### Creating a Callee
For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener. For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener.
1. Configure the ability startup mode. 1. Configure the ability startup mode.
......
...@@ -39,33 +39,36 @@ OpenHarmony does not support creation of a Service Extension ability for third-p ...@@ -39,33 +39,36 @@ OpenHarmony does not support creation of a Service Extension ability for third-p
``` ```
2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined and override the lifecycle callbacks of the base class. The code sample is as follows: 2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined (**entry\src\main\ets\ServiceExtAbility\ServiceExtAbility.ts** by default) and override the lifecycle callbacks of the base class. The code sample is as follows:
```js ```js
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc' import rpc from '@ohos.rpc'
class StubTest extends rpc.RemoteObject { class StubTest extends rpc.RemoteObject {
constructor(des) { constructor(des) {
super(des); super(des);
} }
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
} }
} }
class ServiceExt extends ServiceExtensionAbility { class ServiceExtAbility extends ServiceExtensionAbility {
console.log('onCreate, want:' + want.abilityName); onCreate(want) {
} console.log('onCreate, want:' + want.abilityName);
onRequest(want, startId) { }
console.log('onRequest, want:' + want.abilityName); onRequest(want, startId) {
} console.log('onRequest, want:' + want.abilityName);
onConnect(want) { }
console.log('onConnect , want:' + want.abilityName); onConnect(want) {
return new StubTest("test"); console.log('onConnect , want:' + want.abilityName);
} return new StubTest("test");
onDisconnect(want) { }
console.log('onDisconnect, want:' + want.abilityName); onDisconnect(want) {
} console.log('onDisconnect, want:' + want.abilityName);
onDestroy() { }
console.log('onDestroy'); onDestroy() {
} console.log('onDestroy');
}
} }
``` ```
\ No newline at end of file
...@@ -17,7 +17,7 @@ Call **createDistributedObject()** to create a distributed data object instance. ...@@ -17,7 +17,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance **Table 1** API for creating a distributed data object instance
| Package| API| Description| | Package| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- **source**: attributes of the **distributedObject** set.<br>- **DistributedObject**: returns the distributed object created.| | ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- **source**: attributes of the **distributedObject** set.<br>- **DistributedObject**: returns the distributed object created.|
### Generating a Session ID ### Generating a Session ID
...@@ -35,16 +35,16 @@ Call **setSessionId()** to set a session ID for a distributed data object. The s ...@@ -35,16 +35,16 @@ Call **setSessionId()** to set a session ID for a distributed data object. The s
**Table 3** API for setting a session ID **Table 3** API for setting a session ID
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br> **sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| | DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br>**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes ### Observing Data Changes
Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes. Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
**Table 4** APIs for observing data changes of a distributed data object **Table 4** APIs for observing data changes of a distributed data object
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.| | DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| | DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
### Observing Online or Offline Status ### Observing Online or Offline Status
...@@ -85,7 +85,11 @@ The following example shows how to implement a distributed data object synchroni ...@@ -85,7 +85,11 @@ The following example shows how to implement a distributed data object synchroni
```js ```js
import distributedObject from '@ohos.data.distributedDataObject'; import distributedObject from '@ohos.data.distributedDataObject';
``` ```
2. Request the permission. <br>Add the required permission in the **config.json** file. The sample code is as follows:
2. Request the permission.
Add the required permission in the **config.json** file. The sample code is as follows:
``` ```
{ {
"module": { "module": {
...@@ -97,10 +101,11 @@ The following example shows how to implement a distributed data object synchroni ...@@ -97,10 +101,11 @@ The following example shows how to implement a distributed data object synchroni
} }
} }
``` ```
This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows: This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows:
```js
```
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function grantPermission() { function grantPermission() {
console.info('grantPermission'); console.info('grantPermission');
let context = featureAbility.getContext(); let context = featureAbility.getContext();
...@@ -108,11 +113,13 @@ The following example shows how to implement a distributed data object synchroni ...@@ -108,11 +113,13 @@ The following example shows how to implement a distributed data object synchroni
console.info(`result.requestCode=${result.requestCode}`) console.info(`result.requestCode=${result.requestCode}`)
}) })
console.info('end grantPermission'); console.info('end grantPermission');
} }
grantPermission(); grantPermission();
``` ```
3. Obtain a distributed data object instance. 3. Obtain a distributed data object instance.
The sample code is as follows: The sample code is as follows:
...@@ -130,7 +137,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -130,7 +137,7 @@ The following example shows how to implement a distributed data object synchroni
```js ```js
// Local object // Local object
var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true,
parent:{mother:"jack mom",father:"jack Dad"},list:[{mother:"jack mom"}, {father:"jack Dad"}]}); parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]});
local_object.setSessionId(sessionId); local_object.setSessionId(sessionId);
// Remote object // Remote object
...@@ -140,8 +147,10 @@ The following example shows how to implement a distributed data object synchroni ...@@ -140,8 +147,10 @@ The following example shows how to implement a distributed data object synchroni
// After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
``` ```
5. Observe the data changes of the distributed data object. <br>You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes. 5. Observe the data changes of the distributed data object.
You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes.
The sample code is as follows: The sample code is as follows:
```js ```js
...@@ -152,26 +161,32 @@ The following example shows how to implement a distributed data object synchroni ...@@ -152,26 +161,32 @@ The following example shows how to implement a distributed data object synchroni
changeData.forEach(element => { changeData.forEach(element => {
console.info("changed !" + element + " " + local_object[element]); console.info("changed !" + element + " " + local_object[element]);
}); });
} }
} }
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback. // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this)); local_object.on("change", this.changeCallback.bind(this));
``` ```
6. Modify object attributes. <br>The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). 6. Modify object attributes.
The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
The sample code is as follows: The sample code is as follows:
```js ```js
local_object.name = "jack"; local_object.name = "jack";
local_object.age = 19; local_object.age = 19;
local_object.isVis = false; local_object.isVis = false;
local_object.parent = {mother:"jack mom",father:"jack Dad"}; local_object.parent = {mother:"jack mom", father:"jack Dad"};
local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}]; local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}];
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example: >
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified.
Example:
```js ```js
// Supported modification. // Supported modification.
local_object.parent = {mother:"mom", father:"dad"}; local_object.parent = {mother:"mom", father:"dad"};
...@@ -179,13 +194,18 @@ The following example shows how to implement a distributed data object synchroni ...@@ -179,13 +194,18 @@ The following example shows how to implement a distributed data object synchroni
local_object.parent.mother = "mom"; local_object.parent.mother = "mom";
``` ```
7. Access the distributed data object. <br>Obtain the distributed data object attribute, which is the latest data on the network. 7. Access the distributed data object.
Obtain the distributed data object attribute, which is the latest data on the network.
The sample code is as follows: The sample code is as follows:
```js ```js
console.info("name " + local_object["name"]); console.info("name " + local_object["name"]);
``` ```
8. Unsubscribe from data changes. <br>You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered.
8. Unsubscribe from data changes.
You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered.
The sample code is as follows: The sample code is as follows:
```js ```js
...@@ -194,6 +214,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -194,6 +214,7 @@ The following example shows how to implement a distributed data object synchroni
// Unregister all data change callbacks. // Unregister all data change callbacks.
local_object.off("change"); local_object.off("change");
``` ```
9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline. 9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
The sample code is as follows: The sample code is as follows:
```js ```js
...@@ -207,58 +228,62 @@ The following example shows how to implement a distributed data object synchroni ...@@ -207,58 +228,62 @@ The following example shows how to implement a distributed data object synchroni
10. Save a distributed data object and revoke the data saving operation. 10. Save a distributed data object and revoke the data saving operation.
- Callback - Callback
```js ```
// Save a distributed data object. ​```js
local_object.save("local", (result, data)=>{ // Save a distributed data object.
console.log("save callback"); local_object.save("local", (result, data) => {
console.info("save sessionId " + data.sessionId); console.log("save callback");
console.info("save version " + data.version); console.info("save sessionId " + data.sessionId);
console.info("save deviceId " + data.deviceId); console.info("save version " + data.version);
}); console.info("save deviceId " + data.deviceId);
// Revoke the data saving operation. });
local_object.revokeSave((result, data) =>{ // Revoke the data saving operation.
console.log("revokeSave callback"); local_object.revokeSave((result, data) => {
console.info("revokeSave sessionId " + data.sessionId); console.log("revokeSave callback");
}); console.info("revokeSave sessionId " + data.sessionId);
``` });
- Promise ​```
```js ```
// Save a distributed data object.
g_object.save("local").then((result)=>{ - Promise
console.info("save sessionId " + result.sessionId);
console.info("save version " + result.version); ```
console.info("save deviceId " + result.deviceId); ​```js
}, (result)=>{ // Save a distributed data object.
console.info("save local failed."); g_object.save("local").then((result) => {
}); console.info("save sessionId " + result.sessionId);
// Revoke the data saving operation. console.info("save version " + result.version);
g_object.revokeSave().then((result)=>{ console.info("save deviceId " + result.deviceId);
console.info("revokeSave success."); }, (result)=>{
}, (result)=>{ console.info("save local failed.");
console.info("revokeSave failed."); });
}); // Revoke the data saving operation.
``` g_object.revokeSave().then((result) => {
11. Unsubscribe from the status changes of the distributed data object. <br>You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object. console.info("revokeSave success.");
}, (result)=>{
console.info("revokeSave failed.");
});
​```
```
11. Unsubscribe from the status changes of the distributed data object.
You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object.
The sample code is as follows: The sample code is as follows:
```js ```js
// Unregister the specified status change callback. // Unregister the specified status change callback.
local_object.off("status", this.statusCallback); local_object.off("status", this.statusCallback);
// Unregister all status change callbacks. // Unregister all status change callbacks.
local_object.off("status"); local_object.off("status");
``` ```
12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object. 12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
The sample code is as follows: The sample code is as follows:
```js ```js
local_object.setSessionId(""); local_object.setSessionId("");
``` ```
## Development Example
The following example is provided for you to better understand the development of distributed data objects:
- [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad)
When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network.
...@@ -6,22 +6,20 @@ The Distributed Data Service (DDS) implements synchronization of application dat ...@@ -6,22 +6,20 @@ The Distributed Data Service (DDS) implements synchronization of application dat
## Available APIs ## Available APIs
For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md). For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md).
The table below describes the APIs provided by the OpenHarmony DDS module.
**Table 1** APIs provided by the DDS **Table 1** APIs provided by the DDS
| Category | API | Description | | API | Description |
| ------------ | ------------- | ------------- | | ------------------------------------------------------------ | ----------------------------------------------- |
| Creating a distributed database| createKVManager(config: KVManagerConfig, callback: AsyncCallback&lt;KVManager&gt;): void<br>createKVManager(config: KVManagerConfig): Promise&lt;KVManager> | Creates a **KVManager** object for database management.| | createKVManager(config:KVManagerConfig,callback:AsyncCallback&lt;KVManager&gt;):void<br>createKVManager(config:KVManagerConfig):Promise&lt;KVManager> | Creates a **KVManager** object for database management.|
| Obtaining a distributed KV store| getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options, callback: AsyncCallback&lt;T&gt;): void<br>getKVStore&lt;T extends KVStore&gt;(storeId: string, options: Options): Promise&lt;T&gt; | Obtains the KV store with the specified **Options** and **storeId**.| | getKVStore&lt;TextendsKVStore&gt;(storeId:string,options:Options,callback:AsyncCallback&lt;T&gt;):void<br>getKVStore&lt;TextendsKVStore&gt;(storeId:string,options:Options):Promise&lt;T&gt; | Obtains a KV store with the specified **Options** and **storeId**.|
| Managing data in a distributed KV store| put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback&lt;void&gt;): void<br>put(key: string, value: Uint8Array \| string \| number \| boolean): Promise&lt;void> | Inserts and updates data.| | put(key:string,value:Uint8Array\|string\|number\|boolean,callback:AsyncCallback&lt;void&gt;):void<br>put(key:string,value:Uint8Array\|string\|number\|boolean):Promise&lt;void> | Inserts and updates data. |
| Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback&lt;void&gt;): void<br>delete(key: string): Promise&lt;void> | Deletes data. | | delete(key:string,callback:AsyncCallback&lt;void&gt;):void<br>delete(key:string):Promise&lt;void> | Deletes data. |
| Managing data in a distributed KV store| get(key: string, callback: AsyncCallback&lt;Uint8Array \| string \| boolean \| number&gt;): void<br>get(key: string): Promise&lt;Uint8Array \| string \| boolean \| number> | Queries data. | | get(key:string,callback:AsyncCallback&lt;Uint8Array\|string\|boolean\|number&gt;):void<br>get(key:string):Promise&lt;Uint8Array\|string\|boolean\|number> | Queries data. |
| Subscribing to changes in the distributed data| on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;ChangeNotification&gt;): void<br>on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void | Subscribes to data changes in the KV store.| | on(event:'dataChange',type:SubscribeType,observer:Callback&lt;ChangeNotification&gt;):void<br>on(event:'syncComplete',syncCallback:Callback&lt;Array&lt;[string,number]&gt;&gt;):void | Subscribes to data changes in the KV store. |
| Synchronizing data across devices| sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | | sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | Triggers database synchronization in manual mode. |
...@@ -36,11 +34,14 @@ The following uses a single KV store as an example to describe the development p ...@@ -36,11 +34,14 @@ The following uses a single KV store as an example to describe the development p
``` ```
2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. 2. Create a **KvManager** instance based on the specified **KvManagerConfig** object.
(1) Create a **KvManagerConfig** object based on the application context. (1) Create a **KvManagerConfig** object based on the application context.
(2) Create a **KvManager** instance.
(2) Create a **KvManager** instance.
The sample code is as follows: The sample code is as follows:
```js
```
let kvManager; let kvManager;
try { try {
const kvManagerConfig = { const kvManagerConfig = {
...@@ -62,9 +63,12 @@ The following uses a single KV store as an example to describe the development p ...@@ -62,9 +63,12 @@ The following uses a single KV store as an example to describe the development p
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
} }
``` ```
3. Create and obtain a single KV store. 3. Create and obtain a single KV store.
(1) Declare the ID of the single KV store to create. (1) Declare the ID of the single KV store to create.
(2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required. (2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required.
The sample code is as follows: The sample code is as follows:
...@@ -92,8 +96,9 @@ The following uses a single KV store as an example to describe the development p ...@@ -92,8 +96,9 @@ The following uses a single KV store as an example to describe the development p
} }
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**
> For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (**kvStore** in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle. >
> For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (`kvStore` in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle.
4. Subscribe to changes in the distributed data.<br/> 4. Subscribe to changes in the distributed data.<br/>
The following is the sample code for subscribing to the data changes of a single KV store: The following is the sample code for subscribing to the data changes of a single KV store:
...@@ -104,7 +109,9 @@ The following uses a single KV store as an example to describe the development p ...@@ -104,7 +109,9 @@ The following uses a single KV store as an example to describe the development p
``` ```
5. Write data to the single KV store. 5. Write data to the single KV store.
(1) Construct the key and value to be written into the single KV store. (1) Construct the key and value to be written into the single KV store.
(2) Write key-value pairs into the single KV store. (2) Write key-value pairs into the single KV store.
The following is the sample code for writing key-value pairs of the string type into the single KV store: The following is the sample code for writing key-value pairs of the string type into the single KV store:
...@@ -126,7 +133,9 @@ The following uses a single KV store as an example to describe the development p ...@@ -126,7 +133,9 @@ The following uses a single KV store as an example to describe the development p
``` ```
6. Query data in the single KV store. 6. Query data in the single KV store.
(1) Construct the key to be queried from the single KV store. (1) Construct the key to be queried from the single KV store.
(2) Query data from the single KV store. (2) Query data from the single KV store.
The following is the sample code for querying data of the string type from the single KV store: The following is the sample code for querying data of the string type from the single KV store:
...@@ -152,7 +161,11 @@ The following uses a single KV store as an example to describe the development p ...@@ -152,7 +161,11 @@ The following uses a single KV store as an example to describe the development p
7. Synchronize data to other devices.<br/> 7. Synchronize data to other devices.<br/>
Select the devices in the same network and the synchronization mode to synchronize data. Select the devices in the same network and the synchronization mode to synchronize data.
The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync()**, and **1000** indicates that the maximum delay time is 1000 ms. > **NOTE**
>
> The APIs of the `deviceManager` module are system interfaces.
The following is the sample code for synchronizing data in a single KV store:
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
...@@ -161,7 +174,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -161,7 +174,7 @@ The following uses a single KV store as an example to describe the development p
deviceManager.createDeviceManager("bundleName", (err, value) => { deviceManager.createDeviceManager("bundleName", (err, value) => {
if (!err) { if (!err) {
devManager = value; devManager = value;
// Obtain deviceIds. // deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync().
let deviceIds = []; let deviceIds = [];
if (devManager != null) { if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync(); var devices = devManager.getTrustedDeviceListSync();
...@@ -170,6 +183,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -170,6 +183,7 @@ The following uses a single KV store as an example to describe the development p
} }
} }
try{ try{
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000);
}catch (e) { }catch (e) {
console.log("An unexpected error occurred. Error:" + e); console.log("An unexpected error occurred. Error:" + e);
...@@ -177,7 +191,3 @@ The following uses a single KV store as an example to describe the development p ...@@ -177,7 +191,3 @@ The following uses a single KV store as an example to describe the development p
} }
}); });
``` ```
## Samples
The following samples are provided to help you better understand the distributed data development:
- [`KvStore`: Distributed Database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)
...@@ -84,7 +84,7 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -84,7 +84,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
} }
``` ```
For details about the fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). For details about these fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......
...@@ -65,9 +65,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ...@@ -65,9 +65,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.vibrate(1000).then((error) => { vibrator.vibrate(1000).then((error) => {
if (error) { // The call fails, and error.code and error.message are printed. if (error) { // The call fails, and error.code and error.message are printed.
Console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); console.log("Promise return failed.error.code " + error.code + "error.message " + error.message);
} else { // The call is successful, and the device starts to vibrate. } else { // The call is successful, and the device starts to vibrate.
Console.log("Promise returned to indicate a successful vibration.") console.log("Promise returned to indicate a successful vibration.")
} }
}) })
``` ```
...@@ -78,9 +78,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ...@@ -78,9 +78,9 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
import vibrator from "@ohos.vibrator" import vibrator from "@ohos.vibrator"
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error) => { vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error) => {
if (error) { // The call fails, and error.code and error.message are printed. if (error) { // The call fails, and error.code and error.message are printed.
Console.log("Promise return failed.error.code " + error.code + "error.message " + error.message); console.log("Promise return failed.error.code " + error.code + "error.message " + error.message);
} else { // The call is successful, and the device stops vibrating. } else { // The call is successful, and the device stops vibrating.
Console.log("Promise returned to indicate a successful stop."); console.log("Promise returned to indicate successful.");
} }
}) })
``` ```
...@@ -39,28 +39,28 @@ function printfDescription(obj) { ...@@ -39,28 +39,28 @@ function printfDescription(obj) {
// Set the player callbacks. // Set the player callbacks.
function setCallBack(audioPlayer) { function setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered.
}); });
audioPlayer.on('play', () => { // Set the `play` event callback. audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success'); console.info('audio play success');
audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback.
}); });
audioPlayer.on('pause', () => { // Set the `pause` event callback. audioPlayer.on('pause', () => { // Set the 'pause' event callback.
console.info('audio pause success'); console.info('audio pause success');
audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback.
}); });
audioPlayer.on('stop', () => { // Set the `stop` event callback. audioPlayer.on('stop', () => { // Set the 'stop' event callback.
console.info('audio stop success'); console.info('audio stop success');
audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song.
}); });
audioPlayer.on('reset', () => { // Set the `reset` event callback. audioPlayer.on('reset', () => { // Set the 'reset' event callback.
console.info('audio reset success'); console.info('audio reset success');
audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer.release(); // Release the AudioPlayer instance.
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the `timeUpdate` event callback. audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the 'timeUpdate' event callback.
if (typeof(seekDoneTime) == 'undefined') { if (typeof(seekDoneTime) == 'undefined') {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
...@@ -68,7 +68,7 @@ function setCallBack(audioPlayer) { ...@@ -68,7 +68,7 @@ function setCallBack(audioPlayer) {
console.info('audio seek success, and seek time is ' + seekDoneTime); console.info('audio seek success, and seek time is ' + seekDoneTime);
audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback.
}); });
audioPlayer.on('volumeChange', () => { // Set the `volumeChange` event callback. audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback.
console.info('audio volumeChange success'); console.info('audio volumeChange success');
audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode.
if (typeof (arrlist) != 'undefined') { if (typeof (arrlist) != 'undefined') {
...@@ -107,7 +107,7 @@ async function audioPlayerDemo() { ...@@ -107,7 +107,7 @@ async function audioPlayerDemo() {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
} }
``` ```
...@@ -119,11 +119,11 @@ import fileIO from '@ohos.fileio' ...@@ -119,11 +119,11 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Set the `play` event callback. audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success'); console.info('audio play success');
}); });
audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete.
...@@ -147,7 +147,7 @@ export class AudioDemo { ...@@ -147,7 +147,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
} }
} }
``` ```
...@@ -161,15 +161,15 @@ export class AudioDemo { ...@@ -161,15 +161,15 @@ export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
private isNextMusic = false; private isNextMusic = false;
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
}); });
audioPlayer.on('play', () => { // Set the `play` event callback. audioPlayer.on('play', () => { // Set the 'play' event callback.
console.info('audio play success'); console.info('audio play success');
audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback.
}); });
audioPlayer.on('reset', () => { // Set the `reset` event callback. audioPlayer.on('reset', () => { // Set the 'reset' event callback.
console.info('audio play success'); console.info('audio play success');
if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented.
this.nextMusic(audioPlayer); // Changing songs is implemented. this.nextMusic(audioPlayer); // Changing songs is implemented.
...@@ -223,7 +223,7 @@ import fileIO from '@ohos.fileio' ...@@ -223,7 +223,7 @@ import fileIO from '@ohos.fileio'
export class AudioDemo { export class AudioDemo {
// Set the player callbacks. // Set the player callbacks.
setCallBack(audioPlayer) { setCallBack(audioPlayer) {
audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully.
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.loop = true; // Set the loop playback attribute. audioPlayer.loop = true; // Set the loop playback attribute.
audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback.
...@@ -247,7 +247,7 @@ export class AudioDemo { ...@@ -247,7 +247,7 @@ export class AudioDemo {
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
} }
} }
``` ```
...@@ -267,7 +267,7 @@ imageSourceApi.getImageInfo(imageInfo => { ...@@ -267,7 +267,7 @@ imageSourceApi.getImageInfo(imageInfo => {
}) })
// Update incremental data. // Update incremental data.
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {}) imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error, data)=> {})
``` ```
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
- [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- [@ohos.application.StartOptions](js-apis-application-StartOptions.md) - [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
- [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
- [@ohos.application.WindowExtensionAbility](js-apis-application-WindowExtensionAbility.md)
- application/[AbilityContext](js-apis-ability-context.md) - application/[AbilityContext](js-apis-ability-context.md)
- application/[ApplicationContext](js-apis-application-applicationContext.md) - application/[ApplicationContext](js-apis-application-applicationContext.md)
- application/[AbilityStageContext](js-apis-abilitystagecontext.md) - application/[AbilityStageContext](js-apis-abilitystagecontext.md)
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
- [@ohos.application.Configuration](js-apis-configuration.md) - [@ohos.application.Configuration](js-apis-configuration.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
- [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md) - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- [@ohos.application.errorManager](js-apis-errorManager.md)
- [@ohos.application.formBindingData](js-apis-formbindingdata.md) - [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- [@ohos.application.formError](js-apis-formerror.md) - [@ohos.application.formError](js-apis-formerror.md)
- [@ohos.application.formHost](js-apis-formhost.md) - [@ohos.application.formHost](js-apis-formhost.md)
...@@ -68,18 +70,25 @@ ...@@ -68,18 +70,25 @@
- [@ohos.bundle](js-apis-Bundle.md) - [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md) - [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md)
- [@ohos.bundle.innerBundleManager)](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md) - [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.distributedBundle)](js-apis-Bundle-distributedBundle.md)
- [@ohos.zlib](js-apis-zlib.md) - [@ohos.zlib](js-apis-zlib.md)
- bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md) - bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md)
- bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md) - bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo](js-apis-bundle-BundleInfo.md) - bundle/[BundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[BundleInstaller](js-apis-bundle-BundleInstaller.md)
- bundle/[CustomizeData](js-apis-bundle-CustomizeData.md) - bundle/[CustomizeData](js-apis-bundle-CustomizeData.md)
- bundle/[DispatchInfo](js-apis-dispatchInfo.md)
- bundle/[ElementName](js-apis-bundle-ElementName.md) - bundle/[ElementName](js-apis-bundle-ElementName.md)
- bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) - bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md) - bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- bundle/[Metadata](js-apis-bundle-Metadata.md) - bundle/[Metadata](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md) - bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- bundle/[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[ShortcutInfo](js-apis-bundle-ShortcutInfo.md)
- UI Page - UI Page
- [@ohos.animator](js-apis-animator.md) - [@ohos.animator](js-apis-animator.md)
...@@ -90,6 +99,7 @@ ...@@ -90,6 +99,7 @@
- Graphics - Graphics
- [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md)
- [@ohos.display ](js-apis-display.md) - [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md) - [@ohos.effectKit](js-apis-effectKit.md)
- [@ohos.screen](js-apis-screen.md) - [@ohos.screen](js-apis-screen.md)
...@@ -115,6 +125,7 @@ ...@@ -115,6 +125,7 @@
- Resource Scheduling - Resource Scheduling
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md)
- [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.workScheduler ](js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
......
# innerBundleManager
The **innerBundleManager** module manages internal bundles.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import innerBundleManager from '@ohos.bundle.innerBundleManager';
```
## System Capability
SystemCapability.BundleManager.BundleFramework
## Required Permissions
| Permission | Permission Level | Description |
| ------------------------------------------ | ------------ | ---------------------------- |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications. |
| ohos.permission.LISTEN_BUNDLE_CHANGE | system_grant | Permission to listen for application changes.|
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
## innerBundleManager.getLauncherAbilityInfos
getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback&lt;Array&lt;LauncherAbilityInfo&gt;&gt;) : void;
Obtains the launcher ability information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. |
## innerBundleManager.getLauncherAbilityInfos
getLauncherAbilityInfos(bundleName: string, userId: number) : Promise&lt;Array&lt;LauncherAbilityInfo&gt;&gt;
Obtains the launcher ability information based on a given bundle name. This API uses a promise to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------- |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Promise used to return an array of the launcher ability information.|
## innerBundleManager.on
on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback&lt;string&gt;) : void;
Registers a callback to receive bundle status changes. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.LISTEN_BUNDLE_CHANGE
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | --------------------- | ---- | ---------------------------------------------------- |
| type | "BundleStatusChange" | Yes | Event type. |
| bundleStatusCallback | BundleStatusCallback | Yes | Callback to register. |
| callback | AsyncCallback\<string> | Yes | Callback used to return a successful result or error information.|
## innerBundleManager.on
on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise&lt;string&gt;
Registers a callback to receive bundle status changes. This API uses a promise to return the result.
**Required permissions**
ohos.permission.LISTEN_BUNDLE_CHANGE
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | -------------------- | ---- | ------------------ |
| type | "BundleStatusChange" | Yes | Event type. |
| bundleStatusCallback | BundleStatusCallback | Yes | Callback to register.|
**Return value**
| Type | Description |
| --------------- | ----------------------------------- |
| Promise\<string> | Promise used to return a successful result or error information.|
## innerBundleManager.off
off(type:"BundleStatusChange", callback: AsyncCallback&lt;string&gt;) : void;
Deregisters the callback that receives bundle status changes. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.LISTEN_BUNDLE_CHANGE
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------------------------------- |
| type | "BundleStatusChange" | Yes | Event type. |
| callback | AsyncCallback\<string> | Yes | Callback used to return a successful result or error information.|
## innerBundleManager.off
off(type:"BundleStatusChange"): Promise&lt;string&gt;
Deregisters the callback that receives bundle status changes. This API uses a promise to return the result.
**Required permissions**
ohos.permission.LISTEN_BUNDLE_CHANGE
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | -------------------- | ---- | ---------------- |
| type | "BundleStatusChange" | Yes | Event type.|
**Return value**
| Type | Description |
| --------------- | ----------------------------------- |
| Promise\<string> | Promise used to return a successful result or error information.|
## innerBundleManager.getAllLauncherAbilityInfos
getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback&lt;Array&lt;LauncherAbilityInfo&gt;&gt;) : void;
Obtains the information about all launcher abilities. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. |
## innerBundleManager.getAllLauncherAbilityInfos
getAllLauncherAbilityInfos(userId: number) : Promise&lt;Array&lt;LauncherAbilityInfo&gt;&gt;
Obtains the information about all launcher abilities. This API uses a promise to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------- |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------- |
| Promise\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Promise used to return an array of the launcher ability information.|
## innerBundleManager.getShortcutInfos
getShortcutInfos(bundleName :string, callback: AsyncCallback&lt;Array&lt;ShortcutInfo&gt;&gt;) : void;
Obtains the shortcut information based on a given bundle name. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| callback | AsyncCallback\<Array<[ShortcutInfo](js-apis-bundle-ShortcutInfo.md)>> | Yes | Callback used to return an array of the shortcut information.|
## innerBundleManager.getShortcutInfos
getShortcutInfos(bundleName : string) : Promise&lt;Array&lt;ShortcutInfo&gt;&gt;
Obtains the shortcut information based on a given bundle name. This API uses a promise to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.BundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------ |
| bundleName | string | Yes | Bundle name of an application.|
**Return value**
| Type | Description |
| -------------------------------------------------------- | ----------------------------- |
| Promise\<Array<[ShortcutInfo](js-apis-bundle-ShortcutInfo.md)>> | Promise used to return an array of the shortcut information.|
# distributedBundle
The **distributedBundle** module manages distributed bundles.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import distributedBundle from '@ohos.distributedBundle';
```
## System Capability
SystemCapability.BundleManager.DistributedBundleFramework
## Required Permissions
| Permission | Permission Level | Description |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications.|
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void;
Obtains information about the remote ability that matches the given element name. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.DistributedBundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**. |
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Yes | Callback used to return the remote ability information.|
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt;
Obtains information about the remote ability that matches the given element name. This API uses a promise to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.DistributedBundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promise used to return the remote ability information.|
## distributedBundle.getRemoteAbilityInfos
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void;
Obtains information about remote abilities that match the given element names. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.DistributedBundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.|
## distributedBundle.getRemoteAbilityInfos
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt;
Obtains information about remote abilities that match the given element names. This API uses a promise to return the result.
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**
SystemCapability.BundleManager.DistributedBundleFramework
**System API**
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Promise used to return an array of the remote ability information.|
# wantConstant # wantConstant
The **wantConstant** module provides the action, entity, and flags used in **Want** objects. The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **NOTE** > **NOTE**
> >
...@@ -23,15 +23,15 @@ Enumerates the action constants of the **Want** object. ...@@ -23,15 +23,15 @@ Enumerates the action constants of the **Want** object.
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. | | ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. | | ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. | | ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. | | ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. | | ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. | | ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. | | ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. | | ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. | | ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. | | ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. | | ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. | | ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. | | ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. | | ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. | | ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
......
...@@ -49,7 +49,7 @@ Checks whether an application has been granted the specified permission. This AP ...@@ -49,7 +49,7 @@ Checks whether an application has been granted the specified permission. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ | | -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
| permissionName | string | Yes | Name of the permission to verify.| | permissionName | string | Yes | Name of the permission to verify.|
**Return value** **Return value**
...@@ -105,7 +105,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl ...@@ -105,7 +105,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
Grants a user granted permission to an application. This API uses a promise to return the result. Grants a user granted permission to an application. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications. This is a system API.
**Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS **Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS
...@@ -143,7 +143,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl ...@@ -143,7 +143,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
Grants a user granted permission to an application. This API uses an asynchronous callback to return the result. Grants a user granted permission to an application. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications. This is a system API.
**Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS **Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS
...@@ -179,7 +179,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF ...@@ -179,7 +179,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
Revokes a user granted permission given to an application. This API uses a promise to return the result. Revokes a user granted permission given to an application. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications. This is a system API.
**Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS **Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
...@@ -217,7 +217,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF ...@@ -217,7 +217,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
Revokes a user granted permission given to an application. This API uses an asynchronous callback to return the result. Revokes a user granted permission given to an application. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications. This is a system API.
**Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS **Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
...@@ -253,7 +253,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise&lt;number&g ...@@ -253,7 +253,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise&lt;number&g
Obtains the flags of the specified permission of a given application. This API uses a promise to return the result. Obtains the flags of the specified permission of a given application. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications. This is a system API.
**Required permissions**: ohos.permission.GET_SENSITIVE_PERMISSIONS, ohos.permission.GRANT_SENSITIVE_PERMISSIONS, or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS **Required permissions**: ohos.permission.GET_SENSITIVE_PERMISSIONS, ohos.permission.GRANT_SENSITIVE_PERMISSIONS, or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
......
...@@ -23,23 +23,94 @@ import Want from '@ohos.application.Want'; ...@@ -23,23 +23,94 @@ import Want from '@ohos.application.Want';
| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| | abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).| | flags | Read only | number | No | How the **Want** object will be handled. For details, see [flags](js-apis-featureAbility.md#flags).|
| action | Read only | string | No | Action option. | | action | Read only | string | No | Action option. |
| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.js) module can be used to obtain application and bundle information. | | parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.md) module can be used to obtain application and bundle information. |
| entities | Read only | Array\<string> | No | List of entities. | | entities | Read only | Array\<string> | No | List of entities. |
| moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs.| | moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs.|
**Example** **Example**
``` js - Basic usage
var want = {
"deviceId": "", // An empty deviceId indicates the local device. ``` js
"bundleName": "com.extreme.test", var want = {
"abilityName": "MainAbility", "deviceId": "", // An empty deviceId indicates the local device.
"moduleName": "entry" // moduleName is optional. "bundleName": "com.extreme.test",
}; "abilityName": "MainAbility",
this.context.startAbility(want, (error) => { "moduleName": "entry" // moduleName is optional.
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters uniquely identify an ability. };
console.log("error.code = " + error.code) this.context.startAbility(want, (error) => {
}) // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
``` console.log("error.code = " + error.code)
})
```
- Passing a file descriptor (FD)
``` js
var fd;
try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
} catch(e) {
console.log("openSync fail:" + JSON.stringify(e));
}
var want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.extreme.test",
"abilityName": "MainAbility",
"moduleName": "entry" // moduleName is optional.
"parameters": {
"keyFd":{"type":"FD", "value":fd}
}
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code)
})
```
- Passing **RemoteObject** data
``` js
class Stub extends rpc.RemoteObject {
constructor(des) {
if (typeof des == 'string') {
super(des);
} else {
return null;
}
}
onRemoteRequest(code, data, reply, option) {
if (code === 1) {
console.log('onRemoteRequest called')
let token = data.readInterfaceToken();
let num = data.readInt();
this.method();
return true;
}
return false;
}
method() {
console.log('method called');
}
}
var remoteObject = new Stub('want-test');
var want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.extreme.test",
"abilityName": "MainAbility",
"moduleName": "entry" // moduleName is optional.
"parameters": {
"keyRemoteObject":{"type":"RemoteObject", "value":remoteObject}
}
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code)
})
```
<!--no_check-->
\ No newline at end of file
# AbilityLifecycleCallback # AbilityLifecycleCallback
The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to receive lifecycle state changes in the application context. The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context.
> **NOTE** > **NOTE**
> >
...@@ -30,9 +30,9 @@ Called when an ability is created. ...@@ -30,9 +30,9 @@ Called when an ability is created.
| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityWindowStageCreate ## AbilityLifecycleCallback.onWindowStageCreate
onAbilityWindowStageCreate(ability: Ability): void; onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void;
Called when the window stage of an ability is created. Called when the window stage of an ability is created.
...@@ -43,11 +43,44 @@ Called when the window stage of an ability is created. ...@@ -43,11 +43,44 @@ Called when the window stage of an ability is created.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onAbilityWindowStageDestroy ## AbilityLifecycleCallback.onWindowStageActive
onAbilityWindowStageDestroy(ability: Ability): void; onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void;
Called when the window stage of an ability gains focus.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageInactive
onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void;
Called when the window stage of an ability loses focus.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageDestroy
onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void;
Called when the window stage of an ability is destroyed. Called when the window stage of an ability is destroyed.
...@@ -58,6 +91,7 @@ Called when the window stage of an ability is destroyed. ...@@ -58,6 +91,7 @@ Called when the window stage of an ability is destroyed.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.| | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onAbilityDestroy ## AbilityLifecycleCallback.onAbilityDestroy
...@@ -132,12 +166,22 @@ Called when an ability is continued on another device. ...@@ -132,12 +166,22 @@ Called when an ability is continued on another device.
onAbilityCreate(ability){ onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
}, },
onAbilityWindowStageCreate(ability){ onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability)); console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability));
}, console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
onAbilityWindowStageDestroy(ability){ },
console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability)); onWindowStageActive(ability, windowStage){
}, console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
},
onAbilityDestroy(ability){ onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
}, },
......
...@@ -19,7 +19,7 @@ import AbilityContext from '@ohos.application.Ability' ...@@ -19,7 +19,7 @@ import AbilityContext from '@ohos.application.Ability'
let context = this.context.createBundleContext(test); let context = this.context.createBundleContext(test);
} }
} }
``` ```
## Attributes ## Attributes
...@@ -53,15 +53,15 @@ Creates a context for a given application. ...@@ -53,15 +53,15 @@ Creates a context for a given application.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes| Application bundle name.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
...@@ -87,15 +87,15 @@ Creates a context for a given HAP. ...@@ -87,15 +87,15 @@ Creates a context for a given HAP.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.| | moduleName | string | Yes| HAP name in the application.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
...@@ -123,16 +123,16 @@ Creates a context for a given HAP in an application. ...@@ -123,16 +123,16 @@ Creates a context for a given HAP in an application.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.| | moduleName | string | Yes| HAP name in the application.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
......
...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| | callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example** **Example**
...@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.| | Promise&lt;number&gt; | Size of the application memory.|
**Example** **Example**
...@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.| | callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
**Example** **Example**
...@@ -155,7 +155,11 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -155,7 +155,11 @@ Obtains the memory size of this application. This API uses an asynchronous callb
console.log('startAbility result success:' + JSON.stringify(data)); console.log('startAbility result success:' + JSON.stringify(data));
}) })
``` ```
## appManager.getProcessRunningInfos<sup>8+</sup> ## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>; getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
...@@ -181,7 +185,11 @@ Obtains information about the running processes. This API uses a promise to retu ...@@ -181,7 +185,11 @@ Obtains information about the running processes. This API uses a promise to retu
}); });
``` ```
## appManager.getProcessRunningInfos<sup>8+</sup> ## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void; getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
...@@ -206,11 +214,62 @@ Obtains information about the running processes. This API uses an asynchronous c ...@@ -206,11 +214,62 @@ Obtains information about the running processes. This API uses an asynchronous c
}) })
``` ```
## appManager.getProcessRunningInformation<sup>9+</sup>
getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;
Obtains information about the running processes. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<Array\<ProcessRunningInformation>> | Promise used to return the process information.|
**Example**
```js
app.getProcessRunningInformation().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
## appManager.getProcessRunningInformation<sup>9+</sup>
getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInformation>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInformation>> | No| Callback used to return the process information.|
**Example**
```js
app.getProcessRunningInformation((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
```
## appManager.registerApplicationStateObserver<sup>8+</sup> ## appManager.registerApplicationStateObserver<sup>8+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver): number; registerApplicationStateObserver(observer: ApplicationStateObserver): number;
Registers the application state observer. Registers an observer to listen for the state of all applications.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER **Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
...@@ -222,7 +281,7 @@ Registers the application state observer. ...@@ -222,7 +281,7 @@ Registers the application state observer.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| observer | ApplicationStateObserver | No| Numeric code of the observer.| | observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
**Example** **Example**
...@@ -244,6 +303,48 @@ Registers the application state observer. ...@@ -244,6 +303,48 @@ Registers the application state observer.
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode); console.log('-------- observerCode: ---------', observerCode);
```
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number;
Registers an observer to listen for the state of a specified application.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
| bundleNameList | Array<string> | No| **bundleName** array to be registered for listening. The maximum value is 128.|
**Example**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
}
}
var bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
console.log('-------- observerCode: ---------', observerCode);
``` ```
## appManager.unregisterApplicationStateObserver<sup>8+</sup> ## appManager.unregisterApplicationStateObserver<sup>8+</sup>
...@@ -258,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba ...@@ -258,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.| | observerId | number | No| Numeric code of the observer.|
...@@ -319,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th ...@@ -319,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th
getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void; getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
Obtains applications that run in the foreground. This API uses an asynchronous callback to return the result. Obtains applications that are running in the foreground. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO **Required permissions**: ohos.permission.GET_RUNNING_INFO
...@@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c ...@@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c
getForegroundApplications(): Promise\<Array\<AppStateData>>; getForegroundApplications(): Promise\<Array\<AppStateData>>;
Obtains applications that run in the foreground. This API uses a promise to return the result. Obtains applications that are running in the foreground. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO **Required permissions**: ohos.permission.GET_RUNNING_INFO
...@@ -380,7 +481,7 @@ Obtains applications that run in the foreground. This API uses a promise to retu ...@@ -380,7 +481,7 @@ Obtains applications that run in the foreground. This API uses a promise to retu
killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
Kills the process by bundle name and account ID. This API uses a promise to return the result. Kills a process by bundle name and account ID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES **Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
...@@ -390,10 +491,10 @@ Kills the process by bundle name and account ID. This API uses a promise to retu ...@@ -390,10 +491,10 @@ Kills the process by bundle name and account ID. This API uses a promise to retu
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.| | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Example** **Example**
...@@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId) ...@@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId)
killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\<void\>): void killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\<void\>): void
Kills the process by bundle name and account ID. This API uses an asynchronous callback to return the result. Kills a process by bundle name and account ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -424,11 +525,11 @@ Kills the process by bundle name and account ID. This API uses an asynchronous c ...@@ -424,11 +525,11 @@ Kills the process by bundle name and account ID. This API uses an asynchronous c
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.| | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); ...@@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. | | bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. |
| abilityName<sup>8+</sup> | string | Yes | No | Ability name. | | abilityName<sup>8+</sup> | string | Yes | No | Ability name. |
| uid<sup>8+</sup> | number | Yes | No | User ID. | | uid<sup>8+</sup> | number | Yes | No | User ID. |
| state<sup>8+</sup> | number | Yes | No | Application information. | | state<sup>8+</sup> | number | Yes | No | Ability state. |
| moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the ability belongs. | | moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the ability belongs. |
| abilityType<sup>8+</sup> | string | Yes | No | Ability type. | | abilityType<sup>8+</sup> | string | Yes | No | Ability type. |
...@@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); ...@@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| uid<sup>9+</sup> | Read only | number | No | User ID.| | uid<sup>9+</sup> | Read only | number | No | User ID.|
| processName<sup>9+</sup> | Read only | string | No | Process name.| | processName<sup>9+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.| | bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
## ApplicationStateObserver
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| [onForegroundApplicationChanged<sup>8+</sup>](#applicationstateobserveronforegroundapplicationchanged8) | AsyncCallback\<void> | Yes | No | Callback invoked when the foreground or background state of an application changes. |
| [onAbilityStateChanged<sup>8+</sup>](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\<void> | Yes | No | Callback invoked when the ability state changes. |
| [onProcessCreated<sup>8+</sup>](#applicationstateobserveronprocesscreated8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is created. |
| [onProcessDied<sup>8+</sup>](#applicationstateobserveronprocessdied8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is destroyed. |
# BackgroundTaskManager # Background Task Management
This module provides background task management. The **BackgroundTaskManager** module provides APIs to manage background tasks.
If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type. If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type.
...@@ -15,7 +15,7 @@ If an application has a service that can be intuitively perceived by users and n ...@@ -15,7 +15,7 @@ If an application has a service that can be intuitively perceived by users and n
## Modules to Import ## Modules to Import
``` ```js
import backgroundTaskManager from '@ohos.backgroundTaskManager'; import backgroundTaskManager from '@ohos.backgroundTaskManager';
``` ```
...@@ -144,12 +144,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -144,12 +144,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ------------------------ | | --------- | ---------------------------------- | ---- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. | | context | Context | Yes | Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| | wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
...@@ -196,11 +196,11 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -196,11 +196,11 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ----------------------- | | --------- | ---------------------------------- | ---- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. | | context | Context | Yes | Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. | | bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked.| | wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -245,10 +245,10 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to ...@@ -245,10 +245,10 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ------------------------- | ---- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. | | context | Context | Yes | Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
...@@ -276,9 +276,9 @@ Requests to cancel a continuous task. This API uses a promise to return the resu ...@@ -276,9 +276,9 @@ Requests to cancel a continuous task. This API uses a promise to return the resu
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------------------------- | ---- | --------- | | ------- | ------- | ---- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context.| | context | Context | Yes | Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -314,14 +314,14 @@ Provides the information about the suspension delay. ...@@ -314,14 +314,14 @@ Provides the information about the suspension delay.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
| Name | Value| Description | | Name | Value | Description |
| ----------------------- | ------ | ------------------------------------------------------------ | | ----------------------- | ---- | --------------------- |
| DATA_TRANSFER | 1 | Data transfer. | | DATA_TRANSFER | 1 | Data transfer. |
| AUDIO_PLAYBACK | 2 | Audio playback. | | AUDIO_PLAYBACK | 2 | Audio playback. |
| AUDIO_RECORDING | 3 | Audio recording. | | AUDIO_RECORDING | 3 | Audio recording. |
| LOCATION | 4 | Positioning and navigation. | | LOCATION | 4 | Positioning and navigation. |
| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | | BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | | MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
| WIFI_INTERACTION | 7 | WLAN-related.<br>This is a system API and cannot be called by third-party applications.| | WIFI_INTERACTION | 7 | WLAN-related.<br>This is a system API.|
| VOIP | 8 | Audio and video calls.<br>This is a system API and cannot be called by third-party applications.| | VOIP | 8 | Audio and video calls.<br>This is a system API. |
| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | | TASK_KEEPING | 9 | Computing task (effective only for specific devices). |
# AbilityInfo # AbilityInfo
Unless otherwise specified, ability information is obtained through **GET_BUNDLE_DEFAULT**.
> **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## AbilityInfo
Provides the ability information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
...@@ -25,24 +20,24 @@ Provides the ability information. ...@@ -25,24 +20,24 @@ Provides the ability information.
| iconId | number | Yes | No | Ability icon ID. | | iconId | number | Yes | No | Ability icon ID. |
| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. | | moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. |
| process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.| | process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.|
| targetAbility | string | Yes | No | Target ability that the ability alias points to. | | targetAbility | string | Yes | No | Target ability that the ability alias points to.<br>This attribute can be used only in the FA model.|
| backgroundModes | number | Yes | No | Background service mode of the ability. | | backgroundModes | number | Yes | No | Background service mode of the ability.<br>This attribute can be used only in the FA model. |
| isVisible | boolean | Yes | No | Whether the ability can be called by other applications. | | isVisible | boolean | Yes | No | Whether the ability can be called by other applications. |
| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability. | | formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability.<br>This attribute can be used only in the FA model.|
| type | AbilityType | Yes | No | Ability type. | | type | AbilityType | Yes | No | Ability type.<br>This attribute can be used only in the FA model. |
| orientation | DisplayOrientation | Yes | No | Ability display orientation. | | orientation | DisplayOrientation | Yes | No | Ability display orientation. |
| launchMode | LaunchMode | Yes | No | Ability launch mode. | | launchMode | LaunchMode | Yes | No | Ability launch mode. |
| permissions | Array\<string> | Yes | No | Permissions required for other applications to call the ability.| | permissions | Array\<string> | Yes | No | Permissions required for other applications to call the ability.<br>The value is obtained by passing **GET_ABILITY_INFO_WITH_PERMISSION**.|
| deviceTypes | Array\<string> | Yes | No | Device types supported by the ability. | | deviceTypes | Array\<string> | Yes | No | Device types supported by the ability. |
| deviceCapabilities | Array\<string> | Yes | No | Device capabilities required for the ability. | | deviceCapabilities | Array\<string> | Yes | No | Device capabilities required for the ability. |
| readPermission | string | Yes | No | Permission required for reading the ability data. | | readPermission | string | Yes | No | Permission required for reading the ability data.<br>This attribute can be used only in the FA model.|
| writePermission | string | Yes | No | Permission required for writing data to the ability. | | writePermission | string | Yes | No | Permission required for writing data to the ability.<br>This attribute can be used only in the FA model.|
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. | | applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information.<br>The value is obtained by passing **GET_ABILITY_INFO_WITH_APPLICATION**.|
| uri | string | Yes | No | URI of the ability. | | uri | string | Yes | No | URI of the ability.<br>This attribute can be used only in the FA model.|
| labelId | number | Yes | No | Ability label ID. | | labelId | number | Yes | No | Ability label ID. |
| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. | | subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability.<br>This attribute can be used only in the FA model.|
| metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability. | | metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability.<br>The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.|
| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. | | metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability.<br>The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.|
| enabled<sup>8+</sup> | boolean | Yes | No | Whether the ability is enabled. | | enabled<sup>8+</sup> | boolean | Yes | No | Whether the ability is enabled. |
| supportWindowMode<sup>9+</sup> | Array\<[SupportWindowMode](js-apis-Bundle.md)> | Yes | No | Window modes supported by the ability. | | supportWindowMode<sup>9+</sup> | Array\<[SupportWindowMode](js-apis-Bundle.md)> | Yes | No | Window modes supported by the ability. |
| maxWindowRatio<sup>9+</sup> | number | Yes | No | Maximum window ratio supported by the ability. | | maxWindowRatio<sup>9+</sup> | number | Yes | No | Maximum window ratio supported by the ability. |
......
# BundleInstaller
The **BundleInstaller** module provides APIs for installing, updating, and deleting bundles on devices.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## System Capability
SystemCapability.BundleManager.BundleFramework
## BundleInstaller.install
install(bundleFilePaths: Array&lt;string&gt;, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
Installs bundles. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.INSTALL_BUNDLE
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| bundleFilePaths | Array&lt;string&gt; | Yes | Paths where the bundles are stored. Each path should point to a relative directory of the current application's data directory.|
| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | Yes | Callback used to return the installation status. |
## BundleInstaller.uninstall
uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
Uninstalls a bundle. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.INSTALL_BUNDLE
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | Yes | Bundle name. |
| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | Yes | Callback used to return the installation status.|
## BundleInstaller.recover
recover(bundleName: string, param: InstallParam, callback: AsyncCallback&lt;InstallStatus&gt;): void;
Recovers a bundle. This API uses an asynchronous callback to return the result.
**Required permissions**
ohos.permission.INSTALL_BUNDLE
**System capability**
SystemCapability.BundleManager.BundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| bundleName | string | Yes | Bundle name. |
| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. |
| callback | AsyncCallback&lt;[InstallStatus](#installstatus)&gt; | Yes | Callback used to return the installation status.|
## InstallParam
Describes the parameters required for bundle installation or uninstall.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Description |
| ----------- | ------- | ------------------ |
| userId | number | User ID. |
| installFlag | number | Installation flag. |
| isKeepData | boolean | Whether data is kept.|
## InstallStatus
Describes the bundle installation status.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ |
| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. |
| statusMessage | string | Yes | No | Installation or uninstall status message.|
# ElementName # ElementName
The **ElementName** module provides the element name information.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the element name information.
## ElementName ## ElementName
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
......
# LauncherAbilityInfo
The **LauncherAbilityInfo** module provides information about a launcher ability.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## LauncherAbilityInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the launcher ability.|
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the launcher ability. |
| labelId | number | Yes | No | Label ID of the launcher ability. |
| iconId | number | Yes | No | Icon ID of the launcher ability. |
| userId | number | Yes | No | User ID of the launcher ability. |
| installTime | number | Yes | No | Time when the launcher ability is installed. |
# PermissionDef
The **PermissionDef** module provides permission details defined in the configuration file.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **PermissionDef**
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| -------------- | ------ | ---- | ---- | -------------- |
| permissionName | string | Yes | No | Name of the permission. |
| grantMode | number | Yes | No | Grant mode of the permission.|
| labelId | number | Yes | No | Label ID of the permission. |
| descriptionId | number | Yes | No | Description ID of the permission. |
# ShortcutInfo
The **ShortcutInfo** module provides shortcut information defined in the configuration file.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ShortcutWant
Describes the information about the target to which the shortcut points.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- |
| targetBundle | string | Yes | No | Target bundle of the shortcut.|
| targetModule<sup>9+</sup> | string | Yes | No | Target module of the shortcut. |
| targetClass | string | Yes | No | Target class required by the shortcut.|
## ShortcutInfo
Describes the shortcut attribute information.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- |
| id | string | Yes | No | ID of the application to which the shortcut belongs. |
| bundleName | string | Yes | No | Name of the bundle that contains the shortcut. |
| hostAbility | string | Yes | No | Local ability information of the shortcut. |
| icon | string | Yes | No | Icon of the shortcut. |
| iconId<sup>8+</sup> | number | Yes | No | Icon ID of the shortcut. |
| label | string | Yes | No | Label of the shortcut. |
| labelId<sup>8+</sup> | number | Yes | No | Label ID of the shortcut. |
| disableMessage | string | Yes | No | Message displayed when the shortcut is disabled. |
| wants | Array&lt;[ShortcutWant](#shortcutwant)&gt; | Yes | No | Want information required for the shortcut. |
| isStatic | boolean | Yes | No | Whether the shortcut is static. |
| isHomeShortcut | boolean | Yes | No | Whether the shortcut is a home shortcut.|
| isEnabled | boolean | Yes | No | Whether the shortcut is enabled. |
| moduleName<sup>9+</sup> | string | Yes | No | Module name of the shortcut. |
# RemoteAbilityInfo
The **RemoteAbilityInfo** module provides information about a remote ability.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## RemoteAbilityInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | No | Element name of the ability. |
| label | string | Yes | No | Label of the ability. |
| icon | string | Yes | No | Icon of the ability.|
...@@ -19,6 +19,10 @@ startTrace(name: string, taskId: number, expectedTime?: number): void ...@@ -19,6 +19,10 @@ startTrace(name: string, taskId: number, expectedTime?: number): void
Marks the start of a timeslice trace task. Marks the start of a timeslice trace task.
> **NOTE**
>
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.Developtools.Bytrace
**Parameters** **Parameters**
...@@ -29,9 +33,6 @@ Marks the start of a timeslice trace task. ...@@ -29,9 +33,6 @@ Marks the start of a timeslice trace task.
| taskId | number | Yes| ID of a timeslice trace task.| | taskId | number | Yes| ID of a timeslice trace task.|
| expectedTime | number | No| Expected duration of the trace, in ms.| | expectedTime | number | No| Expected duration of the trace, in ms.|
> **NOTE**
>
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**Example** **Example**
...@@ -47,6 +48,10 @@ finishTrace(name: string, taskId: number): void ...@@ -47,6 +48,10 @@ finishTrace(name: string, taskId: number): void
Marks the end of a timeslice trace task. Marks the end of a timeslice trace task.
> **NOTE**
>
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.Developtools.Bytrace
**Parameters** **Parameters**
...@@ -56,9 +61,6 @@ Marks the end of a timeslice trace task. ...@@ -56,9 +61,6 @@ Marks the end of a timeslice trace task.
| name | string | Yes| Name of a timeslice trace task.| | name | string | Yes| Name of a timeslice trace task.|
| taskId | number | Yes| ID of a timeslice trace task.| | taskId | number | Yes| ID of a timeslice trace task.|
> **NOTE**
>
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**Example** **Example**
...@@ -95,7 +97,7 @@ traceByValue(name: string, count: number): void ...@@ -95,7 +97,7 @@ traceByValue(name: string, count: number): void
Defines the variable that indicates the number of timeslice trace tasks. Defines the variable that indicates the number of timeslice trace tasks.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
......
# Standard NFC Card Emulation # Standard NFC Card Emulation
The cardEmulation module implements Near-Field Communication (NFC) card emulation. The **cardEmulation** module implements Near-Field Communication (NFC) card emulation.
> **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -19,7 +19,7 @@ isSupported(feature: number): boolean ...@@ -19,7 +19,7 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported. Checks whether a certain type of card emulation is supported.
**System capability**: SystemCapability.Communication.NFC **System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -27,11 +27,11 @@ Checks whether a certain type of card emulation is supported. ...@@ -27,11 +27,11 @@ Checks whether a certain type of card emulation is supported.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the card emulation is supported; returns **false** otherwise.| | boolean | Returns **true** if the card emulation is supported; returns **false** otherwise.|
## HceService ## HceService<sup>8+</sup>
Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance. Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance.
### startHCE ### startHCE<sup>8+</sup>
startHCE(aidList: string[]): boolean startHCE(aidList: string[]): boolean
...@@ -39,7 +39,7 @@ Starts HCE. ...@@ -39,7 +39,7 @@ Starts HCE.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC **System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Parameters**
...@@ -47,7 +47,7 @@ Starts HCE. ...@@ -47,7 +47,7 @@ Starts HCE.
| ------- | -------- | ---- | ----------------------- | | ------- | -------- | ---- | ----------------------- |
| aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.| | aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.|
### stopHCE ### stopHCE<sup>8+</sup>
stopHCE(): boolean stopHCE(): boolean
...@@ -55,9 +55,9 @@ Stops HCE. ...@@ -55,9 +55,9 @@ Stops HCE.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC **System capability**: SystemCapability.Communication.NFC.Core
### on ### on<sup>8+</sup>
on(type: "hceCmd", callback: AsyncCallback<number[]>): void; on(type: "hceCmd", callback: AsyncCallback<number[]>): void;
...@@ -65,7 +65,7 @@ Subscribes to messages from the peer device after **startHCE()**. ...@@ -65,7 +65,7 @@ Subscribes to messages from the peer device after **startHCE()**.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC **System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Parameters**
...@@ -74,7 +74,7 @@ Subscribes to messages from the peer device after **startHCE()**. ...@@ -74,7 +74,7 @@ Subscribes to messages from the peer device after **startHCE()**.
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. | | type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the subscribed event. The input parameter is a data array that complies with the Application Protocol Data Unit (APDU).| | callback | AsyncCallback<number[]> | Yes | Callback invoked to return the subscribed event. The input parameter is a data array that complies with the Application Protocol Data Unit (APDU).|
### sendResponse ### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void; sendResponse(responseApdu: number[]): void;
...@@ -82,7 +82,7 @@ Sends a response to the peer device. ...@@ -82,7 +82,7 @@ Sends a response to the peer device.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC **System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Parameters**
......
# Active Tag # Active Tag
The **connectedTag** module provides methods for using active tags. You can use the APIs provided by this module to initialize the active tag chip and read and write active tags.
> **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. 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 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -22,9 +24,9 @@ Initializes the active tag chip. ...@@ -22,9 +24,9 @@ Initializes the active tag chip.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value - Return value
| **Type** | **Description** | | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the initialization is successful; returns **false** otherwise. | | boolean | Returns **true** if the initialization is successful; returns **false** otherwise.|
## connectedTag.uninit ## connectedTag.uninit
...@@ -38,9 +40,9 @@ Uninitializes the active tag resources. ...@@ -38,9 +40,9 @@ Uninitializes the active tag resources.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value - Return value
| **Type** | **Description** | | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.readNdefTag ## connectedTag.readNdefTag
...@@ -54,14 +56,14 @@ Reads the content of this active tag. This method uses a promise to return the r ...@@ -54,14 +56,14 @@ Reads the content of this active tag. This method uses a promise to return the r
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Return value - Return value
| **Type** | **Description** | | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the content of the active tag. | | Promise&lt;string&gt; | Promise used to return the content of the active tag.|
- Example - Example
``` ```
import connectedTag from '@ohos.connectedTag'; import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag().then(result => { connectedTag.readNdefTag().then(result => {
console.log("promise recv ndef response: " + result); console.log("promise recv ndef response: " + result);
}); });
...@@ -78,9 +80,9 @@ Reads the content of this active tag. This method uses an asynchronous callback ...@@ -78,9 +80,9 @@ Reads the content of this active tag. This method uses an asynchronous callback
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters - Parameters
| **Name** | **Type** | **Mandatory** | **Description** | | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the active tag content obtained. | | callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example - Example
``` ```
...@@ -102,14 +104,14 @@ Writes data to this active tag. This method uses a promise to return the result. ...@@ -102,14 +104,14 @@ Writes data to this active tag. This method uses a promise to return the result.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters - Parameters
| **Name** | **Type** | **Mandatory** | **Description** | | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | string | Yes | Data to write. The maximum length is 1024 bytes. | | data | string | Yes| Data to write. The maximum length is 1024 bytes.|
- Return value - Return value
| **Type** | **Description** | | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. This method returns no value. | | Promise&lt;void&gt; | Promise used to return the result. This method returns no value.|
- Example - Example
``` ```
...@@ -127,7 +129,7 @@ Writes data to this active tag. This method uses a promise to return the result. ...@@ -127,7 +129,7 @@ Writes data to this active tag. This method uses a promise to return the result.
## connectedTag.writeNdefTag ## connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback&lt;string&gt;): void writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void
Writes data to this active tag. This method uses an asynchronous callback to return the result. Writes data to this active tag. This method uses an asynchronous callback to return the result.
...@@ -136,10 +138,10 @@ Writes data to this active tag. This method uses an asynchronous callback to ret ...@@ -136,10 +138,10 @@ Writes data to this active tag. This method uses an asynchronous callback to ret
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters - Parameters
| **Name** | **Type** | **Mandatory** | **Description** | | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | string | Yes | Data to write. The maximum length is 1024 bytes. | | data | string | Yes| Data to write. The maximum length is 1024 bytes.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the operation result. | | callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example - Example
``` ```
...@@ -151,7 +153,7 @@ Writes data to this active tag. This method uses an asynchronous callback to ret ...@@ -151,7 +153,7 @@ Writes data to this active tag. This method uses an asynchronous callback to ret
console.error(`failed to write event because ${err.code}`); console.error(`failed to write event because ${err.code}`);
return; return;
} }
// Data is written to the tag. // Data is written to the tag.
console.log(`success to write event: ${value}`); console.log(`success to write event: ${value}`);
}); });
...@@ -168,16 +170,16 @@ Registers the NFC field strength state events. ...@@ -168,16 +170,16 @@ Registers the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters - Parameters
| **Name** | **Type** | **Mandatory** | **Description** | | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event type. The value is **notify**. | | type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes | Callback invoked to return the field strength state. | | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the field strength state.|
- Enumerates the field strength states. - Enumerates the field strength states.
| **Value** | **Description** | | **Value**| **Description**|
| -------- | -------- | | -------- | -------- |
| 0 | Field off. | | 0 | Field off.|
| 1 | Field on. | | 1 | Field on.|
## connectedTag.off('notify') ## connectedTag.off('notify')
...@@ -191,10 +193,10 @@ Unregisters the NFC field strength state events. ...@@ -191,10 +193,10 @@ Unregisters the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag **System capability**: SystemCapability.Communication.ConnectedTag
- Parameters - Parameters
| **Name** | **Type** | **Mandatory** | **Description** | | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event type. The value is **notify**. | | type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | No | Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered. | | callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
- Example - Example
``` ```
...@@ -206,10 +208,10 @@ Unregisters the NFC field strength state events. ...@@ -206,10 +208,10 @@ Unregisters the NFC field strength state events.
console.info("nfc rf receive state: " + result); console.info("nfc rf receive state: " + result);
} }
// Register event notification // Register event notification.
connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
// Unregister event notification // Unregister event notification.
connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc); connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
``` ```
...@@ -217,7 +219,9 @@ Unregisters the NFC field strength state events. ...@@ -217,7 +219,9 @@ Unregisters the NFC field strength state events.
Enumerates the NFC states. Enumerates the NFC states.
| Name | Default Value | Description | **System capability**: SystemCapability.Communication.ConnectedTag
| -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field off. | | Name| Default Value| Description|
| NFC_RF_ENTER | 1 | Field on. | | -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field on.|
| NFC_RF_ENTER | 1 | Field on.|
# DispatchInfo
The **DispatchInfo** module provides dispatch information.
> **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.
## DispatchInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----------- | ------ | ---- | ---- | ------------------------ |
| verison | string | Yes | No | Version of the API to dispatch.|
| dispatchAPI | string | Yes | No | API to dispatch. |
...@@ -2,13 +2,32 @@ ...@@ -2,13 +2,32 @@
The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities. The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities.
You can use the APIs of this module to start abilities. You can use the APIs of this module to start Form Extension abilities.
> **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 of this module can be used only in the stage model. > The APIs of this module can be used only in the stage model.
## Usage
Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtension** instance.
```js
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onCreate() {
let dataObj1 = {
temperature:"11c",
"time":"11:00"
};
let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1;
}
}
```
## FormExtensionContext.startAbility ## FormExtensionContext.startAbility
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
...@@ -64,7 +83,7 @@ Starts an ability. This API uses a promise to return the result. ...@@ -64,7 +83,7 @@ Starts an ability. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------ | ---------------------------------- | | ------------ | ---------------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise&lt;void&lt; | Promise used to return the result.|
**Example** **Example**
......
...@@ -536,7 +536,7 @@ Parameters ...@@ -536,7 +536,7 @@ Parameters
**Example** **Example**
``` ```
var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); var pluralRules= new Intl.PluralRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"});
``` ```
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册