提交 6fdca60f 编写于 作者: H Handsome_Afraican_Man

IssueNo:#I77N81

    Description:fix Bm
    Sig:bundleManager
    Feature or Bugfix:Bugfix
    Binary Source:No
Signed-off-by: Nzhouwenzhi <zhouwenzhi@huawei.com>
......@@ -3,7 +3,7 @@
## Overview
[Context](../reference/apis/js-apis-inner-application-context.md) is the context of an object in an application. It provides basic information about the application, for example, **resourceManager**, **applicationInfo**, **dir** (application development path), and **area** (encrypted area). It also provides basic methods such as **createBundleContext()** and **getApplicationContext()**. The UIAbility component and ExtensionAbility derived class components have their own **Context** classes, for example, the base class **Context**, **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, **ExtensionContext**, and **ServiceExtensionContext**.
[Context](../reference/apis/js-apis-inner-application-context.md) is the context of an object in an application. It provides basic information about the application, for example, **resourceManager**, **applicationInfo**, **dir** (application development path), and **area** (encryption level). It also provides basic methods such as **createBundleContext()** and **getApplicationContext()**. The UIAbility component and ExtensionAbility derived class components have their own **Context** classes, for example, the base class **Context**, **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, **ExtensionContext**, and **ServiceExtensionContext**.
- The figure below illustrates the inheritance relationship of contexts.
......@@ -71,7 +71,7 @@ This topic describes how to use the context in the following scenarios:
- [Obtaining the Application Development Path](#obtaining-the-application-development-path)
- [Obtaining and Modifying Encryption Areas](#obtaining-and-modifying-encryption-areas)
- [Obtaining and Modifying Encryption Levels](#obtaining-and-modifying-encryption-levels)
- [Creating Context of Another Application or Module](#creating-context-of-another-application-or-module)
- [Subscribing to UIAbility Lifecycle Changes in a Process](#subscribing-to-uiability-lifecycle-changes-in-a-process)
......@@ -144,19 +144,19 @@ export default class EntryAbility extends UIAbility {
>
> The sample code obtains the sandbox path of the application development path. The absolute path can be obtained by running the **find / -name <fileName>** command in the hdc shell after file creation or modification.
### Obtaining and Modifying Encryption Areas
### Obtaining and Modifying Encryption Levels
Encrypting application files enhances data security by preventing files from unauthorized access. Different application files require different levels of protection. For private files, such as alarms and wallpapers, the application must place them in the device-level encryption area (EL1) to ensure that they can be accessed before the user enters the password. For sensitive files, such as personal privacy data, the application must place them in the user-level encryption area (EL2).
Encrypting application files enhances data security by preventing files from unauthorized access. Different application files require different levels of protection. For private files, such as alarms and wallpapers, the application must place them in a directory with the device-level encryption (EL1) to ensure that they can be accessed before the user enters the password. For sensitive files, such as personal privacy data, the application must place them in a directory with the user-level encryption (EL2).
In practice, you need to select a proper encrypted area based on scenario-specific requirements to protect application data security. The proper use of EL1 and the EL2 can efficiently improve the security.
In practice, you need to select a proper encryption level based on scenario-specific requirements to protect application data security. The proper use of EL1 and the EL2 can efficiently improve the security.
> **NOTE**
>
> - AreaMode.EL1: device-level encryption area, which is accessible after the device is powered on.
> - AreaMode.EL1: device-level encryption. Directories with this encryption level are accessible after the device is powered on.
>
> - AreaMode.EL2: user-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).
> - AreaMode.EL2: user-level encryption. Directories with this encryption level are accessible only after the device is powered on and the password is entered (for the first time).
You can obtain and set the encryption area by reading and writing the [area attribute in Context](../reference/apis/js-apis-inner-application-context.md).
You can obtain and set the encryption level by reading and writing the [area attribute in Context](../reference/apis/js-apis-inner-application-context.md).
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
......
......@@ -17,11 +17,14 @@ Before developing an audio feature, especially before implementing audio data pr
Before developing features related to audio and video playback, you are advised to understand the following concepts:
- Playback process: network protocol > container format > audio and video codec > graphics/audio rendering
- Network protocols: HLS, HTTP, HTTPS, and more
- Container formats: MP4, MKV, MPEG-TS, WebM, and more
- Encoding formats: H.263/H.264/H.265, MPEG4/MPEG2, and more
## Introduction to Audio Streams
## Introduction to Audio Streams
An audio stream is an independent audio data processing unit that has a specific audio format and audio usage scenario information. The audio stream can be used in playback and recording scenarios, and supports independent volume adjustment and audio device routing.
......@@ -29,20 +32,20 @@ The basic audio stream information is defined by [AudioStreamInfo](../reference/
### Audio Stream Usage Scenario Information
In addition to the basic information (which describes only audio data), an audio stream has usage scenario information. This is because audio streams differ in the volume, device routing, and concurrency policy. The system chooses an appropriate processing policy for an audio stream based on the usage scenario information, thereby delivering the optimal user experience.
In addition to the basic information (which describes only audio data), an audio stream has usage scenario information. This is because audio streams differ in the volume, device routing, and concurrency policy. The system chooses an appropriate processing policy for an audio stream based on the usage scenario information, thereby delivering better user experience.
- Playback scenario
Information about the audio playback scenario is defined by using [StreamUsage](../reference/apis/js-apis-audio.md#streamusage) and [ContentType](../reference/apis/js-apis-audio.md#contenttype).
- **StreamUsage** specifies the usage type of an audio stream, for example, used for media, voice communication, voice assistant, notification, and ringtone.
- **ContentType** specifies the content type of data in an audio stream, for example, speech, music, movie, notification tone, and ringtone.
Information about the audio playback scenario is defined by using [StreamUsage](../reference/apis/js-apis-audio.md#streamusage) and [ContentType](../reference/apis/js-apis-audio.md#contenttype).
- **StreamUsage** specifies the usage type of an audio stream, for example, used for media, voice communication, voice assistant, notification, and ringtone.
- **ContentType** specifies the content type of data in an audio stream, for example, speech, music, movie, notification tone, and ringtone.
- Recording scenario
Information about the audio stream recording scenario is defined by [SourceType](../reference/apis/js-apis-audio.md#sourcetype8).
Information about the audio stream recording scenario is defined by [SourceType](../reference/apis/js-apis-audio.md#sourcetype8).
**SourceType** specifies the recording source type of an audio stream, including the mic source, voice recognition source, and voice communication source.
## Supported Audio Formats
......@@ -58,9 +61,9 @@ The sampling rate varies according to the device type.
- Mono and stereo are supported. For details, see [AudioChannel](../reference/apis/js-apis-audio.md#audiochannel8).
- The following sampling formats are supported: U8 (unsigned 8-bit integer), S16LE (signed 16-bit integer, little endian), S24LE (signed 24-bit integer, little endian), S32LE (signed 32-bit integer, little endian), and F32LE (signed 32-bit floating point number, little endian). For details, see [AudioSampleFormat](../reference/apis/js-apis-audio.md#audiosampleformat8).
Due to system restrictions, only some devices support the sampling formats S24LE, S32LE, and F32LE.
Due to system restrictions, only some devices support the sampling formats S24LE, S32LE, and F32LE.
Little endian means that the most significant byte is stored at the largest memory address and the least significant byte of data is stored at the smallest. This storage mode effectively combines the memory address with the bit weight of the data. Specifically, the largest memory address has a high weight, and the smallest memory address has a low weight.
The audio and video formats supported by the APIs of the media module are described in [AVPlayer and AVRecorder](avplayer-avrecorder-overview.md).
......@@ -16,7 +16,7 @@ AppStorage is a singleton LocalStorage object that is created by the UI framewor
UI components synchronize application state attributes with the AppStorage. Implementation of application business logic can access AppStorage as well.
Selected state attributes of AppStorage can be synched with different data sources or data sinks. Those data sources and sinks can be on a local or remote device, and have different capabilities, such as data persistence (see [PersistentStorage](arkts-persiststorage.md)). These data sources and sinks are implemented in the business logic, separate from the UI. Link those AppStorage attributes to [@StorageProp](#storageprop) and [@StorageLink](#storagelink) whose values should be kept until application re-start.
Selected state attributes of AppStorage can be synced with different data sources or data sinks. Those data sources and sinks can be on a local or remote device, and have different capabilities, such as data persistence (see [PersistentStorage](arkts-persiststorage.md)). These data sources and sinks are implemented in the business logic, separate from the UI. Link those AppStorage attributes to [@StorageProp](#storageprop) and [@StorageLink](#storagelink) whose values should be kept until application re-start.
## \@StorageProp
......
......@@ -35,7 +35,8 @@ LocalStorage provides two decorators based on the synchronization type of the co
## Restrictions
Once created, the type of a named attribute cannot be changed. Subsequent calls to **Set** must set a value of same type.
- Once created, the type of a named attribute cannot be changed. Subsequent calls to **Set** must set a value of same type.
- LocalStorage provides page-level storage. The [GetShared](../reference/arkui-ts/ts-state-management.md#getshared9) API can only obtain the LocalStorage instance transferred through [windowStage.loadContent](../reference/apis/js-apis-window.md#loadcontent9) in the current stage. Otherwise, **undefined** is returned. Example: [Sharing a LocalStorage Instance from UIAbility to One or More Pages](#sharing-a-localstorage-instance-from-uiability-to-one-or-more-pages).
## \@LocalStorageProp
......@@ -51,7 +52,7 @@ When a custom component is initialized, the \@LocalStorageProp(key)/\@LocalStora
> Since API version 9, this decorator is supported in ArkTS widgets.
By decorating a variable with \@LocalStorageProp(key), a one-way data synchronization is established with the attribute with the given key in LocalStorage. A local change can be made, but it will not besynchronized to LocalStorage. An update to the attribute with the given key in LocalStorage will overwrite local changes.
By decorating a variable with \@LocalStorageProp(key), a one-way data synchronization is established with the attribute with the given key in LocalStorage. A local change can be made, but it will not be synchronized to LocalStorage. An update to the attribute with the given key in LocalStorage will overwrite local changes.
### Rules of Use
......@@ -127,7 +128,7 @@ By decorating a variable with \@LocalStorageProp(key), a one-way data synchroniz
| Transfer/Access | Description |
| ---------- | ---------------------------------------- |
| Initialization and update from the parent component| Forbidden.|
| Subnode initialization | Supported; can be used to initialize a n \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.|
| Subnode initialization | Supported; can be used to initialize an \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.|
| Access | None. |
......
......@@ -15,17 +15,17 @@ For an \@Prop decorated variable, the value synchronization is uni-directional f
- An @Prop variable is allowed to be modified locally, but the change does not propagate back to its parent component.
- Whenever that data source changes, the @Prop decorated variable gets updated, and any locally made changes are overwritten.
- Whenever that data source changes, the @Prop decorated variable gets updated, and any locally made changes are overwritten. In other words, the value synchronization is from the parent component to the (owning) child component, but not from the other way around.
## Rules of Use
| \@Prop Decorator| Description |
| ----------- | ---------------------------------------- |
| Decorator parameters | None. |
| Synchronization type | One-way: from the data source provided by the parent component to the @Prop decorated variable.|
| Allowed variable types | string, number, boolean, or enum type.<br>**any** is not supported. The **undefined** and **null** values are not allowed.<br>The type must be specified.<br>Negative examples:<br>CompA&nbsp;({&nbsp;aProp:&nbsp;undefined&nbsp;})<br>CompA&nbsp;({&nbsp;aProp:&nbsp;null&nbsp;})<br>The type must be the same as that of the [data source](arkts-state-management-overview.md#basic-concepts). There are three cases (\@State is used as an example of the data source):<br>- The type of the \@Prop decorated variable is the same as that of the state variable of the parent component, that is, \@Prop: S and \@State: S. For an example, see [Simple Type @Prop Synced from @State in Parent Component](#simple-type-prop-synced-from-state-in-parent-component).<br>- When the state variable of the parent component is an array, the type of the \@Prop decorated variable is the same as that of the array item of the state variable of the parent component, that is, \@Prop: S and \@State: Array\<S>. For examples, see [Simple Type @Prop Synched from @State Array Item in Parent Component](#simple-type-prop-synched-from-state-array-item-in-parent-component).<br>- When the state variable of the parent component is Object or class, the type of the \@Prop decorated variableis the same as the attribute type of the state variable of the parent component, that is, \@Prop: S and \@State: { propA: S }. For examples, see [Class Object Type @Prop Synchedd from @State Class Object Property in Parent Component](#class-object-type-prop-synchedd-from-state-class-object-property-in-parent-component).|
| Initial value for the decorated variable | Local initialization is allowed. |
| \@Prop Decorator | Description |
| ------------------ | ------------------------------------------------------------ |
| Decorator parameters | None. |
| Synchronization type | One-way: from the data source provided by the parent component to the @Prop decorated variable. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).|
| Allowed variable types| Object, class, string, number, Boolean, enum, and array of these types.<br>**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.<br>The type must be specified.<br>**NOTE**<br>The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.<br>Negative examples:<br>CompA&nbsp;({&nbsp;aProp:&nbsp;undefined&nbsp;})<br>CompA&nbsp;({&nbsp;aProp:&nbsp;null&nbsp;})<br>The type must be the same as that of the [data source](arkts-state-management-overview.md#basic-concepts). There are three cases:<br>- Synchronizing the \@Prop decorated variable from an \@State or other decorated variable. Example: [Simple Type @Prop Synced from @State in Parent Component](#simple-type-prop-synced-from-state-in-parent-component).<br>- Synchronizing the \@Prop decorated variable from the item of an \@State or other decorated array. Example: [Simple Type @Prop Synced from @State Array Item in Parent Component](#simple-type-prop-synced-from-state-array-item-in-parent-component).<br>- Synchronizing the \@Prop decorated variable from a state attribute of the Object or class type in the parent component. Example: [Class Object Type @Prop Synced from @State Class Object Attribute in Parent Component](#class-object-type-prop-synced-from-state-class-object-attribute-in-parent-component).|
| Initial value for the decorated variable| Local initialization is allowed. |
## Variable Transfer/Access Rules
......@@ -50,24 +50,89 @@ For an \@Prop decorated variable, the value synchronization is uni-directional f
\@Prop decorated variables can observe the following changes:
- When the decorated variable is of the string, number, Boolean, or enum type, its value change can be observed.
- When the decorated variable is of the Object, class, string, number, Boolean, or enum type, its value change can be observed.
```ts
// Simple type
@Prop count: number;
// The value assignment can be observed.
this.count = 1;
// Complex type
@Prop count: Model;
// The value assignment can be observed.
this.title = new Model('Hi');
```
When the decorated variable is of the Object or class type, the value changes of attributes at the first layer can be observed, that is, the attributes that **Object.keys(observedObject)** returns.
```
class ClassA {
public value: string;
constructor(value: string) {
this.value = value;
}
}
class Model {
public value: string;
public a: ClassA;
constructor(value: string, a: ClassA) {
this.value = value;
this.a = a;
}
}
@Prop title: Model;
// The value changes at the first layer can be observed.
this.title.value = 'Hi'
// The value changes at the second layer cannot be observed.
this.title.a.value = 'ArkUi'
```
In the scenarios of nested objects, if a class is decorated by \@Observed, the value changes of the class attribute can be observed.
```
@Observed
class ClassA {
public value: string;
constructor(value: string) {
this.value = value;
}
}
class Model {
public value: string;
public a: ClassA;
constructor(value: string, a: ClassA) {
this.value = value;
this.a = a;
}
}
@Prop title: Model;
// The value changes at the first layer can be observed.
this.title.value = 'Hi'
// The value change of the ClassA attribute can be observed because ClassA is decorated by @Observed. this.title.a.value = 'ArkUi'.
```
When the decorated variable is of the array type, the value assignment, addition, deletion, and updates of array items can be observed.
```
// When the object decorated by @State is an array
@Prop title: string[]
// The value assignment of the array itself can be observed.
this.title = ['1']
// The value assignment of array items can be observed.
this.title[0] = '2'
// The deletion of array items can be observed.
this.title.pop()
// The addition of array items can be observed.
this.title.push('3')
```
For synchronization between \@State and \@Prop decorated variables:
- The value of an \@State decorated variable in the parent component initializes an \@Prop decorated variable in the child component. The \@State decorated variable also updates the @Prop decorated variable whenever the value of the former changes.
- Changes to the @Prop decorated variable do not affect the value of its source @State decorated variable.
- In addition to \@State, the source can also be decorated with \@Link or \@Prop, where the mechanisms for syncing the \@Prop would be the same.
- The type of the source and the @Prop decorated variable must be the same.
- The source and \@Prop decorated variable must be of the same type. The \@Prop decorated variable can be of simple and class types.
### Framework Behavior
......@@ -146,16 +211,16 @@ In the preceding example:
1. On initial render, when the **CountDownComponent** child component is created, its @Prop decorated **count** variable is initialized from the \@State decorated **countDownStartValue** variable in the **ParentComponent**.
2. When the "+1" or "-1" button is touched, the @State decorated **countDownStartValue** of the **ParentComponent** changes. This will cause the **ParentComponent** to re-render. At the minumum, the **CountDownComponent** will be updated because of the changed **count** variable value.
2. When the "+1" or "-1" button is touched, the @State decorated **countDownStartValue** of the **ParentComponent** changes. This will cause the **ParentComponent** to re-render. At the minimum, the **CountDownComponent** will be updated because of the changed **count** variable value.
3. Because of the changed **count** variable value, the **CountDownComponent** child component will re-render. At a minimum, the **if** statement's conditions (**this.counter> 0**) is-evaluated and the **\<Text>** child component inside the **if** would be updated.
4. When **Try again** in the **CountDownComponent** child component is touched, the value of the **count** variable is modified, but the change remains within the child component and does not affect the **countDownStartValue** in the parenet component.
4. When **Try again** in the **CountDownComponent** child component is touched, the value of the **count** variable is modified, but the change remains within the child component and does not affect the **countDownStartValue** in the parent component.
5. Updating **countDownStartValue** will overwrite the local value changes of the @Prop decorated **count** in the **CountDownComponent** child component.
### Simple Type @Prop Synched from @State Array Item in Parent Component
### Simple Type @Prop Synced from @State Array Item in Parent Component
The \@State decorated array an array item in the parent component can be used as data source to initialize and update a @Prop decorated variable. In the following example, the \@State decorated array **arr** in the parent component **Index** initializes the \@Prop decorated **value** variable in the child component **Child**.
......@@ -240,7 +305,7 @@ After **replace entire arr** is clicked, the following information is displayed:
```
- Changes made in the **Child** component are not synchronized to the parent component **Index**. Therefore, even if the values of the six intances of the **Child** component are 7, the value of **this.arr** in the **Index** component is still **[1,2,3]**.
- Changes made in the **Child** component are not synchronized to the parent component **Index**. Therefore, even if the values of the six instances of the **Child** component are 7, the value of **this.arr** in the **Index** component is still **[1,2,3]**.
- After **replace entire arr** is clicked, if **this.arr[0] == 1** is true, **this.arr** is set to **[3, 4, 5]**.
......@@ -250,9 +315,11 @@ After **replace entire arr** is clicked, the following information is displayed:
- The change of **this.arr** causes **ForEach** to update: The array item with the ID **3** is retained in this update, array items with IDs **1** and **2** are deleted, and array items with IDs **4** and **5** are added. The array before and after the update is **[1, 2, 3]** and **[3, 4, 5]**, respectively. This implies that the **Child** instance generated for item **3** will be moved to the first place, but not updated. In this case, the component value corresponding to **3** is **7**, and the final render result of **ForEach** is **7**, **4**, and **5**.
### Class Object Type @Prop Synchedd from @State Class Object Property in Parent Component
### Class Object Type @Prop Synced from @State Class Object Attribute in Parent Component
In a library with one book and two users, each user can mark the book as read, but this does not affect the other user reader. Technically speaking, local changes to the \@Prop decorated **book** object do not sync back to the @State decorated **book** in the **Library** component.
In a library with one book and two users, each user can mark the book as read, and the marking does not affect the other user reader. Technically speaking, local changes to the \@Prop decorated **book** object do not sync back to the @State decorated **book** in the **Library** component.
In this example, the \@Observed decorator can be applied to the **book** class, but it is not mandatory. It is only needed for nested structures. This will be further explained in [Class Type @Prop Synced from @State Array Item in Parent Component](#class-type-prop-synced-from-state-array-item-in-parent-component).
```ts
......@@ -269,14 +336,14 @@ class Book {
@Component
struct ReaderComp {
@Prop title: string;
@Prop readIt: boolean;
@Prop book: Book;
build() {
Row() {
Text(this.title)
Text(`... ${this.readIt ? 'I have read' : 'I have not read it'}`)
.onClick(() => this.readIt = true)
Text(this.book.title)
Text(`...has${this.book.pages} pages!`)
Text(`...${this.book.readIt ? "I have read" : 'I have not read it'}`)
.onClick(() => this.book.readIt = true)
}
}
}
......@@ -288,21 +355,107 @@ struct Library {
build() {
Column() {
ReaderComp({ title: this.book.title, readIt: this.book.readIt })
ReaderComp({ title: this.book.title, readIt: this.book.readIt })
ReaderComp({ book: this.book })
ReaderComp({ book: this.book })
}
}
}
```
### Class Type @Prop Synced from @State Array Item in Parent Component
In the following example, an attribute of the **Book** object in the \@State decorated **allBooks** array is changed, but the system does not respond when **Mark read for everyone** is clicked. This is because the attribute is a nested attribute of the second layer, and the \@State decorator can observe only the attribute of the first layer. Therefore, the framework does not update **ReaderComp**.
```
let nextId: number = 1;
// @Observed
class Book {
public id: number;
public title: string;
public pages: number;
public readIt: boolean = false;
constructor(title: string, pages: number) {
this.id = nextId++;
this.title = title;
this.pages = pages;
}
}
@Component
struct ReaderComp {
@Prop book: Book;
build() {
Row() {
Text(this.book.title)
Text(`...has${this.book.pages} pages!`)
Text(`...${this.book.readIt ? "I have read" : 'I have not read it'}`)
.onClick(() => this.book.readIt = true)
}
}
}
@Entry
@Component
struct Library {
@State allBooks: Book[] = [new Book("100 secrets of C++", 765), new Book("Effective C++", 651), new Book("The C++ programming language", 1765)];
build() {
Column() {
Text('library`s all time favorite')
ReaderComp({ book: this.allBooks[2] })
Divider()
Text('Books on loaan to a reader')
ForEach(this.allBooks, book => {
ReaderComp({ book: book })
},
book => book.id)
Button('Add new')
.onClick(() => {
this.allBooks.push(new Book("The C++ Standard Library", 512));
})
Button('Remove first book')
.onClick(() => {
this.allBooks.shift();
})
Button("Mark read for everyone")
.onClick(() => {
this.allBooks.forEach((book) => book.readIt = true)
})
}
}
}
```
To observe the attribute of the **Book** object, you must use \@Observed to decorate the **Book** class. Note that the \@Prop decorated state variable in the child component is one-way synchronized from the data source of the parent component. This means that, the changes of the \@Prop decorated **book** in **ReaderComp** is not synchronized to the parent **library** component. The parent component triggers UI re-rendering only when the value is updated (compared with the last state).
```
@Observed
class Book {
public id: number;
public title: string;
public pages: number;
public readIt: boolean = false;
constructor(title: string, pages: number) {
this.id = nextId++;
this.title = title;
this.pages = pages;
}
}
```
All instances of the \@Observed decorated class are wrapped with an opaque proxy object. This proxy can detect all attribute changes inside the wrapped object. If any attribute change happens, the proxy notifies the \@Prop, and the \@Prop value will be updated.
### Simple Type @Prop with Local Initialization and No Sync from Parent Parent
### Simple Type @Prop with Local Initialization and No Sync from Parent Component
To enable an \@Component decorated component to be reusable, \@Prop allows for optional local initialization. This makes the synchronization with a variable in the parent component a choice, rather than mandatory. Providing a data source in the parent component is optional only when local initialization is provided for the \@Prop decorated variable.
The following example includes two @Prop decorated variables in child component.
- The @Prop decorated variable **customCounter** has no local initialization, and therefore it requires a synchronization source in its parent component. When the source value changes, the @Prop decorated variable is udpated.
- The @Prop decorated variable **customCounter** has no local initialization, and therefore it requires a synchronization source in its parent component. When the source value changes, the @Prop decorated variable is updated.
- The @Prop decorated variable **customCounter2** has local initialization. In this case, specifying a synchronization source in the parent component is allowed but not mandatory.
......@@ -351,13 +504,13 @@ struct MainProgram {
Row() {
Column()
// customCounter must be initialized from the parent component due to lack of local initialization. Here, customCounter2 does not need to be initialized.
MyComponent({ customCounter: this.mainCounter })
// customCounter2 of the child component can also be initialized from the parent component. The value from the parent component overwrites the locally assigned value of customCounter2 during initialization.
MyComponent({ customCounter: this.mainCounter, customCounter2: this.mainCounter })
}.width('40%')
// customCounter must be initialized from the parent component due to lack of local initialization. Here, customCounter2 does not need to be initialized.
MyComponent({ customCounter: this.mainCounter })
// customCounter2 of the child component can also be initialized from the parent component. The value from the parent component overwrites the locally assigned value of customCounter2 during initialization.
MyComponent({ customCounter: this.mainCounter, customCounter2: this.mainCounter })
}.width('40%')
}
}
}
```
<!--no_check-->
\ No newline at end of file
<!--no_check-->
......@@ -7,14 +7,12 @@ The **AbilityLifecycleCallback** module defines the callbacks to receive lifecyc
> 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.
## Modules to Import
```ts
import AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback';
```
## AbilityLifecycleCallback.onAbilityCreate
onAbilityCreate(ability: UIAbility): void;
......
......@@ -11,7 +11,6 @@ The **appRecovery** module provides APIs for recovering faulty applications.
import appRecovery from '@ohos.app.ability.appRecovery';
```
## appRecovery.RestartFlag
Enumerates the application restart flags. This enum is used as an input parameter of [enableAppRecovery](#apprecoveryenableapprecovery).
......@@ -174,9 +173,17 @@ Saves the ability state, which will be used for recovery. This API can be used t
```ts
import appRecovery from '@ohos.app.ability.appRecovery';
onBackground() {
hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground');
appRecovery.saveAppState(this.context)
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg);
appRecovery.saveAppState(this.context);
}
};
try {
errorManager.on('error', observer);
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......
# @ohos.app.ability.contextConstant (ContextConstant)
The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of data encryption levels.
The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of encryption levels.
> **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 APIs of this module can be used only in the stage model.
## Modules to Import
......@@ -21,5 +22,5 @@ You can obtain the value of this constant by calling the **ContextConstant.AreaM
| Name| Value| Description|
| -------- | -------- | -------- |
| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on.|
| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
| EL1 | 0 | Device-level encryption. Directories with this encryption level are accessible after the device is powered on.|
| EL2 | 1 | User-level encryption. Directories with this encryption level are accessible only after the device is powered on and the password is entered (for the first time).|
# AbilityResult
The **AbilityResult** module defines the result code and data returned when an ability is terminated after being started. You can use [startAbilityForResult](js-apis-ability-featureAbility.md#featureabilitystartabilityforresult7) to obtain the **AbilityResult** object returned after the started ability is terminated. The startedability returns the **AbilityResult** object by calling [terminateSelfWithResult](js-apis-ability-featureAbility.md#featureabilityterminateselfwithresult7).
The **AbilityResult** module defines the result code and data returned when an ability is terminated after being started. You can use [startAbilityForResult](js-apis-ability-featureAbility.md#featureabilitystartabilityforresult7) to obtain the **AbilityResult** object returned after the started ability is terminated. The started ability returns the **AbilityResult** object by calling [terminateSelfWithResult](js-apis-ability-featureAbility.md#featureabilityterminateselfwithresult7).
> **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.
## Modules to Import
```ts
import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable | Writable | Type | Mandatory| Description |
| ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ |
| resultCode | Yes | Yes | number | Yes | Result code returned after the started ability is terminated. |
| want | Yes | Yes | [Want](./js-apis-app-ability-want.md) | No | Data returned after the started ability is terminated. |
| resultCode | Yes | Yes | number | Yes | Result code returned after the started ability is terminated. |
| want | Yes | Yes | [Want](./js-apis-app-ability-want.md) | No | Data returned after the started ability is terminated.|
......@@ -2,6 +2,16 @@
**ConnectOptions** can be used as an input parameter to receive status changes during the connection to a background service. For example, it is used as an input parameter of [connectServiceExtensionAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextconnectserviceextensionability) to connect to a ServiceExtensionAbility.
> **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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Mandatory | Description |
......@@ -18,7 +28,7 @@
abilityName: 'MyAbility'
};
let connectOptions = {
let connectOptions: common.ConnectOptions = {
onConnect(elementName, remote) {
console.log('onConnect elementName: ${elementName}');
},
......
......@@ -7,6 +7,12 @@ The **DataAbilityOperation** module defines the operation on DataAbilities. It c
> 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 APIs of this module can be used only in the FA model.
## Modules to Import
```ts
import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Template | Mandatory| Description |
......
......@@ -7,6 +7,12 @@ The **DataAbilityResult** module defines the operation result on DataAbilities.
> 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 APIs of this module can be used only in the FA model.
## Modules to Import
```ts
import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Type | Mandatory | Description |
......@@ -22,7 +28,7 @@ import featureAbility from '@ohos.ability.featureAbility';
// Perform database operations in batches.
function executeBatchOperation() {
let dataAbilityUri = ('dataability:///com.example.myapplication.TestDataAbility');
let DAHelper;
let DAHelper: ability.DataAbilityHelper;
try {
DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
if (DAHelper === null) {
......@@ -61,7 +67,7 @@ function executeBatchOperation() {
try {
DAHelper.executeBatch(dataAbilityUri, operations).then((data) => {
for (let i = 0; i < data.length; i++) {
let dataAbilityResult = data[i];
let dataAbilityResult: ability.DataAbilityResult = data[i];
console.log('dataAbilityResult.uri: ${dataAbilityResult.uri}');
console.log('dataAbilityResult.count: ${dataAbilityResult.count}');
}
......
......@@ -7,6 +7,12 @@ The **StartAbilityParameter** module defines the parameters for starting an abil
> 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.
> The APIs of this module can be used only in the FA model.
## Modules to Import
```ts
import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Type | Mandatory | Description |
......@@ -30,7 +36,7 @@ let abilityStartSetting ={
[featureAbility.AbilityStartSetting.DISPLAY_ID_KEY] : 1,
};
let startAbilityParameter = {
let startAbilityParameter: ability.StartAbilityParameter = {
want : Want,
abilityStartSetting : abilityStartSetting
};
......
......@@ -6,6 +6,12 @@ Want is a carrier for information transfer between objects (application componen
>
> The APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import Want from '@ohos.app.ability.Want';
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Type | Mandatory| Description |
......@@ -17,7 +23,7 @@ Want is a carrier for information transfer between objects (application componen
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags).|
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-ability-wantConstant.md#wantconstantaction). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
| parameters | {[key: string]: Object} | 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 in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| parameters | {[key: string]: Object} | 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 in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantconstantentity). |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
......@@ -68,5 +74,4 @@ Want is a carrier for information transfer between objects (application componen
- For more details and examples, see [Want](../../application-models/want-overview.md).
<!--no_check-->
<!--no_check-->
......@@ -6,6 +6,12 @@ The **AppVersionInfo** module defines the application version information. You c
>
> 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.
## Modules to Import
```ts
import featureAbility from '@ohos.ability.featureAbility';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
......
......@@ -6,6 +6,12 @@ The **ProcessInfo** module defines process information. You can use [getProcessI
>
> The initial APIs of this module are supported since API version 7. The APIs of this module can be used only in the FA model. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import featureAbility from '@ohos.ability.featureAbility';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
......
......@@ -6,6 +6,12 @@ The **AbilityDelegatorArgs** module provides APIs to obtain an **AbilityDelegato
>
> 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
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
```
## Usage
An **AbilityDelegatorArgs** object is obtained by calling [getArguments](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetarguments) in **AbilityDelegatorRegistry**.
......@@ -28,5 +34,5 @@ Describes the ability delegator arguments.
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let args = AbilityDelegatorRegistry.getArguments();
let args: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments();
```
......@@ -9,6 +9,12 @@ This module provides APIs for accessing a specific ability stage. You can use th
> 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage
The ability stage context is obtained through an **AbilityStage** instance.
......
......@@ -2,13 +2,16 @@
The **AbilityStageMonitor** module provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance.
> **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.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| moduleName<sup>9+</sup> | string | Yes | Yes | Module name of the **AbilityStage** instance.|
| srcEntrance<sup>9+</sup> | string | Yes | Yes | Source path of the **AbilityStage** instance.|
| moduleName | string | Yes | Yes | Module name of the **AbilityStage** instance.|
| srcEntrance | string | Yes | Yes | Source path of the **AbilityStage** instance.|
**Example**
```ts
......
......@@ -2,17 +2,27 @@
The **AbilityStateData** module defines the ability state information, which can be obtained through the **onAbilityStateChanged** lifecycle callback of [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md). The callback can be invoked after a lifecycle change listener is registered through [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8).
> **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
```ts
import appManager from '@ohos.application.appManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | Yes | No | Process ID. |
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name. |
| abilityName<sup>8+</sup> | string | Yes | No | Ability name. |
| uid<sup>8+</sup> | number | Yes | No | User ID. |
| state<sup>8+</sup> | number | Yes | No | [Ability state](#ability-states). |
| pid | number | Yes | No | Process ID. |
| bundleName | string | Yes | No | Bundle name. |
| abilityName | string | Yes | No | Ability name. |
| uid | number | Yes | No | User ID. |
| state | number | Yes | No | [Ability state](#ability-states). |
| moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the ability belongs. |
| abilityType<sup>8+</sup> | number | Yes | No | [Ability type](#ability-types), which can be **page** or **service**.|
| abilityType | number | Yes | No | [Ability type](#ability-types), which can be **page** or **service**.|
#### Ability States
......@@ -29,7 +39,7 @@ The **AbilityStateData** module defines the ability state information, which can
#### Ability Types
| Value | Status | Description |
| Value | State | Description |
| ---- | ------- | --------------------- |
| 0 | UNKNOWN | Unknown type. |
| 1 | PAGE | Ability that has the UI. |
......
......@@ -7,12 +7,18 @@ The **ApplicationContext** module provides application-level context. You can us
> 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage
Before calling any APIs in **ApplicationContext**, obtain an **ApplicationContext** instance through the **context** instance.
```ts
let applicationContext = this.context.getApplicationContext();
let applicationContext: common.ApplicationContext = this.context.getApplicationContext();
```
## ApplicationContext.on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback)
......@@ -303,7 +309,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation().then((data) => {
console.log('The process running information is: ${JSON.stringify(data)}');
}).catch((error) => {
......@@ -341,7 +346,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation((err, data) => {
if (err) {
console.error('getRunningProcessInformation faile, err: ${JSON.stringify(err)}');
......@@ -376,7 +380,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses();
```
......@@ -405,7 +408,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses(error => {
if (error) {
console.error('killAllProcesses fail, error: ${JSON.stringify(error)}');
......
......@@ -2,22 +2,30 @@
The **ApplicationStateObserver** module defines an observer to listen for application state changes. It can be used as an input parameter in [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8) to listen for lifecycle changes of the current application.
> **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
```ts
import appManager from '@ohos.app.ability.appManager';
```
**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> | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the foreground or background state of an application changes. |
| onAbilityStateChanged<sup>8+</sup> | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the ability state changes. |
| onProcessCreated<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is created. |
| onProcessDied<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is destroyed. |
| onProcessStateChanged<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the process state is changed. |
| onForegroundApplicationChanged | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the foreground or background state of an application changes. |
| onAbilityStateChanged | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the ability state changes. |
| onProcessCreated | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is created. |
| onProcessDied | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is destroyed. |
| onProcessStateChanged<sup>9+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | Yes | No | Callback invoked when the process state is changed. |
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('onForegroundApplicationChanged appStateData: ${JSON.stringify(appStateData)}');
......
......@@ -6,6 +6,12 @@
>
> 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
```ts
import common from '@ohos.app.ability.common';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
......
......@@ -29,7 +29,7 @@ import common from '@ohos.app.ability.common';
| bundleCodeDir | string | Yes | No | Bundle code directory. Do not access resource files by concatenating paths. Use the [resourceManager API](js-apis-resource-manager.md) instead.|
| distributedFilesDir | string | Yes | No | Distributed file directory.|
| eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.|
| area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Area in which the file to be access is located.|
| area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Encryption level of the directory. |
## Context.createBundleContext
......@@ -41,6 +41,8 @@ Creates the context based on the bundle name.
**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 |
......@@ -103,6 +105,8 @@ Creates the context based on the bundle name and module name.
**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 |
......
......@@ -2,6 +2,10 @@
The **ErrorObserver** module defines an observer to listen for application errors. It can be used as an input parameter in [ErrorManager.on](js-apis-app-ability-errorManager.md#errormanageron) to listen for errors that occur in the current application.
> **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.
## Modules to Import
```ts
......@@ -40,7 +44,7 @@ try {
}
```
## ErrorObserver.onException
## ErrorObserver.onException<sup>10+</sup>
onException?(errObject: Error): void;
......
......@@ -7,6 +7,12 @@ The **EventHub** module provides APIs to subscribe to, unsubscribe from, and tri
> - 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **UIAbility** instance.
......
......@@ -9,6 +9,12 @@ This module provides APIs for accessing resources of a specific Extension abilit
> - 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -23,7 +23,7 @@ Before using the **ServiceExtensionContext** module, you must first obtain a **F
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) {
let formContext = this.context; // Obtain a FormExtensionContext instance.
// ...
......
......@@ -2,6 +2,10 @@
The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo).
> **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
```ts
......
......@@ -2,6 +2,16 @@
The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [on](js-apis-app-ability-missionManager.md#missionmanageron).
> **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
```ts
import missionManager from '@ohos.app.ability.missionManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Mandatory| Description |
......@@ -10,9 +20,9 @@ The **MissionListener** module defines the listeners used to observe the mission
| onMissionDestroyed | function | No | Called when the system destroys the mission.|
| onMissionSnapshotChanged | function | No | Called when the system updates the mission snapshot.|
| onMissionMovedToFront | function | No | Called when the system moves the mission to the foreground.|
| onMissionLabelUpdated | function | No | Called when the system updates the mission label.|
| onMissionIconUpdated | function | No | Called when the system updates the mission icon.|
| onMissionClosed | function | No | Called when the system closes the mission.|
| onMissionLabelUpdated<sup>9+</sup> | function | No | Called when the system updates the mission label.|
| onMissionIconUpdated<sup>9+</sup> | function | No | Called when the system updates the mission icon.|
| onMissionClosed<sup>9+</sup> | function | No | Called when the system closes the mission.|
**Example**
```ts
......
......@@ -2,22 +2,32 @@
The **ProcessData** module defines process data. If a lifecycle change listener is registered by calling [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8), the **onProcessCreated** callback in [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md) is invoked when the lifecycle of an application or ability changes.
> **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
```ts
import appManager from '@ohos.application.appManager';
```
**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 |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | Yes | No | Process ID. |
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of the application. |
| uid<sup>8+</sup> | number | Yes | No | UID of the application. |
| pid | number | Yes | No | Process ID. |
| bundleName | string | Yes | No | Bundle name of the application. |
| uid | number | Yes | No | UID of the application. |
| isContinuousTask<sup>9+</sup> | boolean | Yes | No | Whether the task is a continuous task. The value **true** means that the task is a continuous task, and **false** means the opposite. |
| isKeepAlive<sup>9+</sup> | boolean | Yes | No | Whether the process is a resident task. The value **true** means that the process is a resident, and **false** means the opposite. |
| state<sup>9+</sup> | number | Yes | No | Application state. The value can be **0** (newly created), **2** (foreground), **4** (background), or **5** (terminated). |
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
import appManager from '@ohos.application.appManager';
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
......
......@@ -6,6 +6,12 @@ The **ProcessRunningInfo** module defines the running information of a process.
> - The APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessInformation<sup>9+</sup>](js-apis-inner-application-processInformation.md) instead.
> - The initial APIs of this module are supported since API version 8.
## Modules to Import
```ts
import appManager from '@ohos.app.ability.appManager';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......
......@@ -9,6 +9,12 @@ You can use the APIs of this module to start, terminate, connect, and disconnect
> - 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage
Before using the **ServiceExtensionContext** module, you must define a child class that inherits from **ServiceExtensionAbility**.
......@@ -1348,3 +1354,208 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, callback: AsyncCallback&lt;void&lt;): void;
Starts an ability. If the ability has multiple instances, the latest instance is started. This API uses an asynchronous callback to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
try {
this.context.startRecentAbility(want, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startRecentAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&lt;): void;
Starts an ability with the start options specified. If the ability has multiple instances, the latest instance is started. This API uses an asynchronous callback to return the result.
You can use this API to carry start options.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0
};
try {
this.context.startRecentAbility(want, options, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startRecentAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options?: StartOptions): Promise&lt;void&lt;;
Starts an ability. If the ability has multiple instances, the latest instance is started.
This API uses a promise to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Parameters used for starting the ability.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0,
};
try {
this.context.startRecentAbility(want, options)
.then(() => {
// Carry out normal service processing.
console.info('startRecentAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -7,6 +7,12 @@
> - 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.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -361,7 +367,7 @@ try {
// Carry out normal service processing.
console.info('startAbilityForResult succeed');
});
} catch (paramError) {
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
}
......@@ -779,7 +785,7 @@ try {
// Process service logic errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (paramError) {
} catch (err) {
// Process input parameter errors.
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
......@@ -1391,6 +1397,7 @@ let want = {
bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility'
};
let commRemote;
let options = {
onConnect(elementName, remote) {
commRemote = remote;
......@@ -1460,6 +1467,7 @@ let want = {
abilityName: 'ServiceExtensionAbility'
};
let accountId = 100;
let commRemote;
let options = {
onConnect(elementName, remote) {
commRemote = remote;
......@@ -1516,6 +1524,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
// connection is the return value of connectServiceExtensionAbility.
let connection = 1;
let commRemote;
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
......@@ -1564,6 +1573,24 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
// connection is the return value of connectServiceExtensionAbility.
let connection = 1;
let commRemote;
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
commRemote = null;
if (err.code) {
// Process service logic errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('disconnectServiceExtensionAbility succeed');
});
} catch (err) {
commRemote = null;
// Process input parameter errors.
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
......@@ -1677,11 +1704,11 @@ try {
// Carry out normal service processing.
caller = obj;
console.info('startAbilityByCall succeed');
}).catch((error) => {
}).catch((err) => {
// Process service logic errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
});
} catch (paramError) {
} catch (err) {
// Process input parameter errors.
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
}
......@@ -2065,6 +2092,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
import image from '@ohos.multimedia.image';
let imagePixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
......@@ -2283,5 +2312,210 @@ try {
} catch (err) {
// Process input parameter errors.
console.error(`requestDialogService failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, callback: AsyncCallback&lt;void&lt;): void;
Starts an ability. If the ability has multiple instances, the latest instance is started. This API uses an asynchronous callback to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
try {
this.context.startRecentAbility(want, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startRecentAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&lt;): void;
Starts an ability with the start options specified. If the ability has multiple instances, the latest instance is started. This API uses an asynchronous callback to return the result.
You can use this API to carry start options.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
deviceId: '',
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0
};
try {
this.context.startRecentAbility(want, options, (err) => {
if (err.code) {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// Carry out normal service processing.
console.info('startRecentAbility succeed');
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed failed, code is ${err.code}, message is ${err.message}`);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options?: StartOptions): Promise&lt;void&lt;;
Starts an ability. If the ability has multiple instances, the latest instance is started.
This API uses a promise to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **exported** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Parameters used for starting the ability.|
**Error codes**
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
| ID| Error Message|
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
**Example**
```ts
let want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
};
let options = {
windowMode: 0,
};
try {
this.context.startRecentAbility(want, options)
.then(() => {
// Carry out normal service processing.
console.info('startRecentAbility succeed');
})
.catch((err) => {
// Process service logic errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
});
} catch (err) {
// Process input parameter errors.
console.error(`startRecentAbility failed, code is ${err.code}, message is ${err.message}`);
}
```
......@@ -2,6 +2,16 @@
The **TriggerInfo** module defines the information required for triggering the WantAgent. The information is used as an input parameter of [trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger).
> **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.
## Modules to Import
```ts
import wantAgent from '@ohos.app.ability.wantAgent';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Mandatory| Description |
......
......@@ -2,6 +2,16 @@
The **WantAgentInfo** module defines the information required for triggering a **WantAgent** object. The information can be used as an input parameter in [getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent) to obtain a specified **WantAgent** object.
> **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.
## Modules to Import
```ts
import wantAgent from '@ohos.app.ability.wantAgent';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Mandatory| Description |
......
......@@ -94,7 +94,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 | the screenlock management service is abnormal. |
**Example**
......@@ -130,7 +130,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 | the screenlock management service is abnormal. |
**Example**
......@@ -166,7 +166,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 | the screenlock management service is abnormal. |
**Example**
......@@ -204,7 +204,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 | the screenlock management service is abnormal. |
**Example**
......@@ -246,7 +246,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 | the screenlock management service is abnormal. |
**Example**
......@@ -286,7 +286,7 @@ For details about the error codes, see [Screen Lock Management Error Codes](../e
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | The screenlock management service is abnormal. |
| 13200002 |the screenlock management service is abnormal. |
**Example**
......@@ -325,6 +325,14 @@ Sends an event to the screen lock service. This API uses a promise to return the
| ----------------- | ---------------------------------------------- |
| Promise\<boolean> | Promise used to return the result. The **value** true means that the event is sent successfully, and **false** means the opposite.|
**Error codes**
For details about the error codes, see [Screen Lock Management Error Codes](../errorcodes/errorcode-screenlock.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 13200002 | the screenlock management service is abnormal. |
**Example**
```js
......
......@@ -26,14 +26,27 @@ GridItem()
| columnStart | number | Start column number of the component.|
| columnEnd | number | End column number of the component.|
| forceRebuild<sup>(deprecated)</sup> | boolean | Whether to re-create the component when it is being built.<br>This API is deprecated since API version 9. Whether to re-create the component is automatically determined based on the component attributes and child component changes. No manual configuration is required.<br>Default value: **false**|
| selectable<sup>8+</sup> | boolean | Whether the current grid item is selectable by the mouse.<br>> **NOTE**<br>> This attribute takes effect only when mouse frame selection is enabled for the parent **\<Grid>** container.<br>Default value: **true**|
| selectable<sup>8+</sup> | boolean | Whether the current grid item is selectable by the mouse.<br>**NOTE**<br>This attribute takes effect only when mouse frame selection is enabled for the parent **\<Grid>** container.<br>Default value: **true** |
> **NOTE**
>
> Rules for setting **rowStart**, **rowEnd**, **columnStart**, and **columnEnd**:
>
> - The valid value range of **rowStart** and **rowEnd** is 0 to the total number of rows minus 1. The valid value range of **columnStart** and **columnEnd** is 0 to the total number of columns minus 1.
>
> - Settings outside of the valid ranges do not take effect.
>
> - In the grid that has both **columnTemplate** and **rowTemplate** set, a grid item takes up the specified number of rows (rowEnd – rowStart + 1) or columns (columnEnd – columnStart + 1), depending on whether **rowStart**/**rowEnd** or **columnStart**/**columnEnd** is set.
>- In the grid that has only **columnTemplate** set, a grid item takes up the specified number of columns.
> - In the grid that has only **rowTemplate** set, a grid item takes up the specified number of rows.
>- In the grid that has neither **columnTemplate** nor **rowTemplate** set, the row and column number attributes do not work.
## Events
| Name| Description|
| -------- | -------- |
| onSelect(event: (isSelected: boolean) =&gt; void)<sup>8+</sup> | Triggered when the selected state of the grid item changes.<br>**isSelected**: Returns **true** if the grid item is selected by the mouse; returns **false** otherwise.|
| onSelect(event: (isSelected: boolean) =&gt; void)<sup>8+</sup> | Triggered when the selected state of the grid item changes.<br>**isSelected**: returns **true** if the grid item is being selected by the mouse; returns **false** otherwise. |
## Example
......@@ -57,7 +70,7 @@ struct GridItemExample {
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}.rowStart(1).rowEnd(4)
}.rowStart(1).rowEnd(2).columnStart(1).columnEnd(2) // Set valid row and column numbers.
ForEach(this.numbers, (item) => {
GridItem() {
......@@ -77,7 +90,7 @@ struct GridItemExample {
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}.columnStart(1).columnEnd(5)
}.columnStart(1).columnEnd(4) // Set only the column numbers. The layout does not start from the first column.
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
......@@ -87,4 +100,4 @@ struct GridItemExample {
}
```
![en-us_image_0000001256858433](figures/en-us_image_0000001256858433.gif)
![en-us_image_0000001174582870](figures/en-us_image_0000001174582870.gif)
......@@ -8,3 +8,4 @@
- [Common Event Manager](cem-tool.md)
- [Advanced Notification Manager](anm-tool.md)
- [restool](restool.md)
- [LLDB Usage Guide](lldb-tool.md)
# LLDB Usage Guide
## Overview
Low Lever Debugger (LLDB) is a next-generation high-performance debugger.
LLDB is developed based on the [llvm15.0.4](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.4) and supports debugging on the home screen and OpenHarmony devices or simulators.
## How to Obtain
Obtain the OpenHarmony SDK from http://ci.openharmony.cn/dailys/dailybuilds.
LLDB is in the following path of the SDK:
```
\ohos-sdk\[system]\native\llvm
```
The value of **system** can be **windows**, **linux**, or **darwin**.
For example, for Windows, **lldb.exe** is stored in the following path after the SDK is decompressed:
```
\ohos-sdk\windows\native\llvm\bin
```
## Supported Platform and Architecture
### Local Debugging
#### Example: Local Debugging on the Linux Platform
1. Obtain the name of the executable file with debugging information generated by the clang compiler of the same version as LLDB.
2. Run the following command in the terminal window to specify the name of the file to debug:
```
./lldb filename
```
3. Set a breakpoint at the **main** function in the code and run the following command on the LLDB interface:
```
(lldb) b main
```
4. Run the following command on the LLDB interface. The program will stop at the breakpoint:
```
(lldb) run
```
5. Perform subsequent debugging operations.
### Remote Debugging
> **Note: During remote debugging, the LLDB server and LLDB must be used together.**
- Debugging the OHOS device on the Windows platform (Arm architecture)
- Debugging the OHOS device on the Windows platform (AArch64 architecture)
- Debugging the simulator on the Windows platform
- Debugging the OHOS device on the macOS (M1) platform (Arm architecture)
- Debugging the OHOS device on the macOS (M1) platform (AArch64 architecture)
- Debugging the simulator on the macOS (M1) platform
- Debugging the OHOS device on the macOS (x86) platform (Arm architecture)
- Debugging the OHOS device on the macOS (x86) platform (AArch64 architecture)
- Debugging the simulator on the macOS (x86) platform
- Debugging the OHOS device on the Linux platform (Arm architecture)
- Debugging the OHOS device on the Linux platform (AArch64 architecture)
#### Example: Remote Debugging the OHOS Device on the Linux Platform (Arm Architecture)
1. Run the executable file with debugging information on the device.
```
./filename
```
2. Push the LLDB server to the device and run the LLDB server.
Command line window 1:
```
hdc file send lldb-server /data/local/tmp
hdc shell ./data/local/tmp/lldb-server p --server --listen "*:8080"
```
> **Note: /data/local/tmp is a directory on the device, and 8080 is a listening port. Both of them can be customized.**
3. Start LLDB in another window, select the remote OHOS device, and connect to it.
Command line window 2:
```
./lldb
(lldb) platform select remote-ohos
(lldb) platform connect connect://localhost:8080
```
4. Set breakpoints and perform debugging operations.
Command line window 2:
```
(lldb) breakpoint set --file <filename> --line <linenum>
(lldb) process attach --name process-name
```
## Functions Provided by LLDB
- Loading a program to LLDB
- Setting a breakpoint
- Setting an observation point
- Starting or attaching to a program
- Executing a control program
- Checking the thread status
- Checking the stack frame status
## References
For details about other functions and commands, see [LLDB Usage Guide](https://gitee.com/openharmony/third_party_llvm-project/blob/master/lldb/README_zh.md)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册