提交 2f69d111 编写于 作者: J jiangkai43 提交者: Gitee

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

Signed-off-by: Njiangkai43 <jiangkai43@huawei.com>
...@@ -6,7 +6,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5 ...@@ -6,7 +6,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5
1. Locate the crash-related code based on the service log. 1. Locate the crash-related code based on the service log.
2. View the error information in the crash file. The crash file is located at **/data/log/faultlog/faultlogger/**. 2. View the error information in the crash file, which is located at **/data/log/faultlog/faultlogger/**.
## Why cannot access controls in the UiTest test framework? ## Why cannot access controls in the UiTest test framework?
......
...@@ -51,9 +51,9 @@ build() { ...@@ -51,9 +51,9 @@ build() {
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
1. Obtain data in Uint8Array format by calling the **RawFile** API of **resourceManager**. 1. Obtain Uint8Array data by calling the **RawFile** API of **resourceManager**.
2. Convert data in Uint8Array format to the string type by calling the **String.fromCharCode** API. 2. Convert the Uint8Array data to strings by calling the **String.fromCharCode** API.
Reference: [Resource Manager](../reference/apis/js-apis-resource-manager.md) Reference: [Resource Manager](../reference/apis/js-apis-resource-manager.md)
......
...@@ -19,23 +19,25 @@ const color = new ArrayBuffer(96); // Create a buffer to store image pixel data. ...@@ -19,23 +19,25 @@ const color = new ArrayBuffer(96); // Create a buffer to store image pixel data.
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } // Image pixel data. let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } } // Image pixel data.
// Create a PixelMap object. // Create a PixelMap object.
const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 2, width: 3 } }
image.createPixelMap(color, opts, (err, pixelmap) => { image.createPixelMap(color, opts, (err, pixelmap) => {
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
}) // Failed to create the PixelMap object.
if (err) {
console.info('create pixelmap failed, err' + err);
return
}
// Read pixels. // Read pixels.
const area = { const area = {
pixels: new ArrayBuffer(8), pixels: new ArrayBuffer(8),
offset: 0, offset: 0,
stride: 8, stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 } region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
} }
pixelmap.readPixels(area,() => { pixelmap.readPixels(area,() => {
var bufferArr = new Uint8Array(area.pixels); let bufferArr = new Uint8Array(area.pixels);
var res = true; let res = true;
for (var i = 0; i < bufferArr.length; i++) { for (let i = 0; i < bufferArr.length; i++) {
console.info(' buffer ' + bufferArr[i]); console.info(' buffer ' + bufferArr[i]);
if(res) { if(res) {
if(bufferArr[i] == 0) { if(bufferArr[i] == 0) {
...@@ -45,14 +47,14 @@ pixelmap.readPixels(area,() => { ...@@ -45,14 +47,14 @@ pixelmap.readPixels(area,() => {
} }
} }
} }
}) })
// Store pixels. // Store pixels.
const readBuffer = new ArrayBuffer(96); const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer,() => { pixelmap.readPixelsToBuffer(readBuffer,() => {
var bufferArr = new Uint8Array(readBuffer); let bufferArr = new Uint8Array(readBuffer);
var res = true; let res = true;
for (var i = 0; i < bufferArr.length; i++) { for (let i = 0; i < bufferArr.length; i++) {
if(res) { if(res) {
if (bufferArr[i] !== 0) { if (bufferArr[i] !== 0) {
res = false; res = false;
...@@ -61,15 +63,15 @@ pixelmap.readPixelsToBuffer(readBuffer,() => { ...@@ -61,15 +63,15 @@ pixelmap.readPixelsToBuffer(readBuffer,() => {
} }
} }
} }
}) })
// Write pixels. // Write pixels.
pixelmap.writePixels(area,() => { pixelmap.writePixels(area,() => {
const readArea = { pixels: new ArrayBuffer(20), offset: 0, stride: 8, region: { size: { height: 1, width: 2 }, x: 0, y: 0 }} const readArea = { pixels: new ArrayBuffer(20), offset: 0, stride: 8, region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}
pixelmap.readPixels(readArea,() => { pixelmap.readPixels(readArea,() => {
var readArr = new Uint8Array(readArea.pixels); let readArr = new Uint8Array(readArea.pixels);
var res = true; let res = true;
for (var i = 0; i < readArr.length; i++) { for (let i = 0; i < readArr.length; i++) {
if(res) { if(res) {
if (readArr[i] !== 0) { if (readArr[i] !== 0) {
res = false; res = false;
...@@ -79,15 +81,16 @@ pixelmap.writePixels(area,() => { ...@@ -79,15 +81,16 @@ pixelmap.writePixels(area,() => {
} }
} }
}) })
}) })
// Write pixels to the buffer. const writeColor = new ArrayBuffer(96); // Pixel data of the image.
pixelmap.writeBufferToPixels(writeColor).then(() => { // Write pixels to the buffer.
pixelmap.writeBufferToPixels(writeColor).then(() => {
const readBuffer = new ArrayBuffer(96); const readBuffer = new ArrayBuffer(96);
pixelmap.readPixelsToBuffer(readBuffer).then (() => { pixelmap.readPixelsToBuffer(readBuffer).then (() => {
var bufferArr = new Uint8Array(readBuffer); let bufferArr = new Uint8Array(readBuffer);
var res = true; let res = true;
for (var i = 0; i < bufferArr.length; i++) { for (let i = 0; i < bufferArr.length; i++) {
if(res) { if(res) {
if (bufferArr[i] !== i) { if (bufferArr[i] !== i) {
res = false; res = false;
...@@ -97,34 +100,40 @@ pixelmap.writeBufferToPixels(writeColor).then(() => { ...@@ -97,34 +100,40 @@ pixelmap.writeBufferToPixels(writeColor).then(() => {
} }
} }
}) })
}) })
// Obtain image information. // Obtain image information.
pixelmap.getImageInfo((error, imageInfo) => { pixelmap.getImageInfo((err, imageInfo) => {
// Failed to obtain the image information.
if (err || imageInfo == null) {
console.info('getImageInfo failed, err' + err);
return
}
if (imageInfo !== null) { if (imageInfo !== null) {
console.log('Succeeded in getting imageInfo'); console.log('Succeeded in getting imageInfo');
} }
}) })
// Release the PixelMap object. // Release the PixelMap object.
pixelmap.release(()=>{ pixelmap.release(()=>{
console.log('Succeeded in releasing pixelmap'); console.log('Succeeded in releasing pixelmap');
})
}) })
// Create an image source (uri). // Create an image source (uri).
let path = '/data/local/tmp/test.jpg'; let path = '/data/local/tmp/test.jpg';
const imageSourceApi = image.createImageSource(path); const imageSourceApi1 = image.createImageSource(path);
// Create an image source (fd). // Create an image source (fd).
let fd = 29; let fd = 29;
const imageSourceApi = image.createImageSource(fd); const imageSourceApi2 = image.createImageSource(fd);
// Create an image source (data). // Create an image source (data).
const data = new ArrayBuffer(96); const data = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(data); const imageSourceApi3 = image.createImageSource(data);
// Release the image source. // Release the image source.
imageSourceApi.release(() => { imageSourceApi3.release(() => {
console.log('Succeeded in releasing imagesource'); console.log('Succeeded in releasing imagesource');
}) })
...@@ -133,6 +142,10 @@ const imagePackerApi = image.createImagePacker(); ...@@ -133,6 +142,10 @@ const imagePackerApi = image.createImagePacker();
const imageSourceApi = image.createImageSource(0); const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 }; let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => { imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
if (err) {
console.info('packing from imagePackerApi failed, err' + err);
return
}
console.log('Succeeded in packing'); console.log('Succeeded in packing');
}) })
...@@ -161,36 +174,33 @@ let decodingOptions = { ...@@ -161,36 +174,33 @@ let decodingOptions = {
// Create a pixel map in callback mode. // Create a pixel map in callback mode.
imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => { imageSourceApi.createPixelMap(decodingOptions, (err, pixelmap) => {
// Failed to create the PixelMap object.
if (err) {
console.info('create pixelmap failed, err' + err);
return
}
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
}) })
// Create a pixel map in promise mode. // Create a pixel map in promise mode.
imageSourceApi.createPixelMap().then(pixelmap => { imageSourceApi.createPixelMap().then(pixelmap => {
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
})
// Capture error information when an exception occurs during function invoking.
catch(error => {
console.log('Failed in creating pixelmap.' + error);
})
// Obtain the number of bytes in each line of pixels. // Obtain the number of bytes in each line of pixels.
var num = pixelmap.getBytesNumberPerRow(); let num = pixelmap.getBytesNumberPerRow();
// Obtain the total number of pixel bytes. // Obtain the total number of pixel bytes.
var pixelSize = pixelmap.getPixelBytesNumber(); let pixelSize = pixelmap.getPixelBytesNumber();
// Obtain the pixel map information. // Obtain the pixel map information.
pixelmap.getImageInfo().then( imageInfo => {}); pixelmap.getImageInfo().then( imageInfo => {});
// Release the PixelMap object. // Release the PixelMap object.
pixelmap.release(()=>{ pixelmap.release(()=>{
console.log('Succeeded in releasing pixelmap'); console.log('Succeeded in releasing pixelmap');
}) })
}).catch(error => {
// Capture release failure information. console.log('Failed in creating pixelmap.' + error);
catch(error => {
console.log('Failed in releasing pixelmap.' + error);
}) })
``` ```
...@@ -216,7 +226,7 @@ if (imagePackerApi == null) { ...@@ -216,7 +226,7 @@ if (imagePackerApi == null) {
} }
// Set encoding parameters if the image packer is successfully created. // Set encoding parameters if the image packer is successfully created.
let packOpts = { format:["image/jpeg"], // The supported encoding format is jpg. let packOpts = { format:"image/jpeg", // The supported encoding format is jpg.
quality:98 } // Image quality, which ranges from 0 to 100. quality:98 } // Image quality, which ranges from 0 to 100.
// Encode the image. // Encode the image.
...@@ -233,8 +243,9 @@ imageSourceApi.getImageInfo((err, imageInfo) => { ...@@ -233,8 +243,9 @@ imageSourceApi.getImageInfo((err, imageInfo) => {
console.log('Succeeded in getting imageInfo'); console.log('Succeeded in getting imageInfo');
}) })
const array = new ArrayBuffer(100); // Incremental data.
// Update incremental data. // Update incremental data.
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error, data)=> {}) imageSourceApi.updateData(array, false, 0, 10,(error, data)=> {})
``` ```
...@@ -246,10 +257,15 @@ Example scenario: The camera functions as the client to transmit image data to t ...@@ -246,10 +257,15 @@ Example scenario: The camera functions as the client to transmit image data to t
public async init(surfaceId: any) { public async init(surfaceId: any) {
// (Server code) Create an ImageReceiver object. // (Server code) Create an ImageReceiver object.
var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1); let receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1);
// Obtain the surface ID. // Obtain the surface ID.
receiver.getReceivingSurfaceId((err, surfaceId) => { receiver.getReceivingSurfaceId((err, surfaceId) => {
// Failed to obtain the surface ID.
if (err) {
console.info('getReceivingSurfaceId failed, err' + err);
return
}
console.info("receiver getReceivingSurfaceId success"); console.info("receiver getReceivingSurfaceId success");
}); });
// Register a surface listener, which is triggered after the buffer of the surface is ready. // Register a surface listener, which is triggered after the buffer of the surface is ready.
......
...@@ -230,25 +230,25 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile( ...@@ -230,25 +230,25 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile(
> >
> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API. > The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API.
In the **.ets** file, you can use the resources defined in the **resources** directory. In the **.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Sub-directories](#resource-group-subdirectories):
```ts ```ts
Text($r('app.string.string_hello')) Text($r('app.string.string_hello'))
.fontColor($r('app.color.color_hello')) .fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello')) .fontSize($r('app.float.font_hello'))
}
Text($r('app.string.string_world')) Text($r('app.string.string_world'))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
}
Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. // Reference string resources. The second parameter of $r is used to replace %s, and value is "We will arrive at five'o clock".
Text($r('app.string.message_arrive', "five'o clock"))
.fontColor($r('app.color.color_hello')) .fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello')) .fontSize($r('app.float.font_hello'))
}
Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d. // Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d.
// The value is "5 apple" in singular form and "5 apples" in plural form.
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
} }
...@@ -278,10 +278,16 @@ Text('Hello') ...@@ -278,10 +278,16 @@ Text('Hello')
.fontSize($r('sys.float.ohos_id_text_size_headline1')) .fontSize($r('sys.float.ohos_id_text_size_headline1'))
.fontFamily($r('sys.string.ohos_id_text_font_family_medium')) .fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
.backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) .backgroundColor($r('sys.color.ohos_id_color_palette_aux1'))
Image($r('sys.media.ohos_app_icon')) Image($r('sys.media.ohos_app_icon'))
.border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) .border({
.margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) color: $r('sys.color.ohos_id_color_palette_aux1'),
radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2
})
.margin({
top: $r('sys.float.ohos_id_elements_margin_horizontal_m'),
bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')
})
.height(200) .height(200)
.width(300) .width(300)
``` ```
...@@ -55,7 +55,7 @@ Initiates a call based on the specified options. This API uses an asynchronous c ...@@ -55,7 +55,7 @@ Initiates a call based on the specified options. This API uses an asynchronous c
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- | | ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. | | options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure |
**Example** **Example**
...@@ -313,7 +313,7 @@ Checks whether the called number is an emergency number based on the specified p ...@@ -313,7 +313,7 @@ Checks whether the called number is an emergency number based on the specified p
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | | ----------- | -------------------------------------------------- | ---- | -------------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number options. | | options | [EmergencyNumberOptions](#emergencynumberoptions7) | No | Phone number options. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number. |
**Example** **Example**
...@@ -397,7 +397,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -397,7 +397,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------- | ---- | ------------------------------------ | | ----------- | -------------------------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. | | options | [NumberFormatOptions](#numberformatoptions7) | No | Number formatting options, for example, country code. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -566,33 +566,6 @@ promise.then(data => { ...@@ -566,33 +566,6 @@ promise.then(data => {
}); });
``` ```
## call.answer<sup>7+</sup>
answer\(callback: AsyncCallback<void\>\): void
Answers a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.answer((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.answer<sup>7+</sup> ## call.answer<sup>7+</sup>
answer\(callId: number, callback: AsyncCallback<void\>\): void answer\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -658,7 +631,7 @@ promise.then(data => { ...@@ -658,7 +631,7 @@ promise.then(data => {
## call.hangup<sup>7+</sup> ## call.hangup<sup>7+</sup>
hangup\(callback: AsyncCallback<void\>\): void hangup\(callId: number, callback: AsyncCallback<void\>\): void
Ends a call. This API uses an asynchronous callback to return the result. Ends a call. This API uses an asynchronous callback to return the result.
...@@ -672,22 +645,23 @@ This is a system API. ...@@ -672,22 +645,23 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
call.hangup((err, data) => { call.hangup(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
## call.hangup<sup>7+</sup> ## call.answer<sup>9+</sup>
hangup\(callId: number, callback: AsyncCallback<void\>\): void answer\(callback: AsyncCallback<void\>\): void
Ends a call based on the specified call ID. This API uses an asynchronous callback to return the result. Answers a call.This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
...@@ -699,13 +673,12 @@ This is a system API. ...@@ -699,13 +673,12 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------------- | | -------- | ------------------------- | ---- | ----------------------------------------------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
call.hangup(1, (err, data) => { call.answer((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -746,11 +719,11 @@ promise.then(data => { ...@@ -746,11 +719,11 @@ promise.then(data => {
}); });
``` ```
## call.reject<sup>7+</sup> ## call.hangup<sup>9+</sup>
reject\(callback: AsyncCallback<void\>\): void hangup\(callback: AsyncCallback<void\>\): void
Rejects a call. This API uses an asynchronous callback to return the result. Ends a call. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
...@@ -767,38 +740,7 @@ This is a system API. ...@@ -767,38 +740,7 @@ This is a system API.
**Example** **Example**
```js ```js
call.reject((err, data) => { call.hangup((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.reject<sup>7+</sup>
reject\(options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified options. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | -------------- |
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
call.reject(rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -903,6 +845,65 @@ promise.then(data => { ...@@ -903,6 +845,65 @@ promise.then(data => {
}); });
``` ```
## call.reject<sup>9+</sup>
reject\(callback: AsyncCallback<void\>\): void
Rejects a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example:**
```js
call.reject((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.reject<sup>9+</sup>
reject\(options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | -------------- |
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example:**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
call.reject(rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.holdCall<sup>7+</sup> ## call.holdCall<sup>7+</sup>
holdCall\(callId: number, callback: AsyncCallback<void\>\): void holdCall\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -1345,7 +1346,7 @@ This is a system API. ...@@ -1345,7 +1346,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback&lt;[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.<br><br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.| | callback | AsyncCallback&lt;[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.<br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.|
**Example** **Example**
...@@ -2399,7 +2400,7 @@ promise.then(data => { ...@@ -2399,7 +2400,7 @@ promise.then(data => {
}); });
``` ```
## call.setAudioDevice<sup>8+</sup> ## call.setAudioDevice<sup>9+</sup>
setAudioDevice\(device: AudioDevice, callback: AsyncCallback<void\>\): void setAudioDevice\(device: AudioDevice, callback: AsyncCallback<void\>\): void
...@@ -2425,7 +2426,7 @@ call.setAudioDevice(1, (err, data) => { ...@@ -2425,7 +2426,7 @@ call.setAudioDevice(1, (err, data) => {
``` ```
## call.setAudioDevice<sup>8+</sup> ## call.setAudioDevice<sup>9+</sup>
setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback<void\>\): void setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback<void\>\): void
......
# Internationalization – I18N # Internationalization – I18N
This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N APIs that are not defined in ECMA 402. The I18N module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N APIs that are not defined in ECMA 402.
The [Intl](js-apis-intl.md) module provides basic I18N capabilities through the standard I18N APIs defined in ECMA 402. It works with the I18N module to provide a complete suite of I18N capabilities. The [Intl](js-apis-intl.md) module provides basic I18N capabilities through the standard I18N APIs defined in ECMA 402. It works with the I18N module to provide a complete suite of I18N capabilities.
> **NOTE** > **NOTE**
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N APIs that are not defined in ECMA 402. For details about the basic I18N capabilities, see [Intl](js-apis-intl.md).
## Modules to Import ## Modules to Import
...@@ -247,9 +244,9 @@ This is a system API. ...@@ -247,9 +244,9 @@ This is a system API.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ----- | | -------- | ------ | ----- | ----- |
| language | string | Language ID.| | language | string | Yes | Language ID.|
**Error codes** **Error codes**
...@@ -313,9 +310,9 @@ This is a system API. ...@@ -313,9 +310,9 @@ This is a system API.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ----- | | -------- | ------ | ----- | ----- |
| region | string | Region ID.| | region | string | Yes | Region ID.|
**Error codes** **Error codes**
...@@ -379,9 +376,9 @@ This is a system API. ...@@ -379,9 +376,9 @@ This is a system API.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | --------------- | | -------- | ------ | ----- | ----- |
| locale | string | System locale ID, for example, **zh-CN**.| | locale | string | Yes | System locale ID, for example, **zh-CN**.|
**Error codes** **Error codes**
...@@ -713,9 +710,9 @@ Checks whether the localized script for the specified language is displayed from ...@@ -713,9 +710,9 @@ Checks whether the localized script for the specified language is displayed from
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ------- | | -------- | ------ | ----- | ----- |
| locale | string | Locale ID.| | locale | string | Yes | Locale ID.|
**Return value** **Return value**
...@@ -905,7 +902,7 @@ Sets the start day of a week for this **Calendar** object. ...@@ -905,7 +902,7 @@ Sets the start day of a week for this **Calendar** object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | --------------------- | | ----- | ------ | ---- | --------------------- |
| value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | value | number | Yes | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Example** **Example**
```js ```js
...@@ -947,7 +944,7 @@ Sets the minimum number of days in the first week of a year. ...@@ -947,7 +944,7 @@ Sets the minimum number of days in the first week of a year.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ------------ | | ----- | ------ | ---- | ------------ |
| value | number | No | Minimum number of days in the first week of a year.| | value | number | Yes | Minimum number of days in the first week of a year.|
**Example** **Example**
```js ```js
......
# Internationalization – Intl # Internationalization – Intl
This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N APIs defined in ECMA 402. The Intl module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N APIs defined in ECMA 402.
The [I18N](js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary APIs that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities. The [I18N](js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary APIs that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
The Keycode module provides keycodes for a key device. The Keycode module provides keycodes for a key device.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -337,7 +338,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode'; ...@@ -337,7 +338,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode';
| KEYCODE_WWAN_WIMAX | number | Yes| No| WWAN WiMAX key| | KEYCODE_WWAN_WIMAX | number | Yes| No| WWAN WiMAX key|
| KEYCODE_RFKILL | number | Yes| No| RF Kill key| | KEYCODE_RFKILL | number | Yes| No| RF Kill key|
| KEYCODE_CHANNEL | number | Yes| No| Channel key| | KEYCODE_CHANNEL | number | Yes| No| Channel key|
| KEYCODE_BTN_0 | number | Yes| No| Key 0| | KEYCODE_BTN_0 | number | Yes| No| Button 0|
| KEYCODE_BTN_1 | number | Yes| No| Button 1| | KEYCODE_BTN_1 | number | Yes| No| Button 1|
| KEYCODE_BTN_2 | number | Yes| No| Button 2| | KEYCODE_BTN_2 | number | Yes| No| Button 2|
| KEYCODE_BTN_3 | number | Yes| No| Button 3| | KEYCODE_BTN_3 | number | Yes| No| Button 3|
......
...@@ -332,7 +332,6 @@ connection.getDefaultNet().then(function (netHandle) { ...@@ -332,7 +332,6 @@ connection.getDefaultNet().then(function (netHandle) {
}); });
``` ```
## connection.reportNetConnected ## connection.reportNetConnected
reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt; reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
...@@ -490,7 +489,6 @@ connection.getAddressesByName(host).then(function (addresses) { ...@@ -490,7 +489,6 @@ connection.getAddressesByName(host).then(function (addresses) {
}) })
``` ```
## connection.enableAirplaneMode ## connection.enableAirplaneMode
enableAirplaneMode(callback: AsyncCallback\<void>): void enableAirplaneMode(callback: AsyncCallback\<void>): void
...@@ -539,7 +537,6 @@ connection.enableAirplaneMode().then(function (error) { ...@@ -539,7 +537,6 @@ connection.enableAirplaneMode().then(function (error) {
}) })
``` ```
## connection.disableAirplaneMode ## connection.disableAirplaneMode
disableAirplaneMode(callback: AsyncCallback\<void>): void disableAirplaneMode(callback: AsyncCallback\<void>): void
...@@ -588,7 +585,6 @@ connection.disableAirplaneMode().then(function (error) { ...@@ -588,7 +585,6 @@ connection.disableAirplaneMode().then(function (error) {
}) })
``` ```
## connection.createNetConnection ## connection.createNetConnection
createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection
...@@ -825,7 +821,7 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle** ...@@ -825,7 +821,7 @@ Before invoking NetHandle APIs, call **getNetHandle** to obtain a **NetHandle**
| Name| Type | Description | | Name| Type | Description |
| ------ | ------ | ------------------------- | | ------ | ------ | ------------------------- |
| netId | number | Network ID. The value must be greater than or equal to 100.| | netId | number | Network ID. The value **0** indicates no default network. Any other value must be greater than or equal to 100.|
### bindSocket ### bindSocket
...@@ -847,33 +843,50 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses ...@@ -847,33 +843,50 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses
**Example** **Example**
```js ```js
connection.getDefaultNet().then(function (netHandle) { import socket from "@ohos.net.socket";
connection.getDefaultNet().then((netHandle)=>{
var tcp = socket.constructTCPSocketInstance(); var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance(); var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx"; let socketType = "TCPSocket";
if (socketType == "TCPSocket") { if (socketType == "TCPSocket") {
tcp.bind({ tcp.bind({
address: "xxxx", port: xxxx, family: xxxx address: '192.168.xx.xxx', port: xxxx, family: 1
}, err => { }, err => {
netHandle.bindSocket(tcp, function (error, data) { if (err) {
console.log(JSON.stringify(error)) console.log('bind fail');
console.log(JSON.stringify(data)) }
netHandle.bindSocket(tcp, (error, data)=>{
if (error) {
console.log(JSON.stringify(error));
} else {
console.log(JSON.stringify(data));
}
})
}) })
} else { } else {
let callback = value => {
console.log(TAG + "on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
}
udp.on('message', callback); udp.on('message', callback);
udp.bind({ udp.bind({
address: "xxxx", port: xxxx, family: xxxx address: '192.168.xx.xxx', port: xxxx, family: 1
}, err => { }, err => {
if (err) {
console.log('bind fail');
}
udp.on('message', (data) => { udp.on('message', (data) => {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}); });
netHandle.bindSocket(udp, function (error, data) { netHandle.bindSocket(udp,(error, data)=>{
console.log(JSON.stringify(error)) if (error) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(error));
}); } else {
console.log(JSON.stringify(data));
}
})
}) })
} }
} })
``` ```
### bindSocket ### bindSocket
...@@ -901,31 +914,50 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses ...@@ -901,31 +914,50 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses
**Example** **Example**
```js ```js
connection.getDefaultNet().then(function (netHandle) { import socket from "@ohos.net.socket";
connection.getDefaultNet().then((netHandle)=>{
var tcp = socket.constructTCPSocketInstance(); var tcp = socket.constructTCPSocketInstance();
var udp = socket.constructUDPSocketInstance(); var udp = socket.constructUDPSocketInstance();
let socketType = "xxxx"; let socketType = "TCPSocket";
if(socketType == "TCPSocket") { if (socketType == "TCPSocket") {
tcp.bind({ tcp.bind({
address: "xxxx", port: xxxx, family: xxxx address: '192.168.xx.xxx', port: xxxx, family: 1
}, err => { }, err => {
netHandle.bindSocket(tcp).then(err, data) { if (err) {
console.log(JSON.stringify(data)) console.log('bind fail');
}
netHandle.bindSocket(tcp).then((err, data) => {
if (err) {
console.log(JSON.stringify(err));
} else {
console.log(JSON.stringify(data));
}
})
}) })
} else { } else {
let callback = value => {
console.log(TAG + "on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
}
udp.on('message', callback); udp.on('message', callback);
udp.bind({ udp.bind({
address: "xxxx", port: xxxx, family: xxxx address: '192.168.xx.xxx', port: xxxx, family: 1
}, err => { }, err => {
if (err) {
console.log('bind fail');
}
udp.on('message', (data) => { udp.on('message', (data) => {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data));
});
netHandle.bindSocket(tcp).then(err, data) {
console.log(JSON.stringify(data))
});
}) })
netHandle.bindSocket(udp).then((err, data) => {
if (err) {
console.log(JSON.stringify(err));
} else {
console.log(JSON.stringify(data));
} }
} })
})
}
})
``` ```
......
# Network Sharing Management # Network Sharing Management
The Network Sharing Management module allows you to share your device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing. It also allows you to query the network sharing state and shared mobile data volume. The Network Sharing Management module allows you to share your device's Internet connection with other connected devices by means of Wi-Fi hotspot, and Bluetooth sharing. It also allows you to query the network sharing state and shared mobile data volume.
> **NOTE** > **NOTE**
> >
...@@ -405,7 +405,7 @@ Obtains the names of NICs in the specified network sharing state. This API uses ...@@ -405,7 +405,7 @@ Obtains the names of NICs in the specified network sharing state. This API uses
**Example** **Example**
```js ```js
import SharingIfaceState from '@ohos.net.sharing' import SharingIfaceType from '@ohos.net.sharing'
sharing.getSharingIfaces(SharingIfaceState.SHARING_NIC_CAN_SERVER, (error, data) => { sharing.getSharingIfaces(SharingIfaceState.SHARING_NIC_CAN_SERVER, (error, data) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
...@@ -498,7 +498,7 @@ Obtains the network sharing state of the specified type. This API uses a promise ...@@ -498,7 +498,7 @@ Obtains the network sharing state of the specified type. This API uses a promise
```js ```js
import SharingIfaceType from '@ohos.net.sharing' import SharingIfaceType from '@ohos.net.sharing'
sharing.getSharingIfaces(SharingIfaceType.SHARING_WIFI).then(data => { sharing.getSharingState(SharingIfaceType.SHARING_WIFI).then(data => {
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
...@@ -525,8 +525,8 @@ Obtains regular expressions of NICs of a specified type. This API uses an asynch ...@@ -525,8 +525,8 @@ Obtains regular expressions of NICs of a specified type. This API uses an asynch
**Example** **Example**
```js ```js
import SharingIfaceState from '@ohos.net.sharing' import SharingIfaceType from '@ohos.net.sharing'
sharing.getSharingState(SharingIfaceType.SHARING_WIFI, (error, data) => { sharing.getSharableRegexes(SharingIfaceType.SHARING_WIFI, (error, data) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
}); });
...@@ -565,7 +565,7 @@ sharing.getSharableRegexes(SharingIfaceType.SHARING_WIFI).then(data => { ...@@ -565,7 +565,7 @@ sharing.getSharableRegexes(SharingIfaceType.SHARING_WIFI).then(data => {
}); });
``` ```
## on('sharingStateChange') ## sharing.on('sharingStateChange')
on(type: 'sharingStateChange', callback: Callback\<boolean>): void on(type: 'sharingStateChange', callback: Callback\<boolean>): void
...@@ -591,7 +591,7 @@ sharing.on('sharingStateChange', (error, data) => { ...@@ -591,7 +591,7 @@ sharing.on('sharingStateChange', (error, data) => {
}); });
``` ```
## off('sharingStateChange') ## sharing.off('sharingStateChange')
off(type: 'sharingStateChange', callback?: Callback\<boolean>): void off(type: 'sharingStateChange', callback?: Callback\<boolean>): void
...@@ -617,7 +617,7 @@ sharing.off('sharingStateChange', (error, data) => { ...@@ -617,7 +617,7 @@ sharing.off('sharingStateChange', (error, data) => {
}); });
``` ```
## on('interfaceSharingStateChange') ## sharing.on('interfaceSharingStateChange')
on(type: 'interfaceSharingStateChange', callback: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void on(type: 'interfaceSharingStateChange', callback: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void
...@@ -643,7 +643,7 @@ sharing.on('interfaceSharingStateChange', (error, data) => { ...@@ -643,7 +643,7 @@ sharing.on('interfaceSharingStateChange', (error, data) => {
}); });
``` ```
## off('interfaceSharingStateChange') ## sharing.off('interfaceSharingStateChange')
off(type: 'interfaceSharingStateChange', callback?: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void off(type: 'interfaceSharingStateChange', callback?: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void
...@@ -669,7 +669,7 @@ sharing.off('interfaceSharingStateChange', (error, data) => { ...@@ -669,7 +669,7 @@ sharing.off('interfaceSharingStateChange', (error, data) => {
}); });
``` ```
## on('sharingUpstreamChange') ## sharing.on('sharingUpstreamChange')
on(type: 'sharingUpstreamChange', callback: Callback\<NetHandle>): void on(type: 'sharingUpstreamChange', callback: Callback\<NetHandle>): void
...@@ -695,7 +695,7 @@ sharing.on('sharingUpstreamChange', (error, data) => { ...@@ -695,7 +695,7 @@ sharing.on('sharingUpstreamChange', (error, data) => {
}); });
``` ```
## off('sharingUpstreamChange') ## sharing.off('sharingUpstreamChange')
off(type: 'sharingUpstreamChange', callback?: Callback\<NetHandle>): void off(type: 'sharingUpstreamChange', callback?: Callback\<NetHandle>): void
...@@ -742,5 +742,5 @@ Enumerates the network sharing types of an NIC. ...@@ -742,5 +742,5 @@ Enumerates the network sharing types of an NIC.
| Name | Value | Description | | Name | Value | Description |
| ------------------------ | ---- | ---------------------- | | ------------------------ | ---- | ---------------------- |
| SHARING_WIFI | 0 | Wi-Fi hotspot sharing.| | SHARING_WIFI | 0 | Wi-Fi hotspot sharing.|
| SHARING_USB | 1 | USB sharing.| | SHARING_USB | 1 | USB sharing (not supported currently).|
| SHARING_BLUETOOTH | 2 | Bluetooth sharing.| | SHARING_BLUETOOTH | 2 | Bluetooth sharing.|
...@@ -531,8 +531,8 @@ Enumerates SIM card types and states. ...@@ -531,8 +531,8 @@ Enumerates SIM card types and states.
**System capability**: SystemCapability.Telephony.StateRegistry **System capability**: SystemCapability.Telephony.StateRegistry
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ----------------- | --------------------- | ------------------------------------------------------------ | | -------- | ------- | --------- | ----------- |
| type | [CardType](js-apis-sim.md#cardtype) | SIM card type. For details, see [CardType](js-apis-sim.md#cardtype).| | type | [CardType](js-apis-sim.md#cardtype) | Yes| SIM card type. For details, see [CardType](js-apis-sim.md#cardtype).|
| state | [SimState](js-apis-sim.md#simstate) | SIM card status. For details, see [SimState](js-apis-sim.md#simstate).| | state | [SimState](js-apis-sim.md#simstate) | Yes| SIM card status. For details, see [SimState](js-apis-sim.md#simstate).|
| reason<sup>8+</sup> | [LockReason](#lockreason8) | SIM card lock type.| | reason<sup>8+</sup> | [LockReason](#lockreason8) | Yes| SIM card lock type.|
...@@ -142,7 +142,7 @@ Sets the mouse movement speed. This API uses an asynchronous callback to return ...@@ -142,7 +142,7 @@ Sets the mouse movement speed. This API uses an asynchronous callback to return
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------------------------------- | | -------- | ------------------------- | ---- | ------------------------------------- |
| speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**. | | speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**. |
| callback | AysncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -349,7 +349,7 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t ...@@ -349,7 +349,7 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t
| ------------ | ------------------------------ | ---- | ----------------------------------- | | ------------ | ------------------------------ | ---- | ----------------------------------- |
| windowId | number | Yes | Window ID. | | windowId | number | Yes | Window ID. |
| pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. | | pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. |
| callback | AysncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
......
...@@ -1734,8 +1734,8 @@ Enables listening for **imsRegStateChange** events for the SIM card in the speci ...@@ -1734,8 +1734,8 @@ Enables listening for **imsRegStateChange** events for the SIM card in the speci
**Example** **Example**
```js ```js
radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1763,8 +1763,8 @@ Disables listening for **imsRegStateChange** events for the SIM card in the spec ...@@ -1763,8 +1763,8 @@ Disables listening for **imsRegStateChange** events for the SIM card in the spec
**Example** **Example**
```js ```js
radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, data => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1797,10 +1797,10 @@ Defines the signal strength. ...@@ -1797,10 +1797,10 @@ Defines the signal strength.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ------------------ | | -------- | ------- | --------- | ----------- |
| signalType | [NetworkType](#networktype) | Signal strength type.| | signalType | [NetworkType](#networktype) | Yes| Signal strength type.|
| signalLevel | number | Signal strength level.| | signalLevel | number | Yes| Signal strength level.|
## NetworkType ## NetworkType
...@@ -1825,17 +1825,17 @@ Defines the network status. ...@@ -1825,17 +1825,17 @@ Defines the network status.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ----------------- | --------------------- | ------------------------------------------------------------ | | -------- | ------- | --------- | ----------- |
| longOperatorName | string | Long carrier name of the registered network.| | longOperatorName | string | Yes | Long carrier name of the registered network.|
| shortOperatorName | string | Short carrier name of the registered network.| | shortOperatorName | string | Yes | Short carrier name of the registered network.|
| plmnNumeric | string | PLMN code of the registered network.| | plmnNumeric | string | Yes | PLMN code of the registered network.|
| isRoaming | boolean | Whether the user is roaming.| | isRoaming | boolean | Yes | Whether the user is roaming.|
| regState | [RegState](#regstate) | Network registration status of the device.| | regState | [RegState](#regstate) | Yes | Network registration status of the device.|
| cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | RAT of the device.| | cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | Yes | RAT of the device.|
| nsaState | [NsaState](#nsastate) | NSA network registration status of the device.| | nsaState | [NsaState](#nsastate) | Yes | NSA network registration status of the device.|
| isCaActive | boolean | CA status.| | isCaActive | boolean | Yes | CA status.|
| isEmergency | boolean | Whether only emergency calls are allowed.| | isEmergency | boolean | Yes | Whether only emergency calls are allowed.|
## RegState ## RegState
...@@ -1933,13 +1933,13 @@ Defines the cell information. ...@@ -1933,13 +1933,13 @@ Defines the cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | -------- | ------- | --------- | ----------- |
| networkType | [NetworkType](#networktype) | Network type of the cell. | | networkType | [NetworkType](#networktype) | Yes | Network type of the cell. |
| isCamped | boolean | Status of the cell. | | isCamped | boolean | Yes | Status of the cell. |
| timeStamp | number | Timestamp when cell information is obtained. | | timeStamp | number | Yes | Timestamp when cell information is obtained. |
| signalInformation | [SignalInformation](#signalinformation) | Signal information. | | signalInformation | [SignalInformation](#signalinformation) | Yes | Signal information. |
| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | CDMA cell information \|GSM cell information \|LTE cell information \|NR cell information \|TD-SCDMA cell information| | data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | Yes | CDMA cell information \|GSM cell information \|LTE cell information \|NR cell information \|TD-SCDMA cell information|
## CdmaCellInformation<sup>8+</sup> ## CdmaCellInformation<sup>8+</sup>
...@@ -1949,13 +1949,13 @@ Defines the CDMA cell information. ...@@ -1949,13 +1949,13 @@ Defines the CDMA cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ------------ | | -------- | ------- | --------- | ----------- |
| baseId | number | Base station ID. | | baseId | number | Yes | Base station ID. |
| latitude | number | Longitude. | | latitude | number | Yes | Longitude. |
| longitude | number | Latitude. | | longitude | number | Yes | Latitude. |
| nid | number | Network ID.| | nid | number | Yes | Network ID.|
| sid | number | System ID.| | sid | number | Yes | System ID.|
## GsmCellInformation<sup>8+</sup> ## GsmCellInformation<sup>8+</sup>
...@@ -1965,14 +1965,14 @@ Defines the GSM cell information. ...@@ -1965,14 +1965,14 @@ Defines the GSM cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | -------------------- | | -------- | ------- | --------- | ----------- |
| lac | number | Location area code. | | lac | number | Yes | Location area code. |
| cellId | number | Cell ID. | | cellId | number | Yes | Cell ID. |
| arfcn | number | Absolute radio frequency channel number.| | arfcn | number | Yes | Absolute radio frequency channel number.|
| bsic | number | Base station ID. | | bsic | number | Yes | Base station ID. |
| mcc | string | Mobile country code. | | mcc | string | Yes | Mobile country code. |
| mnc | string | Mobile network code. | | mnc | string | Yes | Mobile network code. |
## LteCellInformation<sup>8+</sup> ## LteCellInformation<sup>8+</sup>
...@@ -1982,16 +1982,16 @@ Defines the LTE cell information. ...@@ -1982,16 +1982,16 @@ Defines the LTE cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------------- | ------- | ----------------------- | | -------- | ------- | --------- | ----------- |
| cgi | number | Cell global identification. | | cgi | number | Yes | Cell global identification. |
| pci | number | Physical cell ID. | | pci | number | Yes | Physical cell ID. |
| tac | number | Tracking area code. | | tac | number | Yes | Tracking area code. |
| earfcn | number | Absolute radio frequency channel number. | | earfcn | number | Yes | Absolute radio frequency channel number. |
| bandwidth | number | Bandwidth. | | bandwidth | number | Yes | Bandwidth. |
| mcc | string | Mobile country code. | | mcc | string | Yes | Mobile country code. |
| mnc | string | Mobile network code. | | mnc | string | Yes | Mobile network code. |
| isSupportEndc | boolean | Support New Radio_Dual Connectivity| | isSupportEndc | boolean | Yes | Support for New Radio_Dual Connectivity. |
## NrCellInformation<sup>8+</sup> ## NrCellInformation<sup>8+</sup>
...@@ -2001,14 +2001,14 @@ Defines the NR cell information. ...@@ -2001,14 +2001,14 @@ Defines the NR cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---------------- | | -------- | ------- | --------- | ----------- |
| nrArfcn | number | 5G frequency number. | | nrArfcn | number | Yes | 5G frequency number. |
| pci | number | Physical cell ID. | | pci | number | Yes | Physical cell ID. |
| tac | number | Tracking area code. | | tac | number | Yes | Tracking area code. |
| nci | number | 5G network cell ID.| | nci | number | Yes | 5G network cell ID.|
| mcc | string | Mobile country code. | | mcc | string | Yes | Mobile country code. |
| mnc | string | Mobile network code. | | mnc | string | Yes | Mobile network code. |
## TdscdmaCellInformation<sup>8+</sup> ## TdscdmaCellInformation<sup>8+</sup>
...@@ -2018,14 +2018,14 @@ Defines the TD-SCDMA cell information. ...@@ -2018,14 +2018,14 @@ Defines the TD-SCDMA cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ------------ | | -------- | ------- | --------- | ----------- |
| lac | number | Location area code.| | lac | number | Yes | Location area code.|
| cellId | number | Cell ID. | | cellId | number | Yes | Cell ID. |
| cpid | number | Cell parameter ID.| | cpid | number | Yes | Cell parameter ID.|
| uarfcn | number | Absolute radio frequency number.| | uarfcn | number | Yes | Absolute radio frequency number.|
| mcc | string | Mobile country code.| | mcc | string | Yes | Mobile country code.|
| mnc | string | Mobile network code. | | mnc | string | Yes | Mobile network code. |
## WcdmaCellInformation<sup>8+</sup> ## WcdmaCellInformation<sup>8+</sup>
...@@ -2035,14 +2035,14 @@ Defines the WCDMA cell information. ...@@ -2035,14 +2035,14 @@ Defines the WCDMA cell information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ------------ | | -------- | ------- | --------- | ----------- |
| lac | number | Location area code.| | lac | number | Yes | Location area code.|
| cellId | number | Cell ID. | | cellId | number | Yes | Cell ID. |
| psc | number | Primary scrambling code. | | psc | number | Yes | Primary scrambling code. |
| uarfcn | number | Absolute radio frequency number.| | uarfcn | number | Yes | Absolute radio frequency number.|
| mcc | string | Mobile country code.| | mcc | string | Yes | Mobile country code.|
| mnc | string | Mobile network code. | | mnc | string | Yes | Mobile network code. |
## NrOptionMode<sup>8+</sup> ## NrOptionMode<sup>8+</sup>
...@@ -2067,10 +2067,10 @@ Defines the network search result. ...@@ -2067,10 +2067,10 @@ Defines the network search result.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ---------------------- | ------------------------------------------------- | -------------- | | -------- | ------- | --------- | ----------- |
| isNetworkSearchSuccess | boolean | Successful network search.| | isNetworkSearchSuccess | boolean | Yes | Successful network search.|
| networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | Network search result.| | networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | Yes | Network search result.|
## NetworkInformation ## NetworkInformation
...@@ -2080,12 +2080,12 @@ Defines the network information. ...@@ -2080,12 +2080,12 @@ Defines the network information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| --------------- | ----------------------------------------- | -------------- | | -------- | ------- | --------- | ----------- |
| operatorName | string | Carrier name.| | operatorName | string | Yes | Carrier name.|
| operatorNumeric | string | Carrier number. | | operatorNumeric | string | Yes | Carrier number. |
| state | [NetworkInformation](#networkinformationstate) | Network information status.| | state | [NetworkInformation](#networkinformationstate) | Yes | Network information status.|
| radioTech | string | Radio technology. | | radioTech | string | Yes | Radio technology. |
## NetworkInformationState ## NetworkInformationState
...@@ -2110,12 +2110,12 @@ Defines the network selection mode. ...@@ -2110,12 +2110,12 @@ Defines the network selection mode.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------------------ | --------------------------------------------- | -------------------------------------- | | -------- | ------- | --------- | ----------- |
| slotId | number | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| selectMode | [NetworkSelectionMode](#networkselectionmode) | Network selection mode. | | selectMode | [NetworkSelectionMode](#networkselectionmode) | Yes | Network selection mode. |
| networkInformation | [NetworkInformation](#networkinformation) | Network information. | | networkInformation | [NetworkInformation](#networkinformation) | Yes | Network information. |
| resumeSelection | boolean | Whether to resume selection. | | resumeSelection | boolean | Yes | Whether to resume selection. |
## ImsRegState<sup>9+</sup> ## ImsRegState<sup>9+</sup>
...@@ -2153,10 +2153,10 @@ Defines the IMS registration information. ...@@ -2153,10 +2153,10 @@ Defines the IMS registration information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------- | ------------- | | -------- | ------- | --------- | ----------- |
| imsRegState | [ImsRegState](#imsregstate9) | IMS registration state.| | imsRegState | [ImsRegState](#imsregstate9) | Yes | IMS registration state.|
| imsRegTech | [ImsRegTech](#imsregtech9) | IMS registration technology.| | imsRegTech | [ImsRegTech](#imsregtech9) | Yes | IMS registration technology.|
## ImsServiceType<sup>9+</sup> ## ImsServiceType<sup>9+</sup>
......
...@@ -15,8 +15,10 @@ import resourceManager from '@ohos.resourceManager'; ...@@ -15,8 +15,10 @@ import resourceManager from '@ohos.resourceManager';
## Instruction ## Instruction
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object.
For details about how to reference **context** in the stage model, see [Context in the Stage Model].
For details about how to reference **context** in the stage model, see Context in the Stage Model.
```ts ```ts
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
...@@ -97,6 +99,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom ...@@ -97,6 +99,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ----------------- | | ---------------------------------------- | ----------------- |
| Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the result.| | Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the result.|
...@@ -134,6 +137,7 @@ Obtains the **ResourceManager** object of an application based on the specified ...@@ -134,6 +137,7 @@ Obtains the **ResourceManager** object of an application based on the specified
| bundleName | string | Yes | Bundle name of the application.| | bundleName | string | Yes | Bundle name of the application.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------ | | ---------------------------------------- | ------------------ |
| Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the result.| | Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the result.|
...@@ -305,7 +309,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco ...@@ -305,7 +309,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
**Example (stage)** **Example (stage)**
```ts ```ts
try { try {
this.context.getStringValue($r('app.string.test').id, (error, value) => { this.context.resourceManager.getStringValue($r('app.string.test').id, (error, value) => {
if (error != null) { if (error != null) {
console.log("error is " + error); console.log("error is " + error);
} else { } else {
...@@ -333,6 +337,7 @@ Obtains the string corresponding to the specified resource ID. This API uses a p ...@@ -333,6 +337,7 @@ Obtains the string corresponding to the specified resource ID. This API uses a p
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -423,6 +428,7 @@ Obtains the string corresponding to the specified resource object. This API uses ...@@ -423,6 +428,7 @@ Obtains the string corresponding to the specified resource object. This API uses
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -512,6 +518,7 @@ Obtains the string array corresponding to the specified resource ID. This API us ...@@ -512,6 +518,7 @@ Obtains the string array corresponding to the specified resource ID. This API us
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------------- | | ---------------------------------- | ------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.|
...@@ -599,6 +606,7 @@ Obtains the string array corresponding to the specified resource object. This AP ...@@ -599,6 +606,7 @@ Obtains the string array corresponding to the specified resource object. This AP
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------------------ | | ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.|
...@@ -687,6 +695,7 @@ Obtains the content of the media file corresponding to the specified resource ID ...@@ -687,6 +695,7 @@ Obtains the content of the media file corresponding to the specified resource ID
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | -------------- | | ------------------------- | -------------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -772,6 +781,7 @@ Obtains the content of the media file corresponding to the specified resource ob ...@@ -772,6 +781,7 @@ Obtains the content of the media file corresponding to the specified resource ob
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | ------------------- | | ------------------------- | ------------------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -859,6 +869,7 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. ...@@ -859,6 +869,7 @@ Obtains the Base64 code of the image corresponding to the specified resource ID.
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------------- | | --------------------- | -------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -944,6 +955,7 @@ Obtains the Base64 code of the image corresponding to the specified resource obj ...@@ -944,6 +955,7 @@ Obtains the Base64 code of the image corresponding to the specified resource obj
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------- | | --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -1014,6 +1026,7 @@ Obtains the device configuration. This API uses a promise to return the result. ...@@ -1014,6 +1026,7 @@ Obtains the device configuration. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ---------------- | | ---------------------------------------- | ---------------- |
| Promise&lt;[Configuration](#configuration)&gt; | Promise used to return the result.| | Promise&lt;[Configuration](#configuration)&gt; | Promise used to return the result.|
...@@ -1069,6 +1082,7 @@ Obtains the device capability. This API uses a promise to return the result. ...@@ -1069,6 +1082,7 @@ Obtains the device capability. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------- | | ---------------------------------------- | ------------------- |
| Promise&lt;[DeviceCapability](#devicecapability)&gt; | Promise used to return the result.| | Promise&lt;[DeviceCapability](#devicecapability)&gt; | Promise used to return the result.|
...@@ -1144,6 +1158,7 @@ Obtains the singular-plural string corresponding to the specified resource ID ba ...@@ -1144,6 +1158,7 @@ Obtains the singular-plural string corresponding to the specified resource ID ba
| num | number | Yes | Number. | | num | number | Yes | Number. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------- | | --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -1234,6 +1249,7 @@ Obtains the singular-plural string corresponding to the specified resource objec ...@@ -1234,6 +1249,7 @@ Obtains the singular-plural string corresponding to the specified resource objec
| num | number | Yes | Number. | | num | number | Yes | Number. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------ | | --------------------- | ------------------------------ |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -1321,6 +1337,7 @@ Obtains the content of the raw file in the **resources/rawfile** directory. This ...@@ -1321,6 +1337,7 @@ Obtains the content of the raw file in the **resources/rawfile** directory. This
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | ----------- | | ------------------------- | ----------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -1402,6 +1419,7 @@ Obtains the descriptor of the raw file in the **resources/rawfile** directory. T ...@@ -1402,6 +1419,7 @@ Obtains the descriptor of the raw file in the **resources/rawfile** directory. T
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------- | | ---------------------------------------- | ------------------- |
| Promise&lt;[RawFileDescriptor](#rawfiledescriptor8)&gt; | Promise used to return the result.| | Promise&lt;[RawFileDescriptor](#rawfiledescriptor8)&gt; | Promise used to return the result.|
...@@ -1470,6 +1488,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th ...@@ -1470,6 +1488,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---- | | ------------------- | ---- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
...@@ -1538,6 +1557,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th ...@@ -1538,6 +1557,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---- | | ------------------- | ---- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
...@@ -1634,6 +1654,7 @@ Obtains the string corresponding to the specified resource name. This API uses a ...@@ -1634,6 +1654,7 @@ Obtains the string corresponding to the specified resource name. This API uses a
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | String corresponding to the resource name.| | Promise&lt;string&gt; | String corresponding to the resource name.|
...@@ -1716,6 +1737,7 @@ Obtains the string array corresponding to the specified resource name. This API ...@@ -1716,6 +1737,7 @@ Obtains the string array corresponding to the specified resource name. This API
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------------ | | ---------------------------------- | ------------ |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.|
...@@ -1798,6 +1820,7 @@ Obtains the content of the media file corresponding to the specified resource na ...@@ -1798,6 +1820,7 @@ Obtains the content of the media file corresponding to the specified resource na
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | ------------- | | ------------------------- | ------------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -1880,6 +1903,7 @@ Obtains the Base64 code of the image corresponding to the specified resource nam ...@@ -1880,6 +1903,7 @@ Obtains the Base64 code of the image corresponding to the specified resource nam
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------- | | --------------------- | ------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -1965,6 +1989,7 @@ Obtains the plural string corresponding to the specified resource name based on ...@@ -1965,6 +1989,7 @@ Obtains the plural string corresponding to the specified resource name based on
| num | number | Yes | Number. | | num | number | Yes | Number. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------------- | | --------------------- | ---------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -2007,6 +2032,7 @@ Obtains the string corresponding to the specified resource ID. This API returns ...@@ -2007,6 +2032,7 @@ Obtains the string corresponding to the specified resource ID. This API returns
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| string | Promise used to return the result.| | string | Promise used to return the result.|
...@@ -2045,6 +2071,7 @@ Obtains the string corresponding to the specified resource object. This API retu ...@@ -2045,6 +2071,7 @@ Obtains the string corresponding to the specified resource object. This API retu
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------------- | | ------ | ---------------- |
| string | Promise used to return the result.| | string | Promise used to return the result.|
...@@ -2088,6 +2115,7 @@ Obtains the string corresponding to the specified resource name. This API return ...@@ -2088,6 +2115,7 @@ Obtains the string corresponding to the specified resource name. This API return
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | String corresponding to the specified resource name.| | string | String corresponding to the specified resource name.|
...@@ -2126,6 +2154,7 @@ Obtains the Boolean result corresponding to the specified resource ID. This API ...@@ -2126,6 +2154,7 @@ Obtains the Boolean result corresponding to the specified resource ID. This API
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------ | | ------- | ------------ |
| boolean | Boolean result corresponding to the specified resource ID.| | boolean | Boolean result corresponding to the specified resource ID.|
...@@ -2163,6 +2192,7 @@ Obtains the Boolean result corresponding to the specified resource object. This ...@@ -2163,6 +2192,7 @@ Obtains the Boolean result corresponding to the specified resource object. This
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Boolean result corresponding to the specified resource object.| | boolean | Boolean result corresponding to the specified resource object.|
...@@ -2206,6 +2236,7 @@ Obtains the Boolean result corresponding to the specified resource name. This AP ...@@ -2206,6 +2236,7 @@ Obtains the Boolean result corresponding to the specified resource name. This AP
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------- | | ------- | ----------- |
| boolean | Boolean result corresponding to the specified resource name.| | boolean | Boolean result corresponding to the specified resource name.|
...@@ -2244,6 +2275,7 @@ Obtains the integer or float value corresponding to the specified resource ID. T ...@@ -2244,6 +2275,7 @@ Obtains the integer or float value corresponding to the specified resource ID. T
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| number | Integer or float value corresponding to the specified resource ID.| | number | Integer or float value corresponding to the specified resource ID.|
...@@ -2288,6 +2320,7 @@ Obtains the integer or float value corresponding to the specified resource objec ...@@ -2288,6 +2320,7 @@ Obtains the integer or float value corresponding to the specified resource objec
| resource | [Resource](#resource9) | Yes | Resource object.| | resource | [Resource](#resource9) | Yes | Resource object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------- | | ------ | --------------- |
| number | Integer or float value corresponding to the specified resource object.| | number | Integer or float value corresponding to the specified resource object.|
...@@ -2331,6 +2364,7 @@ Obtains the integer or float value corresponding to the specified resource name. ...@@ -2331,6 +2364,7 @@ Obtains the integer or float value corresponding to the specified resource name.
| resName | string | Yes | Resource name.| | resName | string | Yes | Resource name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------- | | ------ | --------- |
| number | Integer or float value corresponding to the specified resource name.| | number | Integer or float value corresponding to the specified resource name.|
...@@ -2409,6 +2443,7 @@ This API is deprecated since API version 9. You are advised to use [getStringVal ...@@ -2409,6 +2443,7 @@ This API is deprecated since API version 9. You are advised to use [getStringVal
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -2473,6 +2508,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr ...@@ -2473,6 +2508,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------------- | | ---------------------------------- | ------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the result.|
...@@ -2495,7 +2531,7 @@ getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void ...@@ -2495,7 +2531,7 @@ getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent) instead. This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2526,7 +2562,7 @@ getMedia(resId: number): Promise&lt;Uint8Array&gt; ...@@ -2526,7 +2562,7 @@ getMedia(resId: number): Promise&lt;Uint8Array&gt;
Obtains the content of the media file corresponding to the specified resource ID. This API uses a promise to return the result. Obtains the content of the media file corresponding to the specified resource ID. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent-1) instead. This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9-1) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2537,6 +2573,7 @@ This API is deprecated since API version 9. You are advised to use [getMediaCont ...@@ -2537,6 +2573,7 @@ This API is deprecated since API version 9. You are advised to use [getMediaCont
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | -------------- | | ------------------------- | -------------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -2559,7 +2596,7 @@ getMediaBase64(resId: number, callback: AsyncCallback&lt;string&gt;): void ...@@ -2559,7 +2596,7 @@ getMediaBase64(resId: number, callback: AsyncCallback&lt;string&gt;): void
Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase64) instead. This API is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase649) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2590,7 +2627,7 @@ getMediaBase64(resId: number): Promise&lt;string&gt; ...@@ -2590,7 +2627,7 @@ getMediaBase64(resId: number): Promise&lt;string&gt;
Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses a promise to return the result. Obtains the Base64 code of the image corresponding to the specified resource ID. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase64-1) instead. This API is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase649-1) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2601,6 +2638,7 @@ This API is deprecated since API version 9. You are advised to use [getMediaCont ...@@ -2601,6 +2638,7 @@ This API is deprecated since API version 9. You are advised to use [getMediaCont
| resId | number | Yes | Resource ID.| | resId | number | Yes | Resource ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------------- | | --------------------- | -------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -2623,7 +2661,7 @@ getPluralString(resId: number, num: number): Promise&lt;string&gt; ...@@ -2623,7 +2661,7 @@ getPluralString(resId: number, num: number): Promise&lt;string&gt;
Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses a promise to return the result. Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [getPluralStringValue](#getpluralstringvalue) instead. This API is deprecated since API version 9. You are advised to use [getPluralStringValue](#getpluralstringvalue9) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2635,6 +2673,7 @@ This API is deprecated since API version 9. You are advised to use [getPluralStr ...@@ -2635,6 +2673,7 @@ This API is deprecated since API version 9. You are advised to use [getPluralStr
| num | number | Yes | Number. | | num | number | Yes | Number. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------- | | --------------------- | ------------------------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | Promise used to return the result.|
...@@ -2657,7 +2696,7 @@ getPluralString(resId: number, num: number, callback: AsyncCallback&lt;string&gt ...@@ -2657,7 +2696,7 @@ getPluralString(resId: number, num: number, callback: AsyncCallback&lt;string&gt
Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses an asynchronous callback to return the result. Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [getPluralStringValue](#getpluralstringvalue-1) instead. This API is deprecated since API version 9. You are advised to use [getPluralStringValue](#getpluralstringvalue9-1) instead.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2731,6 +2770,7 @@ This API is deprecated since API version 9. You are advised to use [getRawFileCo ...@@ -2731,6 +2770,7 @@ This API is deprecated since API version 9. You are advised to use [getRawFileCo
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | ----------- | | ------------------------- | ----------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result.| | Promise&lt;Uint8Array&gt; | Promise used to return the result.|
...@@ -2796,6 +2836,7 @@ This API is deprecated since API version 9. You are advised to use [getRawFd](#g ...@@ -2796,6 +2836,7 @@ This API is deprecated since API version 9. You are advised to use [getRawFd](#g
| path | string | Yes | Path of the raw file.| | path | string | Yes | Path of the raw file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------- | | ---------------------------------------- | ------------------- |
| Promise&lt;[RawFileDescriptor](#rawfiledescriptor8)&gt; | Promise used to return the result.| | Promise&lt;[RawFileDescriptor](#rawfiledescriptor8)&gt; | Promise used to return the result.|
......
...@@ -2847,10 +2847,10 @@ Defines the lock status response. ...@@ -2847,10 +2847,10 @@ Defines the lock status response.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| --------------- | ------ | ------------------ | | -------- | ------- | --------- | ----------- |
| result | number | Operation result. | | result | number | Yes | Operation result. |
| remain?: number | number | Remaining attempts (can be null).| | remain?: number | number | Yes | Remaining attempts (can be null).|
## LockInfo<sup>8+</sup> ## LockInfo<sup>8+</sup>
...@@ -2860,11 +2860,11 @@ Defines the lock information. ...@@ -2860,11 +2860,11 @@ Defines the lock information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------ | ------ | | -------- | ------- | --------- | ----------- |
| lockType | [LockType](#locktype8) | Lock type.| | lockType | [LockType](#locktype8) | Yes | Lock type.|
| password | string | Password. | | password | string | Yes | Password. |
| state | [LockState](#lockstate8) | Lock state.| | state | [LockState](#lockstate8) | Yes | Lock state.|
## PersoLockInfo<sup>8+</sup> ## PersoLockInfo<sup>8+</sup>
...@@ -2874,10 +2874,10 @@ Defines the personalized lock information. ...@@ -2874,10 +2874,10 @@ Defines the personalized lock information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ------------ | | -------- | ------- | --------- | ----------- |
| lockType | [PersoLockType](#persolocktype8) | Personalized lock type.| | lockType | [PersoLockType](#persolocktype8) | Yes | Personalized lock type.|
| password | string | Password. | | password | string | Yes | Password. |
## IccAccountInfo<sup>7+</sup> ## IccAccountInfo<sup>7+</sup>
...@@ -2887,15 +2887,15 @@ Defines the ICC account information. ...@@ -2887,15 +2887,15 @@ Defines the ICC account information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ---------- | ------- | ---------------- | | -------- | ------- | --------- | ----------- |
| simId | number | SIM card ID. | | simId | number | Yes | SIM card ID. |
| slotIndex | number | Card slot ID. | | slotIndex | number | Yes | Card slot ID. |
| isEsim | boolean | Whether the SIM card is an eSim card.| | isEsim | boolean | Yes | Whether the SIM card is an eSim card.|
| isActive | boolean | Whether the card is activated. | | isActive | boolean | Yes | Whether the card is activated. |
| iccId | string | ICCID number. | | iccId | string | Yes | ICCID number. |
| showName | string | SIM card display name. | | showName | string | Yes | SIM card display name. |
| showNumber | string | SIM card display number. | | showNumber | string | Yes | SIM card display number. |
## OperatorConfig<sup>8+</sup> ## OperatorConfig<sup>8+</sup>
...@@ -2905,10 +2905,10 @@ Defines the carrier configuration. ...@@ -2905,10 +2905,10 @@ Defines the carrier configuration.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description| | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | | -------- | ------- | --------- | ----------- |
| field | string | Field| | field | string | Yes | Field. |
| value | string | Value | | value | string | Yes | Value. |
## DiallingNumbersInfo<sup>8+</sup> ## DiallingNumbersInfo<sup>8+</sup>
...@@ -2918,12 +2918,12 @@ Defines the contact number information. ...@@ -2918,12 +2918,12 @@ Defines the contact number information.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------------ | ------ | -------- | | -------- | ------- | --------- | ----------- |
| alphaTag | string | Alpha tag. | | alphaTag | string | Yes | Alpha tag. |
| number | string | Contact number. | | number | string | Yes | Contact number. |
| recordNumber | number | Record number.| | recordNumber | number | Yes | Record number.|
| pin2 | string | PIN 2.| | pin2 | string | Yes | PIN 2.|
## ContactType<sup>8+</sup> ## ContactType<sup>8+</sup>
......
...@@ -1116,19 +1116,19 @@ Defines an SMS message instance. ...@@ -1116,19 +1116,19 @@ Defines an SMS message instance.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | -------- | ------- | --------- | ----------- |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: The device returns a response based on the SMSC that sends the SMS message.| | hasReplyPath | boolean | Yes |Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: The device returns a response based on the SMSC that sends the SMS message.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.| | isReplaceMessage | boolean | Yes |Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.| | isSmsStatusReportMessage | boolean | Yes |Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#shortmessageclass) | Enumerates SMS message types. | | messageClass | [ShortMessageClass](#shortmessageclass) | Yes | SMS message type. |
| pdu | Array&lt;number&gt; | PDU in the SMS message. | | pdu | Array&lt;number&gt; | Yes | PDU in the SMS message. |
| protocolId | number | Protocol identifier used for delivering the SMS message. | | protocolId | number | Yes | Protocol identifier used for delivering the SMS message. |
| scAddress | string | SMSC address. | | scAddress | string | Yes | SMSC address. |
| scTimestamp | number | SMSC timestamp. | | scTimestamp | number | Yes | SMSC timestamp. |
| status | number | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.| | status | number | Yes | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.|
| visibleMessageBody | string | SMS message body. | | visibleMessageBody | string | Yes | SMS message body. |
| visibleRawAddress | string | Sender address. | | visibleRawAddress | string | Yes | Sender address. |
## ShortMessageClass ## ShortMessageClass
......
...@@ -70,7 +70,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput ...@@ -70,7 +70,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput
| toolHeight | number | Yes| No| Height of the tool area.| | toolHeight | number | Yes| No| Height of the tool area.|
| rawX | number | Yes| No| X coordinate of the input device.| | rawX | number | Yes| No| X coordinate of the input device.|
| rawY | number | Yes| No| Y coordinate of the input device.| | rawY | number | Yes| No| Y coordinate of the input device.|
| toolType | number | Yes| No| Tool type.| | toolType | ToolType | Yes| No| Tool type.|
## TouchEvent ## TouchEvent
......
...@@ -638,16 +638,16 @@ Represents the USB endpoint from which data is sent or received. You can obtain ...@@ -638,16 +638,16 @@ Represents the USB endpoint from which data is sent or received. You can obtain
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------------- | ------------------------------------------- | ------------- | | -------- | ------- | --------- | ----------- |
| address | number | Endpoint address. | | address | number | Yes | Endpoint address. |
| attributes | number | Endpoint attributes. | | attributes | number | Yes | Endpoint attributes. |
| interval | number | Endpoint interval. | | interval | number | Yes | Endpoint interval. |
| maxPacketSize | number | Maximum size of data packets on the endpoint. | | maxPacketSize | number | Yes | Maximum size of data packets on the endpoint. |
| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction. | | direction | [USBRequestDirection](#usbrequestdirection) | Yes | Endpoint direction. |
| number | number | Endpoint number. | | number | number | Yes | Endpoint number. |
| type | number | Endpoint type. | | type | number | Yes | Endpoint type. |
| interfaceId | number | Unique ID of the interface to which the endpoint belongs.| | interfaceId | number | Yes | Unique ID of the interface to which the endpoint belongs.|
## USBInterface ## USBInterface
...@@ -655,15 +655,15 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U ...@@ -655,15 +655,15 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ---------------- | ---------------------------------------- | --------------------- | | -------- | ------- | --------- | ----------- |
| id | number | Unique ID of the USB interface. | | id | number | Yes | Unique ID of the USB interface. |
| protocol | number | Interface protocol. | | protocol | number | Yes | Interface protocol. |
| clazz | number | Device type. | | clazz | number | Yes | Device type. |
| subClass | number | Device subclass. | | subClass | number | Yes | Device subclass. |
| alternateSetting | number | Settings for alternating between descriptors of the same USB interface.| | alternateSetting | number | Yes | Settings for alternating between descriptors of the same USB interface.|
| name | string | Interface name. | | name | string | Yes | Interface name. |
| endpoints | Array&lt;[USBEndpoint](#usbendpoint)&gt; | Endpoints that belong to the USB interface. | | endpoints | Array&lt;[USBEndpoint](#usbendpoint)&gt; | Yes | Endpoints that belong to the USB interface. |
## USBConfig ## USBConfig
...@@ -671,15 +671,15 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip ...@@ -671,15 +671,15 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| -------------- | ------------------------------------------------ | --------------- | | -------- | ------- | --------- | ----------- |
| id | number | Unique ID of the USB configuration. | | id | number | Yes | Unique ID of the USB configuration. |
| attributes | number | Configuration attributes. | | attributes | number | Yes | Configuration attributes. |
| maxPower | number | Maximum power consumption, in mA. | | maxPower | number | Yes | Maximum power consumption, in mA. |
| name | string | Configuration name, which can be left empty. | | name | string | Yes | Configuration name, which can be left empty. |
| isRemoteWakeup | boolean | Support for remote wakeup.| | isRemoteWakeup | boolean | Yes | Support for remote wakeup.|
| isSelfPowered | boolean | Support for independent power supplies.| | isSelfPowered | boolean | Yes | Support for independent power supplies.|
| interfaces | Array&nbsp;&lt;[USBInterface](#usbinterface)&gt; | Supported interface attributes. | | interfaces | Array&nbsp;&lt;[USBInterface](#usbinterface)&gt; | Yes | Supported interface attributes. |
## USBDevice ## USBDevice
...@@ -687,21 +687,21 @@ Represents the USB device information. ...@@ -687,21 +687,21 @@ Represents the USB device information.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ---------------- | ------------------------------------ | ---------- | | -------- | ------- | --------- | ----------- |
| busNum | number | Bus address. | | busNum | number | Yes | Bus address. |
| devAddress | number | Device address. | | devAddress | number | Yes | Device address. |
| serial | string | Sequence number. | | serial | string | Yes | Sequence number. |
| name | string | Device name. | | name | string | Yes | Device name. |
| manufacturerName | string | Device manufacturer. | | manufacturerName | string | Yes | Device manufacturer. |
| productName | string | Product name. | | productName | string | Yes | Product name. |
| version | string | Version number. | | version | string | Yes | Version number. |
| vendorId | number | Vendor ID. | | vendorId | number | Yes | Vendor ID. |
| productId | number | Product ID. | | productId | number | Yes | Product ID. |
| clazz | number | Device class. | | clazz | number | Yes | Device class. |
| subClass | number | Device subclass. | | subClass | number | Yes | Device subclass. |
| protocol | number | Device protocol code. | | protocol | number | Yes | Device protocol code. |
| configs | Array&lt;[USBConfig](#usbconfig)&gt; | Device configuration descriptor information.| | configs | Array&lt;[USBConfig](#usbconfig)&gt; | Yes | Device configuration descriptor information.|
## USBDevicePipe ## USBDevicePipe
...@@ -709,10 +709,10 @@ Represents a USB device pipe, which is used to determine a USB device. ...@@ -709,10 +709,10 @@ Represents a USB device pipe, which is used to determine a USB device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ----- | | -------- | ------- | --------- | ----------- |
| busNum | number | Bus address.| | busNum | number | Yes | Bus address.|
| devAddress | number | Device address.| | devAddress | number | Yes | Device address.|
## USBControlParams ## USBControlParams
...@@ -720,14 +720,14 @@ Represents control transfer parameters. ...@@ -720,14 +720,14 @@ Represents control transfer parameters.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| ------- | ----------------------------------------------- | ---------------- | | -------- | ------- | --------- | ----------- |
| request | number | Request type. | | request | number | Yes | Request type. |
| target | [USBRequestTargetType](#usbrequesttargettype) | Request target type. | | target | [USBRequestTargetType](#usbrequesttargettype) | Yes | Request target type. |
| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Control request type. | | reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes | Control request type. |
| value | number | Request parameter value. | | value | number | Yes | Request parameter value. |
| index | number | Index of the request parameter value.| | index | number | Yes | Index of the request parameter value.|
| data | Uint8Array | Buffer for writing or reading data. | | data | Uint8Array | Yes | Buffer for writing or reading data. |
## USBPort<sup>9+</sup> ## USBPort<sup>9+</sup>
...@@ -737,11 +737,11 @@ Represents a USB port. ...@@ -737,11 +737,11 @@ Represents a USB port.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type | Description | | Name | Type | Mandatory | Description |
| -------------- | -------------------------------- | ----------------------------------- | | -------- | ------- | --------- | ----------- |
| id | number | Unique identifier of a USB port. | | id | number | Yes | Unique identifier of a USB port. |
| supportedModes | [PortModeType](#portmodetype9) | Numeric mask combination for the supported mode list.| | supportedModes | [PortModeType](#portmodetype9) | Yes | Numeric mask combination for the supported mode list.|
| status | [USBPortStatus](#usbportstatus9) | USB port role. | | status | [USBPortStatus](#usbportstatus9) | Yes | USB port role. |
## USBPortStatus<sup>9+</sup> ## USBPortStatus<sup>9+</sup>
...@@ -751,11 +751,11 @@ Enumerates USB port roles. ...@@ -751,11 +751,11 @@ Enumerates USB port roles.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Type| Description | | Name | Type | Mandatory | Description |
| ---------------- | -------- | ---------------------- | | -------- | ------- | --------- | ----------- |
| currentMode | number | Current USB mode. | | currentMode | number | Yes | Current USB mode. |
| currentPowerRole | number | Current power role. | | currentPowerRole | number | Yes | Current power role. |
| currentDataRole | number | Current data role.| | currentDataRole | number | Yes | Current data role. |
## USBRequestTargetType ## USBRequestTargetType
......
...@@ -720,14 +720,14 @@ Represents the USB endpoint from which data is sent or received. You can obtain ...@@ -720,14 +720,14 @@ Represents the USB endpoint from which data is sent or received. You can obtain
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| ------------- | ------------------------------------------- | ------------- |------------- | | ------------- | ------------------------------------------- | ------------- |------------- |
| address | number | Yes|Endpoint address. | | address | number | Yes | Endpoint address. |
| attributes | number | Yes|Endpoint attributes. | | attributes | number | Yes | Endpoint attributes. |
| interval | number | Yes|Endpoint interval. | | interval | number | Yes | Endpoint interval. |
| maxPacketSize | number | Yes|Maximum size of data packets on the endpoint. | | maxPacketSize | number | Yes | Maximum size of data packets on the endpoint. |
| direction | [USBRequestDirection](#usbrequestdirection) | Yes|Endpoint direction. | | direction | [USBRequestDirection](#usbrequestdirection) | Yes | Endpoint direction. |
| number | number | Yes|Endpoint number. | | number | number | Yes | Endpoint number. |
| type | number | Yes|Endpoint type. | | type | number | Yes | Endpoint type. |
| interfaceId | number | Yes|Unique ID of the interface to which the endpoint belongs.| | interfaceId | number | Yes | Unique ID of the interface to which the endpoint belongs.|
## USBInterface ## USBInterface
...@@ -737,13 +737,13 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U ...@@ -737,13 +737,13 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| ---------------- | ---------------------------------------- | ------------- |--------------------- | | ---------------- | ---------------------------------------- | ------------- |--------------------- |
| id | number | Yes|Unique ID of the USB interface. | | id | number | Yes | Unique ID of the USB interface. |
| protocol | number | Yes|Interface protocol. | | protocol | number | Yes | Interface protocol. |
| clazz | number | Yes|Device type. | | clazz | number | Yes | Device type. |
| subClass | number | Yes|Device subclass. | | subClass | number | Yes | Device subclass. |
| alternateSetting | number | Yes|Settings for alternating between descriptors of the same USB interface.| | alternateSetting | number | Yes | Settings for alternating between descriptors of the same USB interface.|
| name | string | Yes|Interface name. | | name | string | Yes | Interface name. |
| endpoints | Array&lt;[USBEndpoint](#usbendpoint)&gt; | Yes|Endpoints that belong to the USB interface. | | endpoints | Array&lt;[USBEndpoint](#usbendpoint)&gt; | Yes | Endpoints that belong to the USB interface. |
## USBConfig ## USBConfig
...@@ -753,13 +753,13 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip ...@@ -753,13 +753,13 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| -------------- | ------------------------------------------------ | --------------- |--------------- | | -------------- | ------------------------------------------------ | --------------- |--------------- |
| id | number | Yes|Unique ID of the USB configuration. | | id | number | Yes | Unique ID of the USB configuration. |
| attributes | number | Yes|Configuration attributes. | | attributes | number | Yes | Configuration attributes. |
| maxPower | number | Yes|Maximum power consumption, in mA. | | maxPower | number | Yes | Maximum power consumption, in mA. |
| name | string | Yes|Configuration name, which can be left empty. | | name | string | Yes | Configuration name, which can be left empty. |
| isRemoteWakeup | boolean | Yes|Support for remote wakeup.| | isRemoteWakeup | boolean | Yes | Support for remote wakeup.|
| isSelfPowered | boolean | Yes| Support for independent power supplies.| | isSelfPowered | boolean | Yes | Support for independent power supplies.|
| interfaces | Array&nbsp;&lt;[USBInterface](#usbinterface)&gt; | Yes|Supported interface attributes. | | interfaces | Array&nbsp;&lt;[USBInterface](#usbinterface)&gt; | Yes | Supported interface attributes. |
## USBDevice ## USBDevice
...@@ -769,19 +769,19 @@ Represents the USB device information. ...@@ -769,19 +769,19 @@ Represents the USB device information.
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| ---------------- | ------------------------------------ | ---------- |---------- | | ---------------- | ------------------------------------ | ---------- |---------- |
| busNum | number | Yes|Bus address. | | busNum | number | Yes | Bus address. |
| devAddress | number | Yes|Device address. | | devAddress | number | Yes | Device address. |
| serial | string | Yes|Sequence number. | | serial | string | Yes | Sequence number. |
| name | string | Yes|Device name. | | name | string | Yes | Device name. |
| manufacturerName | string | Yes| Device manufacturer. | | manufacturerName | string | Yes | Device manufacturer. |
| productName | string | Yes|Product name. | | productName | string | Yes | Product name. |
| version | string | Yes|Version number. | | version | string | Yes | Version number. |
| vendorId | number | Yes|Vendor ID. | | vendorId | number | Yes | Vendor ID. |
| productId | number | Yes|Product ID. | | productId | number | Yes | Product ID. |
| clazz | number | Yes|Device class. | | clazz | number | Yes | Device class. |
| subClass | number | Yes|Device subclass. | | subClass | number | Yes | Device subclass. |
| protocol | number | Yes|Device protocol code. | | protocol | number | Yes | Device protocol code. |
| configs | Array&lt;[USBConfig](#usbconfig)&gt; | Yes|Device configuration descriptor information.| | configs | Array&lt;[USBConfig](#usbconfig)&gt; | Yes | Device configuration descriptor information.|
## USBDevicePipe ## USBDevicePipe
...@@ -802,12 +802,12 @@ Represents control transfer parameters. ...@@ -802,12 +802,12 @@ Represents control transfer parameters.
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| ------- | ----------------------------------------------- | ---------------- |---------------- | | ------- | ----------------------------------------------- | ---------------- |---------------- |
| request | number | Yes |Request type. | | request | number | Yes | Request type. |
| target | [USBRequestTargetType](#usbrequesttargettype) | Yes |Request target type. | | target | [USBRequestTargetType](#usbrequesttargettype) | Yes | Request target type. |
| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes |Control request type. | | reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes | Control request type. |
| value | number | Yes |Request parameter value. | | value | number | Yes | Request parameter value. |
| index | number | Yes |Index of the request parameter value.| | index | number | Yes | Index of the request parameter value.|
| data | Uint8Array | Yes |Buffer for writing or reading data. | | data | Uint8Array | Yes | Buffer for writing or reading data. |
## USBPort ## USBPort
...@@ -819,9 +819,9 @@ Represents a USB port. ...@@ -819,9 +819,9 @@ Represents a USB port.
| Name | Type | Mandatory |Description | | Name | Type | Mandatory |Description |
| -------------- | ------------------------------- | ------------------- |------------------------ | | -------------- | ------------------------------- | ------------------- |------------------------ |
| id | number | Yes |Unique identifier of a USB port. | | id | number | Yes | Unique identifier of a USB port. |
| supportedModes | [PortModeType](#portmodetype) | Yes |Numeric mask combination for the supported mode list.| | supportedModes | [PortModeType](#portmodetype) | Yes | Numeric mask combination for the supported mode list.|
| status | [USBPortStatus](#usbportstatus) | Yes |USB port role. | | status | [USBPortStatus](#usbportstatus) | Yes | USB port role. |
## USBPortStatus ## USBPortStatus
...@@ -833,9 +833,9 @@ Enumerates USB port roles. ...@@ -833,9 +833,9 @@ Enumerates USB port roles.
| Name | Type| Mandatory |Description | | Name | Type| Mandatory |Description |
| ---------------- | -------- | ---------------- |---------------------- | | ---------------- | -------- | ---------------- |---------------------- |
| currentMode | number | Yes|Current USB mode. | | currentMode | number | Yes | Current USB mode. |
| currentPowerRole | number | Yes |Current power role. | | currentPowerRole | number | Yes | Current power role. |
| currentDataRole | number | Yes |Current data role.| | currentDataRole | number | Yes | Current data role.|
## USBRequestTargetType ## USBRequestTargetType
...@@ -844,11 +844,11 @@ Enumerates request target types. ...@@ -844,11 +844,11 @@ Enumerates request target types.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
| Name | Value | Description | | Name | Value | Description |
| ---------------------------- | ---- | ------ | | ---------------------------- | ----- | ----------- |
| USB_REQUEST_TARGET_DEVICE | 0 | Device| | USB_REQUEST_TARGET_DEVICE | 0 | Device |
| USB_REQUEST_TARGET_INTERFACE | 1 | Interface| | USB_REQUEST_TARGET_INTERFACE | 1 | Interface |
| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint| | USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint |
| USB_REQUEST_TARGET_OTHER | 3 | Other| | USB_REQUEST_TARGET_OTHER | 3 | Other |
## USBControlRequestType ## USBControlRequestType
......
# LCD # LCD
## Overview ## Overview
### Function
The Liquid Crystal Display (LCD) driver performs operations such as powering on the LCD and initializing the internal registers of the driver integrated circuits (ICs). The Liquid Crystal Display (LCD) driver performs operations such as powering on the LCD and initializing the internal registers of the driver integrated circuits (ICs).
The display driver model developed based on the Hardware Driver Foundation [(HDF)](../driver/driver-hdf-overview.md) provides a basic framework for LCD driver development, improves driver development efficiency, and facilitates porting of the driver across OSs and chip platforms. The figure below shows the HDF-based display driver model. The display driver model based on the [Hardware Driver Foundation (HDF)](../driver/driver-hdf-overview.md) provides the following functions:
- Provides a basic framework for LCD driver development to improve development efficiency.
- Facilitates driver porting across OSs and chip platforms.
The following figure shows the HDF-based display driver model.
**Figure 1** HDF-based display driver model **Figure 1** HDF-based display driver model
![image](figures/architecture-of-the-display-driver-model.png "Display Driver Model") ![image](figures/architecture-of-the-display-driver-model.png "Display Driver Model")
The display driver model consists of the display common driver layer, SoC adapter layer, and LCD panel driver layer. The HDF-based display driver model shields the differences between kernel forms through platform and OSAL APIs so that the LCD driver can be easily ported across OSs and chip platforms. The display driver model connects to the display common Hardware Abstraction Layer (HAL), supports the implementation of the Hardware Device Interface (HDI), and provides various driver capability interfaces for graphics services through the Display-HDI.
The display driver model consists of the display common driver layer, SoC adapter layer, and LCD panel driver layer. The HDF-based display driver model shields the differences between kernel forms through platform and OSAL APIs so the LCD driver can be easily ported between different OSs and chip platforms. The display driver model connects to the display common Hardware Abstraction Layer (HAL), supports the implementation of the Hardware Device Interface (HDI), and provides various driver capability interfaces for graphics services through the Display-HDI.
- Display common driver layer: connects to the display common HAL through the IOService data channel provided by the HDF to receive and process various upper-layer calls in a centralized manner. - Display common driver layer: connects to the display common HAL through the IOService data channel provided by the HDF to receive and process various upper-layer calls in a centralized manner.
...@@ -23,8 +29,7 @@ The display driver model consists of the display common driver layer, SoC adapte ...@@ -23,8 +29,7 @@ The display driver model consists of the display common driver layer, SoC adapte
The display driver model leverages the capabilities and APIs provided by the platform to simplify the display driver development and improve the efficiency. The display driver model leverages the capabilities and APIs provided by the platform to simplify the display driver development and improve the efficiency.
### Basic Concepts
## Available APIs
The LCD interfaces include the Mobile Industry Processor Interface (MIPI) Display Serial Interface (DSI), Transistor-Transistor Logic (TTL) interface, and Low Voltage Differential Signaling (LVDS) interface. The MIPI DSI and TTL interfaces are commonly used. Here is a brief introduction to them. The LCD interfaces include the Mobile Industry Processor Interface (MIPI) Display Serial Interface (DSI), Transistor-Transistor Logic (TTL) interface, and Low Voltage Differential Signaling (LVDS) interface. The MIPI DSI and TTL interfaces are commonly used. Here is a brief introduction to them.
...@@ -42,14 +47,31 @@ The LCD interfaces include the Mobile Industry Processor Interface (MIPI) Displa ...@@ -42,14 +47,31 @@ The LCD interfaces include the Mobile Industry Processor Interface (MIPI) Displa
![](figures/ttl-interface.png "ttl-interface") ![](figures/ttl-interface.png "ttl-interface")
TTL level signals are generated by TTL devices, which are a major type of digital integrated circuits. TTL devices are manufactured using the bipolar process and feature high speed, low power consumption, and diversified types. TTL level signals are generated by TTL devices, which are a major type of digital integrated circuits. TTL devices are manufactured using the bipolar process and feature high speed, low power consumption, and diversified types.
The TTL interface is used to transmit data in parallel mode under control signals. It transmits data signals, clock signals, and control signals (such as line synchronization signals, frame synchronization signals, and data validity signals). For the LCD with the TTL, additional peripheral interfaces, such as the Serial Peripheral Interface (SPI) and Inter-Integrated Circuit (I2C), are required for the read and write of the internal registers. The TTL interface is used to transmit data in parallel mode under control signals. It transmits data signals, clock signals, and control signals (such as line synchronization signals, frame synchronization signals, and data validity signals). For the LCD with the TTL, additional peripheral interfaces, such as the Serial Peripheral Interface (SPI) and Inter-Integrated Circuit (I2C), are required for the read and write of the internal registers.
### Constraints
In addition to the IC model, you must consider the LCD peripheral circuit design, LCD interface unit of the baseband chip, backlight IC control, and upper-layer software programs. All these factors affect the development of the LCD driver.
## Development Guidelines
### When to Use
## How to Develop Before applying your device with OpenHarmony system, you need to perform LCD driver adaption. The HDF-based display driver model provides a unified driver model for LCD adaptation regardless of the OS (LiteOS or Linux OS) and chip platform (Hi35xx, Hi38xx, or V3S).
The HDF-based display driver model provides a unified driver model for LCDs regardless of the OS (LiteOS or Linux OS) and chip platform (Hi35xx, Hi38xx, or V3S). The development procedure is as follows: ### Available APIs
Table 1 APIs required for LCD driver adaptation
| API | Description |
| :------------------------------------------------------ | ------------------- |
| display :: host | Sets device information. |
| static int32_t LcdResetOn(void) | Sets the status of the reset pin.|
| int32_t SampleEntryInit(struct HdfDeviceObject *object) | Initializes the entry function of the device driver. |
### How to Develop
1. Add the device configuration related to the LCD driver. 1. Add the device configuration related to the LCD driver.
...@@ -58,23 +80,26 @@ The HDF-based display driver model provides a unified driver model for LCDs rega ...@@ -58,23 +80,26 @@ The HDF-based display driver model provides a unified driver model for LCDs rega
3. Add the LCD panel driver and register the panel driver functions in the driver entry function **Init**. The functions provide capabilities for: 3. Add the LCD panel driver and register the panel driver functions in the driver entry function **Init**. The functions provide capabilities for:
- Powering on/off the LCD device - Powering on/off the LCD device
Based on the LCD hardware connection, use the GPIO APIs provided by the platform to perform operations on the LCD pins, such as the reset pin and IOVCC pin. For details about the power-on sequence, see the SPEC provided by the LCD supplier. Based on the LCD hardware connection, use the GPIO APIs provided by the platform to perform operations on the LCD pins, such as the reset pin and IOVCC pin. For details about the power-on sequence, see the SPEC provided by the LCD supplier.
- Sending the initialization sequence - Sending the initialization sequence
Based on the LCD hardware interfaces, use the I2C, SPI, and MIPI interfaces provided by the platform to download the LCD initialization sequence. For details, see the SPEC provided by the LCD supplier.
4. Implement other HDF APIs as required, for example, **Release()**. Based on the LCD hardware interfaces, use the I2C, SPI, and MIPI interfaces provided by the platform to download the LCD initialization sequence. For details, see the SPEC provided by the LCD supplier.
5. Use the HDF to create other device nodes for implementing service logic or debugging as required. 4. (Optional) Implement other HDF APIs, such as **Release()**, as required.
5. (Optional) Create other device nodes for implementing service logic or debugging based on the HDF as required.
## Development Example ### Example
Add the device configuration. The following uses the Hi35xx series chips as an example to describe how to perform LCD driver adaptation.
1. Add device information in the **vendor/bearpi/bearpi_hm_micro/hdf_config/device_info/device_info.hcs** file.
``` ```c++
/* Configuration of the devices related to the display driver */ /* Configuration of the devices related to the display driver */
display :: host { display :: host {
hostName = "display_host"; hostName = "display_host";
/* Configuration of the HDF display driver */ /* Configuration of the HDF display driver */
device_hdf_disp :: device { device_hdf_disp :: device {
...@@ -109,15 +134,15 @@ display :: host { ...@@ -109,15 +134,15 @@ display :: host {
moduleName = "LCD_SampleXX"; moduleName = "LCD_SampleXX";
} }
} }
} }
``` ```
Adapt the driver to the chip at the SoC adapter layer. The following example shows how to adapt the MIPI device to the Hi35xx series chips at the SoC adapter layer:
2. Configure the chip platform driver information in the **drivers/hdf_core/framework/model/display/driver/adapter_soc/hi35xx_disp.c file**.
``` ```c++
static int32_t MipiDsiInit(struct PanelInfo *info) /* Configuration of the display driver to adapt to the MIPI and chip platform */
{ static int32_t MipiDsiInit(struct PanelInfo *info)
{
int32_t ret; int32_t ret;
struct DevHandle *mipiHandle = NULL; struct DevHandle *mipiHandle = NULL;
struct MipiCfg cfg; struct MipiCfg cfg;
...@@ -152,34 +177,37 @@ static int32_t MipiDsiInit(struct PanelInfo *info) ...@@ -152,34 +177,37 @@ static int32_t MipiDsiInit(struct PanelInfo *info)
HDF_LOGI("%s:pixelClk = %d, phyDataRate = %d\n", __func__, HDF_LOGI("%s:pixelClk = %d, phyDataRate = %d\n", __func__,
cfg.pixelClk, cfg.phyDataRate); cfg.pixelClk, cfg.phyDataRate);
return ret; return ret;
} }
``` ```
Develop an LCD driver. The sample code is as follows: 3. Add a device in **drivers/hdf_core/framework/model/display/driver/panel/mipi_icn9700.c**.
- Define driver-related interface information.
```
#define RESET_GPIO 5 ```c++
#define MIPI_DSI0 0 #define RESET_GPIO 5
#define BLK_PWM1 1 #define MIPI_DSI0 0
#define PWM_MAX_PERIOD 100000 #define BLK_PWM1 1
/* Set the backlight. */ #define PWM_MAX_PERIOD 100000
#define MIN_LEVEL 0 /* Set the backlight. */
#define MAX_LEVEL 255 #define MIN_LEVEL 0
#define DEFAULT_LEVEL 100 #define MAX_LEVEL 255
#define DEFAULT_LEVEL 100
#define WIDTH 480 #define WIDTH 480
#define HEIGHT 960 #define HEIGHT 960
#define HORIZONTAL_BACK_PORCH 20 #define HORIZONTAL_BACK_PORCH 20
#define HORIZONTAL_FRONT_PORCH 20 #define HORIZONTAL_FRONT_PORCH 20
#define HORIZONTAL_SYNC_WIDTH 10 #define HORIZONTAL_SYNC_WIDTH 10
#define VERTICAL_BACK_PORCH 14 #define VERTICAL_BACK_PORCH 14
#define VERTICAL_FRONT_PORCH 16 #define VERTICAL_FRONT_PORCH 16
#define VERTICAL_SYNC_WIDTH 2 #define VERTICAL_SYNC_WIDTH 2
#define FRAME_RATE 60 #define FRAME_RATE 60
```
/* PanelInfo structure */
struct PanelInfo { - Define the **PanelInfo** structure.
```c++
struct PanelInfo {
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
uint32_t hbp; uint32_t hbp;
...@@ -194,64 +222,46 @@ struct PanelInfo { ...@@ -194,64 +222,46 @@ struct PanelInfo {
struct MipiDsiDesc mipi; struct MipiDsiDesc mipi;
struct BlkDesc blk; struct BlkDesc blk;
struct PwmCfg pwm; struct PwmCfg pwm;
}; };
```
/* Initialization sequence of the LCD panel */
static uint8_t g_payLoad0[] = { 0xF0, 0x5A, 0x5A }; - Initialize the LCD.
static uint8_t g_payLoad1[] = { 0xF1, 0xA5, 0xA5 };
static uint8_t g_payLoad2[] = { 0xB3, 0x03, 0x03, 0x03, 0x07, 0x05, 0x0D, 0x0F, 0x11, 0x13, 0x09, 0x0B }; ```c++
static uint8_t g_payLoad3[] = { 0xB4, 0x03, 0x03, 0x03, 0x06, 0x04, 0x0C, 0x0E, 0x10, 0x12, 0x08, 0x0A }; static uint8_t g_payLoad0[] = { 0xF0, 0x5A, 0x5A };
static uint8_t g_payLoad4[] = { 0xB0, 0x54, 0x32, 0x23, 0x45, 0x44, 0x44, 0x44, 0x44, 0x60, 0x00, 0x60, 0x1C }; static uint8_t g_payLoad1[] = { 0xF1, 0xA5, 0xA5 };
static uint8_t g_payLoad5[] = { 0xB1, 0x32, 0x84, 0x02, 0x87, 0x12, 0x00, 0x50, 0x1C }; static uint8_t g_payLoad2[] = { 0xB3, 0x03, 0x03, 0x03, 0x07, 0x05, 0x0D, 0x0F, 0x11, 0x13, 0x09, 0x0B };
static uint8_t g_payLoad6[] = { 0xB2, 0x73, 0x09, 0x08 }; static uint8_t g_payLoad3[] = { 0xB4, 0x03, 0x03, 0x03, 0x06, 0x04, 0x0C, 0x0E, 0x10, 0x12, 0x08, 0x0A };
static uint8_t g_payLoad7[] = { 0xB6, 0x5C, 0x5C, 0x05 }; static uint8_t g_payLoad4[] = { 0xB0, 0x54, 0x32, 0x23, 0x45, 0x44, 0x44, 0x44, 0x44, 0x60, 0x00, 0x60, 0x1C };
static uint8_t g_payLoad8[] = { 0xB8, 0x23, 0x41, 0x32, 0x30, 0x03 }; static uint8_t g_payLoad5[] = { 0xB1, 0x32, 0x84, 0x02, 0x87, 0x12, 0x00, 0x50, 0x1C };
static uint8_t g_payLoad9[] = { 0xBC, 0xD2, 0x0E, 0x63, 0x63, 0x5A, 0x32, 0x22, 0x14, 0x22, 0x03 }; static uint8_t g_payLoad6[] = { 0xB2, 0x73, 0x09, 0x08 };
static uint8_t g_payLoad10[] = { 0xb7, 0x41 }; static uint8_t g_payLoad7[] = { 0xB6, 0x5C, 0x5C, 0x05 };
static uint8_t g_payLoad11[] = { 0xC1, 0x0c, 0x10, 0x04, 0x0c, 0x10, 0x04 }; static uint8_t g_payLoad8[] = { 0xB8, 0x23, 0x41, 0x32, 0x30, 0x03 };
static uint8_t g_payLoad12[] = { 0xC2, 0x10, 0xE0 }; static uint8_t g_payLoad9[] = { 0xBC, 0xD2, 0x0E, 0x63, 0x63, 0x5A, 0x32, 0x22, 0x14, 0x22, 0x03 };
static uint8_t g_payLoad13[] = { 0xC3, 0x22, 0x11 }; static uint8_t g_payLoad10[] = { 0xb7, 0x41 };
static uint8_t g_payLoad14[] = { 0xD0, 0x07, 0xFF }; static uint8_t g_payLoad11[] = { 0xC1, 0x0c, 0x10, 0x04, 0x0c, 0x10, 0x04 };
static uint8_t g_payLoad15[] = { 0xD2, 0x63, 0x0B, 0x08, 0x88 }; static uint8_t g_payLoad12[] = { 0xC2, 0x10, 0xE0 };
static uint8_t g_payLoad16[] = { 0xC6, 0x08, 0x15, 0xFF, 0x10, 0x16, 0x80, 0x60 }; static uint8_t g_payLoad13[] = { 0xC3, 0x22, 0x11 };
static uint8_t g_payLoad17[] = { 0xc7, 0x04 }; static uint8_t g_payLoad14[] = { 0xD0, 0x07, 0xFF };
static uint8_t g_payLoad18[] = { static uint8_t g_payLoad15[] = { 0xD2, 0x63, 0x0B, 0x08, 0x88 };
static uint8_t g_payLoad16[] = { 0xC6, 0x08, 0x15, 0xFF, 0x10, 0x16, 0x80, 0x60 };
static uint8_t g_payLoad17[] = { 0xc7, 0x04 };
static uint8_t g_payLoad18[] = {
0xC8, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x43, 0x4C, 0x40, 0xC8, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x43, 0x4C, 0x40,
0x3D, 0x30, 0x1E, 0x06, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x3D, 0x30, 0x1E, 0x06, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52,
0x43, 0x4C, 0x40, 0x3D, 0x30, 0x1E, 0x06 0x43, 0x4C, 0x40, 0x3D, 0x30, 0x1E, 0x06
}; };
static uint8_t g_payLoad19[] = { 0x11 }; static uint8_t g_payLoad19[] = { 0x11 };
static uint8_t g_payLoad20[] = { 0x29 }; static uint8_t g_payLoad20[] = { 0x29 };
static DevHandle g_mipiHandle = NULL;
struct DsiCmdDesc g_OnCmd[] = { static DevHandle g_pwmHandle = NULL;
{ 0x29, 0, sizeof(g_payLoad0), g_payLoad0 }, ```
{ 0x29, 0, sizeof(g_payLoad1), g_payLoad1 },
{ 0x29, 0, sizeof(g_payLoad2), g_payLoad2 }, - Set the status of the reset pin.
{ 0x29, 0, sizeof(g_payLoad3), g_payLoad3 },
{ 0x29, 0, sizeof(g_payLoad4), g_payLoad4 }, ```c++
{ 0x29, 0, sizeof(g_payLoad5), g_payLoad5 }, static int32_t LcdResetOn(void)
{ 0x29, 0, sizeof(g_payLoad6), g_payLoad6 }, {
{ 0x29, 0, sizeof(g_payLoad7), g_payLoad7 },
{ 0x29, 0, sizeof(g_payLoad8), g_payLoad8 },
{ 0x29, 0, sizeof(g_payLoad9), g_payLoad9 },
{ 0x23, 0, sizeof(g_payLoad10), g_payLoad10 },
{ 0x29, 0, sizeof(g_payLoad11), g_payLoad11 },
{ 0x29, 0, sizeof(g_payLoad12), g_payLoad12 },
{ 0x29, 0, sizeof(g_payLoad13), g_payLoad13 },
{ 0x29, 0, sizeof(g_payLoad14), g_payLoad14 },
{ 0x29, 0, sizeof(g_payLoad15), g_payLoad15 },
{ 0x29, 0, sizeof(g_payLoad16), g_payLoad16 },
{ 0x23, 0, sizeof(g_payLoad17), g_payLoad17 },
{ 0x29, 1, sizeof(g_payLoad18), g_payLoad18 },
{ 0x05, 120, sizeof(g_payLoad19), g_payLoad19 },
{ 0x05, 120, sizeof(g_payLoad20), g_payLoad20 },
};
static DevHandle g_mipiHandle = NULL;
static DevHandle g_pwmHandle = NULL;
/* Set the status of the reset pin. */
static int32_t LcdResetOn(void)
{
int32_t ret; int32_t ret;
ret = GpioSetDir(RESET_GPIO, GPIO_DIR_OUT); ret = GpioSetDir(RESET_GPIO, GPIO_DIR_OUT);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
...@@ -266,79 +276,14 @@ static int32_t LcdResetOn(void) ...@@ -266,79 +276,14 @@ static int32_t LcdResetOn(void)
/* Set the delay to 20 ms. */ /* Set the delay to 20 ms. */
OsalMSleep(20); OsalMSleep(20);
return HDF_SUCCESS; return HDF_SUCCESS;
}
static int32_t SampleInit(void)
{
/* Open the MIPI DSI device handle. */
g_mipiHandle = MipiDsiOpen(MIPI_DSI0);
if (g_mipiHandle == NULL) {
HDF_LOGE("%s: MipiDsiOpen failure", __func__);
return HDF_FAILURE;
} }
return HDF_SUCCESS; ```
}
static int32_t SampleOn(void) - Initialize the entry function of the device driver.
{
int32_t ret; ```c++
/* Power on the LCD. */ int32_t SampleEntryInit(struct HdfDeviceObject *object)
ret = LcdResetOn(); {
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: LcdResetOn failure", __func__);
return HDF_FAILURE;
}
if (g_mipiHandle == NULL) {
HDF_LOGE("%s: g_mipiHandle is null", __func__);
return HDF_FAILURE;
}
/* Send the initialization sequence via MIPI. */
int32_t count = sizeof(g_OnCmd) / sizeof(g_OnCmd[0]);
int32_t i;
for (i = 0; i < count; i++) {
ret = MipiDsiTx(g_mipiHandle, &(g_OnCmd[i]));
if (ret != HDF_SUCCESS) {
HDF_LOGE("MipiDsiTx failure");
return HDF_FAILURE;
}
}
/* Set MIPI to the high speed (HS) mode. */
MipiDsiSetHsMode(g_mipiHandle);
return HDF_SUCCESS;
}
/* PanelInfo structure variables */
static struct PanelInfo g_panelInfo = {
.width = WIDTH, /* width */
.height = HEIGHT, /* height */
.hbp = HORIZONTAL_BACK_PORCH, /* horizontal back porch */
.hfp = HORIZONTAL_FRONT_PORCH, /* horizontal front porch */
.hsw = HORIZONTAL_SYNC_WIDTH, /* horizontal sync width */
.vbp = VERTICAL_BACK_PORCH, /* vertical back porch */
.vfp = VERTICAL_FRONT_PORCH, /* vertical front porch */
.vsw = VERTICAL_SYNC_WIDTH, /* vertical sync width */
.frameRate = FRAME_RATE, /* frame rate */
.intfType = MIPI_DSI, /* panel interface type */
.intfSync = OUTPUT_USER, /* output timing type */
/* MIPI configuration */
.mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT },
/* backlight config info */
.blk = { BLK_PWM, MIN_LEVEL, MAX_LEVEL, DEFAULT_LEVEL },
.pwm = { BLK_PWM1, PWM_MAX_PERIOD },
};
/* Basic APIs that need to be adapted for the chip driver */
static struct PanelData g_panelData = {
.info = &g_panelInfo,
.init = SampleInit,
.on = SampleOn,
.off = SampleOff,
.setBacklight = SampleSetBacklight,
};
/* Entry function of the chip driver */
int32_t SampleEntryInit(struct HdfDeviceObject *object)
{
HDF_LOGI("%s: enter", __func__); HDF_LOGI("%s: enter", __func__);
if (object == NULL) { if (object == NULL) {
HDF_LOGE("%s: param is null!", __func__); HDF_LOGE("%s: param is null!", __func__);
...@@ -350,13 +295,13 @@ int32_t SampleEntryInit(struct HdfDeviceObject *object) ...@@ -350,13 +295,13 @@ int32_t SampleEntryInit(struct HdfDeviceObject *object)
return HDF_FAILURE; return HDF_FAILURE;
} }
return HDF_SUCCESS; return HDF_SUCCESS;
} }
struct HdfDriverEntry g_sampleDevEntry = { struct HdfDriverEntry g_sampleDevEntry = {
.moduleVersion = 1, .moduleVersion = 1,
.moduleName = "LCD_SAMPLE", .moduleName = "LCD_SAMPLE",
.Init = SampleEntryInit, .Init = SampleEntryInit,
}; };
HDF_INIT(g_sampleDevEntry); HDF_INIT(g_sampleDevEntry);
``` ```
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
### Function ### Function
The motion module provides motion recognition and control capabilities. Currently, OpenHarmony supports recognition of pick-up, flip, shake, and rotation. The motion module provides motion recognition and control capabilities. OpenHarmony supports recognition of pick-up, flip, shake, and rotation.
The motion driver is developed based on the hardware driver foundation (HDF). It shields hardware differences and provides APIs for the Multimodal Sensor Data Platform (MSDP) to implement capabilities such as enabling or disabling motion recognition, and subscribing to or unsubscribing from motion recognition data. The motion driver is developed based on the hardware driver foundation (HDF). It shields hardware differences and provides APIs for the Multimodal Sensor Data Platform (MSDP) to implement capabilities such as enabling or disabling motion recognition, and subscribing to or unsubscribing from motion recognition data.
The figure below shows the motion driver architecture. The framework layer provides MSDP services, and interacts with the Motion Stub through the Motion Proxy in the User Hardware Driver Foundation (UHDF). The Motion Stub calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services. The following figure shows the motion driver architecture. The framework layer provides MSDP services, and interacts with the Motion Stub through the Motion Proxy in the User Hardware Driver Foundation (UHDF). The Motion Stub calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services.
**Figure 1** Motion driver architecture **Figure 1** Motion driver architecture
...@@ -24,7 +24,7 @@ The figure below illustrates how a motion driver works. ...@@ -24,7 +24,7 @@ The figure below illustrates how a motion driver works.
1. MSDP: The MSDP service obtains a Motion HDI service instance from the Motion Proxy and calls the Motion HDI API. 1. MSDP: The MSDP service obtains a Motion HDI service instance from the Motion Proxy and calls the Motion HDI API.
2. IDL: The IService Manager allocates a Motion HDI instance requested by the MSDP service, and the Motion Proxy forwards the instance to the MSDP service. After the MSDP service calls the HDI API provided by the Motion Proxy, Motion Stub is called through Inter-Process Communication (IPC) to invoke the Motion Service API. The code is automatically generated by a tool and does not need to be developed by the component vendor. 2. IDL: The IService Manager allocates a Motion HDI instance requested by the MSDP service, and the Motion Proxy forwards the instance to the MSDP service. After the MSDP service calls the HDI API provided by the Motion Proxy, Motion Stub is called through Inter-Process Communication (IPC) to invoke the Motion Service API. The code is automatically generated by a tool and does not need to be developed by the component vendor.
3. HDI Service: HDI Service consists of Motion Interface Driver, Motion Service, and Motion Impl. Motion Interface Driver provides the motion driver code. A **HdfDriverEntry** structure is defined to implement the **Init**, **Bind**, and **Release** functions. The **HDF_INIT** macro is used to load the driver in the functions. Motion Service provides the motion recognition service interface class. The specific implementation is described in Motion Impl. The code of HDI Service must be developed by the component vendor. 3. HDI Service: The HDI service consists of Motion Interface Driver, Motion Service, and Motion Impl. Motion Interface Driver provides the motion driver code. A **HdfDriverEntry** structure is defined to implement the **Init**, **Bind**, and **Release** functions. The **HDF_INIT** macro is used to load the driver in the functions. Motion Service provides the motion recognition service interface class. The specific implementation is described in Motion Impl. The code of HDI Service must be developed by the component vendor.
## Development Guidelines ## Development Guidelines
...@@ -61,7 +61,7 @@ The motion recognition directory structure is as follows: ...@@ -61,7 +61,7 @@ The motion recognition directory structure is as follows:
The following describes how to develop a user-mode motion driver based on the HDF. For details, see [motion_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/motion/hdi_service/motion_interface_driver.cpp). The following describes how to develop a user-mode motion driver based on the HDF. For details, see [motion_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/motion/hdi_service/motion_interface_driver.cpp).
To develop the user-mode driver for motion recognition, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions. The **Bind** function provides service capabilities. The **Init** function initializes the driver before the driver is loaded. The **Release** function releases resources when the **Init** function fails. You need to implement the **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions. The **Bind()** function binds the service capability with the driver; **Init()** implements the initialization required before the driver is loaded; **Release()** reclaims resources when **Init()** fails; **Dispatch()** implements the service, which is bound in **Bind()**.
```c++ ```c++
// Custom HdfMotionInterfaceHost object // Custom HdfMotionInterfaceHost object
...@@ -153,7 +153,6 @@ struct HdfDriverEntry g_motioninterfaceDriverEntry = { ...@@ -153,7 +153,6 @@ struct HdfDriverEntry g_motioninterfaceDriverEntry = {
HDF_INIT(g_userAuthInterfaceDriverEntry); HDF_INIT(g_userAuthInterfaceDriverEntry);
``` ```
### Verification ### Verification
The procedure is as follows: The procedure is as follows:
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
## Overview ## Overview
### Introduction ### Function
The sensor driver model masks the sensor hardware differences and provides interfaces for the upper-layer sensor service to implement basic sensor capabilities, including querying the sensor list, enabling or disabling a sensor, subscribing to or unsubscribing from sensor data changes, and setting sensor options. The model is developed on the Hardware Driver Foundation (HDF), Operating System Abstraction Layer (OSAL), and platform driver interfaces (such as the I2C, SPI, and UART buses). It provides functionalities such as cross-OS migration and differentiated device configurations. The figure below shows the architecture of the sensor driver model. The sensor driver model shields the hardware difference and provides interfaces for the upper-layer sensor service to implement basic sensor capabilities, including querying the sensor list, enabling or disabling a sensor, subscribing to or unsubscribing from sensor data changes, and setting sensor attributes. Developed based on the Hardware Driver Foundation (HDF), the sensor driver model leverages the capabilities of the OS adaptation layer (OSAL) and platform driver interfaces (such as I2C, SPI, and UART buses) to shield the difference between OSs and platform bus resources, achieving "one-time development and multi-system deployment" of the sensor driver. The figure below shows the architecture of the sensor driver model.
**Figure 1** Sensor driver model **Figure 1** Sensor driver model
...@@ -13,29 +13,29 @@ The sensor driver model masks the sensor hardware differences and provides inter ...@@ -13,29 +13,29 @@ The sensor driver model masks the sensor hardware differences and provides inter
### Basic Concepts ### Basic Concepts
Currently, sensors are classified into medical sensors and traditional sensors by sensor ID. Sensors are classified into the following types by sensor ID:
- The IDs of medical sensors range from 128 to 160. - Medical sensors: The sensor IDs range from 128 to 160.
- The IDs of traditional sensors are out of the range of 128 to 160. - Traditional sensors: The sensor IDs are out of the range of 128 to 160.
### Working Principles ### Working Principles
Based on the loading and running process (shown below) of the sensor driver model, the relationships between key modules in the model and associated modules are clearly defined. The following figure shows how a sensor driver works.
**Figure 2** How sensor driver works **Figure 2** How a sensor driver works
![How sensor driver works](figures/sensor_working.png) ![How sensor driver works](figures/sensor_working.png)
The following uses the acceleration sensor driver on the Hi3516D V300 development board of the standard system as an example to describe the driver loading and running process. The following uses the acceleration sensor driver on the Hi3516D V300 development board of the standard system as an example to describe the driver loading and running process.
1. The sensor host reads the sensor management configuration from the Sensor Host node of the device_info HCS (sensor device information HCS). 1. The sensor host reads the sensor device management configuration from **Sensor Host** in the **device_info.hcs** file.
2. The sensor host parses the sensor management configuration from the HCB database and associates the corresponding sensor driver. 2. The sensor host parses the sensor management configuration from the HCB database and associates the configuration with the sensor driver.
3. The sensor host loads and initializes the sensor manager driver. 3. The sensor host loads and initializes the sensor manager driver.
4. The sensor manager driver publishes the sensor hardware device interfaces (HDIs). 4. The sensor manager driver publishes the sensor APIs for the hardware driver interface (HDI).
5. The sensor host reads the acceleration sensor driver configuration from the Sensor Host node of the device_info HCS. 5. The sensor host reads the acceleration sensor driver configuration information from **Sensor Host** in the **device_info.hcs** configuration file.
6. The sensor host loads the acceleration sensor abstract driver and calls the initialization interface to allocate the sensor driver resources and create the data processing queue. 6. The sensor host loads the acceleration sensor abstract driver and calls the initialization interface to allocate the sensor driver resources and create the data processing queue.
7. The sensor host reads the chipset driver configuration and private configuration of the acceleration sensor from the accel_xxx_config HCS (sensor private configuration HCS). 7. The sensor host reads the chipset driver configuration and private configuration of the acceleration sensor from the **accel_xxx_config.hcs** file.
8. The acceleration sensor chipset driver calls the common configuration parsing interface to parse the sensor attributes and registers. 8. The acceleration sensor chipset driver calls the common configuration parsing interface to parse the sensor attributes and registers.
9. The chipset driver detects sensors, allocates configuration resources to the acceleration sensor, and registers the acceleration sensor chipset interfaces. 9. The chipset driver detects sensors, allocates configuration resources to the acceleration sensor, and registers the acceleration sensor chipset interfaces.
10. Upon successful sensor detection, the chipset driver instructs the abstract driver to register the acceleration sensor to the sensor manager driver. 10. Upon successful sensor detection, the chipset driver instructs the abstract driver to register the acceleration sensor to the sensor manager driver.
...@@ -54,11 +54,15 @@ The following uses the acceleration sensor driver on the Hi3516D V300 developmen ...@@ -54,11 +54,15 @@ The following uses the acceleration sensor driver on the Hi3516D V300 developmen
The sensor driver model offers the following APIs: The sensor driver model offers the following APIs:
- Sensor HDIs, for easier sensor service development - Sensor HDI APIs, for easier sensor service development
- Sensor driver model capability interfaces
- Interfaces for registering, loading, and deregistering sensor drivers, and detecting sensors - APIs for implementing sensor driver model capabilities
- Driver normalization interface, register configuration parsing interface, bus access abstract interface, and platform abstract interface for the same type of sensors - APIs for loading, registering, and deregitering sensor drivers, and detecting sensors based on the HDF
- Interfaces to be implemented by developers: Based on the HDF Configuration Source (HCS) and differentiated configuration for sensors of the same type, developers need to implement serialized configuration of sensor device parameters and some sensor device operation interfaces to simplify sensor driver development. - Unified driver API, register configuration parsing API, bus access abstract API, and platform abstract API for the same type of sensors
- APIs to be implemented by developers
Based on the HDF Configuration Source (HCS) and differentiated configuration for sensors of the same type, you need to implement serialized configuration of sensor device parameters and some sensor device operation interfaces to simplify sensor driver development.
The sensor driver model provides APIs for the hardware service to make sensor service development easier. See the table below. The sensor driver model provides APIs for the hardware service to make sensor service development easier. See the table below.
...@@ -79,7 +83,7 @@ The sensor driver model provides APIs for the hardware service to make sensor se ...@@ -79,7 +83,7 @@ The sensor driver model provides APIs for the hardware service to make sensor se
The sensor driver model provides driver development APIs that do not require further implementation. See the table below. The sensor driver model provides driver development APIs that do not require further implementation. See the table below.
**Table 2** Sensor driver development APIs that do not need to be implemented by driver developers **Table 2** Sensor driver development APIs
| API| Description| | API| Description|
| ----- | -------- | | ----- | -------- |
...@@ -97,10 +101,9 @@ The sensor driver model provides driver development APIs that do not require fur ...@@ -97,10 +101,9 @@ The sensor driver model provides driver development APIs that do not require fur
The sensor driver model also provides certain driver development APIs that need to be implemented by driver developers. See the table below. The sensor driver model also provides certain driver development APIs that need to be implemented by driver developers. See the table below.
**Table 3** APIs that need to be implemented by driver developers **Table 3** APIs to be implemented by driver developers
| API| Description| | API| Description|
| ----- | -------- | | ----- | -------- |
...@@ -125,10 +128,10 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -125,10 +128,10 @@ The sensor driver model also provides certain driver development APIs that need
.moduleName = "HDF_SENSOR_ACCEL", // Name of the acceleration sensor module. The value must be the same as that of moduleName in the device_info.hcs file. .moduleName = "HDF_SENSOR_ACCEL", // Name of the acceleration sensor module. The value must be the same as that of moduleName in the device_info.hcs file.
.Bind = BindAccelDriver, // Function for binding an acceleration sensor. .Bind = BindAccelDriver, // Function for binding an acceleration sensor.
.Init = InitAccelDriver, // Function for initializing an acceleration sensor. .Init = InitAccelDriver, // Function for initializing an acceleration sensor.
.Release = ReleaseAccelDriver, // Function for releasing acceleration sensor resources. .Release = ReleaseAccelDriver // Function for releasing acceleration sensor resources.
}; };
/* Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind function first and then the Init function. If the Init function fails to be called, the HDF will call Release to release the driver resource and exit the sensor driver model. */ /* Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls Bind() and then Init() to load the driver. If Init() fails to be called, the HDF calls Release() to release resources and exit. */
HDF_INIT(g_sensorAccelDevEntry); HDF_INIT(g_sensorAccelDevEntry);
``` ```
...@@ -228,7 +231,7 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -228,7 +231,7 @@ The sensor driver model also provides certain driver development APIs that need
return drvData->accelCfg; return drvData->accelCfg;
... ...
} }
/* The entry function of the acceleration sensor driver is used to initialize the sensor private data structure object, allocate space for the sensor HCS data configuration object, call the entry function for initializing the sensor HCS data configuration, detect whether the sensor device is in position, create a sensor data reporting timer, register the sensor normalization APIs, and register the sensor device. */ /* The entry function of the acceleration sensor driver is used to initialize the sensor private data structure object, allocate space for the sensor HCS data configuration object, call the entry function for initializing the sensor HCS data configuration, detect whether the sensor device is in position, create a timer for sensor data reporting, register the sensor normalization APIs, and register the sensor device. */
int32_t AccelInitDriver(struct HdfDeviceObject *device) int32_t AccelInitDriver(struct HdfDeviceObject *device)
{ {
... ...
...@@ -271,16 +274,16 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -271,16 +274,16 @@ The sensor driver model also provides certain driver development APIs that need
The acceleration sensor model uses the HCS as the configuration source code. For details about the HCS configuration fields, see [Driver Configuration Management](driver-hdf-manage.md). The acceleration sensor model uses the HCS as the configuration source code. For details about the HCS configuration fields, see [Driver Configuration Management](driver-hdf-manage.md).
``` ```hcs
/* Device information HCS configuration of the acceleration sensor. */ /* Device information HCS configuration of the acceleration sensor. */
device_sensor_accel :: device { device_sensor_accel :: device {
device0 :: deviceNode { device0 :: deviceNode {
policy = 1; // Policy for publishing the driver service. policy = 1; // Policy for the driver to publish services.
priority = 110; // Driver startup priority (0–200). A larger value indicates a lower priority. The default value 100 is recommended. The sequence for loading devices with the same priority is random. priority = 100; // Priority (0–200) for starting the driver. A larger value indicates a lower priority. The recommended value is 100. If the priorities are the same, the device loading sequence is not ensured.
preload = 0; // Field for specifying whether to load the driver. The value 0 means to load the driver, and 2 means the opposite. preload = 0; // The value 0 means to load the driver by default during the startup of the system. The value 2 means the opposite.
permission = 0664; // Permission for the driver to create a device node. permission = 0664; // Permission for the device node created.
moduleName = "HDF_SENSOR_ACCEL"; // Driver name. The value must be the same as that of moduleName in the driver entry structure. moduleName = "HDF_SENSOR_ACCEL"; // Driver name. It must be the same as moduleName in the driver entry structure.
serviceName = "sensor_accel"; // Name of the service provided by the driver. The name must be unique. serviceName = "sensor_accel"; // Name of the service published by the driver. The name must be unique.
deviceMatchAttr = "hdf_sensor_accel_driver"; // Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. deviceMatchAttr = "hdf_sensor_accel_driver"; // Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver.
} }
} }
...@@ -466,7 +469,7 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -466,7 +469,7 @@ The sensor driver model also provides certain driver development APIs that need
/* Release the resources allocated during driver initialization. */ /* Release the resources allocated during driver initialization. */
void Bmi160ReleaseDriver(struct HdfDeviceObject *device) void Bmi160ReleaseDriver(struct HdfDeviceObject *device)
{ {
...... ...
if (drvData->sensorCfg != NULL) { if (drvData->sensorCfg != NULL) {
AccelReleaseCfgData(drvData->sensorCfg); AccelReleaseCfgData(drvData->sensorCfg);
drvData->sensorCfg = NULL; drvData->sensorCfg = NULL;
...@@ -511,18 +514,12 @@ The sensor driver model also provides certain driver development APIs that need ...@@ -511,18 +514,12 @@ The sensor driver model also provides certain driver development APIs that need
} }
``` ```
>![](../public_sys-resources/icon-note.gif) **NOTE** ### Verification
>
>- The sensor driver model provides certain APIs to implement sensor driver capabilities, including the driver device management, abstract bus and platform operation, common configuration, and configuration parsing capabilities. For details about them, see Table 2.
>- You need to implement the following functions: certain sensor operation interfaces (listed in Table 3) and sensor chipset HCS configuration.
>- You also need to verify basic driver functions.
### How to Verify After the driver is developed, develop test cases in the sensor unit test to verify the basic functions of the driver. Use your test platform to set up the test environment.
After the driver is developed, you can develop self-test cases in the sensor unit test to verify the basic functions of the driver. Use the developer self-test platform as the test environment. ```c++
static int32_t g_sensorDataFlag = 0; // Whether to report sensor data.
```
static int32_t g_sensorDataFlag = 0; // Indicates whether to report sensor data.
static const struct SensorInterface *g_sensorDev = nullptr; // Retain the obtained sensor interface instance address. static const struct SensorInterface *g_sensorDev = nullptr; // Retain the obtained sensor interface instance address.
/* Register the data reporting function. */ /* Register the data reporting function. */
...@@ -559,8 +556,8 @@ void HdfSensorTest::TearDownTestCase() ...@@ -559,8 +556,8 @@ void HdfSensorTest::TearDownTestCase()
HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0) HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0)
{ {
int32_t sensorInterval = 1000000000; // Data sampling interval, in nanoseconds. int32_t sensorInterval = 1000000000; // Data sampling interval, in nanoseconds.
int32_t pollTime = 5; // Data sampling duration, in seconds. int32_t pollTime = 5; // Data sampling time, in seconds.
int32_t accelSensorId = 1; // Acceleration sensor ID, which is 1. int32_t accelSensorId = 1; // Acceleration sensor ID, which specifies the sensor type.
int32_t count = 0; int32_t count = 0;
int ret; int ret;
struct SensorInformation *sensorInfo = nullptr; struct SensorInformation *sensorInfo = nullptr;
......
# 使用显式Want启动Ability # 使用显式Want启动Ability
在应用使用场景中,当用户点击某个按钮时,应用经常需要拉起指定UIAbility组件来完成某些特定任务。下面介绍如何通过显式Want拉起应用内一个指定UIAbility组件。 在应用使用场景中,当用户在应用内点击某个按钮时,经常需要拉起指定UIAbility组件来完成某些特定任务。在启动UIAbility时,指定了abilityName和bundleName参数,可以使用显示Want方式启动UIAbility。显示Want的使用请参见[启动应用内的UIAbility](uiability-intra-device-interaction.md#启动应用内的uiability)
## 开发步骤
1. Stage模型工程内,创建一个Ability(此示例内命名为callerAbility)与相应Page(此示例中名为Index.ets),并在callerAbility.ts文件内的onWindowStageCreate函数内通过windowStage.loadContent()方法将两者绑定。
```ts
// ...
// callerAbility.ts
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info('[Demo] EntryAbility onWindowStageCreate')
// Bind callerAbility with a paged named Index
windowStage.loadContent('pages/Index')
}
// ...
```
2. 同上方法再创建一个Ability,此示例内命名为“calleeAbility”。
3. 在callerAbility的“Index.ets”页面内新增一个按钮。
```ts
// ...
build() {
Row() {
Column() {
Text('hello')
.fontSize(50)
.fontWeight(FontWeight.Bold)
// A new button with will call explicitStartAbility() when clicked.
Button("CLICKME")
.onClick(this.explicitStartAbility) // explicitStartAbility见下面示例代码
// ...
}
.width('100%')
}
.height('100%')
}
// ...
```
4. 补充相对应的onClick方法,并使用**显式Want**在方法内启动calleeAbility。bundleName字段可在工程AppScope&gt;app.json5文件内获取;abilityName可在对应模块内的“yourModuleName &gt; src &gt; main &gt; module.json5”文件查看。
```ts
import common from '@ohos.app.ability.common';
// ...
async explicitStartAbility() {
try {
// Explicit want with abilityName specified.
let want = {
deviceId: "",
bundleName: "com.example.myapplication",
abilityName: "calleeAbility"
};
let context = getContext(this) as common.UIAbilityContext;
await context.startAbility(want);
console.info(`explicit start ability succeed`);
} catch (error) {
console.info(`explicit start ability failed with ${error.code}`);
}
}
// ...
```
5. 至此,当您点击CLICKME按钮时,应看到页面的跳转。
<img src="figures/startAbilityWtExplicitWant.PNG" alt="startAbilityWtExplicitWant" style="zoom: 80%;" />
...@@ -74,9 +74,9 @@ ...@@ -74,9 +74,9 @@
2. want内entities不为空,且被skills内entities包括,匹配成功。 2. want内entities不为空,且被skills内entities包括,匹配成功。
3. skills内uris拼接为https://www.test.com:8080/query\* (\*为通配符)包含want内uri,匹配成功。 3. skills内uris拼接为`https://www.test.com:8080/query*` (\*为通配符)包含want内uri,匹配成功。
4. want内type不为空,且被skills内type包含,匹配成功。 4. want内type不为空,且被skills内type包含,匹配成功。
2. 当有多个匹配应用时,会被应用选择器展示给用户进行选择。 2. 当有多个匹配应用时,会被应用选择器展示给用户进行选择。
<img src="figures/stage-want1.png" alt="stage-want1" style="zoom:80%;" /> <img src="figures/stage-want1.png" alt="stage-want1" style="zoom:80%;" />
# 常见action与entities # 常见action与entities
**[action](../reference/apis/js-apis-ability-wantConstant.md#wantconstantaction)**:表示调用方要执行的通用操作(如查看、分享、应用详情)。在隐式Want中,您可定义该字段,配合uri或parameters来表示对数据要执行的操作。如打开,查看该uri数据。例如,当uri为一段网址,action为ohos.want.action.viewData则表示匹配可查看该网址的Ability。在Want内声明action字段表示希望被调用方应用支持声明的操作。在被调用方应用配置文件skills字段内声明actions表示该应用支持声明操作。 **[action](../reference/apis/js-apis-ability-wantConstant.md#wantconstantaction)**:表示调用方要执行的通用操作(如查看、分享、应用详情)。在隐式Want中,您可定义该字段,配合uri或parameters来表示对数据要执行的操作。如打开,查看该uri数据。例如,当uri为一段网址,action为ohos.want.action.viewData则表示匹配可查看该网址的Ability。在Want内声明action字段表示希望被调用方应用支持声明的操作。在被调用方应用配置文件skills字段内声明actions表示该应用支持声明操作。
...@@ -15,7 +14,6 @@ ...@@ -15,7 +14,6 @@
- ACTION_VIEW_MULTIPLE_DATA:发送多个数据记录的操作。 - ACTION_VIEW_MULTIPLE_DATA:发送多个数据记录的操作。
**[entities](../reference/apis/js-apis-ability-wantConstant.md#wantconstantentity)**:表示目标Ability的类别信息(如浏览器、视频播放器),在隐式Want中是对action的补充。在隐式Want中,开发者可定义该字段,来过滤匹配应用的类别,例如必须是浏览器。在Want内声明entities字段表示希望被调用方应用属于声明的类别。在被调用方应用配置文件skills字段内声明entites表示该应用支持的类别。 **[entities](../reference/apis/js-apis-ability-wantConstant.md#wantconstantentity)**:表示目标Ability的类别信息(如浏览器、视频播放器),在隐式Want中是对action的补充。在隐式Want中,开发者可定义该字段,来过滤匹配应用的类别,例如必须是浏览器。在Want内声明entities字段表示希望被调用方应用属于声明的类别。在被调用方应用配置文件skills字段内声明entites表示该应用支持的类别。
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
### want参数的action匹配规则 ### want参数的action匹配规则
将调用方传入的want参数的action与待匹配Ability的skills配置中的actions进行匹配。 将调用方传入的want参数的[action](../reference/apis/js-apis-ability-wantConstant.md#wantconstantaction)与待匹配Ability的skills配置中的actions进行匹配。
- 调用方传入的want参数的action不为空,待匹配Ability的skills配置中的actions为空,则action匹配失败。 - 调用方传入的want参数的action不为空,待匹配Ability的skills配置中的actions为空,则action匹配失败。
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
### want参数的entities匹配规则 ### want参数的entities匹配规则
将调用方传入的want参数的entities与待匹配Ability的skills配置中的entities进行匹配。 将调用方传入的want参数的[entities](../reference/apis/js-apis-ability-wantConstant.md#wantconstantentity)与待匹配Ability的skills配置中的entities进行匹配。
- 调用方传入的want参数的entities为空,待匹配Ability的skills配置中的entities不为空,则entities匹配成功。 - 调用方传入的want参数的entities为空,待匹配Ability的skills配置中的entities不为空,则entities匹配成功。
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
调用方传入的want参数中设置uri和type参数发起组件启动请求,系统会遍历当前系统已安装的组件列表,并逐个匹配待匹配Ability的skills配置中的uris数组,如果待匹配Ability的skills配置中的uris数组中只要有一个可以匹配调用方传入的want参数中设置的uri和type即为匹配成功。 调用方传入的want参数中设置uri和type参数发起组件启动请求,系统会遍历当前系统已安装的组件列表,并逐个匹配待匹配Ability的skills配置中的uris数组,如果待匹配Ability的skills配置中的uris数组中只要有一个可以匹配调用方传入的want参数中设置的uri和type即为匹配成功。
**图3** want参数中uri和type皆不为空时的匹配规则 **图3** want参数中uri和type皆不为空时的匹配规则
<img src="figures/want-uri-type1.png" alt="want-uri-type1" style="zoom: 80%;" /> <img src="figures/want-uri-type1.png" alt="want-uri-type1" style="zoom: 80%;" />
实际应用中,uri和type共存在四种情况,下面将讲解四种情况的具体匹配规则: 实际应用中,uri和type共存在四种情况,下面将讲解四种情况的具体匹配规则:
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
下图为了简化描述,称want中传入的uri为w_uri,称want中传入的type为w_type, 待匹配Ability的skills配置中uris为s_uris,其中每个元素为s_uri;按自上而下顺序匹配。 下图为了简化描述,称want中传入的uri为w_uri,称want中传入的type为w_type, 待匹配Ability的skills配置中uris为s_uris,其中每个元素为s_uri;按自上而下顺序匹配。
**图4** want参数中uri和type的具体匹配规则 **图4** want参数中uri和type的具体匹配规则
<img src="figures/want-uri-type2.png" alt="want-uri-type2" style="zoom:80%;" /> <img src="figures/want-uri-type2.png" alt="want-uri-type2" style="zoom:80%;" />
...@@ -133,24 +133,24 @@ ...@@ -133,24 +133,24 @@
> **说明:** > **说明:**
> 待匹配Ability的skills配置的uris中scheme、host、port、path、pathStartWith和pathRegex属性拼接,如果依次声明了path、pathStartWith和pathRegex属性时,uris将分别拼接为如下三种表达式: > 待匹配Ability的skills配置的uris中scheme、host、port、path、pathStartWith和pathRegex属性拼接,如果依次声明了path、pathStartWith和pathRegex属性时,uris将分别拼接为如下三种表达式:
> >
> - **全路径表达式**:scheme://host:port/path > - **全路径表达式**:`scheme://host:port/path`
> >
> - **前缀表达式**:scheme://host:port/pathStartWith > - **前缀表达式**:`scheme://host:port/pathStartWith`
> >
> - **正则表达式**:scheme://host:port/pathRegex > - **正则表达式**:`scheme://host:port/pathRegex`
### type匹配规则 ### type匹配规则
> **说明:** > **说明:**
> 此小节所述的type匹配规则的适用性需建立在want参数内type不为空的基础上。当want参数内type为空时请参[want参数的uri和type匹配规则](#want参数的uri和type匹配规则)。 > 此小节所述的type匹配规则的适用性需建立在want参数内type不为空的基础上。当want参数内type为空时请参[want参数的uri和type匹配规则](#want参数的uri和type匹配规则)。
这里为了简化描述,称want中传入的uri为w_type,待匹配Ability的skills数组中uris的type数据为s_type,具体的匹配规则如下: 这里为了简化描述,称want中传入的uri为w_type,待匹配Ability的skills数组中uris的type数据为s_type,具体的匹配规则如下:
- 如果s_type为空,则匹配失败。 - 如果s_type为空,则匹配失败。
- 如果s_type或者w_type为通配符"\*/\*",则匹配成功。 - 如果s_type或者w_type为通配符`*/*`,则匹配成功。
- 如果s_type最后一个字符为通配符'\*',如"prefixType/\*",则当w_type包含"prefixType/"时匹配成功,否则匹配失败。 - 如果s_type最后一个字符为通配符`*`,如`prefixType/*`,则当w_type包含`prefixType/`时匹配成功,否则匹配失败。
- 如果w_type最后一个字符为通配符'\*',如"prefixType/\*",则当s_type包含"prefixType/"时匹配成功,否则匹配失败。 - 如果w_type最后一个字符为通配符`*`,如`prefixType/*`,则当s_type包含`prefixType/`时匹配成功,否则匹配失败。
...@@ -15,15 +15,14 @@ UIAbility的启动模式是指UIAbility实例在启动时的不同呈现状态 ...@@ -15,15 +15,14 @@ UIAbility的启动模式是指UIAbility实例在启动时的不同呈现状态
singleton启动模式为单实例模式,也是默认情况下的启动模式。 singleton启动模式为单实例模式,也是默认情况下的启动模式。
每次调用startAbility()方法时,如果应用进程中该类型的UIAbility实例已经存在,则复用系统中的UIAbility实例。系统中只存在唯一一个该UIAbility实例,即在最近任务列表中只存在一个该类型的UIAbility实例。 每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,如果应用进程中该类型的UIAbility实例已经存在,则复用系统中的UIAbility实例。系统中只存在唯一一个该UIAbility实例,即在最近任务列表中只存在一个该类型的UIAbility实例。
**图1** 单实例模式演示效果 **图1** 单实例模式演示效果
<img src="figures/uiability-launch-type1.png" alt="uiability-launch-type1" style="zoom:50%;" /> <img src="figures/uiability-launch-type1.png" alt="uiability-launch-type1" width="40%;" />
> **说明:** > **说明**:应用的UIAbility实例已创建,该UIAbility配置为单实例模式,再次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动该UIAbility实例。由于启动的还是原来的UIAbility实例,并未重新创建一个新的UIAbility实例,此时只会进入该UIAbility的[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其[onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)和[onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)生命周期回调。
> 应用的UIAbility实例已创建,该UIAbility配置为单实例模式,再次调用startAbility()方法启动该UIAbility实例,此时只会进入该UIAbility的[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其onCreate()和onWindowStageCreate()生命周期回调。
如果需要使用singleton启动模式,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的"launchType"字段配置为"singleton"即可。 如果需要使用singleton启动模式,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的`launchType`字段配置为`singleton`即可。
```json ```json
...@@ -43,12 +42,12 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式 ...@@ -43,12 +42,12 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式
## standard启动模式 ## standard启动模式
standard启动模式为标准实例模式,每次调用startAbility()方法时,都会在应用进程中创建一个新的该类型UIAbility实例。即在最近任务列表中可以看到有多个该类型的UIAbility实例。这种情况下可以将UIAbility配置为standard(标准实例模式)。 standard启动模式为标准实例模式,每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,都会在应用进程中创建一个新的该类型UIAbility实例。即在最近任务列表中可以看到有多个该类型的UIAbility实例。这种情况下可以将UIAbility配置为standard(标准实例模式)。
**图2** 标准实例模式演示效果 **图2** 标准实例模式演示效果
<img src="figures/standard-mode.png" alt="standard-mode" style="zoom:50%;" /> <img src="figures/standard-mode.png" alt="standard-mode" width="40%;" />
standard启动模式的开发使用,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的"launchType"字段配置为"standard"即可。 standard启动模式的开发使用,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的`launchType`字段配置为`standard`即可。
```json ```json
...@@ -70,19 +69,12 @@ standard启动模式的开发使用,在[module.json5配置文件](../quick-sta ...@@ -70,19 +69,12 @@ standard启动模式的开发使用,在[module.json5配置文件](../quick-sta
specified启动模式为指定实例模式,针对一些特殊场景使用(例如文档应用中每次新建文档希望都能新建一个文档实例,重复打开一个已保存的文档希望打开的都是同一个文档实例)。 specified启动模式为指定实例模式,针对一些特殊场景使用(例如文档应用中每次新建文档希望都能新建一个文档实例,重复打开一个已保存的文档希望打开的都是同一个文档实例)。
在UIAbility实例创建之前,允许开发者为该实例创建一个唯一的字符串Key,创建的UIAbility实例绑定Key之后,后续每次调用startAbility()方法时,都会询问应用使用哪个Key对应的UIAbility实例来响应startAbility()请求。运行时由UIAbility内部业务决定是否创建多实例,如果匹配有该UIAbility实例的Key,则直接拉起与之绑定的UIAbility实例,否则创建一个新的UIAbility实例。 **图3** 指定实例模式演示效果
**图3** 指定实例模式演示效果
<img src="figures/uiability-launch-type2.png" alt="uiability-launch-type2" style="zoom:50%;" /> <img src="figures/uiability-launch-type2.png" alt="uiability-launch-type2" style="zoom:50%;" />
> **说明:** 例如有两个UIAbility:EntryAbility和SpecifiedAbility,SpecifiedAbility配置为specified启动模式,需要从EntryAbility的页面中启动SpecifiedAbility。
>
> 1. 应用的UIAbility实例已创建,该UIAbility配置为指定实例模式,再次调用startAbility()方法启动该UIAbility实例,且[AbilityStage](abilitystage.md)的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)回调匹配到一个已创建的UIAbility实例。此时,再次启动该UIAbility时,只会进入该UIAbility的[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其onCreate()和onWindowStageCreate()生命周期回调。
> 2. DevEco Studio默认工程中未自动生成AbilityStage,AbilityStage文件的创建请参见[AbilityStage组件容器](abilitystage.md)。
例如有两个UIAbility:EntryAbility和FuncAbility,FuncAbility配置为specified启动模式,需要从EntryAbility的页面中启动FuncAbility。
1.FuncAbility中,将[module.json5配置文件](../quick-start/module-configuration-file.md)的"launchType"字段配置为"specified" 1.SpecifiedAbility中,将[module.json5配置文件](../quick-start/module-configuration-file.md)`launchType`字段配置为`specified`
```json ```json
{ {
...@@ -98,7 +90,8 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( ...@@ -98,7 +90,8 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
} }
``` ```
2. 在EntryAbility中,调用startAbility()方法时,在want参数中,增加一个自定义参数来区别UIAbility实例,例如增加一个"instanceKey"自定义参数。 2. 在UIAbility实例创建之前,允许开发者为该实例创建一个唯一的字符串Key,创建的UIAbility实例绑定Key之后,后续每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,都会询问应用使用哪个Key对应的UIAbility实例来响应[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)请求。
在EntryAbility中,调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,在want参数中,增加一个自定义参数来区别UIAbility实例,例如增加一个`instanceKey`自定义参数。
```ts ```ts
// 在启动指定实例模式的UIAbility时,给每一个UIAbility实例配置一个独立的Key标识 // 在启动指定实例模式的UIAbility时,给每一个UIAbility实例配置一个独立的Key标识
...@@ -110,7 +103,7 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( ...@@ -110,7 +103,7 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
let want = { let want = {
deviceId: '', // deviceId为空表示本设备 deviceId: '', // deviceId为空表示本设备
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'SpecifiedAbility',
moduleName: 'module1', // moduleName非必选 moduleName: 'module1', // moduleName非必选
parameters: { // 自定义信息 parameters: { // 自定义信息
instanceKey: getInstance(), instanceKey: getInstance(),
...@@ -124,7 +117,8 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( ...@@ -124,7 +117,8 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
}) })
``` ```
3. 由于FuncAbility的启动模式配置为了指定实例启动模式,在FuncAbility启动之前,会先进入其对应的AbilityStage的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)生命周期回调中,解析传入的want参数,获取"instanceKey"自定义参数。根据业务需要通过AbilityStage的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)生命周期回调返回一个字符串Key标识。[如果返回的Key对应一个已启动的UIAbility](mission-management-launch-type.md#fig14520125175314),则会将之前的UIAbility拉回前台并获焦,而不创建新的实例,否则创建新的实例并启动。 3. 运行时由UIAbility内部业务决定是否创建多实例,如果匹配有该UIAbility实例的Key,则直接拉起与之绑定的UIAbility实例,否则创建一个新的UIAbility实例。
由于SpecifiedAbility的启动模式配置为了指定实例启动模式,在SpecifiedAbility启动之前,会先进入其对应的AbilityStage的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)生命周期回调中,解析传入的want参数,获取`instanceKey`自定义参数。根据业务需要通过AbilityStage的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)生命周期回调返回一个字符串Key标识。[如果返回的Key对应一个已启动的UIAbility](mission-management-launch-type.md#fig14520125175314),则会将之前的UIAbility拉回前台并获焦,而不创建新的实例,否则创建新的实例并启动。
```ts ```ts
import AbilityStage from '@ohos.app.ability.AbilityStage'; import AbilityStage from '@ohos.app.ability.AbilityStage';
...@@ -132,10 +126,10 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( ...@@ -132,10 +126,10 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onAcceptWant(want): string { onAcceptWant(want): string {
// 在被调用方的AbilityStage中,针对启动模式为specified的UIAbility返回一个UIAbility实例对应的一个Key值 // 在被调用方的AbilityStage中,针对启动模式为specified的UIAbility返回一个UIAbility实例对应的一个Key值
// 当前示例指的是module1 Module的FuncAbility // 当前示例指的是module1 Module的SpecifiedAbility
if (want.abilityName === 'FuncAbility') { if (want.abilityName === 'SpecifiedAbility') {
// 返回的字符串Key标识为自定义拼接的字符串内容 // 返回的字符串Key标识为自定义拼接的字符串内容
return `FuncAbilityInstance_${want.parameters.instanceKey}`; return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`;
} }
return ''; return '';
...@@ -143,6 +137,11 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( ...@@ -143,6 +137,11 @@ specified启动模式为指定实例模式,针对一些特殊场景使用(
} }
``` ```
> **说明:**
>
> 1. 应用的UIAbility实例已创建,该UIAbility配置为指定实例模式,再次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动该UIAbility实例,且[AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md)的[onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)回调匹配到一个已创建的UIAbility实例。由于启动的还是原来的UIAbility实例,并未重新创建一个新的UIAbility实例,此时再次启动该UIAbility时,只会进入该UIAbility的[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其[onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)和[onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)生命周期回调。
> 2. DevEco Studio默认工程中未自动生成AbilityStage,AbilityStage文件的创建请参见[AbilityStage组件容器](abilitystage.md)。
例如在文档应用中,可以对不同的文档实例内容绑定不同的Key值。当每次新建文档的时候,可以传入不同的新Key值(如可以将文件的路径作为一个Key标识),此时AbilityStage中启动UIAbility时都会创建一个新的UIAbility实例;当新建的文档保存之后,回到桌面,或者新打开一个已保存的文档,回到桌面,此时再次打开该已保存的文档,此时AbilityStage中再次启动该UIAbility时,打开的仍然是之前原来已保存的文档界面。 例如在文档应用中,可以对不同的文档实例内容绑定不同的Key值。当每次新建文档的时候,可以传入不同的新Key值(如可以将文件的路径作为一个Key标识),此时AbilityStage中启动UIAbility时都会创建一个新的UIAbility实例;当新建的文档保存之后,回到桌面,或者新打开一个已保存的文档,回到桌面,此时再次打开该已保存的文档,此时AbilityStage中再次启动该UIAbility时,打开的仍然是之前原来已保存的文档界面。
以如下步骤所示进行举例说明。 以如下步骤所示进行举例说明。
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
## Want的类型 ## Want的类型
- **显式Want**:在启动Ability时指定了abilityName和bundleName的Want称为显式Want。 - **显式Want**:在启动Ability时指定了abilityName和bundleName的Want称为显式Want。
当有明确处理请求的对象时,通过提供目标Ability所在应用的Bundle名称信息(bundleName),并在Want内指定abilityName便可启动目标Ability。显式Want通常用于在当前应用开发中启动某个已知的Ability。参数说明参见[Want参数说明](want-overview.md#Want参数说明) 当有明确处理请求的对象时,通过提供目标Ability所在应用的Bundle名称信息(bundleName),并在Want内指定abilityName便可启动目标Ability。显式Want通常用于在当前应用开发中启动某个已知的Ability。
```ts ```ts
let wantInfo = { let wantInfo = {
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
} }
``` ```
- **隐式Want**:在启动UIAbility时未指定abilityName的Want称为隐式Want。 - **隐式Want**:在启动Ability时未指定abilityName的Want称为隐式Want。
当请求处理的对象不明确时,希望在当前应用中使用其他应用提供的某个能力(通过[skills标签](../quick-start/module-configuration-file.md#skills标签)定义),而不关心提供该能力的具体应用,可以使用隐式Want。例如使用隐式Want描述需要打开一个链接的请求,而不关心通过具体哪个应用打开,系统将匹配声明支持该请求的所有应用。 当请求处理的对象不明确时,希望在当前应用中使用其他应用提供的某个能力(通过[skills标签](../quick-start/module-configuration-file.md#skills标签)定义),而不关心提供该能力的具体应用,可以使用隐式Want。例如使用隐式Want描述需要打开一个链接的请求,而不关心通过具体哪个应用打开,系统将匹配声明支持该请求的所有应用。
...@@ -47,18 +47,3 @@ ...@@ -47,18 +47,3 @@
> - 调用方传入的want参数中不带有abilityName和bundleName,则不允许通过隐式Want启动所有应用的ServiceExtensionAbility。 > - 调用方传入的want参数中不带有abilityName和bundleName,则不允许通过隐式Want启动所有应用的ServiceExtensionAbility。
> >
> - 调用方传入的want参数中带有bundleName,则允许使用startServiceExtensionAbility()方法隐式Want启动ServiceExtensionAbility,默认返回优先级最高的ServiceExtensionAbility,如果优先级相同,返回第一个。 > - 调用方传入的want参数中带有bundleName,则允许使用startServiceExtensionAbility()方法隐式Want启动ServiceExtensionAbility,默认返回优先级最高的ServiceExtensionAbility,如果优先级相同,返回第一个。
## Want参数说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| deviceId | 只读 | string | 否 | 表示目标Ability所在设备ID。如果未设置该字段,则表明本设备。 |
| bundleName | 只读 | string | 否 | 表示目标Ability所在应用名称。 |
| moduleName | 只读 | string | 否 | 表示目标Ability所属的模块名称。 |
| abilityName | 只读 | string | 否 | 表示目标Ability名称。如果未设置该字段,则该Want为隐式。如果在Want中同时指定了bundleName,moduleName和abilityName,则Want可以直接匹配到指定的Ability。 |
| uri | 只读 | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括scheme,&nbsp;schemeSpecificPart,&nbsp;authority和path信息。 |
| type | 只读 | string | 否 | 表示携带数据类型,使用[MIME类型](https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com%E3%80%82)规范。例如:"text/plain"、"image/\*"等。 |
| [action](../reference/apis/js-apis-ability-wantConstant.md) | 只读 | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可定义该字段,配合uri或parameters来表示对数据要执行的操作。如打开,查看该uri数据。例如,当uri为一段网址,action为ohos.want.action.viewData则表示匹配可查看该网址的Ability。 |
| [entities](../reference/apis/js-apis-ability-wantConstant.md) | 只读 | Array&lt;string&gt; | 否 | 表示目标Ability额外的类别信息(如:浏览器,视频播放器),在隐式Want中是对action的补充。在隐式Want中,您可定义该字段,来过滤匹配UIAbility类别,如必须是浏览器。例如,在action字段的举例中,可存在多个应用声明了支持查看网址的操作,其中有应用为普通社交应用,有的为浏览器应用,您可通过entity.system.browsable过滤掉非浏览器的其他应用。 |
| [flags](../reference/apis/js-apis-ability-wantConstant.md#wantconstantflags) | 只读 | number | 否 | 表示处理Want的方式。例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
| parameters | 只读 | {[key:&nbsp;string]:&nbsp;any} | 否 | 此参数用于传递自定义数据,通过用户自定义的键值对进行数据填充,具体支持的数据类型如[Want&nbsp;API](../reference/apis/js-apis-app-ability-want.md)所示。 |
...@@ -191,7 +191,7 @@ currentSession.on('playNext', () => { ...@@ -191,7 +191,7 @@ currentSession.on('playNext', () => {
}); });
console.log("调用AudioPlayer.play方法"); console.log("调用AudioPlayer.play方法");
// 设置播放状态 // 设置播放状态
let time = (new Data()).getTime(); let time = (new Date()).getTime();
currentSession.setAVPlaybackState({state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, position: {elapsedTime: 0, updateTime: time}, bufferedTime:2000}).then(() => { currentSession.setAVPlaybackState({state: avSession.PlaybackState.PLAYBACK_STATE_PLAY, position: {elapsedTime: 0, updateTime: time}, bufferedTime:2000}).then(() => {
console.info('setAVPlaybackState successfully'); console.info('setAVPlaybackState successfully');
}).catch((err) => { }).catch((err) => {
...@@ -286,7 +286,7 @@ currentSession.off('outputDeviceChange'); ...@@ -286,7 +286,7 @@ currentSession.off('outputDeviceChange');
// 去激活session并销毁对象 // 去激活session并销毁对象
currentSession.deactivate().then(() => { currentSession.deactivate().then(() => {
currentSession.destory(); currentSession.destroy();
}); });
``` ```
......
...@@ -91,7 +91,9 @@ struct MyComponent { ...@@ -91,7 +91,9 @@ struct MyComponent {
- 支持多个实例:一个组件中可以定义多个标有@Prop的属性; - 支持多个实例:一个组件中可以定义多个标有@Prop的属性;
- 创建自定义组件时将值传递给@Prop变量进行初始化:在创建组件的新实例时,必须初始化所有@Prop变量,不支持在组件内部进行初始化。 - 创建自定义组件时将值传递给@Prop变量进行初始化:在创建组件的新实例时,必须初始化所有@Prop变量,不支持在组件内部进行初始化。
> **说明:** @Prop修饰的变量不能在组件内部进行初始化。 > **说明:**
>
> @Prop修饰的变量不能在组件内部进行初始化。
**示例:** **示例:**
...@@ -158,7 +160,9 @@ struct CountDownComponent { ...@@ -158,7 +160,9 @@ struct CountDownComponent {
- 双向通信:子组件对@Link变量的更改将同步修改父组件中的@State变量; - 双向通信:子组件对@Link变量的更改将同步修改父组件中的@State变量;
- 创建自定义组件时需要将变量的引用传递给@Link变量,在创建组件的新实例时,必须使用命名参数初始化所有@Link变量。@Link变量可以使用@State变量或@Link变量的引用进行初始化,@State变量可以通过`'$'`操作符创建引用。 - 创建自定义组件时需要将变量的引用传递给@Link变量,在创建组件的新实例时,必须使用命名参数初始化所有@Link变量。@Link变量可以使用@State变量或@Link变量的引用进行初始化,@State变量可以通过`'$'`操作符创建引用。
> **说明:** @Link修饰的变量不能在组件内部进行初始化。 > **说明:**
>
> @Link修饰的变量不能在组件内部进行初始化。
**简单类型示例:** **简单类型示例:**
...@@ -395,7 +399,9 @@ struct ViewB { ...@@ -395,7 +399,9 @@ struct ViewB {
@Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。@Consume在感知到@Provide数据的更新后,会触发当前自定义组件的重新渲染。 @Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。@Consume在感知到@Provide数据的更新后,会触发当前自定义组件的重新渲染。
> **说明:** 使用@Provide和@Consume时应避免循环引用导致死循环。 > **说明:**
>
> 使用@Provide和@Consume时应避免循环引用导致死循环。
### @Provide ### @Provide
......
# 应用配置文件概述(Stage模型)
每个应用项目必须在项目的代码目录下加入配置文件,这些配置文件会向编译工具、操作系统和应用市场提供应用的基本信息。
在基于Stage模型开发的应用项目代码下,都存在一个app.json5及一个或多个module.json5这两种配置文件。
[app.json5](app-configuration-file.md)主要包含以下内容:
- 应用的全局配置信息,包含应用的Bundle名称、开发厂商、版本号等基本信息。
- 特定设备类型的配置信息。
[module.json5](module-configuration-file.md)主要包含以下内容:
- Module的基本配置信息,例如Module名称、类型、描述、支持的设备类型等基本信息。
- [应用组件](../application-models/stage-model-development-overview.md)信息,包含UIAbility组件和ExtensionAbility组件的描述信息。
- 应用运行过程中所需的权限信息。
# @ohos.app.ability.Want (Want) # @ohos.app.ability.Want (Want)
Want是对象间信息传递的载体, 可以用于应用组件间的信息传递。 Want的使用场景之一是作为startAbility的参数, 其包含了指定的启动目标, 以及启动时需携带的相关数据, 如bundleName和abilityName字段分别指明目标Ability所在应用的包名以及对应包内的Ability名称。当Ability A需要启动Ability B并传入一些数据时, 可使用Want作为载体将这些数据传递给Ability B。 Want是对象间信息传递的载体, 可以用于应用组件间的信息传递。 Want的使用场景之一是作为startAbility的参数, 其包含了指定的启动目标, 以及启动时需携带的相关数据, 如bundleName和abilityName字段分别指明目标Ability所在应用的包名以及对应包内的Ability名称。当UIAbilityA需要启动UIAbilityB并传入一些数据时, 可使用Want作为载体将这些数据传递给UIAbilityB。
> **说明:** > **说明:**
> >
...@@ -19,25 +19,25 @@ import Want from '@ohos.app.ability.Want'; ...@@ -19,25 +19,25 @@ import Want from '@ohos.app.ability.Want';
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | string | 否 | 表示运行指定Ability的设备ID。如果未设置该字段,则表明指定本设备。 | | deviceId | string | 否 | 表示运行指定Ability的设备ID。如果未设置该字段,则表明指定本设备。 |
| bundleName | string | 否 | 表示Bundle名称。 | | bundleName | string | 否 | 表示待启动Ability所在的应用Bundle名称。 |
| abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | | moduleName | string | 否 | 表示待启动的Ability所属的模块名称。 |
| uri | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | | abilityName | string | 否 | 表示待启动Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | [action](js-apis-app-ability-wantConstant.md#wantConstant.Action) | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。隐式Want定义及匹配规则请参见[显式Want与隐式Want匹配规则](application-models/explicit-implicit-want-mappings.md) |
| flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-app-ability-wantConstant.md#wantConstant.Flags)。 | | [entities](js-apis-app-ability-wantConstant.md#wantConstant.Entity) | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。具体参考:[action说明](js-apis-app-ability-wantConstant.md#wantConstant.Action)。隐式Want定义及匹配规则参考:[显式Want与隐式Want匹配规则](application-models/explicit-implicit-want-mappings.md) | | uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 |
| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。 | | type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。具体参考:[entity说明](js-apis-app-ability-wantConstant.md#wantConstant.Entity) | | parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。 |
| moduleName | string | 否 | 表示待启动的Ability所属的模块(module)。 | | [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
**示例:** **示例:**
- 基础用法(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象) - 基础用法(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)。
```ts ```ts
let want = { let want = {
"deviceId": "", // deviceId为空表示本设备 "deviceId": "", // deviceId为空表示本设备
"bundleName": "com.extreme.test", "bundleName": "com.example.myapplication",
"abilityName": "MainAbility", "abilityName": "FuncAbility",
"moduleName": "entry" // moduleName非必选 "moduleName": "entry" // moduleName非必选
}; };
this.context.startAbility(want, (error) => { this.context.startAbility(want, (error) => {
...@@ -46,13 +46,13 @@ import Want from '@ohos.app.ability.Want'; ...@@ -46,13 +46,13 @@ import Want from '@ohos.app.ability.Want';
}) })
``` ```
- 通过自定字段传递数据, 以下为当前支持类型。(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象) - 通过自定字段传递数据, 以下为当前支持类型(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)。
* 字符串(String) * 字符串(String)
```ts ```ts
let want = { let want = {
bundleName: "com.example.demo", bundleName: "com.example.myapplication",
abilityName: "com.example.demo.MainAbility", abilityName: "FuncAbility",
parameters: { parameters: {
keyForString: "str", keyForString: "str",
}, },
...@@ -61,8 +61,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -61,8 +61,8 @@ import Want from '@ohos.app.ability.Want';
* 数字(Number) * 数字(Number)
```ts ```ts
let want = { let want = {
bundleName: "com.example.demo", bundleName: "com.example.myapplication",
abilityName: "com.example.demo.MainAbility", abilityName: "FuncAbility",
parameters: { parameters: {
keyForInt: 100, keyForInt: 100,
keyForDouble: 99.99, keyForDouble: 99.99,
...@@ -72,8 +72,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -72,8 +72,8 @@ import Want from '@ohos.app.ability.Want';
* 布尔(Boolean) * 布尔(Boolean)
```ts ```ts
let want = { let want = {
bundleName: "com.example.demo", bundleName: "com.example.myapplication",
abilityName: "com.example.demo.MainAbility", abilityName: "FuncAbility",
parameters: { parameters: {
keyForBool: true, keyForBool: true,
}, },
...@@ -82,8 +82,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -82,8 +82,8 @@ import Want from '@ohos.app.ability.Want';
* 对象(Object) * 对象(Object)
```ts ```ts
let want = { let want = {
bundleName: "com.example.demo", bundleName: "com.example.myapplication",
abilityName: "com.example.demo.MainAbility", abilityName: "FuncAbility",
parameters: { parameters: {
keyForObject: { keyForObject: {
keyForObjectString: "str", keyForObjectString: "str",
...@@ -97,8 +97,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -97,8 +97,8 @@ import Want from '@ohos.app.ability.Want';
* 数组(Array) * 数组(Array)
```ts ```ts
let want = { let want = {
bundleName: "com.example.demo", bundleName: "com.example.myapplication",
abilityName: "com.example.demo.MainAbility", abilityName: "FuncAbility",
parameters: { parameters: {
keyForArrayString: ["str1", "str2", "str3"], keyForArrayString: ["str1", "str2", "str3"],
keyForArrayInt: [100, 200, 300, 400], keyForArrayInt: [100, 200, 300, 400],
...@@ -118,8 +118,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -118,8 +118,8 @@ import Want from '@ohos.app.ability.Want';
} }
let want = { let want = {
"deviceId": "", // deviceId为空表示本设备 "deviceId": "", // deviceId为空表示本设备
"bundleName": "com.extreme.test", "bundleName": "com.example.myapplication",
"abilityName": "MainAbility", "abilityName": "FuncAbility",
"moduleName": "entry", // moduleName非必选 "moduleName": "entry", // moduleName非必选
"parameters": { "parameters": {
"keyFd":{"type":"FD", "value":fd} "keyFd":{"type":"FD", "value":fd}
...@@ -135,4 +135,3 @@ import Want from '@ohos.app.ability.Want'; ...@@ -135,4 +135,3 @@ import Want from '@ohos.app.ability.Want';
<!--no_check--> <!--no_check-->
...@@ -48,20 +48,17 @@ createFormBindingData(obj?: Object | string): FormBindingData ...@@ -48,20 +48,17 @@ createFormBindingData(obj?: Object | string): FormBindingData
**示例:** **示例:**
```ts ```ts
import featureAbility from '@ohos.ability.featureAbility'; import fs from '@ohos.file.fs';
import fileio from '@ohos.fileio'; import formBindingData from '@ohos.app.form.formBindingData';
let context=featureAbility.getContext();
context.getOrCreateLocalDir((err,data)=>{ try {
let path=data+"/xxx.jpg"; let fd = fs.openSync('/path/to/form.png')
let fd = fileio.openSync(path);
let obj = { let obj = {
"temperature": "21°", "temperature": "21°",
"formImages": {"image": fd} "formImages": { "image": fd }
}; };
try {
formBindingData.createFormBindingData(obj); formBindingData.createFormBindingData(obj);
} catch (error) { } catch (error) {
console.log(`catch err->${JSON.stringify(err)}`); console.log(`catch error, code: ${error.code}, message: ${error.message})`);
} }
})
``` ```
\ No newline at end of file
...@@ -33,7 +33,7 @@ onAddForm(want: Want): formBindingData.FormBindingData ...@@ -33,7 +33,7 @@ onAddForm(want: Want): formBindingData.FormBindingData
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | 是 | 当前ExtensionAbility相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 | | want | [Want](js-apis-application-want.md) | 是 | 当前卡片相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 |
**返回值:** **返回值:**
...@@ -45,17 +45,19 @@ onAddForm(want: Want): formBindingData.FormBindingData ...@@ -45,17 +45,19 @@ onAddForm(want: Want): formBindingData.FormBindingData
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) { onAddForm(want) {
console.log('FormExtensionAbility onAddForm, want:' + want.abilityName); console.log('FormExtensionAbility onAddForm, want:' + want.abilityName);
let dataObj1 = { let dataObj1 = {
temperature:"11c", temperature: "11c",
"time":"11:00" "time": "11:00"
}; };
let obj1 = formBindingData.createFormBindingData(dataObj1); let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1; return obj1;
} }
} };
``` ```
## onCastToNormalForm ## onCastToNormalForm
...@@ -75,11 +77,13 @@ onCastToNormalForm(formId: string): void ...@@ -75,11 +77,13 @@ onCastToNormalForm(formId: string): void
**示例:** **示例:**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId) { onCastToNormalForm(formId) {
console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId); console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId);
} }
} };
``` ```
## onUpdateForm ## onUpdateForm
...@@ -99,17 +103,24 @@ onUpdateForm(formId: string): void ...@@ -99,17 +103,24 @@ onUpdateForm(formId: string): void
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.app.form.formBindingData' import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId) { onUpdateForm(formId) {
console.log('FormExtensionAbility onUpdateForm, formId:' + formId); console.log('FormExtensionAbility onUpdateForm, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj2 = formBindingData.createFormBindingData({
this.context.updateForm(formId, obj2).then((data)=>{ temperature: "22c",
time: "22:00"
});
formProvider.updateForm(formId, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data:' + data); console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => { }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);}); console.error('Operation updateForm failed. Cause: ' + error);
});
} }
} };
``` ```
## onChangeFormVisibility ## onChangeFormVisibility
...@@ -129,21 +140,28 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void ...@@ -129,21 +140,28 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void
**示例:** **示例:**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData' import formBindingData from '@ohos.app.form.formBindingData'
import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) { onChangeFormVisibility(newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus); console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj2 = formBindingData.createFormBindingData({
temperature: "22c",
time: "22:00"
});
for (let key in newStatus) { for (let key in newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]); console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]);
this.context.updateForm(key, obj2).then((data)=>{ formProvider.updateForm(key, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data:' + data); console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => { }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);}); console.error('Operation updateForm failed. Cause: ' + error);
});
} }
} }
} };
``` ```
## onFormEvent ## onFormEvent
...@@ -164,11 +182,13 @@ onFormEvent(formId: string, message: string): void ...@@ -164,11 +182,13 @@ onFormEvent(formId: string, message: string): void
**示例:** **示例:**
```ts ```ts
export default class MyFormExtension extends FormExtensionAbility { import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) { onFormEvent(formId, message) {
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message); console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message);
} }
} };
``` ```
## onRemoveForm ## onRemoveForm
...@@ -188,11 +208,13 @@ onRemoveForm(formId: string): void ...@@ -188,11 +208,13 @@ onRemoveForm(formId: string): void
**示例:** **示例:**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId) { onRemoveForm(formId) {
console.log('FormExtensionAbility onRemoveForm, formId:' + formId); console.log('FormExtensionAbility onRemoveForm, formId:' + formId);
} }
} };
``` ```
## onConfigurationUpdate ## onConfigurationUpdate
...@@ -212,11 +234,13 @@ onConfigurationUpdate(newConfig: Configuration): void; ...@@ -212,11 +234,13 @@ onConfigurationUpdate(newConfig: Configuration): void;
**示例:** **示例:**
```ts ```ts
class MyFormExtensionAbility extends FormExtensionAbility { import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(config) { onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config)); console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
} }
} };
``` ```
## onAcquireFormState ## onAcquireFormState
...@@ -236,13 +260,15 @@ onAcquireFormState?(want: Want): formInfo.FormState; ...@@ -236,13 +260,15 @@ onAcquireFormState?(want: Want): formInfo.FormState;
**示例:** **示例:**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formInfo from '@ohos.app.form.formInfo'; import formInfo from '@ohos.app.form.formInfo';
class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState(want) { onAcquireFormState(want) {
console.log('FormExtensionAbility onAcquireFormState, want:' + want); console.log('FormExtensionAbility onAcquireFormState, want:' + want);
return formInfo.FormState.UNKNOWN; return formInfo.FormState.UNKNOWN;
} }
} };
``` ```
## onShareForm ## onShareForm
...@@ -270,14 +296,16 @@ onShareForm?(formId: string): { [key: string]: any } ...@@ -270,14 +296,16 @@ onShareForm?(formId: string): { [key: string]: any }
**示例:** **示例:**
```ts ```ts
class MyFormExtensionAbility extends FormExtensionAbility { import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId) { onShareForm(formId) {
console.log('FormExtensionAbility onShareForm, formId:' + formId); console.log('FormExtensionAbility onShareForm, formId:' + formId);
let wantParams = { let wantParams = {
"temperature":"20", "temperature": "20",
"time":"2022-8-8 09:59", "time": "2022-8-8 09:59",
}; };
return wantParams; return wantParams;
} }
} };
``` ```
\ No newline at end of file
# @ohos.app.form.formInfo (FormInfo) # @ohos.app.form.formInfo (formInfo)
FormInfo模块提供对卡片的相关卡片信息和状态进行设置和查询的能力 formInfo模块提供了卡片信息和状态等相关类型和枚举
> **说明:** > **说明:**
> >
...@@ -30,11 +30,11 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -30,11 +30,11 @@ import formInfo from '@ohos.app.form.formInfo';
| colorMode | [ColorMode](#colormode) | 是 | 否 | 卡片颜色模式。 | | colorMode | [ColorMode](#colormode) | 是 | 否 | 卡片颜色模式。 |
| isDefault | boolean | 是 | 否 | 卡片是否是默认卡片。 | | isDefault | boolean | 是 | 否 | 卡片是否是默认卡片。 |
| updateEnabled | boolean | 是 | 否 | 卡片是否使能更新。 | | updateEnabled | boolean | 是 | 否 | 卡片是否使能更新。 |
| formVisibleNotify | string | 是 | 否 | 卡片是否使能可见通知。 | | formVisibleNotify | boolean | 是 | 否 | 卡片是否使能可见通知。 |
| relatedBundleName | string | 是 | 否 | 卡片所属的相关联Bundle名称。 | | relatedBundleName | string | 是 | 否 | 卡片所属的相关联Bundle名称。 |
| scheduledUpdateTime | string | 是 | 否 | 卡片更新时间。 | | scheduledUpdateTime | string | 是 | 否 | 卡片更新时间。 |
| formConfigAbility | string | 是 | 否 | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 | | formConfigAbility | string | 是 | 否 | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 |
| updateDuration | string | 是 | 否 | 卡片更新周期。 | | updateDuration | number | 是 | 否 | 卡片更新周期。 |
| defaultDimension | number | 是 | 否 | 表示卡片规格 | | defaultDimension | number | 是 | 否 | 表示卡片规格 |
| supportDimensions | Array&lt;number&gt; | 是 | 否 | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) | | supportDimensions | Array&lt;number&gt; | 是 | 否 | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) |
| customizeData | {[key: string]: [value: string]} | 是 | 否 | 卡片用户数据。 | | customizeData | {[key: string]: [value: string]} | 是 | 否 | 卡片用户数据。 |
...@@ -100,8 +100,8 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -100,8 +100,8 @@ import formInfo from '@ohos.app.form.formInfo';
| WIDTH_KEY | "ohos.extra.param.key.form_width" | 卡片宽度。 | | WIDTH_KEY | "ohos.extra.param.key.form_width" | 卡片宽度。 |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度。 | | HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度。 |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片。 | | TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片。 |
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | ability名称 | | ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | ability名称 |
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | 设备标识。<br/>**系统接口**: 此接口为系统接口。 | | DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | 设备标识。 |
| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | 指示指定要获取的捆绑Bundle名称的键。 | | BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | 指示指定要获取的捆绑Bundle名称的键。 |
## FormDimension ## FormDimension
...@@ -127,7 +127,7 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -127,7 +127,7 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 说明 | | 名称 | 说明 |
| ----------- | ------------ | | ----------- | ------------ |
| moduleName | 仅保留moduleName与提供值相符的卡片信息。 | | moduleName | 选填。仅保留moduleName与提供值相符的卡片信息。未填写时则不通过moduleName进行过滤。 |
## VisibilityType ## VisibilityType
......
# FormExtensionContext # FormExtensionContext
FormExtensionContext模块是FormExtension的上下文环境,继承自ExtensionContext。 FormExtensionContext模块是FormExtensionAbility的上下文环境,继承自ExtensionContext。
FormExtensionContext模块提供FormExtension具有的接口和能力。 FormExtensionContext模块提供FormExtensionAbility具有的接口和能力。
> **说明:** > **说明:**
> >
...@@ -11,23 +11,24 @@ FormExtensionContext模块提供FormExtension具有的接口和能力。 ...@@ -11,23 +11,24 @@ FormExtensionContext模块提供FormExtension具有的接口和能力。
## 使用说明 ## 使用说明
在使用FormExtensionContext的功能前,需要通过FormExtension获取。 在使用FormExtensionContext的功能前,需要通过FormExtensionAbility获取。
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm() { onAddForm(want) {
let formContext = this.context; // 获取FormExtensionContext let formContext = this.context; // 获取FormExtensionContext
// ... // ...
let dataObj1 = { let dataObj1 = {
temperature:"11c", temperature: "11c",
"time":"11:00" "time": "11:00"
}; };
let obj1 = formBindingData.createFormBindingData(dataObj1); let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1; return obj1;
} }
} };
``` ```
## startAbility ## startAbility
...@@ -50,23 +51,29 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void ...@@ -50,23 +51,29 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```ts ```ts
var want = { import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) {
// 当触发卡片message事件时,执行startAbility
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message);
let want = {
deviceId: "", deviceId: "",
bundleName: "com.example.formstartability", bundleName: "com.example.formstartability",
abilityName: "MainAbility", abilityName: "MainAbility",
action: "action1", parameters: {
entities: ["entity1"], "message": message
type: "MIMETYPE", }
uri: "key={true,true,false}", };
parameters: {} this.context.startAbility(want, (error, data) => {
}
this.context.startAbility(want, (error, data) => {
if (error) { if (error) {
console.log('FormExtensionContext startAbility, error:' + JSON.stringify(error)); console.log('FormExtensionContext startAbility, error:' + JSON.stringify(error));
} else { } else {
console.log(`FormExtensionContext startAbility success`); console.log('FormExtensionContext startAbility success');
}
});
} }
}) };
``` ```
## startAbility ## startAbility
...@@ -89,24 +96,30 @@ startAbility(want: Want): Promise&lt;void&gt; ...@@ -89,24 +96,30 @@ startAbility(want: Want): Promise&lt;void&gt;
| 类型 | 说明 | | 类型 | 说明 |
| ------------ | ---------------------------------- | | ------------ | ---------------------------------- |
| Promise&lt;void&lt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```ts ```ts
var want = { import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) {
// 当触发卡片message事件时,执行startAbility
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message);
let want = {
deviceId: "", deviceId: "",
bundleName: "com.example.formstartability", bundleName: "com.example.formstartability",
abilityName: "MainAbility", abilityName: "MainAbility",
action: "action1", parameters: {
entities: ["entity1"], "message": message
type: "MIMETYPE", }
uri: "key={true,true,false}", };
parameters: {} this.context.startAbility(want).then(() => {
}
this.context.startAbility(want).then(() => {
console.info("StartAbility Success"); console.info("StartAbility Success");
}).catch((error) => { }).catch((error) => {
console.info("StartAbility failed"); console.info("StartAbility failed");
}); });
}
};
``` ```
\ No newline at end of file
...@@ -275,7 +275,7 @@ let result = lightWeightMap.get("sparrow"); ...@@ -275,7 +275,7 @@ let result = lightWeightMap.get("sparrow");
getIndexOfKey(key: K): number getIndexOfKey(key: K): number
查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。 查找key元素第一次出现的下标值,如果没有找到该元素返回-1。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -289,7 +289,7 @@ getIndexOfKey(key: K): number ...@@ -289,7 +289,7 @@ getIndexOfKey(key: K): number
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | | number | 返回key元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:** **错误码:**
...@@ -313,7 +313,7 @@ let result = lightWeightMap.getIndexOfKey("sparrow"); ...@@ -313,7 +313,7 @@ let result = lightWeightMap.getIndexOfKey("sparrow");
getIndexOfValue(value: V): number getIndexOfValue(value: V): number
查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。 查找value元素第一次出现的下标值,如果没有找到该元素返回-1。
**系统能力:** SystemCapability.Utils.Lang **系统能力:** SystemCapability.Utils.Lang
...@@ -327,7 +327,7 @@ getIndexOfValue(value: V): number ...@@ -327,7 +327,7 @@ getIndexOfValue(value: V): number
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | | number | 返回value元素第一次出现时的下标值,查找失败返回-1。 |
**错误码:** **错误码:**
......
# @ohos.util.LightWeightSet (非线性容器LightWeightSet)@ohos.util.LightWeightSet (非线性容器LightWeightSet) # @ohos.util.LightWeightSet (非线性容器LightWeightSet)
> **说明:** > **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
...@@ -7,7 +7,7 @@ LinkedList底层通过双向链表实现,双向链表的每个节点都包含 ...@@ -7,7 +7,7 @@ LinkedList底层通过双向链表实现,双向链表的每个节点都包含
LinkedList和[List](js-apis-list.md)相比,LinkedList是双向链表,可以快速地在头尾进行增删,而List是单向链表,无法双向操作。 LinkedList和[List](js-apis-list.md)相比,LinkedList是双向链表,可以快速地在头尾进行增删,而List是单向链表,无法双向操作。
LinkedList和[ArrayList](js-apis-arraylist.md)相比,存取数据的效率不如ArrayList。 LinkedList和[ArrayList](js-apis-arraylist.md)相比,插入数据效率LinkedList优于ArrayList,而查询效率ArrayList优于LinkedList。
**推荐使用场景:** 当需要频繁的插入删除时,推荐使用LinkedList高效操作。 **推荐使用场景:** 当需要频繁的插入删除时,推荐使用LinkedList高效操作。
......
...@@ -546,8 +546,8 @@ list.add(2); ...@@ -546,8 +546,8 @@ list.add(2);
list.add(4); list.add(4);
list.add(5); list.add(5);
list.add(4); list.add(4);
list.sort((a: number, b: number) => a - b); list.sort((a: number, b: number) => a - b); // 结果为升序排列
list.sort((a: number, b: number) => b - a); list.sort((a: number, b: number) => b - a); // 结果为降序排列
``` ```
### getSubList ### getSubList
......
...@@ -70,7 +70,7 @@ Not found. ...@@ -70,7 +70,7 @@ Not found.
**可能原因** **可能原因**
在调用删除数据库、数据查询、数据删除等接口时未找到相关数据,可能原因如下。 在调用删除数据库、数据查询、数据同步等接口时未找到相关数据,可能原因如下。
1. 删除数据库操作时,数据库不存在或已删除。 1. 删除数据库操作时,数据库不存在或已删除。
2. 数据库数据查询操作时,相关数据不存在或已删除。 2. 数据库数据查询操作时,相关数据不存在或已删除。
3. 数据库数据同步操作时,数据库不存在或已删除。 3. 数据库数据同步操作时,数据库不存在或已删除。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册