diff --git a/en/application-dev/dfx/hitracemeter-guidelines.md b/en/application-dev/dfx/hitracemeter-guidelines.md index 316ee1b07898a24721b81625c2e9193ae08aa85f..1b45886ca4c593bbfff1b1b07d5892ad20ba58ae 100644 --- a/en/application-dev/dfx/hitracemeter-guidelines.md +++ b/en/application-dev/dfx/hitracemeter-guidelines.md @@ -12,7 +12,7 @@ The performance tracing APIs are provided by the **hiTraceMeter** module. For de | API| Return Value| Description| | ---------------------------------------------------------------------------- | --------- | ------------ | -| hiTraceMeter.startTrace(name: string, taskId: number, expectedTime?: number) | void | Starts a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.| +| hiTraceMeter.startTrace(name: string, taskId: number) | void | Starts a trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used.| | hiTraceMeter.finishTrace(name: string, taskId: number) | void | Stops a trace task. The values of **name** and **taskId** must be the same as those of **hiTraceMeter.startTrace**.| | hiTraceMeter.traceByValue(name: string, value: number) | void | Traces the value changes of a variable.| @@ -31,10 +31,6 @@ In this example, distributed call chain tracing begins when the application star }, onInit() { this.title = this.$t('strings.world'); - - // The expected duration of the trace task is 5 ms. - hiTraceMeter.startTrace("business", 1); - hiTraceMeter.startTrace("business", 1, 5); // Start track tasks with the same name concurrently. hiTraceMeter.startTrace("business", 1); diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 9b20ccb9f359ed6f8109d3fc57fdebd9d4d728ed..5ea820e6160af090dbaf1e784970adfcb01ba013 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -319,7 +319,7 @@ Checks whether the called number is an emergency number based on the specified p **Example** ```js -call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { +call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -468,9 +468,7 @@ The phone number must match the specified country code. For example, for a China **Example** ```js -call.formatPhoneNumberToE164("138xxxxxxxx",{ - countryCode: "CN" -}, (err, data) => { +call.formatPhoneNumberToE164("138xxxxxxxx", "CN", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -504,9 +502,7 @@ All country codes are supported. **Example** ```js -let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { - countryCode: "CN" -}); +let promise = call.formatPhoneNumberToE164("138xxxxxxxx", "CN"); promise.then(data => { console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1700,7 +1696,7 @@ This is a system API. **Example** ```js -isNewCallAllowedcall.on('mmiCodeResult', (err, data) => { +call.on('mmiCodeResult', (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2069,9 +2065,6 @@ This is a system API. **Example** ```js -let callTransferTyp={ - CallTransferType: 1 -} call.getCallTransferInfo(0, callTransferTyp, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -2104,10 +2097,7 @@ This is a system API. **Example** ```js -let callTransferTyp={ - CallTransferType: 1 -} -let promise = call.getCallTransferInfo(0, callTransferTyp); +let promise = call.getCallTransferInfo(0, call.CallTransferType.TRANSFER_TYPE_BUSY); promise.then(data => { console.log(`getCallTransferInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2396,7 +2386,7 @@ This is a system API. let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, bluetoothAddress, (err, value) => { +call.setAudioDevice(1, audioDeviceOptions, (err, value) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2460,7 +2450,10 @@ This is a system API. **Example** ```js -call.joinConference(1, "138XXXXXXXX", (err, data) => { +let callNumberList: Array = [ + "138XXXXXXXX" +]; +call.joinConference(1, callNumberList, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2491,7 +2484,10 @@ This is a system API. **Example** ```js -let promise = call.joinConference(1, "138XXXXXXXX"); +let callNumberList: Array = [ + "138XXXXXXXX" +]; +let promise = call.joinConference(1, callNumberList); promise.then(data => { console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); }).catch(err => { diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index ee5cf3137c7aa5d1ef6cb8ef1c1ef47ef8b35236..67b846c17b94a6acee894da72ae28cedefd2532c 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -22,6 +22,7 @@ Adds a contact. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------ | | contact | [Contact](#contact) | Yes | Contact information. | @@ -31,7 +32,7 @@ Adds a contact. This API uses an asynchronous callback to return the result. ```js contact.addContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, (err, data) => { if (err) { @@ -54,11 +55,13 @@ Adds a contact. This API uses a promise to return the result. **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ------- | ------------------- | ---- | ------------ | | contact | [Contact](#contact) | Yes | Contact information.| **Return Value** + | Type | Description | | --------------------- | ------------------------------------------- | | Promise<number> | Promise used to return the contact ID.| @@ -89,6 +92,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------ | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -118,11 +122,13 @@ Deletes a contact based on the specified contact key. This API uses a promise to **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| **Return Value** + | Type | Description | | ------------------- | --------------------------------------------- | | Promise<void> | Promise used to return the result.| @@ -150,6 +156,7 @@ Updates a contact based on the specified contact information. This API uses an a **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------ | | contact | [Contact](#contact) | Yes | Contact information. | @@ -182,6 +189,7 @@ Updates a contact based on the specified contact information and attributes. Thi **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------ | | contact | [Contact](#contact) | Yes | Contact information. | @@ -192,7 +200,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js contact.updateContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] },{ attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] @@ -217,12 +225,14 @@ Updates a contact based on the specified contact information and attributes. Thi **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ------- | --------------------------------------- | ---- | ------------------ | | contact | [Contact](#contact) | Yes | Contact information. | | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes.| **Return Value** + | Type | Description | | ------------------- | ------------------------------------------------- | | Promise<void> | Promise used to return the result.| @@ -231,7 +241,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js let promise = contact.updateContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] @@ -255,6 +265,7 @@ Checks whether the ID of this contact is in the local address book. This API use **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | id | number | Yes | Contact ID. Each contact corresponds to one ID. | @@ -284,11 +295,13 @@ Checks whether the ID of this contact is in the local address book. This API use **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------ | | id | number | Yes | Contact ID. Each contact corresponds to one ID.| **Return Value** + | Type | Description | | ---------------------- | ------------------------------------------------------------ | | Promise<boolean> | Promise used to return the result. The value **true** indicates that the contact ID is in the local address book, and the value **false** indicates the opposite.| @@ -316,6 +329,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | id | number | Yes | Contact ID. | @@ -345,11 +359,13 @@ Checks whether a contact is included in my card. This API uses a promise to retu **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------- | | id | number | Yes | Contact ID.| **Return Value** + | Type | Description | | ---------------------- | ------------------------------------------------------------ | | Promise<boolean> | Promise used to return the result. The value **true** indicates that the contact is included in my card, and the value **false** indicates the opposite.| @@ -377,6 +393,7 @@ Queries my card. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | ------------------------------ | | callback | AsyncCallback<[Contact](#contact)> | Yes | Callback used to return the result.| @@ -405,6 +422,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | ------------------------------ | | attrs | [ContactAttributes](#contactattributes) | Yes | List of contact attributes. | @@ -436,11 +454,13 @@ Queries my card based on the specified contact attributes. This API uses a promi **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | --------------------------------------- | ---- | ------------------ | | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes.| **Return Value** + | Type | Description | | ---------------------------------- | ------------------------------------------- | | Promise<[Contact](#contact)> | Promise used to return the result.| @@ -467,9 +487,10 @@ Selects a contact. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS -**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData +**System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | ------------------------------------ | | callback | AsyncCallback<Array<[Contact](#contact)>> | Yes | Callback used to return the result.| @@ -495,9 +516,10 @@ Selects a contact. This API uses a promise to return the result. **Permission required**: ohos.permission.READ_CONTACTS -**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData +**System capability**: SystemCapability.Applications.ContactsData **Return Value** + | Type | Description | | ----------------------------------------------- | ------------------------------------------------- | | Promise<Array<[Contact](#contact)>> | Promise used to return the result.| @@ -525,6 +547,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -554,6 +577,7 @@ Queries contacts based on the specified key and application. This API uses an as **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -588,6 +612,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -620,6 +645,7 @@ Queries contacts based on the specified key, application, and attributes. This A **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -658,6 +684,7 @@ Queries contacts based on the specified key, application, and attributes. This A **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | --------------------------------------- | ---- | -------------------------------------- | | key | string | Yes | Contact key. Each contact corresponds to one key.| @@ -665,6 +692,7 @@ Queries contacts based on the specified key, application, and attributes. This A | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** + | Type | Description | | ---------------------------------- | ----------------------------------------------- | | Promise<[Contact](#contact)> | Promise used to return the result.| @@ -699,6 +727,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | callback | AsyncCallback<Array<[Contact](#contact)>> | Yes | Callback used to return the result.| @@ -727,6 +756,7 @@ Queries all contacts based on the specified application. This API uses an asynch **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | holder | [Holder](#holder) | Yes | Application that creates the contacts. | @@ -760,6 +790,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | attrs | [ContactAttributes](#contactattributes) | Yes | List of contact attributes. | @@ -791,6 +822,7 @@ Queries all contacts based on the specified application and attributes. This API **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | holder | [Holder](#holder) | Yes | Application that creates the contacts. | @@ -827,12 +859,14 @@ Queries all contacts based on the specified application and attributes. This API **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | --------------------------------------- | ---- | ---------------------- | | holder | [Holder](#holder) | No | Application that creates the contacts.| | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** + | Type | Description | | ----------------------------------------------- | --------------------------------------------------- | | Promise<Array<[Contact](#contact)>> | Promise used to return the result.| @@ -866,6 +900,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ----------- | ----------------------------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number of the contacts. | @@ -895,6 +930,7 @@ Queries contacts based on the specified phone number and application. This API u **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ----------- | ----------------------------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number of the contacts. | @@ -929,6 +965,7 @@ Queries contacts based on the specified phone number and attributes. This API us **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ----------- | ----------------------------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number of the contacts. | @@ -961,6 +998,7 @@ Queries contacts based on the specified phone number, application, and attribute **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ----------- | ----------------------------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number of the contacts. | @@ -998,6 +1036,7 @@ Queries contacts based on the specified phone number, application, and attribute **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | ----------- | --------------------------------------- | ---- | ---------------------- | | phoneNumber | string | Yes | Phone number of the contacts. | @@ -1005,6 +1044,7 @@ Queries contacts based on the specified phone number, application, and attribute | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** + | Type | Description | | ----------------------------------------------- | --------------------------------------------------- | | Promise<Array<[Contact](#contact)>> | Promise used to return the result.| @@ -1038,6 +1078,7 @@ Queries contacts based on the specified email address. This API uses an asynchro **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | email | string | Yes | Email address of the contact. | @@ -1067,6 +1108,7 @@ Queries contacts based on the specified email address and application. This API **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | -------------------------------------- | | email | string | Yes | Email address of the contact. | @@ -1101,6 +1143,7 @@ Queries contacts based on the specified email address and attributes. This API u **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | ------------------------------------ | | email | string | Yes | Email address of the contact. | @@ -1133,6 +1176,7 @@ Queries contacts based on the specified email address, application, and attribut **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------------- | ---- | ------------------------------------ | | email | string | Yes | Email address of the contact. | @@ -1170,6 +1214,7 @@ Queries contacts based on the specified email address, application, and attribut **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | --------------------------------------- | ---- | ---------------------- | | email | string | Yes | Email address of the contact. | @@ -1177,6 +1222,7 @@ Queries contacts based on the specified email address, application, and attribut | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** + | Type | Description | | ----------------------------------------------- | --------------------------------------------------- | | Promise<Array<[Contact](#contact)>> | Promise used to return the result.| @@ -1210,6 +1256,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | | callback | AsyncCallback<Array<[Group](#group)>> | Yes | Callback used to return the result.| @@ -1238,6 +1285,7 @@ Queries all groups of this contact based on the specified application. This API **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | | holder | Holder | Yes | Application that creates the contacts. | @@ -1271,11 +1319,13 @@ Queries all groups of this contact based on the specified application. This API **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | ----------------- | ---- | ---------------------- | | holder | [Holder](#holder) | No | Application that creates the contacts.| **Return Value** + | Type | Description | | ------------------------------------------- | ------------------------------------------------- | | Promise<Array<[Group](#group)>> | Promise used to return the result.| @@ -1307,6 +1357,7 @@ Queries all applications that have created contacts. This API uses an asynchrono **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ---------------------------------------------------- | | callback | AsyncCallback<Array<[Holder](#holder)>> | Yes | Callback used to return the result.| @@ -1335,6 +1386,7 @@ Queries all applications that have created contacts. This API uses a promise to **System capability**: SystemCapability.Applications.ContactsData **Return Value** + | Type | Description | | --------------------------------------------- | ------------------------------------------------------------ | | Promise<Array<[Holder](#holder)>> | Promise used to return the result.| @@ -1362,6 +1414,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | --------------------------------------- | | id | number | Yes | Contact ID. | @@ -1391,6 +1444,7 @@ Queries the key of a contact based on the specified contact ID and application. **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | --------------------------------------- | | id | number | Yes | Contact ID. | @@ -1400,7 +1454,7 @@ Queries the key of a contact based on the specified contact ID and application. **Example** ```js - contact.queryKey(id, { + contact.queryKey(/*id*/1, { holderId: 0, bundleName: "", displayName: "" @@ -1425,12 +1479,14 @@ Queries the key of a contact based on the specified contact ID and application. **System capability**: SystemCapability.Applications.ContactsData **Parameters** + | Name| Type | Mandatory| Description | | ------ | ----------------- | ---- | ---------------------- | | id | number | Yes | Contact ID. | | holder | [Holder](#holder) | No | Application that creates the contacts.| **Return Value** + | Type | Description | | --------------------- | ---------------------------------------------------- | | Promise<string> | Promise used to return the result.| @@ -1438,7 +1494,7 @@ Queries the key of a contact based on the specified contact ID and application. **Example** ```js - let promise = contact.queryKey(id, { + let promise = contact.queryKey(/*id*/1, { holderId: 0, bundleName: "", displayName: "" @@ -1553,7 +1609,7 @@ Or, create data by configuring a **ContactAttributes** object. ```js let contactAttributes = new contact.ContactAttributes(); -contactAttributes.attributes = ["ATTR_EMAIL"]; +contactAttributes.attributes = [contact.Attribute.ATTR_EMAIL]; ``` @@ -2191,4 +2247,4 @@ let website = { ```js let website = new contact.Website(); website.website = "website"; -``` +``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index 9f1110f241e37530914961c21f688e67d44b05af..cc7d684666b28555597b406fddfc7b4c5cd7e130 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -304,11 +304,8 @@ hiAppEvent.addWatcher({ console.error("holder is null"); return; } - while (true) { - let eventPkg = holder.takeNext(); - if (eventPkg == null) { - return; - } + let eventPkg = null; + while ((eventPkg = holder.takeNext()) != null) { console.info("eventPkg.packageId=" + eventPkg.packageId); console.info("eventPkg.row=" + eventPkg.row); console.info("eventPkg.size=" + eventPkg.size); @@ -324,15 +321,14 @@ let holder = hiAppEvent.addWatcher({ name: "watcher2", }); if (holder != null) { - let eventPkg = holder.takeNext(); - if (eventPkg == null) { - return; - } - console.info("eventPkg.packageId=" + eventPkg.packageId); - console.info("eventPkg.row=" + eventPkg.row); - console.info("eventPkg.size=" + eventPkg.size); - for (const eventInfo of eventPkg.data) { - console.info("eventPkg.data=" + eventInfo); + let eventPkg = null; + while ((eventPkg = holder.takeNext()) != null) { + console.info("eventPkg.packageId=" + eventPkg.packageId); + console.info("eventPkg.row=" + eventPkg.row); + console.info("eventPkg.size=" + eventPkg.size); + for (const eventInfo of eventPkg.data) { + console.info("eventPkg.data=" + eventInfo); + } } } ``` @@ -417,6 +413,9 @@ Sets the data size threshold for fetching an application event package. The defa **Example** ```js +let holder = hiAppEvent.addWatcher({ + name: "watcher", +}); holder.setSize(1000); ``` @@ -429,6 +428,9 @@ Extracts subscription event data based on the configured data size threshold. If **Example** ```js +let holder = hiAppEvent.addWatcher({ + name: "watcher", +}); let eventPkg = holder.takeNext(); ``` diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md index 5620062988d8b16d374f7cfc010e2b77b378cb3a..469fcae6f1c0f82f0894422b3e2a4416fabc7a60 100644 --- a/en/application-dev/reference/apis/js-apis-hidebug.md +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -30,9 +30,10 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. **Example** - ```js - let nativeHeapSize = hidebug.getNativeHeapSize(); - ``` + +```js +let nativeHeapSize = hidebug.getNativeHeapSize(); +``` ## hidebug.getNativeHeapAllocatedSize @@ -45,17 +46,18 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | --------------------------------- | | bigint | Size of the allocated native heap memory, in kB.| **Example** - ```js - let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); - ``` + +```js +let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); +``` ## hidebug.getNativeHeapFreeSize @@ -68,17 +70,18 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | ------------------------------- | | bigint | Size of the free native heap memory, in kB.| **Example** - ```js - let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); - ``` + +```js +let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); +``` ## hidebug.getPss @@ -89,17 +92,18 @@ Obtains the PSS of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | ------------------------- | | bigint | PSS of the process, in kB.| **Example** - ```js - let pss = hidebug.getPss(); - ``` + +```js +let pss = hidebug.getPss(); +``` ## hidebug.getSharedDirty @@ -110,17 +114,18 @@ Obtains the size of the shared dirty memory of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | -------------------------- | | bigint | Size of the shared dirty memory of the process, in kB.| **Example** - ```js - let sharedDirty = hidebug.getSharedDirty(); - ``` + +```js +let sharedDirty = hidebug.getSharedDirty(); +``` ## hidebug.getPrivateDirty9+ @@ -130,8 +135,8 @@ Obtains the size of the private dirty memory of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | -------------------------- | | bigint | Size of the private dirty memory of the process, in kB.| @@ -152,17 +157,18 @@ For example, if the CPU usage is **50%**, **0.5** is returned. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug - **Return value** + | Type | Description | | ------ | -------------------------- | | number | CPU usage of the process.| **Example** - ```js - let cpuUsage = hidebug.getCpuUsage(); - ``` + +```js +let cpuUsage = hidebug.getCpuUsage(); +``` ## hidebug.startProfiling @@ -189,7 +195,6 @@ hidebug.stopProfiling(); ``` - ## hidebug.stopProfiling stopProfiling() : void @@ -245,6 +250,7 @@ This is a system API and cannot be called by third-party applications. | serviceid | number | Yes | ID of the system service. | **Return value** + | Type | Description | | ------ | -------------------------- | | string | Absolute path of the file that contains the service information to dump. | diff --git a/en/application-dev/reference/apis/js-apis-hisysevent.md b/en/application-dev/reference/apis/js-apis-hisysevent.md index e3c08ce24cf92eda9534812d664aa466c4b7c1ef..65952c0b23946b02582d74e5be9fbc5f8c33b42d 100644 --- a/en/application-dev/reference/apis/js-apis-hisysevent.md +++ b/en/application-dev/reference/apis/js-apis-hisysevent.md @@ -60,20 +60,24 @@ Writes event information to the event file. This API uses an asynchronous callba ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}, (err, val) => { - // do something here. -}) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }, (err, val) => { + // do something here. + }) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` @@ -102,26 +106,30 @@ Writes event information to the event file. This API uses a promise to return th ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}).then( - (val) => { - // do something here. - } -).catch( - (err) => { - // do something here. - } -) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` ## RuleType @@ -177,32 +185,30 @@ Adds a watcher for event subscription. | ------ | ----------------------------- | ---- | ------------------------ | | watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.| -**Return value** - -| Type | Description| -| ------- | -------------------------------------------------- | -| number | Event subscription result.
- **0**: Event subscription is successful.
- A value smaller than **0**: Event subscription has failed.| - **Example** ```js import hiSysEvent from '@ohos.hiSysEvent'; let watcher = { - rules: [{ - domain: "RELIABILITY", - name: "STACK", - tag: "STABILITY", - ruleType: hiSysEvent.RuleType.WHOLE_WORD, - }], - onEvent: (info) => { - // do something here. - }, - onServiceDied: () => { - // do something here. - } + rules: [{ + domain: "RELIABILITY", + name: "STACK", + tag: "STABILITY", + ruleType: hiSysEvent.RuleType.WHOLE_WORD, + }], + onEvent: (info) => { + // do something here. + }, + onServiceDied: () => { + // do something here. + } +} +try { + hiSysEvent.addWatcher(watcher) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); } -let ret = hiSysEvent.addWatcher(watcher) ``` ## hiSysEvent.removeWatcher @@ -221,33 +227,31 @@ Removes a watcher used for event subscription. | ------ | ------------- | ---- | ------------------------ | | watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.| -**Return value** - -| Type | Description| -| ------- | ----------------------------------------------------------- | -| number | Result of removing the watcher.
- **0**: Removing the watcher is successful.
- A value smaller than **0**: Removing the watcher has failed.| - **Example** ```js import hiSysEvent from '@ohos.hiSysEvent'; let watcher = { - rules: [{ - domain: "RELIABILITY", - name: "STACK", - tag: "STABILITY", - ruleType: hiSysEvent.RuleType.WHOLE_WORD, - }], - onEvent: (info) => { - // do something here. - }, - onServiceDied: () => { - // do something here. - } + rules: [{ + domain: "RELIABILITY", + name: "STACK", + tag: "STABILITY", + ruleType: hiSysEvent.RuleType.WHOLE_WORD, + }], + onEvent: (info) => { + // do something here. + }, + onServiceDied: () => { + // do something here. + } +} +try { + hiSysEvent.addWatcher(watcher) + hiSysEvent.removeWatcher(watcher) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); } -let ret = hiSysEvent.addWatcher(watcher) -hiSysEvent.removeWatcher(watcher) ``` ## QueryArg @@ -281,7 +285,7 @@ Defines an event query instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| onQuery | function | Yes| Callback of queried events: (infos: [SysEventInfo](#syseventinfo)[], seqs: number[]) => void| +| onQuery | function | Yes| Callback of queried events: (infos: [SysEventInfo](#syseventinfo)[]) => void| | onComplete | function | Yes| Callback of query result statistics: (reason: number, total: number) => void| ## hiSysEvent.query @@ -302,44 +306,42 @@ Queries system events. | rules | [QueryRule](#queryrule)[] | Yes | Array of event query rules.| | querier | [Querier](#querier) | Yes | Event query instance.| -**Return value** - -| Type | Description | -| ------- | ----------------------------------------------------------- | -| number | Event query result.
- **0**: Event query is successful.
- A value smaller than **0**: Event query has failed.| - **Example** ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}, (err, val) => { - // do something here. -}) -hiSysEvent.query({ - beginTime: -1, - endTime: -1, - maxEvents: 5, -}, [{ - domain: "RELIABILITY", - names: ["STACK"], -}], { - onQuery: function (infos, seqs) { - // do something here. - }, - onComplete: function(reason, total) { - // do something here. - } -}) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }, (err, val) => { + // do something here. + }) + hiSysEvent.query({ + beginTime: -1, + endTime: -1, + maxEvents: 5, + }, [{ + domain: "RELIABILITY", + names: ["STACK"], + }], { + onQuery: function (infos) { + // do something here. + }, + onComplete: function(reason, total) { + // do something here. + } + }) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md index cbaf898f75c37ba8921fe3d8ffd11e5484ec28e8..198615d8bf57c3749b527eb7fcc7fccdcaeb9fe1 100644 --- a/en/application-dev/reference/apis/js-apis-hitracechain.md +++ b/en/application-dev/reference/apis/js-apis-hitracechain.md @@ -71,7 +71,7 @@ Defines a **HiTraceId** object. ## hiTraceChain.begin -begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId +begin(name: string, flags?: number): HiTraceId Starts call chain tracing. This API works in synchronous manner. @@ -82,7 +82,7 @@ Starts call chain tracing. This API works in synchronous manner. | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | name | string | Yes| Traced service name. | -| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). | +| flags | number | No| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). | **Return Value** @@ -113,7 +113,7 @@ Stops call chain tracing. This API works in synchronous manner. **Example** ```js -let asyncTraceId = hiTraceChain.begin("business"); +let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); // End the call chain tracing after the service logic is executed for several times. hiTraceChain.end(asyncTraceId); ``` @@ -135,7 +135,7 @@ Obtains the trace ID. This API works in synchronous manner. **Example** ```js -let traceId = hiTraceChain.begin("business"); +let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); // Obtain the current trace ID after the service logic is executed for several times. let curTraceId = hiTraceChain.getId(); ``` @@ -158,7 +158,7 @@ Sets a trace ID. This API works in synchronous manner. ```js let asyncTraceId; -let traceId = hiTraceChain.begin("business"); +let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); // Set the current trace ID after the service logic is executed for several times. hiTraceChain.setId(asyncTraceId); ``` @@ -174,7 +174,7 @@ Clears the trace ID. This API works in synchronous manner. **Example** ```js -let traceId = hiTraceChain.begin("business"); +let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); // Clear the current trace ID after the service logic is executed for several times. hiTraceChain.clearId(); ``` @@ -196,7 +196,7 @@ Creates a trace span. This API works in synchronous manner. **Example** ```js -let traceId = hiTraceChain.begin("business"); +let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); // Create a trace span after the service logic is executed for several times. let spanTraceId = hiTraceChain.createSpan(); ``` @@ -249,7 +249,7 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous **Example** ```js -let traceId = hiTraceChain.begin("business"); +let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceIdIsvalid = hiTraceChain.isValid(traceId); ``` @@ -291,6 +291,7 @@ Enables the specified trace flag in the **HiTraceId** instance. This API works i **System capability**: SystemCapability.HiviewDFX.HiTrace **Parameters** + | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | | id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. | diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index fcf2858aa7b4a1adda999a0e1bf0850495c0d00f..3c908fabdc24cccc6f5949c9d5add8da88a08d01 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -404,7 +404,7 @@ Provides the device capability. | currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. | | unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.| -| unitUsage8+ | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| +| unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| | signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.| | compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. | | notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.| diff --git a/en/application-dev/reference/apis/js-apis-keycode.md b/en/application-dev/reference/apis/js-apis-keycode.md index 3a711c0ea13132547c4fc2bb9cc76066f71ab0ee..dd4ac0b22afb7e0101579db5b6d639504f58197d 100644 --- a/en/application-dev/reference/apis/js-apis-keycode.md +++ b/en/application-dev/reference/apis/js-apis-keycode.md @@ -96,7 +96,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode' | KEYCODE_EQUALS | number | Yes| No| Key =| | KEYCODE_LEFT_BRACKET | number | Yes| No| Key [| | KEYCODE_RIGHT_BRACKET | number | Yes| No| Key ]| -| KEYCODE_BACKSLASH | number | Yes| No| Key \| +| KEYCODE_BACKSLASH | number | Yes| No| Key \\| | KEYCODE_SEMICOLON | number | Yes| No| Key ;| | KEYCODE_APOSTROPHE | number | Yes| No| Key ' | | KEYCODE_SLASH | number | Yes| No| Key /| diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index ec63d11121dcd5138d11d7a2e1898833deaaf9c7..1d272e9f03c4956e141456324b1eb1f05293cea8 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -47,7 +47,7 @@ Obtains the default active data network. This API uses a promise to return the r **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** | Type | Description | | --------------------------------- | ------------------------------------- | @@ -92,7 +92,7 @@ Checks whether the default data network is activated. This API uses a promise to **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** | Type | Description | | ----------------- | ----------------------------------------------- | @@ -117,6 +117,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | Yes| Callback used to return the result.| @@ -141,7 +142,8 @@ Obtains the list of all active data networks. This API uses a promise to return **System capability**: SystemCapability.Communication.NetManager.Core -**Return Value** +**Return value** + | Type| Description| | -------- | -------- | | Promise<Array<[NetHandle](#nethandle)>> | Promise used to return the result.| @@ -198,7 +200,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi | --------- | ----------------------- | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------------------- | --------------------------------- | @@ -258,7 +260,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th | --------- | ----------------------- | ---- | ---------------- | | netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| -**Return Value** +**Return value** | Type | Description | | --------------------------------------------- | --------------------------------- | @@ -285,6 +287,7 @@ Reports connection of the data network. This API uses an asynchronous callback t **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| @@ -312,11 +315,13 @@ Reports connection of the data network. This API uses a promise to return the re **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -**Return Value** +**Return value** + | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -343,6 +348,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| @@ -370,11 +376,13 @@ Reports disconnection of the data network. This API uses a promise to return the **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | netHandle | [NetHandle](#nethandle) | Yes| Handle of the data network. For details, see [NetHandle](#nethandle).| -**Return Value** +**Return value** + | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| @@ -432,7 +440,7 @@ Resolves the host name by using the default network to obtain all IP addresses. | ------ | ------ | ---- | ------------------ | | host | string | Yes | Host name to be resolved.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------- | ----------------------------- | @@ -561,7 +569,7 @@ Obtains the handle of the network specified by **netSpecifier**. | netSpecifier | [NetSpecifier](#netspecifier) | No | Network specifier. If this parameter is not set, the default network is used. | | timeout | number | No | Timeout interval for obtaining the network specified by **netSpecifier**. This parameter is valid only when **netSpecifier** is set.| -**Return Value** +**Return value** | Type | Description | | ------------------------------- | -------------------- | @@ -829,7 +837,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre | ------ | ------ | ---- | ------------------ | | host | string | Yes | Host name to be resolved.| -**Return Value** +**Return value** | Type | Description | | ------------------------------------------- | ----------------------------- | @@ -891,7 +899,7 @@ Resolves the host name by using the corresponding network to obtain the first IP | ------ | ------ | ---- | ------------------ | | host | string | Yes | Host name to be resolved.| -**Return Value** +**Return value** | Type | Description | | ----------------------------------- | ------------------------------- | diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index d094a5c7e3abd27ebc042ab377543a3d2898b1e1..26d35ffeca4fe9c60ae46d8a8794fe46cb3d1748 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -1100,12 +1100,12 @@ Sets the network selection mode. This API uses an asynchronous callback to retur let networkInformation={ operatorName: "China Mobile", operatorNumeric: "898600", - state: 1, + state: radio.NetworkInformationState.NETWORK_AVAILABLE, radioTech: "CS" } let networkSelectionModeOptions={ - slotid: 0, - selectMode: 1, + slotId: 0, + selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC, networkInformation: networkInformation, resumeSelection: true } @@ -1144,12 +1144,12 @@ Sets the network selection mode. This API uses a promise to return the result. let networkInformation={ operatorName: "China Mobile", operatorNumeric: "898600", - state: 1, + state: radio.NetworkInformationState.NETWORK_AVAILABLE, radioTech: "CS" } let networkSelectionModeOptions={ - slotid: 0, - selectMode: 1, + slotId: 0, + selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC, networkInformation: networkInformation, resumeSelection: true } @@ -1190,7 +1190,7 @@ radio.getNetworkSearchInformation(0, (err, data) => { ## radio.getNetworkSearchInformation -getNetworkSearchInformation\(slotId: number\): Promise +getNetworkSearchInformation\(slotId: number\): Promise Obtains network search information for the SIM card in the specified slot. This API uses a promise to return the result. @@ -1586,7 +1586,7 @@ radio.getPreferredNetwork(0, (err, data) => { ## radio.getPreferredNetwork8+ -getPreferredNetwork(slotId: number): Promise +getPreferredNetwork(slotId: number): Promise Obtains the preferred network for the SIM card in the specified slot. This API uses a promise to return the result. @@ -1642,7 +1642,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI **Example** ```js -radio.getImsRegInfo(0, 1, (err, data) => { +radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1675,7 +1675,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI **Example** ```js -let promise = radio.getImsRegInfo(0, 1); +let promise = radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO); promise.then(data => { console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1707,7 +1707,7 @@ Enables listening for **imsRegStateChange** events for the SIM card in the speci **Example** ```js -radio.on('imsRegStateChange', 0, 1, (err, data) => { +radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1736,7 +1736,7 @@ Disables listening for **imsRegStateChange** events for the SIM card in the spec **Example** ```js -radio.off('imsRegStateChange', 0, 1, (err, data) => { +radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index a2d761225c3169bd6d9f5a7603232d4050c0342b..ae9a1ece9c9b419ea23162f354d7a428bd104a6c 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -589,7 +589,7 @@ Obtains the account information list of the active SIM card. This API uses an as **Example** ```js -sim.getActiveSimAccountInfoList(0, (err, data) => { +sim.getActiveSimAccountInfoList((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy **Example** ```js -const name='China Mobile'; +let name = 'China Mobile'; sim.setShowName(0, name, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -744,7 +744,7 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom **Example** ```js -const name='China Mobile'; +let name = 'China Mobile'; let promise = sim.setShowName(0, name); promise.then(data => { console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); @@ -1096,9 +1096,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy ```js let lockInfo = { - lockType = 1, + lockType: sim.LockType.PIN_LOCK, password = "1234", - state = 0 + state: sim.LockState.LOCK_OFF }; sim.setLockState(0, lockInfo, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -1135,9 +1135,9 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom ```js let lockInfo = { - lockType = 1, + lockType: sim.LockType.PIN_LOCK, password = "1234", - state = 0 + state: sim.LockState.LOCK_OFF }; let promise = sim.setLockState(0, lockInfo); promise.then(data => { @@ -2236,12 +2236,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.addIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2277,12 +2277,12 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.addIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2315,12 +2315,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.delIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2356,12 +2356,12 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.delIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2394,12 +2394,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2435,12 +2435,12 @@ Updates contact numbers for the SIM card in the specified slot. This API uses a ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2602,7 +2602,7 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba ```js let persoLockInfo = { - lockType = 0, + lockType = sim.PersoLockType.PN_PIN_LOCK, password = "1234" }; sim.unlockSimLock(0, persoLockInfo, (err, data) => { @@ -2640,7 +2640,7 @@ Unlocks the SIM card in the specified slot. This API uses a promise to return th ```js let persoLockInfo = { - lockType = 0, + lockType = sim.PersoLockType.PN_PIN_LOCK, password = "1234" }; let promise = sim.unlockSimLock(0, persoLockInfo); diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index 5443e18d1bd7e01ca1bbe74f62fdd9cce061e343..6920c9dbf3aea204efb78c292e949a7ec0e4a053 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -397,7 +397,7 @@ Splits an SMS message into multiple segments. This API uses an asynchronous call **Example** ```js -string content= "long message"; +let content = "long message"; sms.splitMessage(content, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -431,7 +431,7 @@ Splits an SMS message into multiple segments. This API uses a promise to return **Example** ```js -string content = "long message"; +let content = "long message"; let promise = sms.splitMessage(content); promise.then(data => { console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); @@ -463,10 +463,10 @@ Adds a SIM message. This API uses an asynchronous callback to return the result. ```js let simMessageOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxx", - status = 0 + slotId: 0, + smsc: "test", + pdu: "xxxxxx", + status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; sms.addSimMessage(simMessageOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -502,10 +502,10 @@ Adds a SIM message. This API uses a promise to return the result. ```js let simMessageOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxx", - status = 0 + slotId: 0, + smsc: "test", + pdu: "xxxxxx", + status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; let promise = sms.addSimMessage(simMessageOptions); promise.then(data => { @@ -607,9 +607,9 @@ Updates a SIM message. This API uses an asynchronous callback to return the resu ```js let updateSimMessageOptions = { - slotId = 0, - msgIndex = 1, - newStatus = 0, + slotId: 0, + msgIndex: 1, + newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE, pdu = "xxxxxxx", smsc = "test" }; @@ -647,9 +647,9 @@ Updates a SIM message. This API uses a promise to return the result. ```js let updateSimMessageOptions = { - slotId = 0, - msgIndex = 1, - newStatus = 0, + slotId: 0, + msgIndex: 1, + newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE, pdu = "xxxxxxx", smsc = "test" }; @@ -749,10 +749,11 @@ Sets the cell broadcast configuration. This API uses an asynchronous callback to ```js let cbConfigOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxxxx", - status = 0 + slotId: 0, + enable: true, + startMessageId: 100, + endMessageId: 200, + ranType: sms.RanType.TYPE_GSM }; sms.setCBConfig(cbConfigOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -788,13 +789,14 @@ Sets the cell broadcast configuration. This API uses a promise to return the res ```js let cbConfigOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxxxx", - status = 0 + slotId: 0, + enable: true, + startMessageId: 100, + endMessageId: 200, + ranType: sms.RanType.TYPE_GSM }; let promise = sms.setCBConfig(cbConfigOptions); -promise.then(data => +promise.then(data => { console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); }).catch(err => { console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); @@ -859,7 +861,7 @@ Obtains SMS message segment information. This API uses a promise to return the r ```js let slotId = 0; let promise = sms.getSmsSegmentsInfo(slotId, "message", false); -promise.then(data => +promise.then(data => { console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`); @@ -886,7 +888,7 @@ Checks whether SMS is supported on IMS. This API uses an asynchronous callback t ```js sms.isImsSmsSupported((err, data) => { - console.log(`callback: err->${JSON.(err)}, data->${JSON.stringify(data)}`); + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1023,7 +1025,7 @@ Decodes MMS messages. This API uses a promise to return the result. ```js let mmsFilePathName = "filename"; -let promise = sms.getSmscAddr(mmsFilePathName); +let promise = sms.decodeMms(mmsFilePathName); promise.then(data => { console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1092,13 +1094,13 @@ Encodes MMS messages. This API uses a promise to return the result. ```js let mmsAcknowledgeInd = { - transactionId = "100", - version = 0x10, - reportAllowed = 128 + transactionId: "100", + version: sms.MmsVersionType.MMS_VERSION_1_0, + reportAllowed = sms.ReportType.MMS_YES }; let mmsInformation = { - messageType = 133, - mmsType = mmsAcknowledgeInd + messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND, + mmsType: mmsAcknowledgeInd }; let promise = sms.encodeMms(mmsInformation); promise.then(data => { diff --git a/en/device-dev/Readme-EN.md b/en/device-dev/Readme-EN.md index 99194b48e979df7822002596d27c74f6c76b29da..8c0087ff8a5a049d1b967416c3d5eaecda1b971a 100644 --- a/en/device-dev/Readme-EN.md +++ b/en/device-dev/Readme-EN.md @@ -32,7 +32,7 @@ - [Graphics](subsystems/subsys-graphics-overview.md) - [Multimedia](subsystems/subsys-multimedia-camera-overview.md) - [Utils](subsystems/subsys-utils-overview.md) - - [AI Framework](subsystems/subsys-aiframework-guide.md) + - [AI Framework](subsystems/subsys-ai-aiframework-devguide.md) - [Data Management](subsystems/subsys-data-relational-database-overview.md) - [Sensor](subsystems/subsys-sensor-overview.md) - [USB](subsystems/subsys-usbservice-overview.md) diff --git a/en/device-dev/driver/driver-platform-i3c-des.md b/en/device-dev/driver/driver-platform-i3c-des.md index 8931ca30f57affa7998d5736ae248f22bfb97f51..1108e71375a1baa49cf7e649909a392ce612d9de 100644 --- a/en/device-dev/driver/driver-platform-i3c-des.md +++ b/en/device-dev/driver/driver-platform-i3c-des.md @@ -274,7 +274,7 @@ int32_t I3cTestRequestIbi(void) } ret = I3cRequestIbi(i3cHandle, 0x3F, TestI3cIbiFunc, 16); if (ret != 0) { - HDF_LOGE("%s: Requset IBI failed!", __func__); + HDF_LOGE("%s: Request IBI failed!", __func__); return -1; } diff --git a/en/device-dev/driver/driver-platform-mmc-develop.md b/en/device-dev/driver/driver-platform-mmc-develop.md index c7224cc2cd444fde8c8f365e0ca9cd0e37a853b5..6b9f16227b2c0968dccf04732d54852270fd0b69 100644 --- a/en/device-dev/driver/driver-platform-mmc-develop.md +++ b/en/device-dev/driver/driver-platform-mmc-develop.md @@ -25,10 +25,10 @@ struct MmcCntlrOps { int32_t (*setSdioIrq)(struct MmcCntlr *cntlr, bool enable); int32_t (*hardwareReset)(struct MmcCntlr *cntlr); int32_t (*systemInit)(struct MmcCntlr *cntlr); - int32_t (*setEnhanceSrobe)(struct MmcCntlr *cntlr, bool enable); + int32_t (*setEnhanceStrobe)(struct MmcCntlr *cntlr, bool enable); int32_t (*switchVoltage)(struct MmcCntlr *cntlr, enum MmcVolt volt); bool (*devReadOnly)(struct MmcCntlr *cntlr); - bool (*devPluged)(struct MmcCntlr *cntlr); + bool (*devPlugged)(struct MmcCntlr *cntlr); bool (*devBusy)(struct MmcCntlr *cntlr); int32_t (*tune)(struct MmcCntlr *cntlr, uint32_t cmdCode); int32_t (*rescanSdioDev)(struct MmcCntlr *cntlr); @@ -47,10 +47,10 @@ struct MmcCntlrOps { | setSdioIrq | **cntlr**: structure pointer to the MMC controller at the core layer.
**enable**: whether to enable Secure Digital Input Output (SDIO) interrupts.| HDF_STATUS| Enables or disables SDIO interrupts.| | hardwareReset | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Resets hardware.| | systemInit | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Performs system initialization.| -| setEnhanceSrobe | **cntlr**: structure pointer to the MMC controller at the core layer.
**enable**: whether to enable the enhanced strobe feature.| HDF_STATUS| Sets the enhanced strobe feature.| +| setEnhanceStrobe | **cntlr**: structure pointer to the MMC controller at the core layer.
**enable**: whether to enable the enhanced strobe feature.| HDF_STATUS| Sets the enhanced strobe feature.| | switchVoltage | **cntlr**: structure pointer to the MMC controller at the core layer.
**volt**: voltage to set, which can be 3.3 V, 1.8 V, or 1.2 V.| HDF_STATUS| Sets the voltage.| | devReadOnly | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is read-only.| -| cardPluged | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is removed.| +| cardPlugged | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is removed.| | devBusy | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is being used.| | tune | **cntlr**: structure pointer to the MMC controller at the core layer.
**cmdCode**: command code of the uint32_t type.| HDF_STATUS| Tunes the oscillator circuit frequency.| | rescanSdioDev | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Scans and adds an SDIO device.| @@ -254,7 +254,7 @@ The following uses **himci.c** as an example to present the information required uint32_t maxBlkNum; uint32_t maxBlkSize; uint32_t maxReqSize; - bool devPluged; + bool devPlugged; bool detecting; void *priv; }; @@ -273,10 +273,10 @@ The following uses **himci.c** as an example to present the information required .setSdioIrq = HimciSetSdioIrq, .hardwareReset = HimciHardwareReset, .systemInit = HimciSystemInit, - .setEnhanceSrobe= HimciSetEnhanceSrobe, + .setEnhanceStrobe= HimciSetEnhanceStrobe, .switchVoltage = HimciSwitchVoltage, .devReadOnly = HimciDevReadOnly, - .devPluged = HimciCardPluged, + .devPlugged = HimciCardPlugged, .devBusy = HimciDevBusy, .tune = HimciTune, .rescanSdioDev = HimciRescanSdioDev, diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index cf146746b25096da1d2c1b4e648024ed0b0374f7..610803fa36a0371bf293a995027c5be363736202 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -39,21 +39,7 @@ - [Utils Overview](subsys-utils-overview.md) - [Utils Development](subsys-utils-guide.md) - [Utils FAQ](subsys-utils-faqs.md) -- AI Framework - - [AI Engine Framework](subsys-aiframework-guide.md) - - [Development Environment](subsys-aiframework-envbuild.md) - - Technical Specifications - - [Code Management](subsys-aiframework-tech-codemanage.md) - - [Naming](subsys-aiframework-tech-name.md) - - [API Development](subsys-aiframework-tech-interface.md) - - Development Guidelines - - [SDK](subsys-aiframework-devguide-sdk.md) - - [Plug-in](subsys-aiframework-devguide-plugin.md) - - [Configuration File](subsys-aiframework-devguide-conf.md) - - Development Examples - - [KWS SDK](subsys-aiframework-demo-sdk.md) - - [KWS Plug-in](subsys-aiframework-demo-plugin.md) - - [KWS Configuration File](subsys-aiframework-demo-conf.md) +- [AI Framework](subsys-ai-aiframework-devguide.md) - Data Management - RDB - [RDB Overview](subsys-data-relational-database-overview.md) @@ -106,6 +92,7 @@ - [HiTraceChain Development](subsys-dfx-hitracechain.md) - [HiCollie Development](subsys-dfx-hicollie.md) - HiSysEvent Development + - [HiSysEvent Overview](subsys-dfx-hisysevent-overview.md) - [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent Logging](subsys-dfx-hisysevent-logging.md) - [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md) diff --git a/en/device-dev/subsystems/figure/code-dependency-(2).jpg b/en/device-dev/subsystems/figure/en-us_image_0000001151931738.jpg similarity index 100% rename from en/device-dev/subsystems/figure/code-dependency-(2).jpg rename to en/device-dev/subsystems/figure/en-us_image_0000001151931738.jpg diff --git a/en/device-dev/subsystems/figure/en-us_image_0000001077727032.png b/en/device-dev/subsystems/figure/en-us_image_0000001200128073.png similarity index 100% rename from en/device-dev/subsystems/figure/en-us_image_0000001077727032.png rename to en/device-dev/subsystems/figure/en-us_image_0000001200128073.png diff --git a/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md b/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md new file mode 100644 index 0000000000000000000000000000000000000000..0a65ca9e584e80c6b1bf8662c85e8759b4711750 --- /dev/null +++ b/en/device-dev/subsystems/subsys-ai-aiframework-devguide.md @@ -0,0 +1,518 @@ +# AI Framework Development Guide + +## **Overview** + +### Introduction + +The AI subsystem is the part of OpenHarmony that provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins. + +The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Specifically, plug-in management implements lifecycle management, on-demand deployment, and quick integration of AI algorithm plug-ins; module management implements task scheduling and client instance management; communication management manages inter-process communication (IPC) between the client and server and data transmission between the AI engine and plug-ins. + +Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies. + +The following figure shows the AI engine framework. + + **Figure 1** AI engine framework + ![en-us_image_0000001200128073](figure/en-us_image_0000001200128073.png) + +### Setting Up the Environment + + +1. Prepare a development board, which can be Hi3516D V300 or Hi3518E V300. + +2. [Download the source code.](../get-code/sourcecode-acquire.md) + +## Technical specifications + +### Code Management + +The AI engine framework consists of three modules: **client**, **server**, and **common**. The client module provides the server connection management function. The SDK needs to encapsulate and call the public APIs provided by the client in the algorithm's external APIs. The server module provides functions such as plug-in loading and task management. Plug-ins are integrated using the plug-in APIs provided by the server. The common module provides platform-related operation methods, engine protocols, and tool classes for other modules. + + +The following figure shows the code dependency between modules of the AI engine framework. + + + **Figure 2** Code dependency + + ![en-us_image_0000001151931738](figure/en-us_image_0000001151931738.jpg) + + +#### Recommendation: Develop plug-ins and SDKs in the directories specified by the AI engine. + +In the overall planning of the AI engine framework, SDKs are a part of the client, and plug-ins are called by the server and are considered a part of the server. Therefore, the following directories have been planned for plug-in and SDK development in the AI engine framework: + +- SDK code directory: //foundation/ai/engine/services/client/algorithm_sdk + + Example 1: //foundation/ai/engine/services/client/algorithm_sdk/cv + + Example 2: //foundation/ai/engine/services/client/algorithm_sdk/nlu + +- Plug-in code directory: //foundation/ai/engine/services/server/plugin + + Example 1: //foundation/ai/engine/services/server/plugin/cv + + Example 2: //foundation/ai/engine/services/server/plugin/nlu + + +#### Rule: Store all external APIs provided by plug-ins in the **interfaces/kits** directory of the AI subsystem. + +The AI subsystem exposes its capabilities through external APIs of SDKs. According to API management requirements of OpenHarmony, store all external APIs of SDKs in the **interfaces/kits** directory of the subsystem. Currently, the external APIs of plug-ins of the AI subsystem are stored in the **//foundation/ai/engine/interfaces/kits** directory. You can add a sub-directory for each newly added plug-in in this directory. For example, if you add a CV plug-in, then store its external APIs in the **//foundation/ai/engine/interfaces/kits/cv** directory. + + +#### Rule: Make sure that plug-in build results are stored in the **/usr/lib** directory. + +Plug-in loading on the server uses the dlopen mode and can only be performed in the** /usr/lib** directory. Therefore, when compiling the **.so** file of a plug-in, set the output directory as **/usr/lib** in the build configuration file. + +### Naming rule + +#### Rule: Name an SDK in the format of **domain\_keyword<*other information 1*\_*other information 2*\_…>\_sdk.so**. + +You are advised to use the commonly known abbreviations for domains. For example, use **cv** for image and video, **asr** for voice recognition, and **translation** for text translation. Add one if there is no available abbreviation for a domain. Use keywords that accurately describe the algorithm capability of the plug-in. For example, use **keyword\_spotting** for wakeup keyword spotting (KWS). Add other information, such as the supported chip type and applicable region, between **keyword** and **sdk**, with each of them separated by an underscore (\_). Note that the name of a SDK must end with **\_sdk**. + +For example, if the SDK for the KWS plug-in supports only the Kirin 9000 chipset and is applicable only in China, then name the SDK as follows: **asr\_keyword\_spotting\_kirin9000\_china\_sdk.so**. + + +#### Rule: Name a plug-in in the format of **domain\_keyword<*other information 1*\_*other information 2*\_…>.so**. + +There is a one-to-one mapping between plug-ins and SDKs. Therefore, the definitions and requirements of terms such as the domain, keyword, and other information in plug-in names are the same as those in SDK names. The only difference is that the name of the SDK ends with **\_sdk** additionally. For example, if the plug-in is named **asr\_keyword\_spotting.so**, the corresponding SDK is named **asr\_keyword\_spotting\_sdk.so**. + +For example, if the SDK for the KWS plug-in supports only the Kirin 9000 chipset and is applicable only in China, then name the plug-in as follows: **asr\_keyword\_spotting\_kirin9000\_china.so**. + +### API Development + +#### Rule: Encapsulate the external APIs provided by the client based on the algorithm call sequence. For the SDK of an asynchronous plug-in, implement the **IClientCb** API provided by the client. + +The external APIs provided by the client of the AI engine include **AieClientInit**, **AieClientPrepare**, **AieClientSyncProcess**, **AieClientAsyncProcess**, **AieClientRelease**, **AieClientDestroy**, **AieClientSetOption**, and **AieClientGetOption**. The SDK needs to encapsulate at least the following five APIs in sequence: **AieClientInit**, **AieClientPrepare**, **AieClientSyncProcess** (or **AieClientAsyncProcess**), **AieClientRelease**, and **AieClientDestroy**. Otherwise, a call failure or memory leakage may occur. For example, if the **AieClientPrepare** API is omitted during encapsulation, the server cannot load the plug-in. As a result, APIs that follow it cannot be called. + +For an asynchronous plug-in, the SDK needs to implement the **IClientCb** API to receive the algorithm inference result from the client and return the result to the third-party caller. + + +#### Rule: Save all common data related to client interaction in the SDK during API implementation. + +The client of the AI engine uses the singleton pattern for API implementation. If the client is connecting to multiple SDKs, each SDK needs to store all common data exchanged with the client so that they can connect to the server to perform operations such as task inference and return the result. Common data usually includes **clientInfo**, **algorithmInfo**, and **configInfo**, which are defined in the SDK's member variables. + + +#### Recommendation: Enable the SDK to implement the **IServiceDeadCb** API defined by the client. + +The processes running on the server are system resident processes. The server provides services for clients by way of system capabilities. The **IServiceDeadCb** API is called if a server process is abnormally killed. The SDK can implement related operations in this API, for example, stopping process call or restarting the server. + +The following is an example of **IServiceDeadCb** API implementation: + + +``` +class ServiceDeadCb : public IServiceDeadCb { +public: +ServiceDeadCb() = default; +~ServiceDeadCb() override = default; +void OnServiceDead() override +{ +printf("[ServiceDeadCb]OnServiceDead Callback happens"); +} +}; +``` + +As shown above, the SDK can implement its own operations in the **OnServiceDead()** function, for example, stopping API call. + + +#### Rule: Convert dedicated algorithm data into common data of the AI engine if the SDK and plug-ins need to use the codec module. + +For plug-ins, inference data is transmitted by the third-party caller to them through the client and server. The required data type varies according to algorithms. For example, the CV algorithm requires image data, and the ASR algorithm requires audio data. To address this issue, the AI engine provides the codec capabilities to convert different types of data into common data that can be used by it. + +The encoded data is as follows: + + +``` +struct DataInfo { +unsigned char *data; +int length; +} DataInfo; + +``` + +As shown above, **DataInfo** consists of two variables: a pointer to the data memory, and the data length. + +To use the APIs of the AI engine framework, you need to: + +1. Add the dependency header file utils/encdec/include/encdec.h. + +2. Add the dependency items in the **build.gn** file. + +Add **//foundation/ai/engine/services/common** to **include\_dirs**. + +Add **//foundation/ai/engine/services/common/utils/encdec:encdec** to **deps**. + +3. Convert different types of data through codec. The following is an example: + + +``` +// Example function for encoding: arg1, arg2, and arg3 are variables to be encoded, and dataInfo is the encoding result. +retCode = ProcessEncode(dataInfo, arg1, arg2, arg3) // The number of parameters can be flexible. +// Example function for decoding: dataInfo is the data to be decoded, and arg1, arg2, and arg3 are the decoding result. +retCode = ProcessDecode(dataInfo, arg1, arg2, arg3) // The number of parameters can be flexible. +``` + +> **NOTE** +> +> - The sequence of parameters must be the same during encoding and decoding. +> - After encoding, the memory used by **dataInfo** needs to be manually released by the caller. +> - The memory is managed and released separately on the server and the client. +> - If a pointer contains the shared memory, no extra processing is required. +> - If other types of pointers are used, you need to dereference them before using **ProcessEncode** or **ProcessDecode**. +> - The codec module has not been adapted to the **class** data type and therefore it is not recommended. + + +#### Rule: Release the memory used by the encoded or decoded parameters in the SDK. Otherwise, a memory leakage occurs. + +Encoding is essentially a process of encapsulating different types of data in the same memory space and then encapsulating the start address and length of the memory into the body. A plug-in is unable to release the memory that has been allocated to output parameter data, which is returned to the SDK through encoding. To obtain the data, the SDK first needs to release the memory. + +The following is an example of releasing the memory: + + +``` +DataInfo outputInfo = { +.data = nullptr, +.length = 0, +}; +AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); +if (outputInfo.data != nullptr) { +free(outputInfo.data); +outputInfo.data = nullptr; +outputInfo.length = 0; +} +``` + + +#### Rule: Enable plug-ins to implement the **IPlugin** API defined by the server and use the **PLUGIN\_INTERFACE\_IMPL** statement to provide the function pointer for external systems. + +The server manages a variety of plug-ins, and the API implementation logic varies according to plug-ins. To unify the plug-in loading process, the AI engine provides the **IPlugin** API. In the runtime environment, a plug-in is loaded as a dynamic link library (DLL) by the AI engine framework in dlopen mode. Therefore, the plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. + + +#### Rule: Use the unified data channel provided by the AI engine for plug-ins. + +The AI engine provides a unified data channel between the server and plug-ins to send inference requests from the SDK and returned results from plug-ins. Plug-ins need to obtain the request data and encapsulate the inference result over the data channel when calling the inference API. + +The following is an example of using the data channel: + + +``` +int SyncProcess(IRequest *request, IResponse *&response) +{ +HILOGI("[IvpPlugin]Begin SyncProcess"); +if (request == nullptr) { +HILOGE("[IvpPlugin]SyncProcess request is nullptr"); +return RETCODE_NULL_PARAM; +} +DataInfo inputInfo = request->GetMsg(); +if (inputInfo.data == nullptr) { +HILOGE("[IvpPlugin]InputInfo data is nullptr"); +return RETCODE_NULL_PARAM; +} + +... + +response = IResponse::Create(request); +response->SetResult(outputInfo); +return RETCODE_SUCCESS; +} +``` + +In the example, the request and response are the data body sent over the data channel. The server encapsulates data in the request and sends it to the plug-in. After completing algorithm processing, the plug-in encapsulates the result into the response and returns it to the server over the data channel. + +## Development Guidelines + +### Developing the SDK + +The function of the SDK header file is implemented by mapping SDK API calls to client API calls. The following table lists the APIs provided by the client. + + + **Table 1** Client APIs + +| API| Description| Parameters| +| -------- | -------- | -------- | +| int **AieClientInit**(const ConfigInfo &configInfo,
 ClientInfo &clientInfo, const AlgorithmInfo
 &algorithmInfo, IServiceDeadCb \*cb) | **Function**: Links and initializes the engine service and activates IPC call.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **configInfo**: engine-related initial configuration data. This parameter must not be null.
**clientInfo**: engine client information. This parameter must not be null.
**algorithmInfo**: information about the called algorithm. This parameter must not be null.
**cb**: death callback object. This parameter can be null. | +| int **AieClientPrepare**(const ClientInfo &clientInfo
, const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo, DataInfo &outputInfo, IClientCb \*cb) | **Function**: Loads an algorithm plug-in.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**algorithmInfo**: information about the called algorithm. This parameter must not be null.
**inputInfo**: input information specified for algorithm plug-in loading. This parameter can be null.
**outputInfo**: information returned after algorithm plug-in loading, if any. This parameter can be null.
**cb**: return result of the asynchronous algorithm. This parameter must not be null for the asynchronous algorithm. For the synchronous algorithm, this parameter must be null. | +| int **AieClientAsyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const DataInfo
 &inputInfo) | **Function**: Executes an asynchronous algorithm.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**algorithmInfo**: information about the called algorithm. This parameter must not be null.
**inputInfo**: input information specified for algorithm operations. This parameter can be null. | +| int **AieClientSyncProcess**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo, DataInfo &outputInfo) | **Function**: Executes a synchronous algorithm.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**algorithmInfo**: information about the called algorithm. This parameter must not be null.
**inputInfo**: input information specified for algorithm operations. This parameter can be null.
**outputInfo**: output information in the return result of the synchronous algorithm. This parameter can be null. | +| int **AieClientRelease**(const ClientInfo &clientInfo,
 const AlgorithmInfo &algorithmInfo, const
 DataInfo &inputInfo) | **Function**: Uninstalls an algorithm plug-in.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**algorithmInfo**: information about the algorithm plug-in to be uninstalled. This parameter must not be null.
**inputInfo**: input information specified for algorithm plug-in uninstallation. This parameter can be null. | +| int **AieClientDestroy**(ClientInfo &clientInfo) | **Function**: Disconnects from the server and releases the cache.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null. | +| int **AieClientSetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo) | **Function**: Sets configuration items. You can use this API to pass algorithm's extended information to plug-ins.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**optionType**: algorithm used for obtaining the configuration item information. An algorithm plug-in can use this parameter as needed. This parameter must not be null.
**inputInfo**: Indicates algorithm parameter information. An algorithm plug-in can use this parameter as needed. This parameter can be null. | +| int **AieClientGetOption**(const ClientInfo &clientInfo,
 int optionType, const DataInfo &inputInfo,
 DataInfo &outputInfo) | **Function**: Obtains configuration item information based on the specified **optionType** and **inputInfo**.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **clientInfo**: engine client information. This parameter must not be null.
**optionType**: algorithm used for obtaining the configuration item information. This parameter must not be null.
**inputInfo**: input information specified for obtaining configuration item information of the algorithm. This parameter can be null.
**outputInfo**: configuration item information in the return result. This parameter can be null. | + + +The following table describes the data structure of **ConfigInfo**, **ClientInfo**, **AlgorithmInfo**, and **DataInfo**. + + + **Table 2** Data structure of ConfigInfo, ClientInfo, AlgorithmInfo, and DataInfo + +| Data Structure| Description| Attributes| +| -------- | -------- | -------- | +| ConfigInfo | Algorithm configuration item information| **const char \*description**: body of configuration item information. | +| ClientInfo | Client information.| **long long clientVersion**: client version number. This parameter is not used currently.
**int clientId**: client ID.
**int sessionId**: session ID.
**uid\_t serverUid**: server UID.
**uid\_t clientUid**: client UID.
**int extendLen**: length of the extended information (**extendMsg**).
**unsigned char \*extendMsg**: body of the extended information. | +| AlgorithmInfo | Algorithm information| **long long clientVersion**: client version number. This parameter is not used currently.
**bool isAsync**: whether asynchronous execution is used.
**int algorithmType**: algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.
**long long algorithmVersion**: algorithm version number.
**bool isCloud**: whether to migrate data to the cloud. This parameter is not used currently.
**int operateId**: execution ID. This parameter is not used currently.
**int requestId**: request ID, which identifies each request and corresponds to the execution result.
**int extendLen**: length of the extended information (**extendMsg**).
**unsigned char \*extendMsg**: body of the extended information. | +| DataInfo | Algorithm input parameter configuration information (**inputInfo**) and output parameter configuration information (**outputInfo**)| **unsigned char \*data**: data subject.
**int length**: data length. | + + +For details about the development process, see the development example of the [KWS SDK](#kws-sdk). + +### Developing a Plug-in +The AI engine framework has defined a set of algorithm plug-in access specifications. Each plug-in needs to implement specified APIs to implement functions such as obtaining the plug-in version information and algorithm inference type, executing synchronous and asynchronous algorithms, loading algorithm plug-ins, uninstalling algorithm plug-ins, setting algorithm configuration information, and obtaining specified algorithm configuration information. Specifically, implement the **SyncProcess** API for the synchronous algorithm and the **AsyncProcess** API for the asynchronous algorithm. + + +The following table describes the **IPlugin** APIs. + + + **Table 3** IPlugin APIs + +| API| Description| Parameters| +| -------- | -------- | -------- | +| const long long GetVersion() const; | **Function**: Obtains the plug-in version information.
**Return value**: version number (in the **long long** format)| - | +| const char \*GetInferMode() const; | **Function**: Obtains the algorithm inference type.
**Return value**: "SYNC" or "ASYNC"| - | +| int SyncProcess(IRequest \*request,
IResponse \*&response); | **Function**: Executes a synchronous algorithm.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **request**: used to pass the request content to the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.
**response**: used to receive the synchronous algorithm execution result returned by the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.| +| int AsyncProcess(IRequest \*request,
IPluginAlgorithmCallback \*callback); | **Function**: Executes an asynchronous algorithm.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **request**: used to pass the request content to the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.
**callback**: used to return the asynchronous algorithm execution result to the engine server. This parameter must not be null.| +| int Prepare(long long transactionId,
const DataInfo &inputInfo, DataInfo
&outputInfo); | **Function**: Loads an algorithm plug-in.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **transactionId**: transaction ID, which is used to identify the client and session. This parameter must not be null.
**inputInfo**: input information specified for algorithm plug-in loading. This parameter can be null.
**outputInfo**: output information in the return result of algorithm plug-in loading. This parameter can be null.| +| int Release(bool isFullUnload, long long
transactionId, const DataInfo &inputInfo); | **Function**: Uninstalls an algorithm plug-in.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **isFullUnload**: whether a plug-in is called by only one client. A plug-in can be uninstalled only when it is called by only one client. This parameter must not be null.
**transactionId**: transaction ID, which is used to identify the client and session. This parameter must not be null.
**inputInfo**: input information specified for algorithm plug-in uninstallation. This parameter can be null.| +| int SetOption(int optionType, const
DataInfo &inputInfo); | **Function**: Sets configuration items. You can use this API to pass algorithm's extended information to plug-ins.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **optionType**: algorithm used for obtaining the configuration item information. An algorithm plug-in can use this parameter as needed. This parameter must not be null.
**inputInfo**: algorithm parameter information. An algorithm plug-in can use this parameter as needed. This parameter can be null.| +| int GetOption(int optionType, const
DataInfo &inputInfo, DataInfo
&outputInfo); | **Function**: Obtains configuration item information based on the specified **optionType** and **inputInfo**.
**Return value**: **0** if the operation is successful; a non-zero value otherwise.| **optionType**: algorithm used for obtaining the configuration item information. This parameter must not be null.
**inputInfo**: input information specified for obtaining configuration item information of the algorithm. This parameter can be null.
**outputInfo**: configuration item information in the return result. This parameter can be null.| + + +Algorithm plug-in APIs including **Prepare**, **SyncProcess**, **AsyncProcess**, **Release**, **SetOption**, and **GetOption** are in 1:1 mapping with the client APIs including **AieClientPrepare**, **AieClientSyncProcess**, **AieClientAsyncProcess**, **AieClientRelease**, **AieClientSetOption**, and **AieClientGetOption**. The **GetInferMode** API is used to return the algorithm execution type, which can be synchronous or asynchronous. + + +The following table describes the **IPluginCallback** APIs. + + + **Table 4** IPluginCallback APIs + +| API| Description| Parameters| +| -------- | -------- | -------- | +| void OnEvent(PluginEvent event,
IResponse \*response); | **Function**: Returns the asynchronous algorithm execution result.| **event**: used to enumerate the algorithm execution result. The value can be **ON\_PLUGIN\_SUCCEED** or **ON\_PLUGIN\_FAIL**.
**response**: used to return the algorithm execution result.| + + +The **Request** and **Response** classes define the requests and responses used for communication between the AI engine server and algorithm plug-ins. A request encapsulates the request content and input data of the caller. The plug-in returns the calculation result to the AI engine server through a response. + + +The following table describes the attributes of the **Request** class. + + + **Table 5** Attributes of the Request class + +| Attribute| Description| Default Value| +| -------- | -------- | -------- | +| innerSequenceId_ | **Type**: long long
**Function**: reserved| 0 | +| requestId_ | **Type**: int
**Function**: Indicates the request sequence, which is used to bind the return result.| 0 | +| operationId_ | **Type**: int
**Function**: reserved| 0 | +| transactionId_ | Type: long long
**Function**: Indicates the transaction ID, which is the combination of **clientId** and **sessionId**.| 0 | +| algoPluginType_ | **Type**: int
**Function**: Indicates the algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.| 0 | +| msg_ | **Type**: DataInfo
**Function**: Stores the input parameters for calling the algorithm API.| .data = nullptr
.length = 0 | + + +The following table describes the attributes of the **Response** class. + + + **Table 6** Attributes of the Response class + +| Attribute| Description| Default Value| +| -------- | -------- | -------- | +| innerSequenceId_ | Type: long long
**Function**: reserved| 0 | +| requestId_ | **Type**: int
**Function**: Indicates the request sequence, which is used to bind the return result.| 0 | +| retCode__ | **Type**: int
**Function**: Indicates the inference result code of the asynchronous algorithm.| 0 | +| retDesc_ | **Type**: string
**Function**: reserved| - | +| transactionId_ | Type: long long
**Function**: Indicates the transaction ID, which is the combination of **clientId** and **sessionId**.| 0 | +| algoPluginType_ | **Type**: int
**Function**: Indicates the algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.| INVALID_ALGO_PLUGIN_TYPE(-1) | +| result_ | **Type**: DataInfo
**Function**: Stores the inference result of the asynchronous algorithm.| .data = nullptr
.length = 0 | + + +For details about the development process, see the development example of the [KWS plug-in](#kws-plug-in). + +### Preparing the Configuration File + +The SDK identifies the plug-in type based on **algorithmVersion** and **algorithmType** in the **AlgorithmInfo** structure so it can call the plug-in capabilities. Therefore, you need to develop the plug-in configuration file as follows: + + +1. Add the plug-in configuration file to the **//foundation/ai/engine/services/common/protocol/plugin\_config/plugin\_config\_ini/** directory. + +2. Add the algorithm type to the **aie\_algorithm_type.h** file in the **//foundation/ai/engine/services/common/protocol/plugin\_config/** directory. + +3. Add the name of the KWS algorithm and its sequence number in **ALGORITHM\_TYPE\_ID\_LIST** to the **aie\_plugin\_info.h** file in the **//foundation/ai/engine/services/server/plugin\_manager/include/** directory. + +For details about the development process, see the development example of the [configuration file](#kws-configuration-file). + +## Development Example + +### KWS SDK + + +1. Add the API definition of the KWS SDK to the **//foundation/ai/engine /interfaces/kits** directory. This API can be called by third-party applications. The following code snippet is an example API for the KWS SDK. The reference code is available at the **//foundation/ai/engine /interfaces/kits/asr/keyword\_spotting** directory. + + ``` + class KWSSdk { + public: + KWSSdk(); + virtual ~KWSSdk(); + + // Create a KWS SDK instance. + int32_t Create(); + + // Synchronously execute the KWS task. + int32_t SyncExecute(const Array &audioInput); + + // Set the KWS callback. + int32_t SetCallback(const std::shared_ptr &callback); + + // Destroy the KWS SDK instance to release the session engaged with the plug-in. + int32_t Destroy(); + }; + ``` + +2. Add the API implementation of the SDK to the **//foundation/ai/engine/services/client/algorithm\_sdk** directory and call the APIs provided by the client to use the algorithm plug-in capabilities. The following code snippet is an example implementation of the **create** method in the API of the KWS SDK. For more details, see the reference code at **//foundation/ai/engine/services/client/algorithm\_sdk/asr/keyword\_spotting**. + + ``` + int32_t KWSSdk::KWSSdkImpl::Create() + { + if (kwsHandle_ != INVALID_KWS_HANDLE) { + HILOGE("[KWSSdkImpl]The SDK has been created"); + return KWS_RETCODE_FAILURE; + } + if (InitComponents() != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]Fail to init sdk components"); + return KWS_RETCODE_FAILURE; + } + // Call the AieClientInit API provided by the client to initialize the engine service and activate IPC call. + int32_t retCode = AieClientInit(configInfo_, clientInfo_, algorithmInfo_, nullptr); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]AieClientInit failed. Error code[%d]", retCode); + return KWS_RETCODE_FAILURE; + } + if (clientInfo_.clientId == INVALID_CLIENT_ID) { + HILOGE("[KWSSdkImpl]Fail to allocate client id"); + return KWS_RETCODE_FAILURE; + } + DataInfo inputInfo = { + .data = nullptr, + .length = 0, + }; + DataInfo outputInfo = { + .data = nullptr, + .length = 0, + }; + // Call the AieClientPrepare API provided by the client to load the algorithm plug-in. + retCode = AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]AieclientPrepare failed. Error code[%d]", retCode); + return KWS_RETCODE_FAILURE; + } + if (outputInfo.data == nullptr || outputInfo.length <= 0) { + HILOGE("[KWSSdkImpl]The data or length of output info is invalid"); + return KWS_RETCODE_FAILURE; + } + MallocPointerGuard pointerGuard(outputInfo.data); + retCode = PluginHelper::UnSerializeHandle(outputInfo, kwsHandle_); + if (retCode != RETCODE_SUCCESS) { + HILOGE("[KWSSdkImpl]Get handle from inputInfo failed"); + return KWS_RETCODE_FAILURE; + } + return KWS_RETCODE_SUCCESS; + } + ``` + + The preceding code is the specific API implementation. The **create** function in the API of the KWS SDK calls the open **AieClientInit** and **AieClientPrepare** APIs provided by the client to connect to the server and load the algorithm model. + + > **NOTE** + > + > The sequence for the SDK to call client APIs of the AI engine is as follows: AieClientInit -> AieClientPrepare -> AieClientSyncProcess/AieClientAsyncProcess -> AieClientRelease -> AieClientDestroy. An exception will be thrown if the call sequence is violated. + +### KWS Plug-in +Add the API definition (that is, **IPlugin**) of the KWS plug-in to the **//foundation/ai/engine/services/server/plugin** directory. This API is used to call AI capabilities. The following code snippet is an example API implementation of the KWS plug-in. The reference code is available at the **//foundation/ai/engine/services/server/plugin/asr/keyword\_spotting** directory. + + ``` + #include "plugin/i_plugin.h + class KWSPlugin : public IPlugin { + public: + KWSPlugin(); + ~KWSPlugin(); + const long long GetVersion() const override; + const char* GetName() const override; + const char* GetInferMode() const override; + int32_t Prepare(long long transactionId, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; + int32_t SetOption(int optionType, const DataInfo &amp;inputInfo) override; + int32_t GetOption(int optionType, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; + int32_t SyncProcess(IRequest *request, IResponse *&amp;response) override; + int32_t AsyncProcess(IRequest *request, IPluginCallback*callback) override; + int32_t Release(bool isFullUnload, long long transactionId, const DataInfo &amp;inputInfo) override; + }; + ``` +The preceding code implements the **IPlugin** APIs provided by the server. The following table shows the mapping between the client APIs and the plug-in APIs. + +**Table 7** Mapping between the client APIs and the plug-in APIs + +| Client API| Plug-in API| Description| +| -------- | -------- | -------- | +| AieClientPrepare | Prepare | Initializes the inference algorithm plug-in. For KWS, this API loads the KWS model from the fixed location (**/sdcard/wenwen\_inst.wk**) to the memory.| +| AieClientSyncProcess | SyncProcess | Executes the inference algorithm synchronously. For KWS, this API synchronously executes the audio inference algorithm to determine whether the specified wakeup keyword exists in the audio.| +| AieClientAsyncProcess | AsyncProcess | Executes the inference algorithm asynchronously. Currently, this API is not used in KWS. However, you can implement the API based on your use case.| +| AieClientSetOption | SetOption | Sets algorithm-related configuration items, such as the confidence threshold and delay. Currently, this API is not used in KWS. However, you can implement the API based on your use case.| +| AieClientGetOption | GetOption | Obtains algorithm-related configuration items. For KWS, this API can obtain the input and output scale of the KWS model. The input scale is the MFCC feature (fixed value: **4000**) required by the KWS model, and the output scale is the confidence (fixed value: **2**) of the result.| +| AieClientRelease | Release | Releases the algorithm model. For KWS, this API releases the specified algorithm model and clears the dynamic memory in the feature processor.| + +> **NOTE** +> +> - The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in. +> - The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. + + + ``` + PLUGIN_INTERFACE_IMPL(KWSPlugin); + ``` + +### KWS Configuration File + +1. Add the KWS configuration file to the **//foundation/ai/engine/services/common/protocol/plugin\_config/plugin\_config\_ini/** directory. + + ``` + [base] + supported_boards = hi3516dv300 + related_sessions = asr_keyword_spotting+20001002 + + // Naming rule: [algorithm name+algorithm version], for example, [asr\_keyword\_spotting+20001002] + [asr_keyword_spotting+20001002] + AID = asr_keyword_spotting + VersionCode = 20001002 + VersionName = 2.00.01.002 + XPU = NNIE + District = China + // Location of the complied **.so** file of the plug-in + FullPath = /usr/lib/libasr_keyword_spotting.so + Chipset = ALL + ChkSum = '' + Key = '' + ``` + +2. Add the type ID of the KWS algorithm to the **aie\_algorithm_type.h** file in the **//foundation/ai/engine/services/common/protocol/plugin\_config/** directory. + + ``` + // Make sure that the type ID maps to the sequence number in **ALGORITHM\_TYPE\_ID\_LIST**. + const int ALGORITHM_TYPE_KWS = 3; + ``` + +3. Add the name of the KWS algorithm and its sequence number in **ALGORITHM\_TYPE\_ID\_LIST** to the **aie\_plugin\_info.h** file in the **//foundation/ai/engine/services/server/plugin\_manager/include/** directory. + + ``` + const std::string ALGORITHM_ID_SAMPLE_1 = "sample_plugin_1"; + const std::string ALGORITHM_ID_SAMPLE_2 = "sample_plugin_2"; + const std::string ALGORITHM_ID_IVP = "cv_human_detect"; + // Add the name of the KWS algorithm: asr\_keyword\_spotting. + // Name the algorithm variable in the same way as the algorithm type ID in ALGORITHM\_TYPE\_ID\_LIST, for example, ALGORITHM_ID_KWS. + const std::string ALGORITHM_ID_KWS = "asr_keyword_spotting"; + const std::string ALGORITHM_ID_IC = "cv_image_classification"; + const std::string ALGORITHM_ID_INVALID = "invalid algorithm id"; + + const std::vector ALGORITHM_TYPE_ID_LIST = { + ALGORITHM_ID_SAMPLE_1, + ALGORITHM_ID_SAMPLE_2, + ALGORITHM_ID_IVP, + // Add the sequence number of the KWS algorithm to ALGORITHM\_TYPE\_ID\_LIST, so that the name of the KWS algorithm can be obtained based on the sequence number. + // Make sure that the algorithm name maps to the sequence number in ALGORITHM\_TYPE\_ID\_LIST. + ALGORITHM_ID_KWS, + ALGORITHM_ID_IC, + }; + ``` diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-conf.md b/en/device-dev/subsystems/subsys-aiframework-demo-conf.md deleted file mode 100644 index b27bf00e86d0dab442ce90b3458bd88ab15b09e9..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-demo-conf.md +++ /dev/null @@ -1,54 +0,0 @@ -# KWS Configuration File - -1. Add the KWS configuration file to the **//foundation/ai/engine/services/common/protocol/plugin\_config/plugin\_config\_ini/** directory. - - ``` - [base] - supported_boards = hi3516dv300 - related_sessions = asr_keyword_spotting+20001002 - - // Naming rule: [algorithm name+algorithm version], for example, [asr_keyword_spotting+20001002] - [asr_keyword_spotting+20001002] - AID = asr_keyword_spotting - VersionCode = 20001002 - VersionName = 2.00.01.002 - XPU = NNIE - District = China - // Location of the complied .so file of the plug-in - FullPath = /usr/lib/libasr_keyword_spotting.so - Chipset = ALL - ChkSum = '' - Key = '' - ``` - -2. Add the type ID of the KWS algorithm to the **aie\_algorithm\_type.h** file in the **//foundation/ai/engine/services/common/protocol/plugin\_config/** directory. - - ``` - // Make sure that the type ID maps to the sequence number in ALGORITHM_TYPE_ID_LITS. - const int ALGORITHM_TYPE_KWS = 3; - ``` - -3. Add the name of the KWS algorithm and its sequence number in **ALGORITHM\_TYPE\_ID\_LITS** to the **aie\_plugin\_info.h** file in the **//foundation/ai/engine/services/server/plugin\_manager/include/** directory. - - ``` - const std::string ALGORITHM_ID_SAMPLE_1 = "sample_plugin_1"; - const std::string ALGORITHM_ID_SAMPLE_2 = "sample_plugin_2"; - const std::string ALGORITHM_ID_IVP = "cv_human_detect"; - // Add the name of the KWS algorithm: asr_keyword_spotting. - // Name the algorithm variable in the same way as the algorithm type ID in ALGORITHM_TYPE_ID_LIST, for example, ALGORITHM_ID_KWS. - const std::string ALGORITHM_ID_KWS = "asr_keyword_spotting"; - const std::string ALGORITHM_ID_IC = "cv_image_classification"; - const std::string ALGORITHM_ID_INVALID = "invalid algorithm id"; - - const std::vector ALGORITHM_TYPE_ID_LIST = { - ALGORITHM_ID_SAMPLE_1, - ALGORITHM_ID_SAMPLE_2, - ALGORITHM_ID_IVP, - // Add the sequence number of the KWS algorithm to ALGORITHM_TYPE_ID_LITS, so that the name of the KWS algorithm can be obtained based on the sequence number. - // Make sure that the algorithm name maps to the sequence number in ALGORITHM_TYPE_ID_LITS. - ALGORITHM_ID_KWS, - ALGORITHM_ID_IC, - }; - ``` - - diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md b/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md deleted file mode 100644 index 5bb827d8262903199e27122c11b9e5f65d5c5cb1..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md +++ /dev/null @@ -1,43 +0,0 @@ -# KWS Plug-in - -1. Add the API of the KWS plug-in to the **//foundation/ai/engine/services/server/plugin** directory. This API is used to call AI capabilities. The following code snippet is an example API implementation of the KWS plug-in. The reference code is available at the **//foundation/ai/engine/services/server/plugin/asr/keyword\_spotting** directory. - - ``` - #include "plugin/i_plugin.h - class KWSPlugin : public IPlugin { - public: - KWSPlugin(); - ~KWSPlugin(); - const long long GetVersion() const override; - const char* GetName() const override; - const char* GetInferMode() const override; - int32_t Prepare(long long transactionId, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; - int32_t SetOption(int optionType, const DataInfo &amp;inputInfo) override; - int32_t GetOption(int optionType, const DataInfo &amp;inputInfo, DataInfo &amp;outputInfo) override; - int32_t SyncProcess(IRequest *request, IResponse *&amp;response) override; - int32_t AsyncProcess(IRequest *request, IPluginCallback*callback) override; - int32_t Release(bool isFullUnload, long long transactionId, const DataInfo &amp;inputInfo) override; - }; - ``` - - The preceding code implements the **IPlugin** API provided by the server. The following table shows the mapping between the client APIs and the plug-in APIs. - - **Table 1** Mapping between the client APIs and the plug-in APIs - -| Client API | Plug-in API | Description | -| ---------- | ----------- | ----------- | -| AieClientPrepare | Prepare | Initializes the inference algorithm plug-in. For KWS, this API loads the KWS model from the fixed location (/sdcard/wenwen_inst.wk) to the memory. | -| AieClientSyncProcess | SyncProcess | Executes the inference algorithm synchronously. For KWS, this API synchronously executes the audio inference algorithm to determine whether the specified wakeup keyword exists in the audio. | -| AieClientAsyncProcess | AsyncProcess | Executes the inference algorithm asynchronously. Currently, this API is not used in KWS. However, you can implement the API based on your use case. | -| AieClientSetOption | SetOption | Sets algorithm-related configuration items, such as the confidence threshold and delay. Currently, this API is not used in KWS. However, you can implement the API based on your use case. | -| AieClientGetOption | GetOption | Obtains algorithm-related configuration items. For KWS, this API can obtain the input and output scale of the KWS model. The input scale is the MFCC feature (fixed value: 4000) required by the KWS model, and the output scale is the confidence (fixed value: 2) of the result. | -| AieClientRelease | Release | Releases the algorithm model. For KWS, this API releases the specified algorithm model and clears the dynamic memory in the feature processor. | - ->![](../public_sys-resources/icon-note.gif)**NOTE** ->- The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in. ->- The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. - - - ``` - PLUGIN_INTERFACE_IMPL(KWSPlugin); - ``` \ No newline at end of file diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md b/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md deleted file mode 100644 index c6e5dbe4195526413c7e86a6b48ecd956b3785e1..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md +++ /dev/null @@ -1,80 +0,0 @@ -# KWS SDK - -1. Add the API of the KWS SDK to the **//foundation/ai/engine /interfaces/kits** directory. This API can be called by third-party applications. The following code snippet is an example API for the KWS SDK. The reference code is available at the **//foundation/ai/engine /interfaces/kits/asr/keyword\_spotting** directory. - - ``` - class KWSSdk { - public: - KWSSdk(); - virtual ~KWSSdk(); - - // Create a KWS SDK instance. - int32_t Create(); - - // Synchronously execute the KWS task. - int32_t SyncExecute(const Array &audioInput); - - // Set the KWS callback. - int32_t SetCallback(const std::shared_ptr &callback); - - // Destroy the KWS SDK instance to release the session engaged with the plug-in. - int32_t Destroy(); - }; - ``` - -2. Add the API implementation of the SDK to the **//foundation/ai/engine/services/client/algorithm\_sdk** directory and call the APIs provided by the client to use the algorithm plug-in capabilities. The following code snippet is an example implementation of the **create** method in the API of the KWS SDK. For more details, see the reference code at **//foundation/ai/engine/services/client/algorithm\_sdk/asr/keyword\_spotting**. - - ``` - int32_t KWSSdk::KWSSdkImpl::Create() - { - if (kwsHandle_ != INVALID_KWS_HANDLE) { - HILOGE("[KWSSdkImpl]The SDK has been created"); - return KWS_RETCODE_FAILURE; - } - if (InitComponents() != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]Fail to init sdk components"); - return KWS_RETCODE_FAILURE; - } - // Call the AieClientInit API provided by the client to initialize the engine service and activate IPC call. - int32_t retCode = AieClientInit(configInfo_, clientInfo_, algorithmInfo_, nullptr); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]AieClientInit failed. Error code[%d]", retCode); - return KWS_RETCODE_FAILURE; - } - if (clientInfo_.clientId == INVALID_CLIENT_ID) { - HILOGE("[KWSSdkImpl]Fail to allocate client id"); - return KWS_RETCODE_FAILURE; - } - DataInfo inputInfo = { - .data = nullptr, - .length = 0, - }; - DataInfo outputInfo = { - .data = nullptr, - .length = 0, - }; - // Call the AieClientPrepare API provided by the client to load the algorithm plug-in. - retCode = AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]AieclientPrepare failed. Error code[%d]", retCode); - return KWS_RETCODE_FAILURE; - } - if (outputInfo.data == nullptr || outputInfo.length <= 0) { - HILOGE("[KWSSdkImpl]The data or length of output info is invalid"); - return KWS_RETCODE_FAILURE; - } - MallocPointerGuard pointerGuard(outputInfo.data); - retCode = PluginHelper::UnSerializeHandle(outputInfo, kwsHandle_); - if (retCode != RETCODE_SUCCESS) { - HILOGE("[KWSSdkImpl]Get handle from inputInfo failed"); - return KWS_RETCODE_FAILURE; - } - return KWS_RETCODE_SUCCESS; - } - ``` - - The preceding code is the specific API implementation. The **create** function in the API of the KWS SDK calls the open **AieClientInit** and **AieClientPrepare** APIs provided by the client to connect to the server and load the algorithm model. For details, see the implementation of the **create** method in following sections. - - >![](../public_sys-resources/icon-note.gif) **NOTE** - > - >The sequence for the SDK to call client APIs: **AieClientInit** -\> **AieClientPrepare** -\> **AieClientSyncProcess** or **AieClientAsyncProcess** -\> **AieClientRelease** -\> **AieClientDestroy**. An exception will be thrown if the call sequence is violated. diff --git a/en/device-dev/subsystems/subsys-aiframework-demo.md b/en/device-dev/subsystems/subsys-aiframework-demo.md deleted file mode 100644 index 0dd54a375edf3ec101a6999dfd25d3f424c5cca4..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-demo.md +++ /dev/null @@ -1,13 +0,0 @@ -# Development Examples - -For your better understanding, a KWS application is used as an example to walk you through the development process. You can develop the KWS SDK and plug-in based on the AI engine framework on the Hi3516D V300 development board, compile an image for the new version, and burn the image into the version. Then, develop an application with the KWS function. The application can receive external audio and pass the audio to the SDK API. If the audio contains specified keywords, the application will be able to recognize these keywords and print them in the command line. - -This example uses a fixed keyword **Hi, xiaowen** for illustration. If the input audio contains **Hi, xiaowen**, the application prints **\[Hi, xiaowen\]**; otherwise, the application prints **\[UNKNOWN\]**. - -- **[KWS SDK](subsys-aiframework-demo-sdk.md)** - -- **[KWS Plug-in](subsys-aiframework-demo-plugin.md)** - -- **[KWS Configuration File](subsys-aiframework-demo-conf.md)** - - diff --git a/en/device-dev/subsystems/subsys-aiframework-devguide-conf.md b/en/device-dev/subsystems/subsys-aiframework-devguide-conf.md deleted file mode 100644 index 6875bfafe43a5f47705daad84747b3993bf5cb44..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-devguide-conf.md +++ /dev/null @@ -1,10 +0,0 @@ -# Configuration File - -The SDK identifies the plug-in type based on **algorithmVersion** and **algorithmType** in the **AlgorithmInfo** structure so it can call the plug-in capabilities. Therefore, you need to develop the plug-in configuration file as follows: - -1. Add the plug-in configuration file to the **//foundation/ai/engine/services/common/protocol/plugin\_config/plugin\_config\_ini/** directory. -2. Add the algorithm type to the **aie\_algorithm\_type.h** file in the **//foundation/ai/engine/services/common/protocol/plugin\_config/** directory. -3. Add the name of the KWS algorithm and its sequence number in **ALGORITHM\_TYPE\_ID\_LITS** to the **aie\_plugin\_info.h** file in the **//foundation/ai/engine/services/server/plugin\_manager/include/** directory. - -For details about the development process, see the development example for the KWS configuration file. - diff --git a/en/device-dev/subsystems/subsys-aiframework-devguide-plugin.md b/en/device-dev/subsystems/subsys-aiframework-devguide-plugin.md deleted file mode 100644 index 2a743f9dc6982779298802ff108d40fd27f0c5c6..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-devguide-plugin.md +++ /dev/null @@ -1,261 +0,0 @@ -# Plug-in - -The AI engine framework has defined a set of algorithm plug-in access specifications. Each plug-in needs to implement specified APIs to implement functions such as obtaining the plug-in version information and algorithm inference type, executing synchronous and asynchronous algorithms, loading algorithm plug-ins, uninstalling algorithm plug-ins, setting algorithm configuration information, and obtaining specified algorithm configuration information. Specifically, implement the **SyncProcess** API for the synchronous algorithm and the **AsyncProcess** API for the asynchronous algorithm. - -[Table 1](#table1329717488505) describes the **IPlugin** APIs. - -**Table 1** IPlugin APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

Parameters

-

const long long GetVersion() const;

-

Function: Obtains the plug-in version information.

-

Return value: version number (long long)

-

-

-

const char *GetInferMode() const;

-

Function: Obtains the algorithm inference type.

-

Return value: SYNC or ASYNC

-

-

-

int SyncProcess(IRequest *request, IResponse *&response);

-

Function: Executes a synchronous algorithm.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

request: Passes the request content to the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.

-

response: Receives the synchronous algorithm execution result returned by the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.

-

int AsyncProcess(IRequest *request, IPluginAlgorithmCallback *callback);

-

Function: Executes an asynchronous algorithm.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

request: Passes the request content to the algorithm plug-in over the data channel between the engine server and the plug-in. This parameter must not be null.

-

callback: Returns the asynchronous algorithm execution result to the engine server. This parameter must not be null.

-

int Prepare(long long transactionId, const DataInfo &inputInfo, DataInfo &outputInfo);

-

Function: Loads an algorithm plug-in.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

transactionId: Indicates the transaction ID, which is used to identify the client and session. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm plug-in loading. This parameter can be null.

-

outputInfo: Indicates output information in the return result of algorithm plug-in loading. This parameter can be null.

-

int Release(bool isFullUnload, long long transactionId, const DataInfo &inputInfo);

-

Function: Uninstalls an algorithm plug-in.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

isFullUnload: Indicates whether a plug-in is called by only one client. A plug-in can be uninstalled only when it is called by only one client. This parameter must not be null.

-

transactionId: Indicates the transaction ID, which is used to identify the client and session. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm plug-in uninstallation. This parameter can be null.

-

int SetOption(int optionType, const DataInfo &inputInfo);

-

Function: Sets configuration items. You can use this API to pass algorithm's extended information to plug-ins.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

optionType: Indicates the algorithm for obtaining the configuration item information. An algorithm plug-in can use this parameter as needed. This parameter must not be null.

-

inputInfo: Indicates algorithm parameter information. An algorithm plug-in can use this parameter as needed. This parameter can be null.

-

int GetOption(int optionType, const DataInfo &inputInfo, DataInfo &outputInfo);

-

Function: Obtains configuration item information based on the specified optionType and inputInfo.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

optionType: Indicates the algorithm for obtaining the configuration item information. This parameter must not be null.

-

inputInfo: Indicates input information specified for obtaining configuration item information of the algorithm. This parameter can be null.

-

outputInfo: Indicates the configuration item information in the return result. This parameter can be null.

-
- -Algorithm plug-in APIs including **Prepare**, **SyncProcess**, **AsyncProcess**, **Release**, **SetOption**, and **GetOption** are in 1:1 mapping with the client APIs including **AieClientPrepare**, **AieClientSyncProcess**, **AieClientAsyncProcess**, **AieClientRelease**, **AieClientSetOption**, and **AieClientGetOption**. The **GetInferMode** API is used to return the algorithm execution type, which can be synchronous or asynchronous. - -[Table 2](#table461192635114) describes the **IPluginCallback** APIs. - -**Table 2** IPluginCallback APIs - - - - - - - - - - - - -

API

-

Description

-

Parameters

-

void OnEvent(PluginEvent event, IResponse *response);

-

Function: Returns the asynchronous algorithm execution result.

-

event: Enumerates the algorithm execution result. The value can be ON_PLUGIN_SUCCEED or ON_PLUGIN_FAIL.

-

response: Encapsulates the algorithm execution result.

-
- -The **Request** and **Response** classes define the requests and responses used for communication between the AI engine server and algorithm plug-ins. A request encapsulates the request content and input data of the caller. The plug-in returns the calculation result to the AI engine server through a response. - -[Table 3](#table16273647125120) describes the attributes of the **Request** class. - -**Table 3** Attributes of the Request class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Default Value

-

innerSequenceId_

-

Type: long long

-

Function: reserved

-

0

-

requestId_

-

Type: int

-

Function: Indicates the request sequence, which is used to bind the return result.

-

0

-

operationId_

-

Type: int

-

Function: reserved

-

0

-

transactionId_

-

Type: long long

-

Function: Indicates the transaction ID, which is the combination of clientId and sessionId.

-

0

-

algoPluginType_

-

Type: int

-

Function: Indicates the algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.

-

0

-

msg_

-

Type: DataInfo

-

Function: Stores the input parameters for calling the algorithm API.

-

.data = nullptr

-

.length = 0

-
- -[Table 4](#table1798597135212) describes the attributes of the **Response** class. - -**Table 4** Attributes of the Response class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Default Value

-

innerSequenceId_

-

Type: long long

-

Function: reserved

-

0

-

requestId_

-

Type: int

-

Function: Indicates the request sequence, which is used to bind the return result.

-

0

-

retCode__

-

Type: int

-

Function: Indicates the inference result code of the asynchronous algorithm.

-

0

-

retDesc_

-

Type: string

-

Function: reserved

-

-

-

transactionId_

-

Type: long long

-

Function: Indicates the transaction ID, which is the combination of clientId and sessionId.

-

0

-

algoPluginType_

-

Type: int

-

Function: Indicates the algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.

-

INVALID_ALGO_PLUGIN_TYPE(-1)

-

result_

-

Type: DataInfo

-

Function: Stores the inference result of the asynchronous algorithm.

-

.data = nullptr

-

.length = 0

-
- -For details about the development process, see the development example for the KWS plug-in. - diff --git a/en/device-dev/subsystems/subsys-aiframework-devguide-sdk.md b/en/device-dev/subsystems/subsys-aiframework-devguide-sdk.md deleted file mode 100644 index f185750d0f6ffa1d1027b717e6b67acc9e1fd666..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-devguide-sdk.md +++ /dev/null @@ -1,162 +0,0 @@ -# SDK - -The function of the SDK header file is implemented by mapping SDK API calls to client API calls. [Table 1](#table203963834718) lists the APIs provided by the client. - -**Table 1** APIs provided by the client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

Parameters

-

int AieClientInit(const ConfigInfo &configInfo, ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, IServiceDeadCb *cb)

-

Function: Links and initializes the engine service and activates IPC call.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

configInfo: Indicates engine-related initial configuration data. This parameter must not be null.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

algorithmInfo: Indicates information about the called algorithm. This parameter must not be null.

-

cb: Indicates the death callback object. This parameter can be null.

-

int AieClientPrepare(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo, DataInfo &outputInfo, IClientCb *cb)

-

Function: Loads an algorithm plug-in.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

algorithmInfo: Indicates information about the called algorithm. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm plug-in loading. This parameter can be null.

-

outputInfo: Indicates information returned after algorithm plug-in loading, if any. This parameter can be null.

-

cb: Indicates the return result of the asynchronous algorithm. This parameter must not be null for the asynchronous algorithm. For the synchronous algorithm, this parameter must be null.

-

int AieClientAsyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo)

-

Function: Executes an asynchronous algorithm.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

algorithmInfo: Indicates information about the called algorithm. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm operations. This parameter can be null.

-

int AieClientSyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo, DataInfo &outputInfo)

-

Function: Executes a synchronous algorithm.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

algorithmInfo: Indicates information about the called algorithm. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm operations. This parameter can be null.

-

outputInfo: Indicates output information in the return result of the synchronous algorithm. This parameter can be null.

-

int AieClientRelease(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo)

-

Function: Uninstalls an algorithm plug-in.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

algorithmInfo: Indicates information about the algorithm plug-in to be uninstalled. This parameter must not be null.

-

inputInfo: Indicates input information specified for algorithm plug-in uninstallation. This parameter can be null.

-

int AieClientDestroy(ClientInfo &clientInfo)

-

Function: Disconnects from the server and releases the cache.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates information about the engine client to be destroyed. This parameter must not be null.

-

int AieClientSetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo)

-

Function: Sets configuration items. You can use this API to pass algorithm's extended information to plug-ins.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

optionType: Indicates the algorithm for obtaining the configuration item information. An algorithm plug-in can use this parameter as needed. This parameter must not be null.

-

inputInfo: Indicates algorithm parameter information. An algorithm plug-in can use this parameter as needed. This parameter can be null.

-

int AieClientGetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo, DataInfo &outputInfo)

-

Function: Obtains configuration item information based on the specified optionType and inputInfo.

-

Return value: Returns 0 if the operation is successful; returns a non-zero value otherwise.

-

clientInfo: Indicates engine client information. This parameter must not be null.

-

optionType: Indicates the algorithm for obtaining the configuration item information. This parameter must not be null.

-

inputInfo: Indicates input information specified for obtaining configuration item information of the algorithm. This parameter can be null.

-

outputInfo: Indicates the configuration item information in the return result. This parameter can be null.

-
- -[Table 2](#table22154317482) describes the data structure of **ConfigInfo**, **ClientInfo**, **AlgorithmInfo**, and **DataInfo**. - -**Table 2** Data structure of ConfigInfo, ClientInfo, AlgorithmInfo, and DataInfo - - - - - - - - - - - - - - - - - - - - - - - - -

Structure

-

Description

-

Attributes

-

ConfigInfo

-

Algorithm configuration item information

-

const char *description: Indicates the body of configuration item information.

-

ClientInfo

-

Client information

-

long long clientVersion: Indicates client version number. This parameter is not used currently.

-

int clientId: Indicates the client ID.

-

int sessionId: Indicates the session ID.

-

uid_t serverUid: Indicates the UID of the server.

-

uid_t clientUid: Indicates the UID of the client.

-

int extendLen: Indicates the length of the extended information (extendMsg).

-

unsigned char *extendMsg: Indicates the body of the extended information.

-

AlgorithmInfo

-

Algorithm information

-

long long clientVersion: Indicates client version number. This parameter is not used currently.

-

bool isAsync: Indicates whether asynchronous execution is used.

-

int algorithmType: Indicates the algorithm type ID allocated by the AI engine framework based on the plug-in loading sequence.

-

long long algorithmVersion: Indicates the algorithm version number.

-

bool isCloud: Indicates whether to migrate data to the cloud. This parameter is not used currently.

-

int operateId: Indicates the execution ID. This parameter is not used currently.

-

int requestId: Indicates the request ID, which identifies each request and corresponds to the execution result.

-

int extendLen: Indicates the length of the extended information (extendMsg).

-

unsigned char *extendMsg: Indicates the body of the extended information.

-

DataInfo

-

Algorithm input parameter configuration information (inputInfo) and output parameter configuration information (outputInfo)

-

unsigned char *data: Indicates the data body.

-

int length: Indicates the data length.

-
- -For details about the development process, see the development example for the KWS SDK. - diff --git a/en/device-dev/subsystems/subsys-aiframework-devguide.md b/en/device-dev/subsystems/subsys-aiframework-devguide.md deleted file mode 100644 index b3bd0bb4e3ccfccd3d91a6b8c35fec13dd570683..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-devguide.md +++ /dev/null @@ -1,11 +0,0 @@ -# Development Guidelines - -To access the AI engine framework, you need to develop the SDKs and plug-ins shown in [Figure 1](subsys-aiframework-guide.md#fig143186187187). In this way, you can call the APIs provided by the SDKs to call the algorithm capabilities of plug-ins to implement lifecycle management and on-demand deployment of AI capabilities. - -- **[SDK](subsys-aiframework-devguide-sdk.md)** - -- **[Plug-in](subsys-aiframework-devguide-plugin.md)** - -- **[Configuration File](subsys-aiframework-devguide-conf.md)** - - diff --git a/en/device-dev/subsystems/subsys-aiframework-envbuild.md b/en/device-dev/subsystems/subsys-aiframework-envbuild.md deleted file mode 100644 index ebfa0e83dcaf00e8123da6264df60db3ddbfa20e..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-envbuild.md +++ /dev/null @@ -1,5 +0,0 @@ -# Development Environment - -1. Prepare development boards Hi3516D V300 and Hi3518E V300. -2. [Download the source code](../get-code/sourcecode-acquire.md). - diff --git a/en/device-dev/subsystems/subsys-aiframework-guide.md b/en/device-dev/subsystems/subsys-aiframework-guide.md deleted file mode 100644 index 3e13aeb62273b5b51cd951aa803db6f0d02426ae..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-guide.md +++ /dev/null @@ -1,9 +0,0 @@ -# AI Engine Framework - -The AI subsystem of OpenHarmony provides native distributed AI capabilities. At the heart of the subsystem is a unified AI engine framework, which implements quick integration of AI algorithm plug-ins. The framework consists of the plug-in management, module management, and communication management modules, fulfilling lifecycle management and on-demand deployment of AI algorithms. Plug-in management implements lifecycle management, on-demand deployment, and quick integration of AI algorithm plug-ins. Module management implements task scheduling and client instance management. Communication management implements inter-process communication \(IPC\) between the client and server and data transmission between the AI engine and plug-ins. Under this framework, AI algorithm APIs will be standardized to facilitate distributed calling of AI capabilities. In addition, unified inference APIs will be provided to adapt to different inference framework hierarchies. [Figure 1](#fig143186187187) shows the AI engine framework. - -**Figure 1** AI engine framework - - -![](figure/en-us_image_0000001077727032.png) - diff --git a/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md b/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md deleted file mode 100644 index e10289c626c0a22be29a97a109d5254c54e4cc75..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-tech-codemanage.md +++ /dev/null @@ -1,40 +0,0 @@ -# Code Management - -Code of the AI engine framework consists of three parts: **client**, **server**, and **common**. The client module provides the server connection management function. The northbound SDK needs to encapsulate and call the public APIs provided by the client in the algorithm's external APIs. The server module provides functions such as plug-in loading and task management. Plug-ins are integrated using the plug-in APIs provided by the server. The common module provides platform-related operation methods, engine protocols, and tool classes for other modules. - -[Figure 1](#fig171811112818) shows the code dependency between modules of the AI engine framework. - -**Figure 1** Code dependency - - -![](figure/code-dependency-(2).jpg) - -## Recommendation: Develop plug-ins and northbound SDKs in the directories specified by the AI engine. - -In the overall planning of the AI engine framework, northbound SDKs are a part of the client, and plug-ins are called by the server and are considered a part of the server. Therefore, the following directories have been planned for plug-in and northbound SDK development in the AI engine framework: - -- SDK code directory: //foundation/ai/engine/services/client/algorithm\_sdk - - Examples: - - //foundation/ai/engine/services/client/algorithm\_sdk/cv - - //foundation/ai/engine/services/client/algorithm\_sdk/nlu - -- Plug-in code directory: //foundation/ai/engine/services/server/plugin - - Examples: - - //foundation/ai/engine/services/server/plugin/cv - - //foundation/ai/engine/services/server/plugin/nlu - - -## Rule: Store all external APIs provided by plug-ins in the **interfaces/kits** directory of the AI subsystem. - -The AI subsystem exposes its capabilities through external APIs of northbound SDKs. According to API management requirements of OpenHarmony, store all external APIs of northbound SDKs in the **interfaces/kits** directory of the subsystem. Currently, the external APIs of plug-ins of the AI subsystem are stored in the following directory: **//foundation/ai/engine/interface/kits**. You can add a sub-directory for each newly added plug-in in this directory. For example, if you add a CV plug-in, then store its external APIs in the **//foundation/ai/engine/interfaces/kits/cv** directory. - -## Rule: Make sure that plug-in compilation results are stored in the **/usr/lib** directory. - -Plug-in loading on the server uses the dlopen mode and can only be performed in the **/usr/lib** directory. Therefore, when compiling the **.so** file of a plug-in, set the output directory as **/usr/lib** in the compilation configuration file. - diff --git a/en/device-dev/subsystems/subsys-aiframework-tech-interface.md b/en/device-dev/subsystems/subsys-aiframework-tech-interface.md deleted file mode 100644 index 8990dbccda18be268d2857a57151bca760fc58b0..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-tech-interface.md +++ /dev/null @@ -1,129 +0,0 @@ -# API Development - -## Rule: Encapsulate the external APIs provided by the client based on the algorithm call sequence. For the SDK of an asynchronous plug-in, implement the **IClientCb** callback API provided by the client. - -The external APIs provided by the client of the AI engine include **AieClientInit**, **AieClientPrepare**, **AieClientSyncProcess**, **AieClientAsyncProcess**, **AieClientRelease**, **AieClientDestroy**, **AieClientSetOption**, and **AieClientGetOption**. The SDK needs to encapsulate at least the following five APIs in sequence: **AieClientInit**, **AieClientPrepare**, **AieClientSyncProcess** \(or **AieClientAsyncProcess**\), **AieClientRelease**, and **AieClientDestroy**. Otherwise, a call failure or memory leakage may occur. For example, if the **AieClientprepare** API is omitted during encapsulation, the server cannot load the plug-in. As a result, APIs that follow it cannot be called. - -For an asynchronous plug-in, the SDK needs to implement the **IClientCb** API to receive the algorithm inference result from the client and return the result to the third-party caller. - -## Rule: Save all common data related to client interaction in the SDK during API implementation. - -The client of the AI engine uses the singleton pattern for API implementation. If the client is connecting to multiple SDKs, each SDK needs to store all common data exchanged with the client so that they can connect to the server to perform operations such as task inference and return the result. Common data usually includes **clientInfo**, **algorithmInfo**, and **configInfo**, which are defined in the SDK's member variables. - -## Recommendation: Enable the SDK to implement the **IServiceDeadCb** API defined by the client. - -The processes running on the server are system resident processes. The server provides services for clients by way of system capabilities. The **IServiceDeadCb** API is called if a server process is abnormally killed. The SDK can implement related operations in this API, for example, stopping process call or restarting the server. - -The following is an example of **IServiceDeadCb** API implementation: - -``` -class ServiceDeadCb : public IServiceDeadCb { -public: -ServiceDeadCb() = default; -~ServiceDeadCb() override = default; -void OnServiceDead() override -{ -printf("[ServiceDeadCb]OnServiceDead Callback happens"); -} -}; -``` - -As shown above, the SDK can implement its own operations in the **OnServiceDead\(\)** function, for example, stopping API call. - -## Rule: Convert dedicated algorithm data into common data of the AI engine if the SDK and plug-ins need to use the codec module. - -For plug-ins, inference data is transmitted by the third-party caller to them through the client and server. The required data type varies according to algorithms. For example, the CV algorithm requires image data, and the ASR algorithm requires audio data. To address this issue, the AI engine provides the codec capabilities to convert different types of data into common data that can be used by it. - -The encoded data is as follows: - -``` -struct DataInfo { -unsigned char *data; -int length; -} DataInfo; - -``` - -As shown above, **DataInfo** consists of two variables: a pointer to the data memory, and the data length. - -To use the APIs of the AI engine framework, you need to: - -1. Add the dependency header file **utils/encdec/include/encdec.h**. - -2. Add the dependency items in the **build.gn** file. - -Add **"//foundation/ai/engine/services/common"** to **include\_dirs**. - -Add **"//foundation/ai/engine/services/common/utils/encdec:encdec"** to **deps**. - -3. Convert different types of data through codec. The following is an example: - -``` -// Example function for encoding: arg1, arg2, and arg3 are variables to be encoded, and dataInfo is the encoding result. -retCode = ProcessEncode(dataInfo, arg1, arg2, arg3) // The number of parameters can be flexible. -// Example function for decoding: dataInfo is the data to be decoded, and arg1, arg2, and arg3 are the decoding result. -retCode = ProcessDecode(dataInfo, arg1, arg2, arg3) // The number of parameters can be flexible. -``` - -Note: - -- The sequence of parameters must be the same during encoding and decoding. -- After encoding, the memory used by **dataInfo** needs to be manually released by the caller. -- The memory is managed and released separately on the server and the client. -- If a pointer contains the shared memory, no extra processing is required. -- If other types of pointers are used, you need to dereference them before using **ProcessEncode** or **ProcessDecode**. -- The codec module has not been adapted to the **class** data type and therefore it is not recommended. - -## Rule: Release the memory used by the encoded or decoded parameters in the SDK. Otherwise, a memory leakage occurs. - -Encoding is essentially a process of encapsulating different types of data in the same memory space and then encapsulating the start address and length of the memory into the body. The plug-in is unable to release the memory that has been allocated to output parameter data returned to the SDK through encoding. To obtain the data, the SDK first needs to release the memory. - -The following is an example of releasing the memory: - -``` -DataInfo outputInfo = { -.data = nullptr, -.length = 0, -}; -AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); -if (outputInfo.data != nullptr) { -free(outputInfo.data); -outputInfo.data = nullptr; -outputInfo.length = 0; -} -``` - -## Rule: Enable plug-ins to implement the **IPlugin** API defined by the server and use the **PLUGIN\_INTERFACE\_IMPL** statement to provide the function pointer for external systems. - -The server manages a variety of plug-ins, and the API implementation logic varies according to plug-ins. To unify the plug-in loading process, the AI engine provides the **IPlugin** API. In the runtime environment, a plug-in is loaded as a dynamic link library \(DLL\) by the AI engine framework in dlopen mode. Therefore, the plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. - -## Rule: Use the unified data channel provided by the AI engine for plug-ins. - -The AI engine provides a unified data channel between the server and plug-ins to send inference requests from the SDK and returned results from plug-ins. Plug-ins need to obtain the request data and encapsulate the inference result over the data channel when calling the inference API. - -The following is an example of using the data channel: - -``` -int SyncProcess(IRequest *request, IResponse *&response) -{ -HILOGI("[IvpPlugin]Begin SyncProcess"); -if (request == nullptr) { -HILOGE("[IvpPlugin]SyncProcess request is nullptr"); -return RETCODE_NULL_PARAM; -} -DataInfo inputInfo = request->GetMsg(); -if (inputInfo.data == nullptr) { -HILOGE("[IvpPlugin]InputInfo data is nullptr"); -return RETCODE_NULL_PARAM; -} - -... - -response = IResponse::Create(request); -response->SetResult(outputInfo); -return RETCODE_SUCCESS; -} -``` - -In the example, the request and response are the data body sent over the data channel. The server encapsulates data in the request and sends it to the plug-in. After completing algorithm processing, the plug-in encapsulates the result into the response and returns it to the server over the data channel. - diff --git a/en/device-dev/subsystems/subsys-aiframework-tech-name.md b/en/device-dev/subsystems/subsys-aiframework-tech-name.md deleted file mode 100644 index 3722cfb4fe782ffef7662589d6ed96fa9670a372..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-tech-name.md +++ /dev/null @@ -1,16 +0,0 @@ -# Naming - -## Rule: Name an SDK in the format of **domain\_keyword<\_other information 1\_other information 2\_...\>\_sdk.so**. - -You are advised to use the commonly known abbreviations for domains. For example, use **cv** for image and video, **asr** for voice recognition, and **translation** for text translation. Add one if there is no available abbreviation for a domain. Use keywords that accurately describe the algorithm capability of the plug-in. For example, use **keyword\_spotting** for wakeup keyword spotting \(KWS\). Add other information, such as the supported chip type and applicable region, between **keyword** and **sdk**, with each of them separated by an underscore \(\_\). Note that the name of a northbound SDK must end with **sdk**. - -For example, if the SDK for the KWS plug-in supports only the Kirin 9000 chipset and is applicable only in China, then name the SDK as follows: **asr\_keyword\_spotting\_kirin9000\_china\_sdk.so**. - -## Rule: Name a plug-in in the format of **domain\_keyword<\_other information 1\_other information 2\_...\>.so**. - -Use the same naming rules as the SDK. - -A plug-in maps to an SDK. Therefore, they have the same requirements for the domain, keyword, and other information in their names. The only difference is that the name of the SDK ends with **\_sdk** additionally. For example, if the plug-in is named **asr\_keyword\_spotting.so**, the corresponding northbound SDK is named **asr\_keyword\_spotting\_sdk.so**. - -For example, if the SDK for the KWS plug-in supports only the Kirin 9000 chipset and is applicable only in China, then name the plug-in as follows: **asr\_keyword\_spotting\_kirin9000\_china.so**. - diff --git a/en/device-dev/subsystems/subsys-aiframework-tech.md b/en/device-dev/subsystems/subsys-aiframework-tech.md deleted file mode 100644 index ed9edda03a6fabc4651e76a13271f159b4510e51..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework-tech.md +++ /dev/null @@ -1,15 +0,0 @@ -# Technical Specifications - -**Conventions** - -**Rule**: a convention that must be observed - -**Recommendation**: a convention that should be considered - -- **[Code Management](subsys-aiframework-tech-codemanage.md)** - -- **[Naming](subsys-aiframework-tech-name.md)** - -- **[API Development](subsys-aiframework-tech-interface.md)** - - diff --git a/en/device-dev/subsystems/subsys-aiframework.md b/en/device-dev/subsystems/subsys-aiframework.md deleted file mode 100644 index bdd0b162508a053ffe7b7b9f62fffa6401d644d1..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-aiframework.md +++ /dev/null @@ -1,13 +0,0 @@ -# AI Framework - -- **[AI Engine Framework](subsys-aiframework-guide.md)** - -- **[Development Environment](subsys-aiframework-envbuild.md)** - -- **[Technical Specifications](subsys-aiframework-tech.md)** - -- **[Development Guidelines](subsys-aiframework-devguide.md)** - -- **[Development Examples](subsys-aiframework-demo.md)** - - diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md index d5ea1ec4528401a14f04d84b4c79b927ff62b29d..efd5de904fcdeed3d2467eb3c1b2f215e1ef4521 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md @@ -7,15 +7,15 @@ HiSysEvent provides event logging APIs for OpenHarmony to record important infor The key modules of HiSysEvent are described as follows: -- Event configuration: enables you to define HiSysEvent events in YAML files. +- [HiSysEvent logging configuration](subsys-dfx-hisysevent-logging-config.md): enables you to define HiSysEvent events in YAML files. -- Trace point configuration: provides trace point APIs and supports flushing of HiSysEvent events to disks. +- [HiSysEvent logging](subsys-dfx-hisysevent-logging.md): provides trace point APIs and supports flushing of HiSysEvent events to disks. -- Event subscription: provides APIs for you to subscribe to HiSysEvent events by event domain and event name. +- [HiSysEvent listening](subsys-dfx-hisysevent-listening.md): provides APIs for you to subscribe to HiSysEvent events by event domain and event name. -- Event query: provides APIs for you to query HiSysEvent events by event domain and event name. +- [HiSysEvent query](subsys-dfx-hisysevent-query.md): provides APIs for you to query HiSysEvent events by event domain and event name. -- Event debugging tool: allows you to subscribe to real-time HiSysEvent events and query historical HiSysEvent events. +- [HiSysEvent tool](subsys-dfx-hisysevent-tool.md): allows you to subscribe to real-time HiSysEvent events and query historical HiSysEvent events. ## Reference diff --git a/zh-cn/Legal-Notices.md b/zh-cn/Legal-Notices.md index 6ae16ba6772cc901958163cbe16039d88fd0c619..ee9cf60f99dc310d7f4e51068aab766205fc526c 100644 --- a/zh-cn/Legal-Notices.md +++ b/zh-cn/Legal-Notices.md @@ -8,7 +8,7 @@ OpenHarmony文档的著作权由OpenHarmony项目拥有。 -OpenHarmony文档根据知识共享署名4.0 (Creative Commons Attribution 4.0,简称CC BY 4.0)国际公共许可协议进行版权许可。为了方便用户理解,您可以通过访问https://creativecommons.org/licenses/by/4.0/了解CC BY 4.0的概要。CC BY 4.0的完整协议内容您可以访问如下网址获取:https://creativecommons.org/licenses/by/4.0/legalcode。 +OpenHarmony文档根据知识共享署名4.0 (Creative Commons Attribution 4.0,简称CC BY 4.0)国际公共许可协议进行版权许可。为了方便用户理解,您可以通过访问https://creativecommons.org/licenses/by/4.0/ 了解CC BY 4.0的概要。CC BY 4.0的完整协议内容您可以访问如下网址获取:https://creativecommons.org/licenses/by/4.0/legalcode 。 diff --git a/zh-cn/application-dev/IDL/idl-guidelines.md b/zh-cn/application-dev/IDL/idl-guidelines.md index 76fc15b2e5939b5bf2c03d9ccc4bcb7a8a11f659..5aa1a084c0bc9d4a28e5504cd29f11954a46fa21 100644 --- a/zh-cn/application-dev/IDL/idl-guidelines.md +++ b/zh-cn/application-dev/IDL/idl-guidelines.md @@ -433,7 +433,7 @@ export default { console.log('ServiceAbility want:' + JSON.stringify(want)); console.log('ServiceAbility want name:' + want.bundleName) } catch(err) { - console.log("ServiceAbility error:" + err) + console.log('ServiceAbility error:' + err) } console.info('ServiceAbility onConnect end'); return new IdlTestImp('connect'); @@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility'; function callbackTestIntTransaction(result: number, ret: number): void { if (result == 0 && ret == 124) { - console.log("case 1 success "); + console.log('case 1 success'); } } function callbackTestStringTransaction(result: number): void { if (result == 0) { - console.log("case 2 success "); + console.log('case 2 success'); } } @@ -472,17 +472,17 @@ var onAbilityConnectDone = { testProxy.testStringTransaction('hello', callbackTestStringTransaction); }, onDisconnect:function (elementName) { - console.log("onDisconnectService onDisconnect"); + console.log('onDisconnectService onDisconnect'); }, onFailed:function (code) { - console.log("onDisconnectService onFailed"); + console.log('onDisconnectService onFailed'); } }; function connectAbility: void { let want = { - "bundleName":"com.example.myapplicationidl", - "abilityName": "com.example.myapplicationidl.ServiceAbility" + bundleName: 'com.example.myapplicationidl', + abilityName: 'com.example.myapplicationidl.ServiceAbility' }; let connectionId = -1; connectionId = featureAbility.connectAbility(want, onAbilityConnectDone); @@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _reply = new rpc.MessageParcel(); _data.writeInt(data); this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) { - if (result.errCode === 0) { + if (result.errCode == 0) { let _errCode = result.reply.readInt(); if (_errCode != 0) { let _returnValue = undefined; @@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _returnValue = result.reply.readInt(); callback(_errCode, _returnValue); } else { - console.log("sendRequest failed, errCode: " + result.errCode); + console.log('sendRequest failed, errCode: ' + result.errCode); } }) } @@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _reply = new rpc.MessageParcel(); _data.writeString(data); this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) { - if (result.errCode === 0) { + if (result.errCode == 0) { let _errCode = result.reply.readInt(); callback(_errCode); } else { - console.log("sendRequest failed, errCode: " + result.errCode); + console.log('sendRequest failed, errCode: ' + result.errCode); } }) } @@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager'; function testIntTransactionCallback(errCode: number, returnValue: number) { - console.log("errCode: " + errCode + " returnValue: " + returnValue); + console.log('errCode: ' + errCode + ' returnValue: ' + returnValue); } function testStringTransactionCallback(errCode: number) { - console.log("errCode: " + errCode); + console.log('errCode: ' + errCode); } function jsProxyTriggerCppStub() @@ -660,6 +660,6 @@ function jsProxyTriggerCppStub() tsProxy.testIntTransaction(10, testIntTransactionCallback); // invoke testStringTransaction - tsProxy.testStringTransaction("test", testIntTransactionCallback); + tsProxy.testStringTransaction('test', testIntTransactionCallback); } ``` diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 70a832e1fcb12e85d4fc742b171fd9bb33a1db23..4743c1e020b9e08362342363ba79178e9c07139e 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -8,8 +8,8 @@ - 快速开始 - 快速入门 - [开发准备](quick-start/start-overview.md) - - [使用eTS语言开发(Stage模型)](quick-start/start-with-ets-stage.md) - - [使用eTS语言开发(FA模型)](quick-start/start-with-ets-fa.md) + - [使用ArkTS语言开发(Stage模型)](quick-start/start-with-ets-stage.md) + - [使用ArkTS语言开发(FA模型)](quick-start/start-with-ets-fa.md) - [使用JS语言开发(FA模型)](quick-start/start-with-js-fa.md) - 开发基础知识 - [应用包结构说明(FA模型)](quick-start/package-structure.md) diff --git a/zh-cn/application-dev/application-test/arkxtest-guidelines.md b/zh-cn/application-dev/application-test/arkxtest-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..410547a5d0ef493f9cee83b670b7a391023fb6e2 --- /dev/null +++ b/zh-cn/application-dev/application-test/arkxtest-guidelines.md @@ -0,0 +1,171 @@ +# 自动化测试框架使用指南 + + +## 概述 + +为支撑OpenHarmony操作系统的自动化测试活动开展,我们提供了支持JS/TS语言的单元及UI测试框架,支持开发者针对应用接口或系统接口进行单元测试,并且可基于UI操作进行UI自动化脚本的编写。 + +本指南重点介绍自动化测试框架的主要功能,同时介绍编写单元/UI自动化测试脚本的方法以及执行过程。 + + +### 简介 + +OpenHarmony自动化测试框架arkxtest,作为OpenHarmony工具集的重要组成部分,提供了OpenHarmony自动化脚本编写和运行的基础能力。编写方面提供了一系列支持测试脚本编写的API,包括了基础流程API、断言API以及UI操作相关的API,运行方面提供了识别测试脚本、调度执行测试脚本以及汇总测试脚本执行结果的能力。 + + +### 实现原理 + +框架重要分为两大部分:单元测试框架和UI测试框架。 + +- 单元测试框架 + + 单元测试框架是测试框架的基础底座,提供了最基本的用例识别、调度、执行及结果汇总的能力。主要功能如下图所示: + + ![](figures/UnitTest.PNG) + + 单元测试脚本的基础运行流程如下图所示,依赖aa test命令作为执行入口,该命令可具体参考[对应指南。](../ability/ability-delegator.md) + + ![](figures/TestFlow.PNG) + +- UI测试框架 + + UI测试框架主要对外提供了[UiTest API](../reference/apis/js-apis-uitest.md)供开发人员在对应测试场景调用,而其脚本的运行基础还是上面提到的单元测试框架。 + + UI测试框架的主要功能如下图所示: + + ![](figures/Uitest.PNG) + + +### 约束与限制 + +- UI测试框架的能力在OpenHarmony 3.1 release版本之后方可使用,历史版本不支持使用。 +- 单元测试框架的部分能力与其版本有关,具体能力与版本匹配信息可见代码仓中的[文档介绍](https://gitee.com/openharmony/testfwk_arkxtest/blob/master/README_zh.md)。 + + +## 环境准备 + +### 环境要求 + +OpenHarmony自动化脚本的编写主要基于DevEco Studio,并建议使用3.0之后的版本进行脚本编写。 + +脚本执行需要PC连接OpenHarmony设备,如RK3568开发板等。 + +### 搭建环境 + +DevEco Studio可参考其官网介绍进行[下载](https://developer.harmonyos.com/cn/develop/deveco-studio#download),并进行相关的配置动作。 + + +## 新建测试脚本 + +1. 在DevEco Studio中新建应用开发工程,其中ohos目录即为测试脚本所在的目录。 +2. 在工程目录下打开待测试模块下的ets文件,将光标置于代码中任意位置,单击**右键 > Show Context Actions** **> Create Ohos Test**或快捷键**Alt+enter** **> Create Ohos Test**创建测试类,更多指导请参考DevEco Studio中[指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-openharmony-test-framework-0000001267284568)。 + +## 编写单元测试脚本 + +```TS +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +const delegator = abilityDelegatorRegistry.getAbilityDelegator() +export default function abilityTest() { + describe('ActsAbilityTest', function () { + it('testUiExample',0, async function (done) { + console.info("uitest: TestUiExample begin"); + //start tested ability + await delegator.executeShellCommand('aa start -b com.ohos.uitest -a MainAbility').then(result =>{ + console.info('Uitest, start ability finished:' + result) + }).catch(err => { + console.info('Uitest, start ability failed: ' + err) + }) + await sleep(1000); + //check top display ability + await delegator.getCurrentTopAbility().then((Ability)=>{ + console.info("get top ability"); + expect(Ability.context.abilityInfo.name).assertEqual('MainAbility'); + }) + done(); + }) + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)); + } + }) +} +``` + +单元测试脚本需要包含如下基本元素: + +1、依赖导包,以便使用依赖的测试接口。 + +2、测试代码编写,主要编写测试代码的相关逻辑,如接口调用等。 + +3、断言接口调用,设置测试代码中的检查点,如无检查点,则不可认为一个完整的测试脚本。 + +## 编写UI测试脚本 + +UI测试脚本是在单元测试框架的基础上编写,主要就是增加了UI测试框架提供的接口调用,实现对应的测试逻辑。 + +下面的示例代码是在上面的测试脚本基础上增量编写,首先需要增加依赖导包,如下示例代码所示: + +```js +import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest' +``` + +然后是具体测试代码编写,场景较为简单,就是在启动的应用页面上进行点击操作,然后增加检查点检查用例。 + +```js +export default function abilityTest() { + describe('ActsAbilityTest', function () { + it('testUiExample',0, async function (done) { + console.info("uitest: TestUiExample begin"); + //start tested ability + await delegator.executeShellCommand('aa start -b com.ohos.uitest -a MainAbility').then(result =>{ + console.info('Uitest, start ability finished:' + result) + }).catch(err => { + console.info('Uitest, start ability failed: ' + err) + }) + await sleep(1000); + //check top display ability + await delegator.getCurrentTopAbility().then((Ability)=>{ + console.info("get top ability"); + expect(Ability.context.abilityInfo.name).assertEqual('MainAbility'); + }) + //ui test code + //init uidriver + var driver = await UiDriver.create(); + await driver.delayMs(1000); + //find button by text 'Next' + var button = await driver.findComponent(BY.text('Next')); + //click button + await button.click(); + await driver.delayMs(1000); + //check text + await driver.assertComponentExist(BY.text('after click')); + await driver.pressBack(); + done(); + }) + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)); + } + }) +} +``` + +## 执行测试脚本 + +执行测试脚本可以直接在DevEco Studio中通过点击按钮执行,当前支持以下执行方式: + +1、测试包级别执行即执行测试包内的全部用例。 + +2、测试套级别执行即执行describe方法中定义的全部测试用例。 + +3、测试方法级别执行即执行指定it方法也就是单条测试用例。 + +![](figures/Execute.PNG) + +## 查看测试结果 + +测试执行完毕后可直接在DevEco Studio中查看测试结果,如下图示例所示: + +![](figures/TestResult.PNG) diff --git a/zh-cn/application-dev/application-test/figures/Execute.PNG b/zh-cn/application-dev/application-test/figures/Execute.PNG new file mode 100644 index 0000000000000000000000000000000000000000..49155c9b3406ea477e08273818e52fe026a62737 Binary files /dev/null and b/zh-cn/application-dev/application-test/figures/Execute.PNG differ diff --git a/zh-cn/application-dev/application-test/figures/TestFlow.PNG b/zh-cn/application-dev/application-test/figures/TestFlow.PNG new file mode 100644 index 0000000000000000000000000000000000000000..c1cd0d4e87070a5af4b7c8d72432a55585754551 Binary files /dev/null and b/zh-cn/application-dev/application-test/figures/TestFlow.PNG differ diff --git a/zh-cn/application-dev/application-test/figures/TestResult.PNG b/zh-cn/application-dev/application-test/figures/TestResult.PNG new file mode 100644 index 0000000000000000000000000000000000000000..300266842efab6da7a4f7469ab8c9e890f238b89 Binary files /dev/null and b/zh-cn/application-dev/application-test/figures/TestResult.PNG differ diff --git a/zh-cn/application-dev/application-test/figures/Uitest.PNG b/zh-cn/application-dev/application-test/figures/Uitest.PNG new file mode 100644 index 0000000000000000000000000000000000000000..2e84b95e4b0e61d78351e46a4ac2706e7847c6e2 Binary files /dev/null and b/zh-cn/application-dev/application-test/figures/Uitest.PNG differ diff --git a/zh-cn/application-dev/application-test/figures/UnitTest.PNG b/zh-cn/application-dev/application-test/figures/UnitTest.PNG new file mode 100644 index 0000000000000000000000000000000000000000..a7af248d62e34bda8e02be095bcdb73c15e97a3f Binary files /dev/null and b/zh-cn/application-dev/application-test/figures/UnitTest.PNG differ diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 5a63c2fc33fab83623b8de9a1b1c8497d5790742..3ca354a1305c8e1282367633aba33c3c098bbac7 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -1,28 +1,34 @@ # 音频播放开发指导 -## 场景介绍 +## 简介 -音频播放的主要工作是将音频数据转码为可听见的音频模拟信号并通过输出设备进行播放,同时对播放任务进行管理。 +音频播放的主要工作是将音频数据转码为可听见的音频模拟信号,并通过输出设备进行播放,同时对播放任务进行管理,包括开始播放、暂停播放、停止播放、释放资源、设置音量、跳转播放位置、获取轨道信息等功能控制。 -**图1** 音频播放状态机 +## 运作机制 + +该模块提供了音频播放状态变化示意图和音频播放外部模块交互图。 + +**图1** 音频播放状态变化示意图 ![zh-ch_image_audio_state_machine](figures/zh-ch_image_audio_state_machine.png) -**说明**:当前为Idle状态,设置src不会改变状态;且src设置成功后,不能再次设置其它src,需调用reset()接口后,才能重新设置src。 +**注意**:当前为Idle状态,设置src不会改变状态;且src设置成功后,不能再次设置其它src,需调用reset()接口后,才能重新设置src。 -**图2** 音频播放零层图 +**图2** 音频播放外部模块交互图 ![zh-ch_image_audio_player](figures/zh-ch_image_audio_player.png) -## 开发步骤 +**说明**:三方应用通过调用JS接口层提供的js接口实现相应功能时,框架层会通过Native Framework的媒体服务,调用音频部件,将软件解码后的音频数据输出至硬件接口层的音频HDI,实现音频播放功能。 + +## 开发指导 详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md#audioplayer) ### 全流程场景 -包含流程:创建实例,设置uri,播放音频,跳转播放位置,设置音量,暂停播放,获取轨道信息,停止播放,重置,释放资源等流程。 +音频播放的全流程场景包含:创建实例,设置uri,播放音频,跳转播放位置,设置音量,暂停播放,获取轨道信息,停止播放,重置,释放资源等流程。 AudioPlayer支持的src媒体源输入类型可参考:[src属性说明](../reference/apis/js-apis-media.md#audioplayer_属性) diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 21fe9c01ad216b331e5c2e708397bfdce4672a4d..94215fe834e26b66115046fbe543137371ed5912 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -1,26 +1,36 @@ # 音频录制开发指导 -## 场景介绍 +## 简介 -音频录制的主要工作是捕获音频信号,完成音频编码并保存到文件中,帮助开发者轻松实现音频录制功能。它允许调用者指定音频录制的采样率、声道数、编码格式、封装格式、文件路径等参数。 +音频录制的主要工作是捕获音频信号,完成音频编码并保存到文件中,帮助开发者轻松实现音频录制功能。该模块允许调用者指定音频录制的采样率、声道数、编码格式、封装格式、输出文件的路径等参数。 -**图1** 音频录制状态机 +## 运作机制 + +该模块提供了音频录制状态变化示意图和音频录制外部模块交互图。 + +**图1** 音频录制状态变化变化示意图 ![zh-ch_image_audio_recorder_state_machine](figures/zh-ch_image_audio_recorder_state_machine.png) -**图2** 音频录制零层图 +**图2** 音频录制外部模块交互图 ![zh-ch_image_audio_recorder_zero](figures/zh-ch_image_audio_recorder_zero.png) -## 开发步骤 +**说明**:三方录音应用或录音机通过调用JS接口层提供的js接口实现相应功能时,框架层会通过Native Framework的媒体服务,调用音频部件获取通过音频HDI捕获的音频数据,再通过软件编码输出编码封装后的音频数据保存至文件中,实现音频录制功能。 + +## 约束与限制 + +开发者在进行录制功能开发前,需要先对所开发的应用配置麦克风权限(ohos.permission.MICROPHONE),权限配置相关内容可参考:[访问控制权限申请指导](../security/accesstoken-guidelines.md) + +## 开发指导 详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md#audiorecorder) ### 全流程场景 -包含流程:创建实例,设置录制参数,录制音频,暂停录制,恢复录制,停止录制,释放资源等流程。 +音频录制的全流程场景包含:创建实例,设置录制参数,开始录制,暂停录制,恢复录制,停止录制,释放资源等流程。 ```js import media from '@ohos.multimedia.media' diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 040b9b479adce001468631ae6920321be06dc894..b9f30aab7ed944d3a702adc002d6e18627b31414 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -1,17 +1,23 @@ # 视频播放开发指导 -## 场景介绍 +## 简介 -视频播放的主要工作是将视频数据转码并输出到设备进行播放,同时管理播放任务。本文将对视频播放全流程、视频切换、视频循环播放等场景开发进行介绍说明。 +视频播放的主要工作是将视频数据转码并输出到设备进行播放,同时管理播放任务,包括开始播放、暂停播放、停止播放、资源释放、音量设置、跳转播放位置、设置倍数、获取轨道信息等功能控制。本文将对视频播放全流程、视频切换、视频循环播放等场景开发进行介绍说明。 -**图1** 视频播放状态机 +## 运作机制 + +该模块提供了视频播放状态变化示意图和视频播放外部模块交互图。 + +**图1** 视频播放状态变化示意图 ![zh-ch_image_video_state_machine](figures/zh-ch_image_video_state_machine.png) -**图2** 视频播放零层图 +**图2** 视频播放外部模块交互图 ![zh-ch_image_video_player](figures/zh-ch_image_video_player.png) +**说明**:三方应用通过调用JS接口层提供的js接口实现相应功能时,框架层会通过Native Framework的媒体服务,调用音频部件将软件解码后的音频数据,输出至音频HDI,和图形子系统将硬件接口层的解码HDI部件的解码后的图像数据,输出至显示HDI,实现视频播放功能。 + *注意:视频播放需要显示、音频、编解码等硬件能力。* 1. 三方应用从Xcomponent组件获取surfaceID。 @@ -31,13 +37,13 @@ | ts | 视频格式:H264/MPEG2/MPEG4 音频格式:AAC/MP3 | 主流分辨率,如1080P/720P/480P/270P | | webm | 视频格式:VP8 音频格式:VORBIS | 主流分辨率,如1080P/720P/480P/270P | -## 开发步骤 +## 开发指导 详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md#videoplayer8) ### 全流程场景 -包含流程:创建实例,设置url,设置SurfaceId,准备播放视频,播放视频,暂停播放,获取轨道信息,跳转播放位置,设置音量,设置倍速,结束播放,重置,释放资源等流程。 +视频播放的全流程场景包含:创建实例,设置url,设置SurfaceId,准备播放视频,播放视频,暂停播放,获取轨道信息,跳转播放位置,设置音量,设置倍速,结束播放,重置,释放资源等流程。 VideoPlayer支持的url媒体源输入类型可参考:[url属性说明](../reference/apis/js-apis-media.md#videoplayer_属性) diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md index 3be9de0cbb47ea787f1861fba9f32aa423fd935a..07b83bdf86217f38bfb47d8fa0850ed8349d4e96 100644 --- a/zh-cn/application-dev/media/video-recorder.md +++ b/zh-cn/application-dev/media/video-recorder.md @@ -1,24 +1,34 @@ # 视频录制开发指导 -## 场景介绍 +## 简介 -视频录制的主要工作是捕获音视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。 +视频录制的主要工作是捕获音视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能,包括开始录制、暂停录制、恢复录制、停止录制、释放资源等功能控制。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。 -**图1** 视频录制状态机 +## 运作机制 + +该模块提供了视频录制状态变化示意图和视频录制外部模块交互图。 + +**图1** 视频录制状态变化示意图 ![zh-ch_image_video_recorder_state_machine](figures/zh-ch_image_video_recorder_state_machine.png) -**图2** 视频录制零层图 +**图2** 视频录制外部模块交互图 ![zh-ch_image_video_recorder_zero](figures/zh-ch_image_video_recorder_zero.png) -## 开发步骤 +**说明**:三方相机应用或系统相机通过调用JS接口层提供的js接口实现相应功能时,框架层会通过Native Framework的媒体服务,调用音频部件通过音频HDI捕获的音频数据,再通过软件编码输出编码封装后的音频数据保存至文件中,和图形子系统通过视频HDI捕获的图像数据,再通过视频编码HDI编码,将编码后的图像数据保存至文件中,实现视频录制功能。 + +## 约束与限制 + +开发者在进行录制功能开发前,需要先对所开发的应用配置麦克风权限(ohos.permission.MICROPHONE)和相机权限(ohos.permission.CAMERA),权限配置相关内容可参考:[访问控制权限申请指导](../security/accesstoken-guidelines.md) + +## 开发指导 详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md#videorecorder9) ### 全流程场景 -包含流程:创建实例、设置录制参数、录制视频、暂停录制、恢复录制、停止录制、释放资源等流程。 +视频录制全流程场景包含:创建实例、设置录制参数、开始录制、暂停录制、恢复录制、停止录制、释放资源等流程。 ```js import media from '@ohos.multimedia.media' diff --git a/zh-cn/application-dev/notification/Readme-CN.md b/zh-cn/application-dev/notification/Readme-CN.md index a85b267052b65b947b5cfd34d25ca940add25804..02b3a06e412f3617b2db876b92bf673e46d4914f 100644 --- a/zh-cn/application-dev/notification/Readme-CN.md +++ b/zh-cn/application-dev/notification/Readme-CN.md @@ -3,7 +3,4 @@ - [公共事件与通知概述](notification-brief.md) - [公共事件开发指导](common-event.md) - [通知开发指导](notification-guidelines.md) -- 后台代理提醒 - - [后台代理提醒开发概述](background-agent-scheduled-reminder-overview.md) - - [后台代理提醒开发指导](background-agent-scheduled-reminder-guide.md) - [调试助手使用指导](assistant-guidelines.md) \ No newline at end of file diff --git a/zh-cn/application-dev/notification/common-event.md b/zh-cn/application-dev/notification/common-event.md index 33af34aac4c374cfe452f20c8a40b6c3acd7b4b2..1ccccada26dfc008c6ecbe669007459e6a42ce51 100644 --- a/zh-cn/application-dev/notification/common-event.md +++ b/zh-cn/application-dev/notification/common-event.md @@ -32,7 +32,8 @@ import commonEvent from '@ohos.commonEvent'; 2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscribeInfo文档](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo)介绍。 ```js -private subscriber = null //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +//用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +private subscriber = null //订阅者信息 var subscribeInfo = { diff --git a/zh-cn/application-dev/notification/notification-brief.md b/zh-cn/application-dev/notification/notification-brief.md index 9eaa31851c87ed6d9f35a1f32a37a797eef45f38..c1a2b37abcb08c2048d5f9d0f367e3c5651a337d 100644 --- a/zh-cn/application-dev/notification/notification-brief.md +++ b/zh-cn/application-dev/notification/notification-brief.md @@ -1,6 +1,6 @@ # 公共事件与通知开发概述 -公共事件与通知提供了应用程序向系统其他应用程序发布消息、接收来自系统或其他应用特定消息的能力,这些消息可以是新闻推送、广告通知或者预警信息。 +公共事件与通知提供了应用程序向系统其他应用程序发布消息、接收来自系统或其他应用特定消息的能力,这些消息可以是新闻推送、广告通知或者预警信息等。 CES(Common Event Service, 即公共事件服务)为应用程序提供发布、订阅及退订公共事件的能力。公共事件根据事件发送方不同可分为系统公共事件和自定义公共事件。 @@ -9,7 +9,7 @@ CES(Common Event Service, 即公共事件服务)为应用程序提供发布 - 系统公共事件:系统将收集到的事件信息,根据系统策略发送给订阅该事件的用户程序。 公共事件包括:终端设备用户可感知的亮灭屏事件,以及系统关键服务发布的系统事件(例如:USB插拔,网络连接,系统升级)等。 - 自定义公共事件:由应用自身定义的期望特定订阅者可以接收到的公共事件,这些公共事件往往与应用自身的业务逻辑相关。 -ANS(Advanced Notification Service,即通知增强服务)为应用程序提供发布通知的能力。这些通知常见的使用场景如下: +ANS(Advanced Notification Service,即通知系统服务)为应用程序提供发布通知的能力。这些通知常见的使用场景如下: - 显示接收到的短消息、即时通讯消息等; - 显示应用的推送消息,如广告、版本更新、新闻通知等; diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index 781fc318540701a0b14a9bad97c4fc1710a5d18b..0789c9dcef1e697ea822f28a1939588495204758 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -2,11 +2,24 @@ - 快速入门 - [开发准备](start-overview.md) - - [使用eTS语言开发(Stage模型)](start-with-ets-stage.md) - - [使用eTS语言开发(FA模型)](start-with-ets-fa.md) + - [使用ArkTS语言开发(Stage模型)](start-with-ets-stage.md) + - [使用ArkTS语言开发(FA模型)](start-with-ets-fa.md) - [使用JS语言开发(FA模型)](start-with-js-fa.md) + - 开发基础知识 - [应用包结构说明(FA模型)](package-structure.md) - [应用包结构说明(Stage模型)](stage-structure.md) + - [SysCap说明](syscap.md) - - [HarmonyAppProvision配置文件](app-provision-structure.md) \ No newline at end of file + - [HarmonyAppProvision配置文件](app-provision-structure.md) + - 学习eTS语言 + - [初识ets语言](ets-get-started.md) + - eTS语法(声明式UI) + - [基本UI描述](ets-basic-ui-description.md) + - 状态管理 + - [基本概念](ets-state-mgmt-concepts.md) + - [页面级变量的状态管理](ets-state-mgmt-page-level.md) + - [应用级变量的状态管理](ets-state-mgmt-application-level.md) + - [动态构建UI元素](ets-dynamic-ui-elememt-building.md) + - [渲染控制](ets-rendering-control.md) + - [使用限制与扩展](ets-restrictions-and-extensions.md) \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/ets-basic-ui-description.md b/zh-cn/application-dev/quick-start/ets-basic-ui-description.md new file mode 100644 index 0000000000000000000000000000000000000000..c9586b3d4b0782d60f981821098de87de267ca43 --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-basic-ui-description.md @@ -0,0 +1,195 @@ +# 基本UI描述 + +eTS通过装饰器@Component和@Entry装饰struct关键字声明的数据结构,构成一个自定义组件。自定义组件中提供了一个build函数,开发者需在该函数内以链式调用的方式进行基本的UI描述,UI描述的方法请参考[UI描述规范](#ui描述规范)。 + +## 基本概念 + +- struct:组件可以基于struct实现,不能有继承关系,对于struct的实例化,可以省略new。 + +- 装饰器:装饰器给被装饰的对象赋予某一种能力,其不仅可以装饰类或结构体,还可以装饰类的属性。多个装饰器可以叠加到目标元素,定义在同一行上或者多行上,推荐定义在多行上。 + + ```ts + @Entry + @Component + struct MyComponent { + } + ``` + +- build函数:自定义组件必须定义build函数,并且自定义组件禁止自定义构造函数。build函数满足Builder构造器接口定义,用于定义组件的声明式UI描述。 + + ```ts + interface Builder { + build: () => void + } + ``` + +- @Component:装饰struct,结构体在装饰后具有基于组件的能力,需要实现build方法来更新UI。 + +- @Entry: 装饰struct,组件被装饰后作为页面的入口,页面加载时将被渲染显示。 + +- @Preview:装饰struct, 用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行实时预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。 + + > **说明:** 在单个源文件中,最多可以使用10个@Preview装饰自定义组件,更多说明请参考[查看eTS组件预览效果](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596#section146052489820)。 + +- 链式调用:以 "." 链式调用的方式配置UI结构及其属性、事件等。 + +## UI描述规范 + +### 无参数构造配置 + +组件的接口定义不包含必选构造参数,组件后面的“()”中不需要配置任何内容。例如,Divider组件不包含构造参数: + +```ts +Column() { + Text('item 1') + Divider() + Text('item 2') +} +``` + +### 必选参数构造配置 + +如果组件的接口定义中包含必选构造参数,则在组件后面的“()”中必须配置参数,参数可以使用常量进行赋值。 + +例如: + +- Image组件的必选参数src: + + ```ts + Image('http://xyz/a.jpg') + ``` + +- Text组件的必选参数content: + + ```ts + Text('123') + ``` + +变量或表达式也可以用于参数赋值,其中表达式返回的结果类型必须满足参数类型要求。例如,传递变量或表达式来构造Image和Text组件的参数: + +```ts +Image(this.imagePath) +Image('http://' + this.imageUrl) +Text(`count: ${this.count}`) +``` + +### 属性配置 + +使用属性方法配置组件的属性,属性方法紧随组件,并用"."运算符连接。 + +- 配置Text组件的字体大小属性: + + ```ts + Text('123') + .fontSize(12) + ``` + +- 使用"."操作进行链式调用并同时配置组件的多个属性,如下所示: + + ```ts + Image('a.jpg') + .alt('error.jpg') + .width(100) + .height(100) + ``` + +- 除了直接传递常量参数外,还可以传递变量或表达式,如下所示: + + ```ts + Text('hello') + .fontSize(this.size) + Image('a.jpg') + .width(this.count % 2 === 0 ? 100 : 200) + .height(this.offset + 100) + ``` + +- 对于系统内置组件,框架还为其属性预定义了一些[枚举类型](../reference/arkui-ts/ts-appendix-enums.md)供开发人员调用,枚举类型必须满足参数类型要求,枚举值可以作为参数传递。可以按以下方式配置Text组件的颜色和字体属性: + + ```ts + Text('hello') + .fontSize(20) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bold) + ``` + +### 事件配置 + +通过事件方法可以配置组件支持的事件。 + +- 使用lambda表达式配置组件的事件方法: + + ```ts + Button('add counter') + .onClick(() => { + this.counter += 2 + }) + ``` + +- 使用匿名函数表达式配置组件的事件方法,要求使用bind,以确保函数体中的this引用包含的组件: + + ```ts + Button('add counter') + .onClick(function () { + this.counter += 2 + }.bind(this)) + ``` + +- 使用组件的成员函数配置组件的事件方法: + + ```ts + myClickHandler(): void { + + } + + ... + + Button('add counter') + .onClick(this.myClickHandler) + ``` + +### 子组件配置 + +对于支持子组件配置的组件,例如容器组件,在"{ ... }"里为组件添加子组件的UI描述。Column、Row、Stack、Button、Grid和List组件都是容器组件。 + +- 以下是简单的Column示例: + + ```ts + Column() { + Text('Hello') + .fontSize(100) + Divider() + Text(this.myText) + .fontSize(100) + .fontColor(Color.Red) + } + ``` + +- 可以嵌套多个子组件: + + ```ts + Column() { + Column() { + Button() { + Text('+ 1') + }.type(ButtonType.Capsule) + .onClick(() => console.log ('+1 clicked!')) + Image('1.jpg') + } + Divider() + Column() { + Button() { + Text('+ 2') + }.type(ButtonType.Capsule) + .onClick(() => console.log ('+2 clicked!')) + Image('2.jpg') + } + Divider() + Column() { + Button() { + Text('+ 3') + }.type(ButtonType.Capsule) + .onClick(() => console.log('+3 clicked!')) + Image('3.jpg') + } + }.alignItems(HorizontalAlign.Center) + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/ets-dynamic-ui-elememt-building.md b/zh-cn/application-dev/quick-start/ets-dynamic-ui-elememt-building.md new file mode 100644 index 0000000000000000000000000000000000000000..be7c8c0a783e48503e951bda57398b22dab6662d --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-dynamic-ui-elememt-building.md @@ -0,0 +1,344 @@ +# 动态构建UI元素 + +前面章节介绍的是如何创建一个组件内部UI结构固定的自定义组件,为了满足开发者自定义组件内部UI结构的需求,eTS同时提供了动态构建UI元素的能力。 + +## @Builder + + +可通过@Builder装饰器进行描述,该装饰器可以修饰一个函数,此函数可以在build函数之外声明,并在build函数中或其他@Builder修饰的函数中使用,在一个自定义组件内快速生成多个布局内容。使用方式如下面示例所示。 + + +```ts +// xxx.ets + +@Component +struct CompB { + @State CompValue: string = ''; + + aboutToAppear() { + console.info('CompB aboutToAppear.'); + } + + aboutToDisappear() { + console.info('CompB aboutToDisappear.'); + } + + build() { + Column() { + Button(this.CompValue); + } + } +} + +@Entry +@Component +struct CompA { + size1: number = 100; + @State CompValue1: string = "Hello,CompValue1"; + @State CompValue2: string = "Hello,CompValue2"; + @State CompValue3: string = "Hello,CompValue3"; + + // @Builder装饰的函数内使用自定义组件 + @Builder CompC(value: string) { + CompB({ CompValue: value }); + } + + @Builder SquareText(label: string) { + Text(label) + .width(1 * this.size1) + .height(1 * this.size1) + } + + @Builder RowOfSquareTexts(label1: string, label2: string) { + Row() { + this.SquareText(label1) + this.SquareText(label2) + } + .width(2 * this.size1) + .height(1 * this.size1) + } + + build() { + Column() { + Row() { + this.SquareText("A") + this.SquareText("B") + // or as long as tsc is used + } + .width(2 * this.size1) + .height(1 * this.size1) + + this.RowOfSquareTexts("C", "D") + Column() { + // 使用三次@Builder装饰的自定义组件 + this.CompC(this.CompValue1); + this.CompC(this.CompValue2); + this.CompC(this.CompValue3); + } + .width(2 * this.size1) + .height(2 * this.size1) + } + .width(2 * this.size1) + .height(2 * this.size1) + } +} +``` +## @BuilderParam8+ + +@BuilderParam装饰器用于修饰自定义组件内函数类型的属性(例如:`@BuilderParam content: () => any;`),并且在初始化自定义组件时被@BuilderParam修饰的属性必须赋值。 + +### 引入动机 + +当开发者创建自定义组件,想对该组件添加特定功能时(如:仅对自定义组件添加一个点击跳转操作)。若直接在组件内嵌入事件方法,将会导致所有初始化该组件的地方均增加了该功能。为解决此问题,引入了@BuilderParam装饰器,此装饰器修饰的属性值可为@Builder修饰的方法,开发者可在初始化自定义组件时对此属性进行赋值,为自定义组件增加特定的的功能。 + +### 参数初始化组件 + +通过参数初始化组件时,将@Builder装饰的方法赋值给@BuilderParam修饰的属性,并在自定义组件内调用content属性值。对@BuilderParam修饰的属性进行赋值时不带参数(如:`content: this.specificParam`),则此属性的类型需定义成无返回值的函数(如:`@BuilderParam content: () => void`)。若带参数(如:`callContent: this.specificParam1("111")`),则此属性的类型需定义成any(如:`@BuilderParam callContent: any;`)。 + +```ts +// xxx.ets +@Component +struct CustomContainer { + header: string = ""; + @BuilderParam noParam: () => void; + @BuilderParam withParam: any; + footer: string = ""; + build() { + Column() { + Text(this.header) + .fontSize(50) + this.noParam() + this.withParam() + Text(this.footer) + .fontSize(50) + } + } +} + +@Entry +@Component +struct CustomContainerUser { + @Builder specificNoParam() { + Column() { + Text("noParam").fontSize(50) + } + } + @Builder SpecificWithParam(label: string) { + Column() { + Text(label).fontSize(50) + } + } + + build() { + Column() { + CustomContainer({ + header: "Header", + noParam: this.specificNoParam, + withParam: this.SpecificWithParam("WithParam"), + footer: "Footer", + }) + } + } +} +``` + +### 尾随闭包初始化组件 + +在自定义组件中使用@BuilderParam修饰的属性接收尾随闭包(在初始化自定义组件时,组件名称紧跟一个大括号“{}”形成尾随闭包场景(`CustomComponent(){}`)。开发者可把尾随闭包看做一个容器,向其填充内容,如在闭包内增加组件(`{Column(){Text("content")}`),闭包内语法规范与build函数一致。此场景下自定义组件内有且仅有一个使用@BuilderParam修饰的属性。 + +示例:在闭包内增加Column组件并添加点击事件,在新增的Column组件内调用@Builder修饰的specificParam方法,点击Column组件后该改变自定义组件中header的属性值为“changeHeader”。并且在初始化自定义组件时会把尾随闭包的内容赋值给使用@BuilderParam修饰的closer属性。 + +```ts +// xxx.ets +@Component +struct CustomContainer { + header: string = ""; + @BuilderParam closer: () => void; + build() { + Column() { + Text(this.header) + .fontSize(50) + this.closer() + } + } +} +@Builder function specificParam(label1: string, label2: string) { + Column() { + Text(label1) + .fontSize(50) + Text(label2) + .fontSize(50) + } +} +@Entry +@Component +struct CustomContainerUser { + @State text: string = "header" + build() { + Column() { + CustomContainer({ + header: this.text, + }){ + Column(){ + specificParam("111", "22") + }.onClick(()=>{ + this.text = "changeHeader" + }) + } + } + } +} +``` + +## @Styles + +eTS为了避免开发者对重复样式的设置,通过@Styles装饰器可以将多条样式设置提炼成一个方法,直接在组件声明的位置使用。@Styles装饰器将新的属性函数添加到基本组件上,如Text、Column、Button等。当前@Styles仅支持通用属性。通过@Styles装饰器可以快速定义并复用组件的自定义样式。 + +@Styles可以定义在组件内或组件外,在组件外定义时需在方法前添加function关键字,组件内定义时不需要添加function关键字。 + +```ts +// xxx.ets +@Styles function globalFancy() { + .backgroundColor(Color.Red) +} + +@Entry +@Component +struct FancyUse { + @Styles componentFancy() { + .backgroundColor(Color.Blue) + } + build() { + Column({ space: 10 }) { + Text("Fancy") + .globalFancy() + .width(100) + .height(100) + .fontSize(30) + Text("Fancy") + .componentFancy() + .width(100) + .height(100) + .fontSize(30) + } + } +} +``` + +@Styles还可以在[StateStyles](../reference/arkui-ts/ts-universal-attributes-polymorphic-style.md)属性内部使用,在组件处于不同的状态时赋予相应的属性。 + +在StateStyles内可以直接调用组件外定义的Styles,但需要通过this关键字调用组件内定义的Styles。 + +```ts +// xxx.ets +@Styles function globalFancy() { + .width(100) + .height(100) +} + +@Entry +@Component +struct FancyUse { + @Styles componentFancy() { + .width(50) + .height(50) + } + build() { + Row({ space: 10 }) { + Button() { + Text("Fancy") + } + .stateStyles({ + normal: { + .width(80) + .height(80) + }, + disabled: this.componentFancy, + pressed: globalFancy + }) + } + } +} +``` + +## @Extend + +@Extend装饰器将新的属性函数添加到内置组件上,如Text、Column、Button等。通过@Extend装饰器可以快速的扩展原生组件。@Extend装饰器不能用在自定义组件struct定义框内。 + +```ts +// xxx.ets +@Extend(Text) function fancy(fontSize: number) { + .fontColor(Color.Red) + .fontSize(fontSize) + .fontStyle(FontStyle.Italic) +} + +@Entry +@Component +struct FancyUse { + build() { + Row({ space: 10 }) { + Text("Fancy") + .fancy(16) + Text("Fancy") + .fancy(24) + } + } +} +``` + +> **说明:** +> +> - @Extend装饰器不能用在自定义组件struct定义框内。 +> - @Extend装饰器内仅支持属性函数语句。 + +## @CustomDialog + +@CustomDialog装饰器用于装饰自定义弹窗,使得弹窗可以动态设置样式。 + +```ts +// custom-dialog-demo.ets +@CustomDialog +struct DialogExample { + controller: CustomDialogController; + action: () => void; + + build() { + Row() { + Button ("Close CustomDialog") + .onClick(() => { + this.controller.close(); + this.action(); + }) + }.padding(20) + } +} + +@Entry +@Component +struct CustomDialogUser { + dialogController : CustomDialogController = new CustomDialogController({ + builder: DialogExample({action: this.onAccept}), + cancel: this.existApp, + autoCancel: true + }); + + onAccept() { + console.log("onAccept"); + } + existApp() { + console.log("Cancel dialog!"); + } + + build() { + Column() { + Button("Click to open Dialog") + .onClick(() => { + this.dialogController.open() + }) + } + } +} +``` + +![custom-dialog-demo](figures/custom-dialog-demo.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/ets-get-started.md b/zh-cn/application-dev/quick-start/ets-get-started.md new file mode 100644 index 0000000000000000000000000000000000000000..f00694cf57a65b67e0865305fbd868b93a0618eb --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-get-started.md @@ -0,0 +1,30 @@ +# 初识eTS语言 + +eTS(extended TypeScript)是OpenHarmony优选的主力应用开发语言。eTS基于TypeScript(简称TS)语言扩展而来,是TS的超集。 + +- eTS继承了TS的所有特性。 + +- 当前,eTS在TS基础上主要扩展了[声明式UI](ets-basic-ui-description.md)能力,让开发者以更简洁、更自然的方式开发高性能应用。 + + 当前扩展的声明式UI包括如下特性。 + + - [基本UI描述](ets-basic-ui-description.md):eTS定义了各种装饰器、自定义组件、UI描述机制,再配合UI开发框架中的UI内置组件、事件方法、属性方法等共同构成了UI开发的主体。 + - [状态管理](ets-state-mgmt-page-level.md):eTS提供了多维度的状态管理机制,在UI开发框架中,和UI相关联的数据,不仅可以在组件内使用,还可以在不同组件层级间传递,比如父子组件之间、爷孙组件之间,也可以是全局范围内的传递,还可以是 跨设备传递。另外,从数据的传递形式来看,可分为只读的单向传递和可变更的双向传递。开发者可以灵活的利用这些能力来实现数据和UI的联动。 + - [动态构建UI元素](ets-dynamic-ui-elememt-building.md):eTS提供了动态构建UI元素的能力,不仅可以自定义组件内部的UI结构,还可复用组件样式,扩展原生组件。 + - [渲染控制](ets-rendering-control.md):eTS提供了渲染控制的能力。条件渲染可根据应用的不同状态,渲染对应状态下的部分内容。循环渲染可从数据源中迭代获取数据,并在每次迭代过程中创建相应的组件。 + - [使用限制与扩展](ets-restrictions-and-extensions.md):eTS在使用过程中存在限制与约束,同时也扩展了双向绑定等能力。 + +- 未来,eTS会结合应用开发/运行的需求持续演进,逐步提供并行和并发能力增强、类型系统增强、分布式开发范式等更多特性。 + +下面我们以一个具体的示例来说明eTS的基本组成。如下图所示的代码示例,UI界面会两段文本和一个按钮,当开发者点击按钮时,文本内容会从'Hello World'变为 'Hello ArkUI'。 + +![ets-get-started](figures/ets-get-started.png) + +这个示例中所包含的eTS声明式开发范式的基本组成说明如下: + +- 装饰器: 用于装饰类、结构、方法以及变量,赋予其特殊的含义,如上述示例中@Entry、@Component和@State都是装饰器。 具体而言,@Component表示这是个自定义组件;@Entry则表示这是个入口组件;@State表示组件中的状态变量,这个状态变换会引起UI变更。 +- 自定义组件:可复用的UI单元,可组合其他组件,如上述被@Component装饰的struct Hello。 +- UI描述:声明式的方法来描述UI的结构,例如build()方法中的代码块。 +- 内置组件:eTS中默认内置的基本组件和布局组件,开发者可以直接调用,如Column、Text、Divider、Button等。 +- 属性方法:用于组件属性的配置,如fontSize()、width()、height()、color()等,可通过链式调用的方式设置多项属性。 +- 事件方法:用于添加组件对事件的响应逻辑,统一通过事件方法进行设置,如跟随在Button后面的onClick()。 diff --git a/zh-cn/application-dev/quick-start/ets-rendering-control.md b/zh-cn/application-dev/quick-start/ets-rendering-control.md new file mode 100644 index 0000000000000000000000000000000000000000..d6b632e98b904e33b5a199a4864d4bfed15e7626 --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-rendering-control.md @@ -0,0 +1,270 @@ +# 渲染控制 + +eTS也提供了渲染控制的能力。条件渲染可根据应用的不同状态,渲染对应状态下的部分内容。循环渲染可从数据源中迭代获取数据,并在每次迭代过程中创建相应的组件。 + +## 条件渲染 + +使用if/else进行条件渲染。 + + +> **说明:** +> +> - if条件语句可以使用状态变量。 +> +> - 使用if可以使子组件的渲染依赖条件语句。 +> +> - 必须在容器组件内使用。 +> +> - 某些容器组件限制子组件的类型或数量。将if放置在这些组件内时,这些限制将应用于if和else语句内创建的组件。例如,Grid组件的子组件仅支持GridItem组件,在Grid组件内使用if时,则if条件语句内仅允许使用GridItem组件。 + + +```ts +Column() { + if (this.count < 0) { + Text('count is negative') + } else if (this.count % 2 === 0) { + Divider() + Text('even') + } else { + Divider() + Text('odd') + } +} +``` + +## 循环渲染 + +通过循环渲染(ForEach组件)来迭代数组,并为每个数组项创建相应的组件,可减少代码复杂度。 + +``` + ForEach( + arr: any[], + itemGenerator: (item: any, index?: number) => void, + keyGenerator?: (item: any, index?: number) => string + ) +``` + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------------- | ------------------------------------- | ---- | ------------------------------------------------------------ | +| arr | any[] | 是 | 必须是数组,允许空数组,空数组场景下不会创建子组件。同时允许设置返回值为数组类型的函数,例如arr.slice(1, 3),设置的函数不得改变包括数组本身在内的任何状态变量,如Array.splice、Array.sort或Array.reverse这些改变原数组的函数。 | +| itemGenerator | (item: any, index?: number) => void | 是 | 生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。 | +| keyGenerator | (item: any, index?: number) => string | 否 | 匿名参数,用于给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则ForEach中的所有节点都将重建。 | + +> **说明:** +> +> - ForEach组件必须在容器组件内使用; +> +> - 生成的子组件允许在ForEach的父容器组件中,允许子组件生成器函数中包含if/else条件渲染,同时也允许ForEach包含在if/else条件渲染语句中; +> +> - 子项生成器函数的调用顺序不一定和数组中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: +> +> ``` +> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), +> item => Text(`${item.i}. item.data.label`), +> item => item.data.id.toString()) +> ``` + +## 示例 + +```ts +// xxx.ets +@Entry +@Component +struct MyComponent { + @State arr: number[] = [10, 20, 30] + + build() { + Column() { + Button() { + Text('Reverse Array') + }.onClick(() => { + this.arr.reverse() + }) + + ForEach(this.arr, + (item: number) => { + Text(`item value: ${item}`) + Divider() + }, + (item: number) => item.toString() + ) + } + } +} +``` + +## 数据懒加载 + +通过数据懒加载(LazyForEach组件)从提供的数据源中按需迭代数据,并在每次迭代过程中创建相应的组件。 + +```ts +LazyForEach( + dataSource: IDataSource, + itemGenerator: (item: any) => void, + keyGenerator?: (item: any) => string +): void + +interface IDataSource { + totalCount(): number; + getData(index: number): any; + registerDataChangeListener(listener: DataChangeListener): void; + unregisterDataChangeListener(listener: DataChangeListener): void; +} + +interface DataChangeListener { + onDataReloaded(): void; + onDataAdd(index: number): void; + onDataMove(from: number, to: number): void; + onDataDelete(index: number): void; + onDataChange(index: number): void; +} +``` + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------------- | --------------------- | ---- | ------------------------------------------------------------ | +| dataSource | IDataSource | 是 | 实现IDataSource接口的对象,需要开发者实现相关接口。 | +| itemGenerator | (item: any) => void | 是 | 生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。 | +| keyGenerator | (item: any) => string | 否 | 匿名函数,用于键值生成,为给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则LazyForEach中的所有节点都将重建。 | + +表2 IDataSource类型说明 + +| 名称 | 描述 | +| ------------------------------------------------------------ | ---------------------- | +| totalCount(): number | 获取数据总数。 | +| getData(index: number): any | 获取索引对应的数据。 | +| registerDataChangeListener(listener:DataChangeListener): void | 注册改变数据的控制器。 | +| unregisterDataChangeListener(listener:DataChangeListener): void | 注销改变数据的控制器。 | + +表3 DataChangeListener类型说明 + +| 名称 | 描述 | +| -------------------------------------------------------- | -------------------------------------- | +| onDataReloaded(): void | 重新加载所有数据。 | +| onDataAdded(index: number): void (deprecated) | 通知组件index的位置有数据添加。 | +| onDataMoved(from: number, to: number): void (deprecated) | 通知组件数据从from的位置移到to的位置。 | +| onDataDeleted(index: number): void (deprecated) | 通知组件index的位置有数据删除。 | +| onDataChanged(index: number): void (deprecated) | 通知组件index的位置有数据变化。 | +| onDataAdd(index: number): void 8+ | 通知组件index的位置有数据添加。 | +| onDataMove(from: number, to: number): void 8+ | 通知组件数据从from的位置移到to的位置。 | +| onDataDelete(index: number): void 8+ | 通知组件index的位置有数据删除。 | +| onDataChange(index: number): void 8+ | 通知组件index的位置有数据变化。 | + +## 示例 + +```ts +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = [] + + public totalCount(): number { + return 0 + } + public getData(index: number): any { + return undefined + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener') + this.listeners.push(listener) + } + } + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener') + this.listeners.splice(pos, 1) + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index) + }) + } + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index) + }) + } + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index) + }) + } + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to) + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = ['/path/image0', '/path/image1', '/path/image2', '/path/image3'] + + public totalCount(): number { + return this.dataArray.length + } + public getData(index: number): any { + return this.dataArray[index] + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data) + this.notifyDataAdd(index) + } + public pushData(data: string): void { + this.dataArray.push(data) + this.notifyDataAdd(this.dataArray.length - 1) + } +} + +@Entry +@Component +struct MyComponent { + private data: MyDataSource = new MyDataSource() + build() { + List({space: 3}) { + LazyForEach(this.data, (item: string) => { + ListItem() { + Row() { + Image(item).width("30%").height(50) + Text(item).fontSize(20).margin({left:10}) + }.margin({left: 10, right: 10}) + } + .onClick(()=>{ + this.data.pushData('/path/image' + this.data.totalCount()) + }) + }, item => item) + } + } +} +``` + +> **说明:** +> +> - 数据懒加载必须在容器组件内使用,且仅有List、Grid以及Swiper组件支持数据的懒加载(即只加载可视部分以及其前后少量数据用于缓冲),其他组件仍然是一次加载所有的数据; +> +> - LazyForEach在每次迭代中,必须且只允许创建一个子组件; +> +> - 生成的子组件必须允许在LazyForEach的父容器组件中; +> +> - 允许LazyForEach包含在if/else条件渲染语句中,不允许LazyForEach中出现if/else条件渲染语句; +> +> - 为了高性能渲染,通过DataChangeListener对象的onDataChange方法来更新UI时,仅itemGenerator中的UI描述的组件内使用了状态变量时,才会触发组件刷新; +> +> - 子项生成器函数的调用顺序不一定和数据源中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: +> +> ```ts +> LazyForEach(dataSource, +> item => Text(`${item.i}. item.data.label`)), +> item => item.data.id.toString()) +> ``` \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/ets-restrictions-and-extensions.md b/zh-cn/application-dev/quick-start/ets-restrictions-and-extensions.md new file mode 100644 index 0000000000000000000000000000000000000000..9cfdc30e912f5324c78fec14783db0a31208da68 --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-restrictions-and-extensions.md @@ -0,0 +1,72 @@ +# 使用限制与扩展 + +## 在生成器函数中的使用限制 + +eTS语言的使用在生成器函数中存在一定的限制: + +- 表达式仅允许在字符串(${expression})、if条件、ForEach的参数和组件的参数中使用; +- 任何表达式都不能导致任何应用程序状态变量(@State、@Link、@Prop)的改变,否则会导致未定义和潜在不稳定的框架行为; +- 生成器函数内部不能有局部变量。 + +上述限制都不适用于事件处理函数(例如onClick)的匿函数实现。 + +## 变量的双向绑定 + +eTS支持通过$$双向绑定变量,通常应用于状态值频繁改变的变量。 + +- 当前$$支持基础类型变量,以及@State、@Link和@Prop装饰的变量。 +- 当前$$仅支持[bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md)属性的show参数和@State变量之间的渲染,Radio组件的checked属性。 +- $$绑定的变量变更时,仅渲染当前组件,提高渲染速度。 + +```ts +// xxx.ets +@Entry +@Component +struct bindPopup { + @State customPopup: boolean = false + build() { + column() { + button() { + Text('Popup') + } + .onClick(() => { + this.customPopup = !this.customPopup + }) + .bindPopup( + $$this.customPopup, { + mesage: "showPopup" + } + ) + } + } +} + +``` + +## 状态变量多种数据类型声明使用限制 + +@State、@Provide、 @Link和@Consume四种状态变量的多种数据类型只能同时由简单数据类型或引用数据类型其中一种构成。 + +示例: + +```ts +// xxx.ets +@Entry +@Component +struct Index { + //错误写法: @State message: string | Resource = 'Hello World' + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(`${ this.message }`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/ets-state-mgmt-application-level.md b/zh-cn/application-dev/quick-start/ets-state-mgmt-application-level.md new file mode 100644 index 0000000000000000000000000000000000000000..922b4715478f37d49ed18a7ed4e4c98d54a3f981 --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-state-mgmt-application-level.md @@ -0,0 +1,234 @@ +# 应用级变量的状态管理 + +在前面的章节中,已经讲述了如何管理页面级变量的状态,本章将说明如何管理应用级变量的状态,具体接口请参考[应用级变量的状态管理接口](../reference/arkui-ts/ts-state-management.md)。 + +## AppStorage + +AppStorage是应用程序中的单例对象,由UI框架在应用程序启动时创建,在应用程序退出时销毁,为应用程序范围内的可变状态属性提供中央存储。 + +AppStorage包含整个应用程序中需要访问的所有状态属性,只要应用程序保持运行,AppStorage就会保存所有属性及属性值,属性值可以通过唯一的键值进行访问。 + + +组件可以通过装饰器将应用程序状态数据与AppStorage进行同步,应用业务逻辑的实现也可以通过接口访问AppStorage。 + + +AppStorage的选择状态属性可以与不同的数据源或数据接收器同步,这些数据源和接收器可以是设备上的本地或远程,并具有不同的功能,如数据持久性。这样的数据源和接收器可以独立于UI在业务逻辑中实现。 + +默认情况下,AppStorage中的属性是可变的,AppStorage还可使用不可变(只读)属性。 + +### @StorageLink装饰器 + +组件通过使用@StorageLink(key)装饰的状态变量,与AppStorage建立双向数据绑定,key为AppStorage中的属性键值。当创建包含@StorageLink的状态变量的组件时,该状态变量的值将使用AppStorage中的值进行初始化。在UI组件中对@StorageLink的状态变量所做的更改将同步到AppStorage,并从AppStorage同步到任何其他绑定实例中,如PersistentStorage或其他绑定的UI组件。 + +### @StorageProp装饰器 + +组件通过使用@StorageProp(key)装饰的状态变量,将与AppStorage建立单向数据绑定,key标识AppStorage中的属性键值。当创建包含@StoageProp的状态变量的组件时,该状态变量的值将使用AppStorage中的值进行初始化。AppStorage中的属性值的更改会导致绑定的UI组件进行状态更新。 + +### 示例 + +每次用户单击Count按钮时,this.varA变量值都会增加,此变量与AppStorage中的varA同步。每次用户单击当前语言按钮时,修改AppStorage中的languageCode,此修改会同步给this.lang变量。 + +```ts +// xxx.ets + +@Entry +@Component +struct ComponentA { + @StorageLink('varA') varA: number = 2 + @StorageProp('languageCode') lang: string = 'en' + private label: string = 'count' + + aboutToAppear() { + this.label = (this.lang === 'zh') ? '数' : 'Count' + } + + build() { + Column(){ + Row({ space: 20 }) { + Button(`${this.label}: ${this.varA}`) + .onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1) + }) + Button(`lang: ${this.lang}`) + .onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en') + } else { + AppStorage.Set('languageCode', 'zh') + } + this.label = (this.lang === 'zh') ? '数' : 'Count' + }) + } + .margin({ bottom: 50 }) + Row(){ + Button(`更改@StorageLink修饰的变量:${this.varA}`).fontSize(10) + .onClick(() => { + this.varA++ + }) + }.margin({ bottom: 50 }) + Row(){ + Button(`更改@StorageProp修饰的变量:${this.lang}`).fontSize(10) + .onClick(() => { + this.lang = 'test' + }) + } + } + } +} +``` + + ![appstorage](figures/appstorage.gif) + +## LocalStorage + +> **说明:** 该组件从API version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +LocalStorage是应用程序中的存储单元,生命周期跟随其关联的Ability。LocalStorage为应用程序范围内的可变状态属性和非可变状态属性提供存储,可变状态属性和非可变状态属性是构建应用程序UI的一部分,如一个Ability的UI。 + +应用层:一个应用程序可以创建多个LocalStorage实例,应用程序的每一个Ability对应一个LocalStorage实例。 + +Ability: 一个应用程序可以拥有多个Ability,一个Ability中的所有子组件最多可以分配一个LocalStorage实例。并且,Ability中的所有子组件都将继承对此LocalStorage实例存储对象的访问权。 + +一个组件最多可以访问一个LocalStorage实例,一个LocalStorage对象可以分配给多个组件。 + +### @LocalStorageLink装饰器 + +组件通过使用@LocalStorageLink(key)装饰的状态变量,key值为LocalStorage中的属性键值,与LocalStorage建立双向数据绑定。当创建包含@LocalStorageLink的状态变量的组件时,该状态变量的值将会使用LocalStorage中的值进行初始化。如果LocalStorage中未定义初始值,将使用@LocalStorageLink定义的初始值。在UI组件中对@LocalStorageLink的状态变量所做的更改将同步到LocalStorage中,并从LocalStorage同步到Ability下的组件中。 + +### @LocalStorageProp装饰器 + +组件通过使用LocalStorageProp(key)装饰的状态变量,key值为LocalStorage中的属性键值,与LocalStorage建立单向数据绑定。当创建包含@LocalStorageProp的状态变量的组件时,该状态变量的值将使用LocalStorage中的值进行初始化。LocalStorage中的属性值的更改会导致当前Ability下的所有UI组件进行状态更新。 + +> **说明:** 创建LocalStorage实例时如未定义初始值,可以使用组件内@LocalStorageLink和@LocalStorageProp的初始值。如果定义时给定了初始值,那么不会再使用@LocalStorageLink和@LocalStorageProp的初始值。 + +### 示例1(在一个Ability创建的LocalStorage) + +LocalStorage通过loadContent接口加载,接口详见[loadContent](../reference/apis/js-apis-window.md#loadcontent9-1)。 + +``` +import Ability from '@ohos.application.Ability' +export default class MainAbility extends Ability { + storage : LocalStorage + onCreate() { + this.storage = new LocalStorage(); + this.storage.setOrCreate("storageSimpleProp",121); + console.log("[Demo MainAbility onCreate]"); + } + onDestroy() { + console.log("[Demo MainAbility onDestroy]") + } + onWindowStageCreate(windowStage) { + // storage作为参数传递给loadContent接口。 + windowStage.loadContent("pages/index",this.storage) + } + onWindowStageDestroy() { + console.log("[Demo] MainAbility onWindoeStageDestroy") + } + onForeground() { + console.log("[Demo] MainAbility onForeground") + } + onBackground() { + console.log("[Demo] MainAbility onBackground") + } +} +``` + +@Component组件获取数据 + +``` +let storage = LocalStorage.GetShared() +@Entry(storage) +@Component +struct LocalStorageComponent { + @LocalStorageLink("storageSimpleProp") simpleVarName: number = 0 + build() { + Column(){ + Text(this.simpleVarName.toString()) + .onClick(()=>{ + this.simpleVarName +=1; + }) + Text(JSON.stringify(this.simpleVarName)) + .fontSize(50) + } + .height(500) + } +} +``` + +### 示例2(在Entry页面定义LocalStorage) + +``` +let storage = new LocalStorage({"PropA":47}); +@Entry(storage) +@Component +struct ComA { + @LocalStorageLink("PropA") storLink: number = 1; + build() { + Column() { + Text(`Parent from LocalStorage ${ this.storLink }`) + .onClick(()=>this.storLink+=1) + Child() + } + } +} + + +@Component +struct Child{ + @LocalStorageLink("PropA") storLink: number = 1; + build() { + Text(`Parent from LocalStorage ${ this.storLink }`) + .onClick(()=>this.storLink+=1) + } +} +``` + +## PersistentStorage + +PersistentStorage类提供了一些静态方法用来管理应用持久化数据,可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据,或者通过@StorageLink装饰器来访问对应key的变量。 + +> **说明:** +> +> - PersistProp接口使用时,需要保证输入对应的key应当在AppStorage存在。 +> - DeleteProp接口使用时,只能对本次启动已经link过的数据生效。 + +```ts +// xxx.ets +PersistentStorage.PersistProp("highScore", "0"); + +@Entry +@Component +struct PersistentComponent { + @StorageLink('highScore') highScore: string = '0' + @State currentScore: number = 0 + build() { + Column() { + if (this.currentScore === Number(this.highScore)) { + Text(`new highScore : ${this.highScore}`) + } + Button() { + Text(`goal!, currentScore : ${this.currentScore}`) + .fontSize(10) + }.onClick(() => { + this.currentScore++ + if (this.currentScore > Number(this.highScore)) { + this.highScore = this.currentScore.toString() + } + }) + } + } +} +``` + + ![PersistentStorage](figures/PersistentStorage.gif) + +## Environment + +Environment是框架在应用程序启动时创建的单例对象,它为AppStorage提供了一系列应用程序需要的环境状态属性,这些属性描述了应用程序运行的设备环境。Environment及其属性是不可变的,所有属性值类型均为简单类型。如下示例展示了从Environment获取语音环境: + +``` +Environment.EnvProp("accessibilityEnabled", "default"); +var enable = AppStorage.Get("accessibilityEnabled"); +``` + +accessibilityEnabled是Environment提供默认系统变量识别符。首先需要将对应系统属性绑定到AppStorage中,再通过AppStorage中的方法或者装饰器访问对应系统的属性数据。 diff --git a/zh-cn/application-dev/quick-start/ets-state-mgmt-concepts.md b/zh-cn/application-dev/quick-start/ets-state-mgmt-concepts.md new file mode 100644 index 0000000000000000000000000000000000000000..52d66dc7b834f15710e040d0e6cf52f4246c2188 --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-state-mgmt-concepts.md @@ -0,0 +1,30 @@ +# 基本概念 + +eTS提供了多维度的状态管理机制,在UI开发框架中,和UI相关联的数据,不仅可以在组件内使用,还可以在不同组件层级间传递,比如父子组件之间、爷孙组件之前,也可以时全局范围内的传递。另外,从数据的传递形式来看,可分为只读的单向传递和可变更的双向传递。开发者可以灵活的利用这些能力来实现数据和UI的联动。 + + +![](figures/CoreSpec_figures_state-mgmt-overview.png) + + +## 页面级变量的状态管理 + +| 装饰器 | 装饰内容 | 说明 | +| ----------- | ------------------------- | ------------------------------------------------------------ | +| @State | 基本数据类型,类,数组 | 修饰的状态数据被修改时会触发组件的build方法进行UI界面更新。 | +| @Prop | 基本数据类型 | 修改后的状态数据用于在父组件和子组件之间建立单向数据依赖关系。修改父组件关联数据时,更新当前组件的UI。 | +| @Link | 基本数据类型,类,数组 | 父子组件之间的双向数据绑定,父组件的内部状态数据作为数据源,任何一方所做的修改都会反映给另一方。 | +| @Observed | 类 | @Observed应用于类,表示该类中的数据变更被UI页面管理。 | +| @ObjectLink | 被@Observed所装饰类的对象 | 装饰的状态数据被修改时,在父组件或者其他兄弟组件内与它关联的状态数据所在的组件都会更新UI。 | +| @Consume | 基本数据类型,类,数组 | @Consume装饰的变量在感知到@Provide装饰的变量更新后,会触发当前自定义组件的重新渲染。 | +| @Provide | 基本数据类型,类,数组 | @Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。 | + +## 应用级变量的状态管理 + +AppStorage是整个UI应用程序状态的中心“数据库”,UI框架会针对应用程序创建单例AppStorage对象,并提供相应的装饰器和接口供应用程序使用。 + +- @StorageLink:@StorageLink(name)的原理类似于@Consume(name),不同的是,该给定名称的链接对象是从AppStorage中获得的,在UI组件和AppStorage之间建立双向绑定同步数据。 +- @StorageProp:@StorageProp(name)将UI组件属性与AppStorage进行单向同步,AppStorage中值的更改会更新组件中的属性,但UI组件无法更改AppStorage中的属性值。 +- AppStorage还提供用于业务逻辑实现的API,用于添加、读取、修改和删除应用程序的状态属性,此API所做的更改会导致修改的状态数据同步到UI组件上进行UI更新。 +- PersistentStorage类提供了一些静态方法用来管理应用持久化数据,可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据,或者通过@StorageLink装饰器来访问对应key的变量。 +- Environment是框架在应用程序启动时创建的单例对象,它为AppStorage提供了一系列应用程序需要的环境状态属性,这些属性描述了应用程序运行的设备环境。 + diff --git a/zh-cn/application-dev/quick-start/ets-state-mgmt-page-level.md b/zh-cn/application-dev/quick-start/ets-state-mgmt-page-level.md new file mode 100644 index 0000000000000000000000000000000000000000..586f3f22473f4e0d3f9d4068d134a893268756fe --- /dev/null +++ b/zh-cn/application-dev/quick-start/ets-state-mgmt-page-level.md @@ -0,0 +1,478 @@ +# 页面级变量的状态管理 + +@State、@Prop、@Link、@Provide、Consume、@ObjectLink、@Observed和@Watch用于管理页面级变量的状态。 + +## @State + +@State装饰的变量是组件内部的状态数据,当这些状态数据被修改时,将会调用所在组件的build方法进行UI刷新。 + +@State状态数据具有以下特征: + + +- 支持多种类型:允许class、number、boolean、string强类型的按值和按引用类型。允许这些强类型构成的数组,即Array<class>、Array<string>、Array<boolean>、Array<number>。不允许object和any。 +- 支持多实例:组件不同实例的内部状态数据独立。 +- 内部私有:标记为@State的属性是私有变量,只能在组件内访问。 +- 需要本地初始化:必须为所有@State变量分配初始值,将变量保持未初始化可能导致框架行为未定义。 +- 创建自定义组件时支持通过状态变量名设置初始值:在创建组件实例时,可以通过变量名显式指定@State状态属性的初始值。 + +**示例:** + +在下面的示例中: + + +- 用户定义的组件MyComponent定义了@State状态变量count和title。如果count或title的值发生变化,则执行MyComponent的build方法来重新渲染组件; + +- EntryComponent中有多个MyComponent组件实例,第一个MyComponent内部状态的更改不会影响第二个MyComponent; + +- 创建MyComponent实例时通过变量名给组件内的变量进行初始化,如: + ```ts + MyComponent({title: {value: 'Hello, World 2'}, count: 7}) + ``` + +```ts +// xxx.ets +class Model { + value: string + constructor(value: string) { + this.value = value + } +} + +@Entry +@Component +struct EntryComponent { + build() { + Column() { + MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document + MyComponent({title: {value: 'Hello, World 2'}, count: 7}) //MyComponent2 in this document + } + } +} + +@Component +struct MyComponent { + @State title: Model = {value: 'Hello World'} + @State count: number = 0 + private toggle: string = 'Hello World' + private increaseBy: number = 1 + + build() { + Column() { + Text(`${this.title.value}`).fontSize(30) + Button() { + Text(`Click to change title`).fontSize(20).fontColor(Color.White) + }.onClick(() => { + this.title.value = (this.toggle == this.title.value) ? 'Hello World' : 'Hello UI' + }) // Modify the internal state of MyComponent using the anonymous method. + + Button() { + Text(`Click to increase count=${this.count}`).fontSize(20).fontColor(Color.White) + }.onClick(() => { + this.count += this.increaseBy + }) // Modify the internal state of MyComponent using the anonymous method. + } + } +} +``` + +![@state1](figures/@state.png) + +## @Prop + +@Prop与@State有相同的语义,但初始化方式不同。@Prop装饰的变量必须使用其父组件提供的@State变量进行初始化,允许组件内部修改@Prop变量,但更改不会通知给父组件,即@Prop属于单向数据绑定。 + +@Prop状态数据具有以下特征: + +- 支持简单类型:仅支持number、string、boolean简单类型; +- 私有:仅在组件内访问; +- 支持多个实例:一个组件中可以定义多个标有@Prop的属性; +- 创建自定义组件时将值传递给@Prop变量进行初始化:在创建组件的新实例时,必须初始化所有@Prop变量,不支持在组件内部进行初始化。 + +**示例:** + +在下面的示例中,当按“+1”或“-1”按钮时,父组件状态发生变化,重新执行build方法,此时将创建一个新的CountDownComponent组件。父组件的countDownStartValue状态属性被用于初始化子组件的@Prop变量,当按下子组件的“Try again”按钮时,其@Prop变量count将被更改,CountDownComponent重新渲染。但是count值的更改不会影响父组件的countDownStartValue值。 + +```ts +// xxx.ets +@Entry +@Component +struct ParentComponent { + @State countDownStartValue: number = 10 // 10 Nuggets default start value in a Game + build() { + Column() { + Text(`Grant ${this.countDownStartValue} nuggets to play.`) + Button() { + Text('+1 - Nuggets in New Game') + }.onClick(() => { + this.countDownStartValue += 1 + }) + Button() { + Text('-1 - Nuggets in New Game') + }.onClick(() => { + this.countDownStartValue -= 1 + }) + // 创建子组件时,必须在构造函数参数中提供其@Prop变量的初始值,同时初始化常规变量CostOfOneAttump(非Prop) + CountDownComponent({ count: this.countDownStartValue, costOfOneAttempt: 2}) + } + } +} + +@Component +struct CountDownComponent { + @Prop count: number + private costOfOneAttempt: number + + build() { + Column() { + if (this.count > 0) { + Text(`You have ${this.count} Nuggets left`) + } else { + Text('Game over!') + } + + Button() { + Text('Try again') + }.onClick(() => { + this.count -= this.costOfOneAttempt + }) + } + } +} +``` + +> **说明:** 创建新组件实例时,必须初始化其所有@Prop变量。 + +## @Link + +@Link装饰的变量可以和父组件的@State变量建立双向数据绑定: + +- 支持多种类型:@Link变量的值与@State变量的类型相同,即class、number、string、boolean或这些类型的数组; +- 私有:仅在组件内访问; +- 单个数据源:初始化@Link变量的父组件的变量必须是@State变量; +- 双向通信:子组件对@Link变量的更改将同步修改父组件的@State变量; +- 创建自定义组件时需要将变量的引用传递给@Link变量,在创建组件的新实例时,必须使用命名参数初始化所有@Link变量。@Link变量可以使用@State变量或@Link变量的引用进行初始化,@State变量可以通过`'$'`操作符创建引用。 + +> 说明: @Link变量不能在组件内部进行初始化 + +**简单类型示例:** + +@Link语义是从`'$'`操作符引出,即`$isPlaying`是`this.isPlaying`内部状态的双向数据绑定。当单击PlayButton时,PlayButton的Image组件和Text组件将同时进行刷新。 + +```ts +// xxx.ets +@Entry +@Component +struct Player { + @State isPlaying: boolean = false + build() { + Column() { + PlayButton({buttonPlaying: $isPlaying}) + Text(`Player is ${this.isPlaying? '':'not'} playing`) + } + } +} + +@Component +struct PlayButton { + @Link buttonPlaying: boolean + build() { + Column() { + Button() { + Image(this.buttonPlaying? 'play.png' : 'pause.png') + }.onClick(() => { + this.buttonPlaying = !this.buttonPlaying + }) + } + } +} +``` + +**复杂类型示例:** + +```ts +// xxx.ets +@Entry +@Component +struct Parent { + @State arr: number[] = [1, 2, 3] + build() { + Column() { + Child({items: $arr}) + ForEach(this.arr, + item => Text(`${item}`), + item => item.toString()) + } + } +} + +@Component +struct Child { + @Link items: number[] + build() { + Column() { + Button() { + Text('Button1: push') + }.onClick(() => { + this.items.push(100) + }) + Button() { + Text('Button2: replace whole item') + }.onClick(() => { + this.items = [100, 200, 300] + }) + } + } +} +``` + +## @Link、@State和@Prop结合使用示例 + +下面示例中,ParentView包含ChildA和ChildB两个子组件,ParentView的状态变量counter分别初始化ChildA和ChildB。 + +- ChildB使用@Link建立双向状态绑定。当ChildB修改counterRef状态变量值时,该更改将同步到ParentView和ChildA共享; +- ChildA使用@Prop建立从ParentView到自身的单向状态绑定。当ChildA修改状态时,ChildA将重新渲染,但该更改不会传达给ParentView和ChildB。 + +```ts +// xxx.ets +@Entry +@Component +struct ParentView { + @State counter: number = 0 + build() { + Column() { + ChildA({counterVal: this.counter}) // pass by value + ChildB({counterRef: $counter}) // $ creates a Reference that can be bound to counterRef + } + } +} + +@Component +struct ChildA { + @Prop counterVal: number + build() { + Button() { + Text(`ChildA: (${this.counterVal}) + 1`) + }.onClick(() => {this.counterVal+= 1}) + } +} + +@Component +struct ChildB { + @Link counterRef: number + build() { + Button() { + Text(`ChildB: (${this.counterRef}) + 1`) + }.onClick(() => {this.counterRef+= 1}) + } +} +``` + +## Observed和ObjectLink数据管理 + +当开发者需要在子组件中针对父组件的一个变量(parent_a)设置双向同步时,开发者可以在父组件中使用\@State装饰变量(parent_a),并在子组件中使用@Link装饰相应的变量(child_a)。这样的话,不仅可以实现父组件与单个子组件之间的数据同步,也可以实现父组件与多个子组件之间的数据同步。如下图所示,可以看到,父子组件针对ClassA类型的变量设置了双向同步,那么当子组件1中变量的属性c的值变化时,会通知父组件同步变化,而当父组件中属性c的值变化时,会通知所有子组件同步变化。 + +![zh-cn_image_0000001251090821](figures/zh-cn_image_0000001251090821.png) + +然而,上述例子是针对某个数据对象进行的整体同步,而当开发者只想针对父组件中某个数据对象的部分信息进行同步时,使用@Link就不能满足要求。如果这些部分信息是一个类对象,就可以使用@ObjectLink配合@Observed来实现,如下图所示。 + +![zh-cn_image_0000001206450834](figures/zh-cn_image_0000001206450834.png) + +### 设置要求 + +- @Observed 用于类,@ObjectLink 用于变量。 + +- @ObjectLink装饰的变量类型必须为类(class type)。 + - 类要被\@Observed装饰器所装饰。 + - 不支持简单类型参数,可以使用@Prop进行单向同步。 + +- @ObjectLink装饰的变量是不可变的(immutable)。 + - 属性的改动是被允许的,当改动发生时,如果同一个对象被多个@ObjectLink变量所引用,那么所有拥有这些变量的自定义组件都会被通知去重新渲染。 + +- @ObjectLink装饰的变量不可设置默认值。 + - 必须让父组件中有一个由@State、@Link、@StorageLink、@Provide或@Consume所装饰变量参与的TS表达式进行初始化。 + +- @ObjectLink装饰的变量是私有变量,只能在组件内访问。 + + +### 示例 + +```ts +// xxx.ets +// 父组件ViewB中的类对象ClassA与子组件ViewA保持数据同步时,可以使用@ObjectLink和@Observed,绑定该数据对象的父组件和其他子组件同步更新 + +var nextID: number = 0; + +@Observed +class ClassA { + public name : string; + public c: number; + public id : number; + constructor(c: number, name: string = 'OK') { + this.name = name; + this.c = c; + this.id = nextID++; + } +} + +@Component +struct ViewA { + label : string = "ViewA1"; + @ObjectLink a: ClassA; + build() { + Row() { + Button(`ViewA [${this.label}] this.a.c= ${this.a.c} +1`) + .onClick(() => { + this.a.c += 1; + }) + }.margin({ top: 10 }) + } +} + +@Entry +@Component +struct ViewB { + @State arrA : ClassA[] = [ new ClassA(0), new ClassA(0) ]; + build() { + Column() { + ForEach (this.arrA, (item) => { + ViewA({label: `#${item.id}`, a: item}) + }, + (item) => item.id.toString() + ) + ViewA({label: `ViewA this.arrA[first]`, a: this.arrA[0]}) + ViewA({label: `ViewA this.arrA[last]`, a: this.arrA[this.arrA.length-1]}) + + Button(`ViewB: reset array`) + .margin({ top: 10 }) + .onClick(() => { + this.arrA = [ new ClassA(0), new ClassA(0) ]; + }) + Button(`ViewB: push`) + .margin({ top: 10 }) + .onClick(() => { + this.arrA.push(new ClassA(0)) + }) + Button(`ViewB: shift`) + .margin({ top: 10 }) + .onClick(() => { + this.arrA.shift() + }) + } + } +} +``` + + ![Observed](figures/Observed.gif) + +## @Consume和@Provide + +Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。Consume在感知到Provide数据的更新后,会触发当前view的重新渲染。 + +> **说明:** 使用@Provide 和@Consume时避免循环引用导致死循环。 + +表1 @Provide + +| 名称 | 说明 | +| -------------- | ------------------------------------------------------------ | +| 装饰器参数 | 是一个string类型的常量,用于给装饰的变量起别名。如果规定别名,则提供对应别名的数据更新。如果没有,则使用变量名作为别名。推荐使用@Provide("alias")这种形式。 | +| 同步机制 | @Provide的变量类似@State,可以修改对应变量进行页面重新渲染。也可以修改@Consume装饰的变量,反向修改@State变量。 | +| 初始值 | 必须制定初始值。 | +| 页面重渲染场景 | 触发页面渲染的修改:
- 基础类型(boolean,string,number)变量的改变;
- @Observed class类型变量及其属性的修改;
- 添加,删除,更新数组中的元素。 | + +表2 @Consume + +| 类型 | 说明 | +| ------ | ---------------- | +| 初始值 | 不可设置默认值。 | + +### 示例 + +```ts +// xxx.ets +@Entry +@Component +struct CompA { + @Provide("reviewVote") reviewVotes : number = 0; + + build() { + Column() { + CompB() + Button() { + Text(`${this.reviewVotes}`) + .fontSize(30) + } + .onClick(() => { + this.reviewVotes += 1; + }) + } + } +} + +@Component +struct CompB { + build() { + Column() { + CompC() + } + } +} + +@Component +struct CompC { + @Consume("reviewVote") reviewVotes : number; + build() { + Column() { + Button() { + Text(`${this.reviewVotes}`) + .fontSize(30) + } + .onClick(() => { + this.reviewVotes += 1; + }) + }.margin({ left:10, top: 10 }) + } +} +``` + +## @Watch + +@Watch用于监听状态变量的变化,语法结构为: + +``` +@State @Watch("onChanged") count : number = 0 +``` + +如上给状态变量增加一个@Watch装饰器,通过@Watch注册一个回调方法onChanged, 当状态变量count被改变时, 触发onChanged回调。 + +装饰器@State、@Prop、@Link、@ObjectLink、@Provide、@Consume、@StorageProp以及@StorageLink装饰的变量可以监听其变化。 + +``` +// xxx.ets +@Entry +@Component +struct CompA { + @State @Watch("onBasketUpdated") shopBasket : Array = [ 7, 12, 47, 3 ]; + @State totalPurchase : number = 0; + + updateTotal() : number { + let sum = 0; + this.shopBasket.forEach((i) => { sum += i; }); + // 计算新的购物篮总价值,如果超过100RMB,则适用折扣 + this.totalPurchase = (sum < 100) ? sum : 0.9 * sum; + return this.totalPurchase; + } + + // @Watch cb + onBasketUpdated(propName: string) : void { + this.updateTotal(); + } + + build() { + Column() { + Button("add to basket").onClick(() => { this.shopBasket.push(Math.round(100 * Math.random())) }) + Text(`${this.totalPurchase}`) + .fontSize(30) + } + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/ui/figures/@state.png b/zh-cn/application-dev/quick-start/figures/@state.png similarity index 100% rename from zh-cn/application-dev/ui/figures/@state.png rename to zh-cn/application-dev/quick-start/figures/@state.png diff --git a/zh-cn/application-dev/ui/figures/@state1.gif b/zh-cn/application-dev/quick-start/figures/@state1.gif similarity index 100% rename from zh-cn/application-dev/ui/figures/@state1.gif rename to zh-cn/application-dev/quick-start/figures/@state1.gif diff --git a/zh-cn/application-dev/quick-start/figures/CoreSpec_figures_state-mgmt-overview.png b/zh-cn/application-dev/quick-start/figures/CoreSpec_figures_state-mgmt-overview.png new file mode 100644 index 0000000000000000000000000000000000000000..37ae5324808a0ab50f210907ca65a09e4456a371 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/CoreSpec_figures_state-mgmt-overview.png differ diff --git a/zh-cn/application-dev/quick-start/figures/Observed.gif b/zh-cn/application-dev/quick-start/figures/Observed.gif new file mode 100644 index 0000000000000000000000000000000000000000..cf1d3b2abb4925544997682c100efcb32b3ea7e4 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/Observed.gif differ diff --git a/zh-cn/application-dev/quick-start/figures/PersistentStorage.gif b/zh-cn/application-dev/quick-start/figures/PersistentStorage.gif new file mode 100644 index 0000000000000000000000000000000000000000..8448907658c66d98d91207a51017ccd5143655ec Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/PersistentStorage.gif differ diff --git a/zh-cn/application-dev/quick-start/figures/appstorage.gif b/zh-cn/application-dev/quick-start/figures/appstorage.gif new file mode 100644 index 0000000000000000000000000000000000000000..907447553819293cf3e7e143aec39116c4166d8d Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/appstorage.gif differ diff --git a/zh-cn/application-dev/ui/figures/custom-dialog-demo.gif b/zh-cn/application-dev/quick-start/figures/custom-dialog-demo.gif similarity index 100% rename from zh-cn/application-dev/ui/figures/custom-dialog-demo.gif rename to zh-cn/application-dev/quick-start/figures/custom-dialog-demo.gif diff --git a/zh-cn/application-dev/quick-start/figures/ets-get-started.png b/zh-cn/application-dev/quick-start/figures/ets-get-started.png new file mode 100644 index 0000000000000000000000000000000000000000..b2a0cb91637601846855c0eaa30e0610a5a11ed6 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/ets-get-started.png differ diff --git a/zh-cn/application-dev/quick-start/figures/forEach.gif b/zh-cn/application-dev/quick-start/figures/forEach.gif new file mode 100644 index 0000000000000000000000000000000000000000..f123d33aa9d97e2e4e04a2de09f99d1758f4a4a1 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/forEach.gif differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001206450834.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001206450834.png new file mode 100644 index 0000000000000000000000000000000000000000..35a5db40879212c9d90e5a02bba02e49e1158c8f Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001206450834.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001251090821.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001251090821.png new file mode 100644 index 0000000000000000000000000000000000000000..69aec480939a34e310d8fbeead6a8e33644bb11b Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001251090821.png differ diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index 0834b0f2e2ea1b612027a5db9ebd43a854ead7c3..8b3da7d45a8f15236dcd3ed13f3fecceff8589f4 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -16,11 +16,11 @@ OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架)。方舟开发框架可为开发者提供应用UI开发所必需的能力,比如多种组件、布局计算、动画能力、UI交互、绘制等。 -方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于eTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。 +方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于ArkTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。 | **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** | | -------- | -------- | -------- | -------- | -------- | -| 声明式开发范式 | eTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | +| 声明式开发范式 | ArkTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | | 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 | 更多UI框架的开发内容及指导,详见[UI开发](../ui/arkui-overview.md)。 @@ -36,7 +36,7 @@ Ability框架模型结构具有两种形态: - **Stage模型**:从API 9开始,Ability框架引入并支持使用Stage模型进行开发。更多Stage模型的内容详见[Stage模型综述](../ability/stage-brief.md)。 -FA模型和Stage模型的工程目录结构存在差异,Stage模型只支持使用eTS语言进行开发。 +FA模型和Stage模型的工程目录结构存在差异,Stage模型只支持使用ArkTS语言进行开发。 关于FA模型和Stage模型的整体架构和设计思想等更多区别,详见[Ability框架概述](../ability/ability-brief.md)。 @@ -49,4 +49,4 @@ FA模型和Stage模型的工程目录结构存在差异,Stage模型只支持 2. 请参考[配置OpenHarmony SDK](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443),完成**DevEco Studio**的安装和开发环境配置。 -完成上述操作及基本概念的理解后,可参照[使用eTS语言进行开发(Stage模型)](start-with-ets-stage.md)、[使用eTS语言开发(FA模型)](start-with-ets-fa.md)、[使用JS语言开发(FA模型)](../quick-start/start-with-js-fa.md)中的任一章节进行下一步体验和学习。 +完成上述操作及基本概念的理解后,可参照[使用ArkTS语言进行开发(Stage模型)](start-with-ets-stage.md)、[使用ArkTS语言开发(FA模型)](start-with-ets-fa.md)、[使用JS语言开发(FA模型)](../quick-start/start-with-js-fa.md)中的任一章节进行下一步体验和学习。 diff --git a/zh-cn/application-dev/quick-start/start-with-ets-fa.md b/zh-cn/application-dev/quick-start/start-with-ets-fa.md index 67029223fecfe851231b29a186dd886cc48d0364..7dc4539e81e291b8b5f79774f4b69752588ad7bc 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-fa.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-fa.md @@ -1,4 +1,4 @@ -# 使用eTS语言开发(FA模型) +# 使用ArkTS语言开发(FA模型) > **说明:** @@ -18,7 +18,7 @@ ![02](figures/02.png) > **说明:** - > DevEco Studio V3.0 Beta3及更高版本支持使用eTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)方式。 + > DevEco Studio V3.0 Beta3及更高版本支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)方式。 > > 低代码开发方式具有丰富的UI界面编辑功能,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。 > @@ -288,4 +288,4 @@ ![zh-cn_image_0000001363934577](figures/zh-cn_image_0000001363934577.png) -恭喜您已经使用eTS语言开发(FA模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 +恭喜您已经使用ArkTS语言开发(FA模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/quick-start/start-with-ets-stage.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md index 33a404e1cc73a1cf5ee03e725cfc3ce8d4f8da81..8ff628f5a300a4257f6414431ef32d9e037e62f2 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-stage.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -1,4 +1,4 @@ -# 使用eTS语言开发(Stage模型) +# 使用ArkTS语言开发(Stage模型) > **说明:** @@ -19,7 +19,7 @@ > **说明:** > - > 支持使用eTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)方式。 + > 支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)方式。 > > 低代码开发方式具有丰富的UI界面编辑功能,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。 > @@ -287,4 +287,4 @@ ![zh-cn_image_0000001311334972](figures/zh-cn_image_0000001311334972.png) -恭喜您已经使用eTS语言开发(Stage模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 +恭喜您已经使用ArkTS语言开发(Stage模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index ac2c0c00973b7e74c82a319c4503489c8b652b8a..4b64eed4162a4bbc9db8cf10e6d4e97c42be8eaa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -14,7 +14,7 @@ AbilityContext模块提供允许访问特定Ability的资源的能力,包括 在使用AbilityContext的功能前,需要通过Ability子类实例获取。 ```js -import Ability from '@ohos.application.Ability' +import Ability from '@ohos.application.Ability'; class MainAbility extends Ability { onWindowStageCreate(windowStage) { let context = this.context; @@ -34,7 +34,7 @@ class MainAbility extends Ability { ## AbilityContext.startAbility -startAbility(want: Want, callback: AsyncCallback<void>): void +startAbility(want: Want, callback: AsyncCallback<void>): void; 启动Ability(callback形式)。 @@ -63,7 +63,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void ## AbilityContext.startAbility -startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void +startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 启动Ability(callback形式)。 @@ -1143,7 +1143,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; ## AbilityContext.setMissionLabel -setMissionLabel(label: string): Promise<void> +setMissionLabel(label: string): Promise<void>; 设置ability在任务中显示的名称(promise形式)。 @@ -1190,7 +1190,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\): void; **示例:** ```js - import image from '@ohos.multimedia.image' + import image from '@ohos.multimedia.image'; var imagePixelMap; var color = new ArrayBuffer(0); var initializationOptions = { @@ -1237,7 +1237,7 @@ setMissionIcon(icon: image.PixelMap): Promise\; **示例:** ```js - import image from '@ohos.multimedia.image' + import image from '@ohos.multimedia.image'; var imagePixelMap; var color = new ArrayBuffer(0); var initializationOptions = { diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 31fec85964459757d137791e1a241ee668b3f966..a21beb5ccc2834c52f2b415b23c891bed0ae3834 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -472,7 +472,7 @@ promise.then(data => { ### PermissionStateChangeType9+ -表示权限状态变化操作类型的枚举。 +表示权限授权状态变化操作类型的枚举。 **系统接口:** 此接口为系统接口。 @@ -485,12 +485,14 @@ promise.then(data => { ### PermissionStateChangeInfo9+ +表示某次权限授权状态变化的详情。 + **系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | ------------------------- | ---- | ---- | ------------------ | -| change | [PermissionStateChangeType](#permissionstatechangetype9) | 是 | 否 | 权限变化类型 | -| tokenID | number | 是 | 否 | 调用方的应用身份标识 | -| permissionName | string | 是 | 否 | 状态发生变化的权限名 | +| change | [PermissionStateChangeType](#permissionstatechangetype9) | 是 | 否 | 权限授权状态变化类型 | +| tokenID | number | 是 | 否 | 被订阅的应用身份标识 | +| permissionName | string | 是 | 否 | 当前授权状态发生变化的权限名 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index 5bad8bf8c1cb69f43ae5cb9a469f70fb3572a261..1f7ab803f4c4d48b2cefcfa7874461b553f02cd5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -20,9 +20,9 @@ getCameraManager(context: Context, callback: AsyncCallback): voi **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ---------------------------------- | -| context | Context | 是 | 应用上下文。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ---------------------------- | +| context | Context | 是 | 应用上下文。 | | callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获取相机管理器实例。 | **示例:** @@ -30,7 +30,7 @@ getCameraManager(context: Context, callback: AsyncCallback): voi ```js camera.getCameraManager(context, (err, cameraManager) => { if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); + console.error(`Failed to get the CameraManager instance ${err.message}`); return; } console.log('Callback returned with the CameraManager instance'); @@ -53,8 +53,8 @@ getCameraManager(context: Context): Promise **返回值:** -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------------- | +| 类型 | 说明 | +| ----------------------------------------- | ----------------------------------- | | Promise<[CameraManager](#cameramanager)\> | 使用Promise的方式获取一个相机管理器实例。 | **示例:** @@ -73,952 +73,969 @@ camera.getCameraManager(context).then((cameraManager) => { | 名称 | 值 | 说明 | | ------------------------- | ---- | ------------ | -| CAMERA_STATUS_APPEAR | 0 | 相机存在。 | -| CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。 | -| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。 | -| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。 | +| CAMERA_STATUS_APPEAR | 0 | 新的相机出现。 | +| CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。 | +| CAMERA_STATUS_AVAILABLE | 2 | 相机可用。 | +| CAMERA_STATUS_UNAVAILABLE | 3 | 相机不可用。 | +## Profile -## CameraPosition - -枚举,相机方向。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -| 名称 | 值 | 说明 | -| --------------------------- | ---- | ---------------- | -| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。 | -| CAMERA_POSITION_BACK | 1 | 后置相机。 | -| CAMERA_POSITION_FRONT | 2 | 前置相机。 | - -## CameraType - -枚举,相机类型。 +相机配置信息项。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ----------------------- | ---- | ---------------- | -| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。 | -| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | -| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。 | -| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | -| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。 | - +| 名称 | 类型 | 只读 | 说明 | +| -------- | ----------------------------- |---- | ------------- | +| format | [CameraFormat](#cameraformat) | 是 | 输出格式。 | +| size | [Size](#size) | 是 | 分辨率。 | -## ConnectionType +## VideoProfile -枚举,相机连接类型。 +视频配置信息项。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ---------------------------- | ---- | ------------- | -| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。 | -| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。 | +| 名称 | 类型 | 只读 | 说明 | +| ------------------------- | ----------------------------------------- | --- |----------- | +| format | [CameraFormat](#cameraformat) | 是 | 输出格式。 | +| size | [Size](#size) | 是 | 分辨率。 | +| frameRate | Array | 是 | 帧率。 | -## Size +## CameraOutputCapability -用于表示相机预览、照片、视频支持的尺寸大小。 +相机输出能力项。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ------------ | -| height | string | 是 | 是 | 图像的高度。 | -| width | number | 是 | 是 | 图像的宽度。 | +| 名称 | 类型 | 只读 | 说明 | +| ----------------------------- | -------------------------------------------------- | --- |------------------- | +| previewProfiles | Array<[Profile](#profile)\> | 是 | 支持的预览配置信息。 | +| photoProfiles | Array<[Profile](#profile)\> | 是 | 支持的拍照配置信息。 | +| videoProfiles | Array<[VideoProfile](#videoprofile)\> | 是 | 支持的录像配置信息。 | +| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支持的metadata流类型信息。| ## CameraManager 相机管理器类,使用前需要通过getCameraManager获取相机管理实例。 -### getCameras +### getSupportedCameras -getCameras(callback: AsyncCallback\>): void +getSupportedCameras(callback: AsyncCallback\>): void -异步获取设备支持的相机列表,通过注册回调函数获取结果。 +获取支持指定的相机设备对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback\> | 是 | 使用callback方式获取支持的相机列表。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback\> | 是 | 使用callback方式获取支持的相机列表。 | **示例:** ```js -cameraManager.getCameras((err, cameras) => { +cameraManager.getSupportedCameras((err, cameras) => { if (err) { - console.error('Failed to get the cameras. ${err.message}'); + console.error(`Failed to get the cameras. ${err.message}`); return; } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); + console.log(`Callback returned with an array of supported cameras: ${cameras.length}`); }) ``` -### getCameras +### getSupportedCameras -getCameras(): Promise\> +getSupportedCameras(): Promise\> -异步获取设备支持的相机列表,通过Promise获取结果。 +获取支持指定的相机设备对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ----------------------------------- | ----------------------------- | -| Promise\> | 使用promise获取支持相机列表。 | +| 类型 | 说明 | +| ----------------------------------------------- | ------------------------- | +| Promise\> | 使用promise获取支持相机列表。 | **示例:** ```js -cameraManager.getCameras().then((cameraArray) => { - console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); +cameraManager.getSupportedCameras().then((cameraArray) => { + console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`); }) ``` -### createCameraInput - -createCameraInput(cameraId: string, callback: AsyncCallback): void +### getSupportedOutputCapability -使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。 +getSupportedOutputCapability(callback: AsyncCallback): void -**需要权限:** ohos.permission.CAMERA +查询相机设备在模式下支持的输出能力,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| cameraId | string | 是 | 指定相机ID。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------------- | -- | -------------------------- | +| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | 是 | 使用callback方式获取相机输出能力。 | **示例:** ```js -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { +cameraManager.getSupportedOutputCapability((err, cameras) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error(`Failed to get the cameras. ${err.message}`); return; } - console.log('Callback returned with the CameraInput instance.'); + console.log('Callback returned with an array of supported outputCapability'); }) ``` -### createCameraInput - -createCameraInput(cameraId: string): Promise +### getSupportedOutputCapability -使用相机ID异步创建CameraInput实例,通过Promise获取结果。 +getSupportedOutputCapability(): Promise -**需要权限:** ohos.permission.CAMERA +查询相机设备在模式下支持的输出能力,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------ | -| cameraId | string | 是 | 指定相机ID。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ---------- | +| camera | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。| **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | +| 类型 | 说明 | +| -------------------------------------------------------------- | ----------------------------- | +| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | 使用Promise的方式获取结果,返回相机输出能力。 | + **示例:** ```js -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); +cameraManager.getSupportedOutputCapability().then((cameraoutputcapability) => { + console.log('Promise returned with an array of supported outputCapability'); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void +### getSupportedMetadataObjectType -使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。 +getSupportedMetadataObjectType(callback: AsyncCallback\>): void -**需要权限:** ohos.permission.CAMERA +查询相机设备支持的元能力信息,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------------- | -- | -------------------------- | +| callback | AsyncCallback\> | 是 | 使用callback方式获取相机支持的元能力力信息。 | **示例:** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { +cameraManager.getSupportedMetadataObjectType((err, metadataobject) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error(`Failed to get the supported metadataObjectType. ${err.message}`); return; } - console.log('Callback returned with the CameraInput instance'); + console.log('Callback returned with an array of supported metadataObjectType.' ); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType): Promise +### getSupportedMetadataObjectType -使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。 +getSupportedMetadataObjectType(): Promise -**需要权限:** ohos.permission.CAMERA +查询相机设备支持的元能力信息,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------- | ---- | ---------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | - **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | +| 类型 | 说明 | +| -------------------------------------------------------------- | ----------------------------- | +| Promise\> | 使用Promise的方式获取结果,返回相机支持的元能力信息。 | + **示例:** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); +cameraManager.getSupportedMetadataObjectType().then((metadataobject) => { + console.log('Promise returned with an array of supported metadataObjectType.' ); }) ``` -### on('cameraStatus') +### createCameraInput -on(type: 'cameraStatus', callback: AsyncCallback): void +createCameraInput(camera: CameraDevice, callback: AsyncCallback): void + +使用CameraDevice对象异步创建CameraInput实例,通过注册回调函数获取结果。 + +此接口为系统接口。 -监听相机的状态变化,通过注册回调函数获取相机的状态变化。 +**需要权限:** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'cameraStatus',即相机状态变化事件。 | -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取相机状态变化信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | --------------------------------- | +| camera | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | **示例:** ```js -cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { +cameraManager.createCameraInput(camera, (err, cameraInput) => { if (err) { - console.error('Failed to get cameraStatus callback. ${err.message}'); + console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); + console.log('Callback returned with the CameraInput instance.'); }) ``` -## Camera - -调用[camera.getCameraManager](#cameragetcameramanager)后,将返回Camera实例,包括相机ID、位置、类型、连接类型等相机相关的元数据。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 类型 | 只读 | 说明 | -| -------------- | --------------------------------- | ---- | -------------- | -| cameraId | string | 是 | 相机ID。 | -| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | -| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | -| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。 | - -**示例:** - -```js -async function getCameraInfo("cameraId") { - var cameraManager = await camera.getCameraManager(context); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var connectionType = cameraObj.connectionType; -} -``` - -## CameraStatusInfo - -相机管理器回调返回的接口实例,表示相机状态信息。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core。 - -| 名称 | 类型 | 说明 | -| ------ | ----------------------------- | ---------- | -| camera | [Camera](#camera) | 相机信息。 | -| status | [CameraStatus](#camerastatus) | 相机状态。 | - - -## CameraInput +### createCameraInput -相机输入类。在使用该类的方法前,需要先构建一个CameraInput实例。 +createCameraInput(camera: CameraDevice): Promise -### getCameraId +使用CameraDevice对象异步创建CameraInput实例,通过Promise获取结果。 -getCameraId(callback: AsyncCallback\): void +此接口为系统接口。 -异步获取该CameraInput实例的相机ID,通过注册回调函数获取结果。 +**需要权限:** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback | 是 | 回调函数,用于获取相机ID。 | - -**示例:** - -```js -cameraInput.getCameraId((err, cameraId) => { - if (err) { - console.error('Failed to get the camera ID. ${err.message}'); - return; - } - console.log('Callback returned with the camera ID: ' + cameraId); -}) -``` - -### getCameraId - -getCameraId(): Promise - -异步获取该CameraInput实例的相机ID,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------- | ---- | ---------- | +| camera | [CameraDevice](#cameradevice) | 是 | CameraDevice对象。 | **返回值:** -| 类型 | 说明 | -| ---------------- | ----------------------------- | -| Promise | 使用Promise的方式获取相机ID。 | +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------ | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | **示例:** ```js -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); +cameraManager.createCameraInput(camera).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` +### createCameraInput -### hasFlash +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void -hasFlash(callback: AsyncCallback): void +根据相机位置和类型创建CameraInput实例,通过注册回调函数获取结果。 -判断设备是否支持闪光灯,通过注册回调函数获取结果。 +此接口为系统接口。 + +**需要权限:** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback | 是 | 回调函数,返回true表示设备支持闪光灯。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | --------------------------------- | +| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| type | [CameraType](#cameratype) | 是 | 相机类型。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | **示例:** ```js -cameraInput.hasFlash((err, status) => { +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); + console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } - console.log('Callback returned with flash light support status: ' + status); + console.log('Callback returned with the CameraInput instance'); }) ``` -### hasFlash +### createCameraInput -hasFlash(): Promise +createCameraInput(position: CameraPosition, type:CameraType ): Promise + +根据相机位置和类型创建CameraInput实例,通过Promise获取结果。 + +此接口为系统接口。 -判断设备是否支持闪光灯,通过Promise获取结果。 +**需要权限:** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ------------ | +| position | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| type | [CameraType](#cameratype) | 是 | 相机类型。 | + **返回值:** -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------- | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------ | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | **示例:** ```js -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` -### isFlashModeSupported +### createPreviewOutput -isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void +createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void -判断设备是否支持指定闪光灯模式,通过注册回调函数获取结果。 +创建预览输出对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------------------------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该闪光灯模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------- | +| profile | [Profile](#profile) | 是 | 支持的预览配置信息。 | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的SurfaceID。| +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。| **示例:** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { +cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => { if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); + console.error(`Failed to gcreate previewOutput. ${err.message}`); return; } - console.log('Callback returned with the flash mode support status: ' + status); + console.log('Callback returned with previewOutput created.'); }) ``` -### isFlashModeSupported +### createPreviewOutput -isFlashModeSupported(flashMode: FlashMode): Promise +createPreviewOutput(profile: Profile, surfaceId: string): Promise -判断设备是否支持指定闪光灯模式,通过Promise获取结果。 +创建预览输出对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------| ---- | ----------------- | +| profile | [Profile](#profile) | 是 | 支持的预览配置信息。 | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的SurfaceID。 | **返回值:** -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------------ | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取PreviewOutput的实例。 | **示例:** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { - console.log('Promise returned with flash mode support status.' + status); +cameraManager.createPreviewOutput(profile, surfaceId).then((previewoutput) => { + console.log('Promise returned with previewOutput created.'); }) ``` -### setFlashMode - -setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void - -设置闪光灯模式,通过注册回调函数获取结果。 +### createDeferredPreviewOutput -进行设置之前,需要先检查: +createDeferredPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void -1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 -2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 +尚未获取surfaceID时创建预览输出对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ------------------------ | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | --------------------------------- | +| profile | [Profile](#profile) | 是 | 支持的预览配置信息。 | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的SurfaceID。 | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。 | **示例:** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { +cameraManager.createDeferredPreviewOutput(profile, surfaceId, (err, previewoutput) => { if (err) { - console.error('Failed to set the flash mode ${err.message}'); + console.error(`Failed to create deferredPreviewOutput. ${err.message}`); return; } - console.log('Callback returned with the successful execution of setFlashMode.'); + console.log('Callback returned with deferredPreviewOutput created.'); }) ``` -### setFlashMode - -setFlashMode(flashMode: FlashMode): Promise - -设置闪光灯模式,通过Promise获取结果。 +### createDeferredPreviewOutput -进行设置之前,需要先检查: +createDeferredPreviewOutput(profile: Profile, surfaceId: string): Promise -1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 -2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 +尚未获取surfaceID时创建预览输出对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------| ---- | ---------- | +| profile | [Profile](#profile) | 是 | 支持的预览配置信息。 | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获取的SurfaceID。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| ----------------------------------------- | --------------------------------------- | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取PreviewOutput的实例。 | **示例:** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); +cameraManager.createDeferredPreviewOutput(profile, surfaceId).then((previewoutput) => { + console.log('Promise returned with DefeerredPreviewOutput created.'); }) ``` -### getFlashMode +### createPhotoOutput -getFlashMode(callback: AsyncCallback): void +createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void -获取当前设备的闪光灯模式,通过注册回调函数获取结果。 +创建拍照输出对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| profile | [Profile](#profile) | 是 | 支持的拍照配置信息。 | +| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的SurfaceID。| +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 | **示例:** ```js -cameraInput.getFlashMode((err, flashMode) => { +cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => { if (err) { - console.error('Failed to get the flash mode ${err.message}'); + console.error(`Failed to create photoOutput. ${err.message}`); return; } - console.log('Callback returned with current flash mode: ' + flashMode); + console.log('Callback returned with photoOutput created.'); }) ``` -### getFlashMode +### createPhotoOutput -getFlashMode(): Promise +createPhotoOutput(profile: Profile, surfaceId: string): Promise -获取当前设备的闪光灯模式,通过Promise获取结果。 +创建拍照输出对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------| ---- | ----------- | +| profile | [Profile](#profile) | 是 | 支持的拍照配置信息。 | +| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的SurfaceID。| + **返回值:** -| 类型 | 说明 | -| --------------------------------- | --------------------------------------- | -| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 | +| 类型 | 说明 | +| ------------------------------------- | -------------------------------------- | +| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput的实例。 | **示例:** ```js -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); +cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => { + console.log('Promise returned with photoOutput created.'); }) ``` -### isFocusModeSupported +### createVideoOutput -isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void +createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void -判断设备是否支持指定的焦距模式,通过注册回调函数获取结果。 +创建录像输出对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该焦距模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | ------------------------------ | +| profile | [VideoProfile](#videoprofile) | 是 | 支持的录像配置信息。 | +| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获取的SurfaceID。| +| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获取VideoOutput实例。 | **示例:** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { +cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => { if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); + console.error(`Failed to create videoOutput. ${err.message}`); return; } - console.log('Callback returned with the focus mode support status: ' + status); + console.log('Callback returned with an array of supported outputCapability' ); }) ``` -### isFocusModeSupported +### createVideoOutput -isFocusModeSupported(afMode: FocusMode): Promise +createVideoOutput(profile: VideoProfile, surfaceId: string): Promise -判断设备是否支持指定的焦距模式,通过Promise获取结果。 +创建录像输出对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------| ---- | ---------- | +| profile | [VideoProfile](#videoprofile) | 是 | 支持的录像配置信息。 | +| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获取的SurfaceID。| **返回值:** -| 类型 | 说明 | -| ----------------- | ----------------------------------------------------------- | -| Promise | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | +| 类型 | 说明 | +| ------------------------------------- | -------------------------------------- | +| Promise<[VideoOutput](#videooutput)\> | 使用Promise的方式获取videoOutput的实例。 | **示例:** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { - console.log('Promise returned with focus mode support status.' + status); +cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => { + console.log('Promise returned with videoOutput created.'); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode, callback: AsyncCallback): void +### createMetadataOutput -设置焦距模式,通过注册回调函数获取结果。 +createMetadataOutput(callback: AsyncCallback): void -进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 +创建metadata流输出对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | ------------------------ | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | -------------------------------------------------- | --- | ---------------------------- | +| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | 是 | 回调函数,用于获取MetadataOutput实例。 | **示例:** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { +cameraManager.createMetadataOutput((err, metadataoutput) => { if (err) { - console.error('Failed to set the focus mode ${err.message}'); + console.error(`Failed to create metadataOutput. ${err.message}`); return; } - console.log('Callback returned with the successful execution of setFocusMode.'); + console.log('Callback returned with metadataOutput created.'); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode): Promise +### createMetadataOutput -设置焦距模式,通过Promise获取结果。 +createMetadataOutput(): Promise -进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 +创建metadata流输出对象,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------------- | +| Promise<[MetadataOutput](#metadataoutput)\> | 使用Promise的方式获取MetadataOutput的实例。 | **示例:** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); +cameraManager.createMetadataOutput().then((metadataoutput) => { + console.log('Promise returned with metadataOutput created.'); }) ``` -### getFocusMode +### createCaptureSession -getFocusMode(callback: AsyncCallback): void +createCaptureSession(callback: AsyncCallback): void -获取当前设备的焦距模式,通过注册回调函数获取结果。 +创建CaptureSession实例,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 | +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | ----------------------------------------- | ----------- | ---------------------------- | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取拍照会话实例。 | **示例:** ```js -cameraInput.getFocusMode((err, afMode) => { +cameraManager.createCaptureSession((err, capturesession) => { if (err) { - console.error('Failed to get the focus mode ${err.message}'); + console.error(`Failed to create captureSession. ${err.message}`); return; } - console.log('Callback returned with current focus mode: ' + afMode); + console.log('Callback returned with captureSession created.'); }) ``` -### getFocusMode +### createCaptureSession -getFocusMode(): Promise +createCaptureSession(): Promise -获取当前设备的焦距模式,通过Promise获取结果。 +创建CaptureSession实例,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------------------- | -| Promise | 使用Promise的方式获取当前的焦距模式。 | +| 类型 | 说明 | +| ------------------------------------------- | ---------------------------------------- | +| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession的实例。 | **示例:** ```js -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); +cameraManager.createCaptureSession().then((capturesession) => { + console.log('Promise returned with captureSession created.'); }) ``` -### getZoomRatioRange +### on('cameraStatus') -getZoomRatioRange\(callback: AsyncCallback\>\): void +on(type: 'cameraStatus', callback: AsyncCallback): void -获取可变焦距比范围,通过注册回调函数获取结果。 +镜头状态回调,通过注册回调函数获取相机的状态变化。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------ | ---- | ------------------------ | -| callback | AsyncCallback\> | 是 | 回调函数,用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | --------- | +| type | string | 是 | 监听事件,固定为'cameraStatus',即镜头状态变化事件。 | +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取镜头状态变化信息。 | **示例:** ```js -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { +cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); + console.error(`Failed to get cameraStatus callback. ${err.message}`); return; } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); + console.log(`camera : ${cameraStatusInfo.camera.cameraId}`); + console.log(`status: ${cameraStatusInfo.status}`); }) ``` -### getZoomRatioRange - -getZoomRatioRange\(\): Promise\> - -获取可变焦距比范围,通过Promise获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**返回值:** - -| 类型 | 说明 | -| ------------------------ | ------------------------------------------- | -| Promise\> | 使用Promise的方式获取当前的可变焦距比范围,返回的数组包括其最小值和最大值。 | - -**示例:** +### on('cameraMute') -```js -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); -}) -``` +on(type: 'cameraMute', callback: AsyncCallback): void -### setZoomRatio +监听相机禁用的状态变化,通过注册回调函数获取相机的状态变化。 -setZoomRatio(zoomRatio: number, callback: AsyncCallback): void +此接口为系统接口。 -设置可变焦距比,通过注册回调函数获取结果。 +**需要权限:** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | -------------------- | ---- | ------------------------ | -| zoomRatio | number | 是 | 可变焦距比。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------- | +| type | string | 是 | 监听事件,固定为'cameraMute',即相机状禁用态变化事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取相机是否禁用。 | **示例:** ```js -cameraInput.setZoomRatio(1, (err) => { +cameraManager.on('cameraMute', (err, status) => { if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); + console.error(`Failed to get cameraMute callback. ${err.message}`); return; } - console.log('Callback returned with the successful execution of setZoomRatio.'); + console.log(`status: ${status}`); }) ``` -### setZoomRatio +## CameraStatusInfo -setZoomRatio(zoomRatio: number): Promise +相机管理器回调返回的接口实例,表示相机状态信息。 -设置可变焦距比,通过Promise获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -**系统能力:** SystemCapability.Multimedia.Camera.Core +| 名称 | 类型 | 说明 | +| ------ | ----------------------------- | ---------- | +| camera | [CameraDevice](#cameradevice) | 相机信息。 | +| status | [CameraStatus](#camerastatus) | 相机状态。 | -**参数:** +## CameraPosition -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ------------ | -| zoomRatio | number | 是 | 可变焦距比。 | +枚举,相机位置。 -**返回值:** +**系统能力:** SystemCapability.Multimedia.Camera.Core -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 名称 | 值 | 说明 | +| --------------------------- | ---- | -------------- | +| CAMERA_POSITION_UNSPECIFIED | 0 | 相机位置未指定。 | +| CAMERA_POSITION_BACK | 1 | 后置相机。 | +| CAMERA_POSITION_FRONT | 2 | 前置相机。 | + +## CameraType + +枚举,相机类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ----------------------- | ---- | -------------- | +| CAMERA_TYPE_UNSPECIFIED | 0 | 相机类型未指定。 | +| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | +| CAMERA_TYPE_ULTRA_WIDE | 2 | 超广角相机。 | +| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | +| CAMERA_TYPE_TRUE_DEPTH | 4 | 带景深信息的相机。 | + +## ConnectionType + +枚举,相机连接类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ---------------------------- | ---- | ------------- | +| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | USB连接的相机。 | +| CAMERA_CONNECTION_REMOTE | 2 | 远程连接的相机。 | + +## CameraDevice + +相机设备信息。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core。 + +| 名称 | 类型 | 只读 | 说明 | +| -------------- | --------------------------------- | ---- | ---------- | +| cameraId | string | 是 | CameraDevice对象| +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | +| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。 | **示例:** ```js -cameraInput.setZoomRatio(1).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); -}) +async function getCameraInfo("cameraId") { + let cameraManager = await camera.getCameraManager(context); + let cameras = await cameraManager.getSupportedCameras(); + let cameraObj = cameras[0]; + let cameraId = cameraObj.cameraId; + let cameraPosition = cameraObj.cameraPosition; + let cameraType = cameraObj.cameraType; + let connectionType = cameraObj.connectionType; +} ``` -### getZoomRatio +## Size -getZoomRatio(callback: AsyncCallback): void +枚举,输出能力查询。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ------------ | +| height | number | 是 | 是 | 图像尺寸高(像素)。 | +| width | number | 是 | 是 | 图像尺寸宽(像素)。 | -获取当前的可变焦距比,通过注册回调函数获取结果。 +## Point + +枚举,点坐标用于对焦、曝光配置。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------ | +| x | number | 是 | 点的x坐标。 | +| y | number | 是 | 点的y坐标。 | + +## CameraFormat + +枚举,输出格式。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 默认值 | 说明 | +| ----------------------- | --------- | ------------ | +| CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SP格式的图片。 | +| CAMERA_FORMAT_JPEG | 2000 | JPEG格式的图片。 | + +## CameraInput + +会话中[CaptureSession](#capturesession)使用的相机信息。 + +### open + +open\(callback: AsyncCallback\): void + +打开相机,通过注册回调函数获取状态。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -cameraInput.getZoomRatio((err, zoomRatio) => { +cameraInput.open((err) => { if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); + console.error(`Failed to open the camera. ${err.message}`); return; } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); + console.log('Callback returned with camera opened.'); }) ``` -### getZoomRatio +### open -getZoomRatio(): Promise +open(): Promise -获取当前的可变焦距比,通过Promise获取结果。 +打开相机,通过Promise获取相机的状态。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ---------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | **示例:** ```js -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); +cameraInput.open().then(() => { + console.log('Promise returned with camera opened.'); }) ``` -### release +### close -release\(callback: AsyncCallback\): void +close\(callback: AsyncCallback\): void -释放相机实例,通过注册回调函数获取结果。 +关闭相机,通过注册回调函数获取状态。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -cameraInput.release((err) => { +cameraInput.close((err) => { if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); + console.error(`Failed to close the cameras. ${err.message}`); return; } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); + console.log('Callback returned with camera closed.'); +}) ``` -### release +### close -release(): Promise +close(): Promise -释放相机实例,通过Promise获取结果。 +关闭相机,通过Promise获取状态。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); +cameraInput.close().then(() => { + console.log('Promise returned with camera closed.'); }) ``` -### on('focusStateChange') +### release -on(type: 'focusStateChange', callback: AsyncCallback): void +release\(callback: AsyncCallback\): void -监听焦距的状态变化,通过注册回调函数获取结果。 +释放资源,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'focusStateChange',即焦距状态变化事件。 | -| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取焦距状态。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); +cameraInput.release((err) => { + if (err) { + console.error(`Failed to release the CameraInput instance ${err.message}`); + return; + } + console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); +}); +``` + +### release + +release(): Promise + +释放资源,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +cameraInput.release().then(() => { + console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); }) ``` @@ -1032,37 +1049,42 @@ on(type: 'error', callback: ErrorCallback): void **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------------------- | :--- | :----------------------------------------------- | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | ------------------------------------------- | | type | string | 是 | 监听事件,固定为'error',即CameraInput错误事件。 | -| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | 是 | 回调函数,用于获取结果。 | +| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | 是 | 回调函数,用于获取结果。 | **示例:** ```js cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); + console.log(`Camera input error code: ${cameraInputError.code}`); }) ``` -## CameraInputErrorCode +## CameraInputErrorCode -枚举,CameraInput的错误码。 +枚举,[CameraInput](#camerainput)错误类型。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ---------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_NO_PERMISSION | 0 | 没有权限。 | +| ERROR_DEVICE_PREEMPTED | 1 | 相机被抢占。 | +| ERROR_DEVICE_DISCONNECTED | 2 | 相机断开连接。 | +| ERROR_DEVICE_IN_USE | 3 | 相机正在使用。 | +| ERROR_DRIVER_ERROR | 4 | 驱动错误。 | -## CameraInputError +## CameraInputError -CameraInput错误对象。 +[CameraInput](#camerainput)错误码。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 说明 | -| ---- | ------------------------------------------- | -------------------------- | +| 名称 | 类型 | 说明 | +| ---- | --------------------------------------------- | --------------------- | | code | [CameraInputErrorCode](#camerainputerrorcode) | CameraInput中的错误码。 | @@ -1072,96 +1094,78 @@ CameraInput错误对象。 **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| 名称 | 值 | 说明 | -| ---------------------- | ---- | ------------ | +| 名称 | 值 | 说明 | +| ---------------------- | ---- | ---------- | | FLASH_MODE_CLOSE | 0 | 闪光灯关闭。 | -| FLASH_MODE_OPEN | 1 | 闪光灯开启。 | +| FLASH_MODE_OPEN | 1 | 闪光灯打开。 | | FLASH_MODE_AUTO | 2 | 自动闪光灯。 | | FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。 | -## FocusMode +## ExposureMode -枚举,焦距模式。 +枚举,曝光模式。 **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| 名称 | 值 | 说明 | -| -------------------------- | ---- | ------------------ | -| FOCUS_MODE_MANUAL | 0 | 手动变焦模式。 | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。 | -| FOCUS_MODE_AUTO | 2 | 自动变焦模式。 | -| FOCUS_MODE_LOCKED | 3 | 定焦模式。 | +| 名称 | 值 | 说明 | +| ----------------------------- | ---- | ----------- | +| EXPOSURE_MODE_LOCKED | 0 | 锁定曝光模式。 | +| EXPOSURE_MODE_AUTO | 1 | 自动曝光模式。 | +| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | 连续自动曝光。 | -## FocusState +## FocusMode -枚举,焦距状态。 +枚举,焦距模式。 **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| 名称 | 值 | 说明 | -| --------------------- | ---- | ------------ | -| FOCUS_STATE_SCAN | 0 | 扫描状态。 | -| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。 | -| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。 | - -## camera.createCaptureSession - -createCaptureSession\(context: Context, callback: AsyncCallback\): void - -获取CaptureSession实例,通过注册回调函数获取结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------- | ---- | -------------------------------------- | -| context | Context | 是 | 应用上下文。 | -| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取CaptureSession实例。 | +| 名称 | 值 | 说明 | +| -------------------------- | ---- | ------------ | +| FOCUS_MODE_MANUAL | 0 | 手动对焦。 | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动对焦。 | +| FOCUS_MODE_AUTO | 2 | 自动变焦。 | +| FOCUS_MODE_LOCKED | 3 | 对焦锁定。 | -**示例:** +## FocusState -```js -camera.createCaptureSession((context), (err, captureSession) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); -``` +枚举,焦距状态。 -## camera.createCaptureSession +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -createCaptureSession(context: Context\): Promise; +| 名称 | 值 | 说明 | +| --------------------- | ---- | --------- | +| FOCUS_STATE_SCAN | 0 | 触发对焦。 | +| FOCUS_STATE_FOCUSED | 1 | 对焦成功。 | +| FOCUS_STATE_UNFOCUSED | 2 | 未完成对焦。 | -获取CaptureSession实例,通过Promise获取结果。 +## ExposureState -**系统能力:** SystemCapability.Multimedia.Camera.Core +枚举,曝光状态。 -**参数:** +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -| 名称 | 类型 | 必填 | 说明 | -| ------- | ------- | ---- | ------------ | -| context | Context | 是 | 应用上下文。 | +| 名称 | 值 | 说明 | +| ------------------------- | ---- | -------- | +| EXPOSURE_STATE_SCAN | 0 | 曝光中。 | +| EXPOSURE_STATE_CONVERGED | 1 | 曝光收敛。 | -**返回值:** +## VideoStabilizationMode -| 类型 | 说明 | -| ------------------------------------------- | ----------------------------------------- | -| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession实例。 | +枚举,视频防抖模式。 -**示例:** +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -```js -camera.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); -}) -``` +| 名称 | 值 | 说明 | +| --------- | ---- | ------------ | +| OFF | 0 | 关闭视频防抖功能。 | +| LOW | 1 | 使用基础防抖算法。 | +| MIDDLE | 2 | 使用防抖效果一般的防抖算法,防抖效果优于LOW类型。 | +| HIGH | 3 | 使用防抖效果最好的防抖算法,防抖效果优于MIDDLE类型。 | +| AUTO | 4 | 自动进行选择。 | ## CaptureSession -拍照会话类。 +拍照会话类,保存一次相机运行所需要的所有资源[CameraInput](#camerainput)、[CameraOutput](#cameraoutput),并向相机设备申请完成相机功能(录像,拍照)。 ### beginConfig @@ -1173,8 +1177,8 @@ beginConfig\(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1182,7 +1186,7 @@ beginConfig\(callback: AsyncCallback\): void ```js captureSession.beginConfig((err) => { if (err) { - console.error('Failed to start the configuration. ${err.message}'); + console.error(`Failed to start the configuration. ${err.message}`); return; } console.log('Callback invoked to indicate the begin config success.'); @@ -1199,8 +1203,8 @@ beginConfig\(\): Promise **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | @@ -1216,14 +1220,14 @@ captureSession.beginConfig().then(() => { commitConfig\(callback: AsyncCallback\): void -提交会话配置,通过注册回调函数获取结果。 +提交配置信息,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1231,7 +1235,7 @@ commitConfig\(callback: AsyncCallback\): void ```js captureSession.commitConfig((err) => { if (err) { - console.error('Failed to commit the configuration. ${err.message}'); + console.error(`Failed to commit the configuration. ${err.message}`); return; } console.log('Callback invoked to indicate the commit config success.'); @@ -1242,14 +1246,14 @@ captureSession.commitConfig((err) => { commitConfig\(\): Promise -提交会话配置,通过Promise获取结果。 +提交配置信息,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1260,546 +1264,529 @@ captureSession.commitConfig().then(() => { }) ``` -### addInput +### canAddInput -addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void +canAddInput(cameraInput: CameraInput, callback: AsyncCallback): void -在当前会话中,添加一个CameraInput实例,通过注册回调函数获取结果。 +判断是否可以添加[CameraInput](#camerainput)到会话中,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | | cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.addInput(cameraInput, (err) => { +captureSession.canAddInput(cameraInput, (err, status) => { if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); + console.error(`Can not add cameraInput. ${err.message}`); return; } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); + console.log('Callback returned with cameraInput can added.'); +}) ``` -### addInput +### canAddInput -addInput\(cameraInput: CameraInput\): Promise +canAddInput(cameraInput: CameraInput): Promise -在当前会话中,添加一个CameraInput实例,通过Promise获取结果。 +判断是否可以添加[CameraInput](#camerainput)到会话中,通过注Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | | cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| -------------- | -------------------------- | +| Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); +captureSession.canAddInput(cameraInput).then(() => { + console.log('Promise returned with cameraInput can added.'); }) ``` -### addOutput +### addInput -addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void +addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -在当前会话中,添加一个PreviewOutput实例,通过注册回调函数获取结果。 +把[CameraInput](#camerainput)加入到会话,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.addOutput(previewOutput, (err) => { +captureSession.addInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); + console.error(`Failed to add the CameraInput instance. ${err.message}`); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); + console.log('Callback invoked to indicate that the CameraInput instance is added.'); }); ``` -### addOutput +### addInput -addOutput\(previewOutput: PreviewOutput\): Promise +addInput\(cameraInput: CameraInput\): Promise -在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 +把[CameraInput](#camerainput)加入到会话,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); +captureSession.addInput(cameraInput).then(() => { + console.log('Promise used to indicate that the CameraInput instance is added.'); }) ``` -### addOutput +### removeInput -addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void +removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -在当前会话中,添加一个PhotoOutput实例,通过注册回调函数获取结果。 +移除[CameraInput](#camerainput),通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.addOutput(photoOutput, (err) => { +captureSession.removeInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); + console.error(`Failed to remove the CameraInput instance. ${err.message}`); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); + console.log('Callback invoked to indicate that the cameraInput instance is removed.'); }); ``` -### addOutput +### removeInput -addOutput\(photoOutput: PhotoOutput\): Promise +removeInput\(cameraInput: CameraInput\): Promise -在当前会话中,添加一个PhotoOutput实例,通过Promise获取结果。 +移除[CameraInput](#camerainput),通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); +captureSession.removeInput(cameraInput).then(() => { + console.log('Promise returned to indicate that the cameraInput instance is removed.'); }) ``` -### addOutput +### canAddOutput -addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void +canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback\): void -在当前会话中,添加一个VideoOutput实例,通过注册回调函数获取结果。 +查询是否可以添加[CameraOutput](#cameraoutput)到会话中,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要添加的CameraOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.addOutput(videoOutput, (err) => { +captureSession.canAddOutput(cameraOutput, (err, status) => { if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); + console.error(`Can not add cameraOutput. ${err.message}`); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); + console.log('Callback returned with cameraOutput can added.'); +}) ``` -### addOutput +### canAddOutput -addOutput\(videoOutput: VideoOutput\): Promise +canAddOutput(cameraOutput: CameraOutput): Promise -在当前会话中,添加一个VideoOutput实例,通过Promise获取结果。 +查询是否可以添加[CameraOutput](#cameraoutput)到会话中,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要添加的CameraOutput实例。 | + **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | +| Promise | 使用Promise的方式获取结果。 | + **示例:** ```js -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); +captureSession.canAddOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput can added.'); }) ``` -### removeInput +### addOutput -removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void +addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void -在当前会话中,移除一个CameraInput实例,通过注册回调函数获取结果。 +把[CameraOutput](#cameraoutput)加入到会话,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------ | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要添加的CameraOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.removeInput(cameraInput, (err) => { +captureSession.addOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); + console.error(`Failed to add output. ${err.message}`); return; } - console.log('Callback invoked to indicate that the cameraInput instance is removed.'); -}); + console.log('Callback returned with output added.'); +}) ``` -### removeInput +### addOutput -removeInput\(cameraInput: CameraInput\): Promise +addOutput\(cameraOutput: CameraOutput\): Promise -在当前会话中,移除一个CameraInput实例,通过Promise获取结果。 +把[CameraOutput](#cameraoutput)加入到会话,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要添加的CameraOutput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\ | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.removeInput(cameraInput).then(() => { - console.log('Promise returned to indicate that the cameraInput instance is removed.'); +captureSession.addOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput added.'); }) ``` ### removeOutput -removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void +removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void -在当前会话中,移除一个PreviewOutput实例,通过注册回调函数获取结果。 +从会话中移除[CameraOutput](#cameraoutput),通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------ | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要移除的CameraOutput实例。 | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.removeOutput(previewOutput, (err) => { +captureSession.removeOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); + console.error(`Failed to remove the CameraOutput instance. ${err.message}`); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); + console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); }); ``` ### removeOutput -removeOutput(previewOutput: PreviewOutput): Promise +removeOutput(cameraOutput: CameraOutput): Promise -在当前会话中,移除一个PreviewOutput实例,通过Promise获取结果。 +从会话中移除[CameraOutput](#cameraoutput),通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraoutput) | 是 | 需要移除的CameraOutput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); +captureSession.removeOutput(cameraOutput).then(() => { + console.log('Promise returned to indicate that the CameraOutput instance is removed.'); }) ``` -### removeOutput +### start -removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void +start\(callback: AsyncCallback\): void -在当前会话中,移除一个PhotoOutput实例,通过注册回调函数获取结果。 +开始会话工作,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要移除的PhotoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.removeOutput(photoOutput, (err) => { +captureSession.start((err) => { if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); + console.error(`Failed to start the session ${err.message}`); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); + console.log('Callback invoked to indicate the session start success.'); }); ``` -### removeOutput +### start -removeOutput(photoOutput: PhotoOutput): Promise +start\(\): Promise -在当前会话中,移除一个PhotoOutput实例,通过Promise获取结果。 +开始会话工作,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要移除的PhotoOutput实例。 | - - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | - **示例:** ```js -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); +captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); }) ``` -### removeOutput +### stop -removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void +stop\(callback: AsyncCallback\): void -在当前会话中,移除一个VideoOutput实例,通过注册回调函数获取结果。 +停止会话工作,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要移除的VideoOutput实例。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.removeOutput(videoOutput, (err) => { +captureSession.stop((err) => { if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); + console.error(`Failed to stop the session ${err.message}`); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); + console.log('Callback invoked to indicate the session stop success.'); }); ``` -### removeOutput +### stop -removeOutput(videoOutput: VideoOutput): Promise +stop(): Promise -在当前会话中,移除一个VideoOutput实例,通过Promise获取结果。 +停止会话工作,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需要移除的VideoOutput实例。 | - - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise | 使用Promise的方式获取结果。 | - **示例:** ```js -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); +captureSession.stop().then(() => { + console.log('Promise returned to indicate the session stop success.'); }) ``` -### start +### lockForControl -start\(callback: AsyncCallback\): void +lockForControl(callback: AsyncCallback): void -启动拍照会话,通过注册回调函数获取结果。 +请求以独占方式控制设备的硬件属性[CameraInput](#camerainput),需要调用[unlockForControl](#unlockforcontrol),通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.start((err) => { +captureSession.lockForControl((err) => { if (err) { - console.error('Failed to start the session ${err.message}'); + console.error(`Failed to lock. ${err.message}`); return; } - console.log('Callback invoked to indicate the session start success.'); -}); + console.log('Locked.'); +}) ``` -### start +### lockForControl -start\(\): Promise +lockForControl(): Promise -启动拍照会话,通过Promise获取结果。 +请求以独占方式控制设备的硬件属性[CameraInput](#camerainput),需要调用[unlockForControl](#unlockforcontrol),通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); +captureSession.lockForControl().then(() => { + console.log('Locked.'); }) ``` -### stop +### unlockForControl -stop\(callback: AsyncCallback\): void +unlockForControl(callback: AsyncCallback): void -停止拍照会话,通过注册回调函数获取结果。 +控制生效,并放弃对设备配置的排他控制,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** - -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -captureSession.stop((err) => { +captureSession.unlockForControl((err) => { if (err) { - console.error('Failed to stop the session ${err.message}'); + console.error(`Failed to unlock. ${err.message}`); return; } - console.log('Callback invoked to indicate the session stop success.'); -}); + console.log('Unlocked.'); +}) ``` -### stop +### unlockForControl -stop(): Promise +unlockForControl(): Promise -停止拍照会话,通过Promise获取结果。 +控制生效,并放弃对设备配置的排他控制,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -captureSession.stop().then(() => { - console.log('Promise returned to indicate the session stop success.'); +captureSession.unlockForControl().then(() => { + console.log('Unlocked.'); }) ``` @@ -1807,14 +1794,14 @@ captureSession.stop().then(() => { release\(callback: AsyncCallback\): void -释放CaptureSession实例,通过注册回调函数获取结果。 +释放会话资源,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1822,7 +1809,7 @@ release\(callback: AsyncCallback\): void ```js captureSession.release((err) => { if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); + console.error(`Failed to release the CaptureSession instance ${err.message}`); return; } console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); @@ -1833,14 +1820,14 @@ captureSession.release((err) => { release(): Promise -释放CaptureSession实例,通过Promise获取结果。 +释放会话资源,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1851,904 +1838,2652 @@ captureSession.release().then(() => { }) ``` -### on('error') +### hasFlash -on(type: 'error', callback: ErrorCallback): void +hasFlash(callback: AsyncCallback): void -监听拍照会话的错误事件,通过注册回调函数获取结果。 +检测是否有闪光灯,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 | -| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获取错误信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------- | +| callback | AsyncCallback | 是 | 回调函数,返回true表示设备支持闪光灯。 | **示例:** ```js -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); +cameraInput.hasFlash((err, status) => { + if (err) { + console.error(`Failed to check whether the device has flash light. ${err.message}`); + return; + } + console.log(`Callback returned with flash light support status: ${status}`); }) ``` -## CaptureSessionErrorCode +### hasFlash + +hasFlash(): Promise -枚举,拍照会话的错误码。 +检测是否有闪光灯,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | - -## CaptureSessionError +**返回值:** -拍照会话错误对象。 +| 类型 | 说明 | +| ----------------- | ----------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | -**系统能力:** SystemCapability.Multimedia.Camera.Core +**示例:** -| 名称 | 类型 | 说明 | -| ---- | ------------------------------------------- | -------------------------- | -| code | [CaptureSessionError](#capturesessionerror) | CaptureSession中的错误码。 | +```js +cameraInput.hasFlash().then((status) => { + console.log(`Promise returned with the flash light support status: ${status}`); +}) +``` -## camera.createPreviewOutput +### isFlashModeSupported -createPreviewOutput(surfaceId: string, callback: AsyncCallback): void +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void -获取PreviewOutput实例,通过注册回调函数获取结果。 +检测闪光灯模式是否支持,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ----------------------------------------------- | ---- | ------------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | -| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | --------------------------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该闪光灯模式。 | **示例:** ```js -camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => { +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); + console.error(`Failed to check whether the flash mode is supported. ${err.message}`); return; } - console.log('Callback returned with previewOutput instance'); -}); + console.log(`Callback returned with the flash mode support status: ${status}`); +}) ``` -## camera.createPreviewOutput +### isFlashModeSupported -createPreviewOutput(surfaceId: string): Promise\ +isFlashModeSupported(flashMode: FlashMode): Promise -获取PreviewOutput实例,通过Promise获取结果。 +检测闪光灯模式是否支持,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ---------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | ------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------- | --------------------------- | -| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| ----------------- | ---------------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | **示例:** ```js -camera.createPreviewOutput("surfaceId").then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { + console.log(`Promise returned with flash mode support status.${status}`); }) ``` -## PreviewOutput +### setFlashMode -预览输出类。 +setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void -### release +设置闪光灯模式,通过注册回调函数获取结果。 -release(callback: AsyncCallback): void +进行设置之前,需要先检查: -释放PreviewOutput实例,通过注册回调函数获取结果。 +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | --------------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -previewOutput.release((err) => { +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); + console.error(`Failed to set the flash mode ${err.message}`); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); + console.log('Callback returned with the successful execution of setFlashMode.'); +}) ``` -### release +### setFlashMode -release(): Promise +setFlashMode(flashMode: FlashMode): Promise + +设置闪光灯模式,通过Promise获取结果。 -释放PreviewOutput实例,通过Promise获取结果。 +进行设置之前,需要先检查: + +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | ------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | + **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise | 使用Promise的方式获取结果。 | - **示例:** ```js -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFlashMode.'); }) ``` -### on('frameStart') +### getFlashMode -on(type: 'frameStart', callback: AsyncCallback): void +getFlashMode(callback: AsyncCallback): void -监听预览帧启动,通过注册回调函数获取结果。 +获取当前设备的闪光灯模式,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameStart',即帧启动事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | --------------------------------- | +| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 | **示例:** ```js -previewOutput.on('frameStart', () => { - console.log('Preview frame started'); +cameraInput.getFlashMode((err, flashMode) => { + if (err) { + console.error(`Failed to get the flash mode ${err.message}`); + return; + } + console.log(`Callback returned with current flash mode: ${flashMode}`); }) ``` -### on('frameEnd') +### getFlashMode -on(type: 'frameEnd', callback: AsyncCallback): void +getFlashMode(): Promise -监听预览帧结束,通过注册回调函数获取结果。 +获取当前设备的闪光灯模式,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** +**返回值:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameEnd',即帧结束事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 类型 | 说明 | +| --------------------------------- | --------------------------------- | +| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 | **示例:** ```js -previewOutput.on('frameEnd', () => { - console.log('Preview frame ended'); +cameraInput.getFlashMode().then((flashMode) => { + console.log(`Promise returned with current flash mode : ${flashMode}`); }) ``` -### on('error') +### isExposureModeSupported -on(type: 'error', callback: ErrorCallback): void +isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; -监听预览输出的错误事件,通过注册回调函数获取结果。 +检测曝光模式是否支持,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。 | -| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获取错误信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取是否支持曝光模式。 | **示例:** ```js -previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log(`Failed to check exposure mode supported ${err.message}`); + return ; + } + console.log('Callback returned with the successful execution of isExposureModeSupported'); }) ``` -## PreviewOutputErrorCode +### isExposureModeSupported + +isExposureModeSupported(aeMode: ExposureMode): Promise -枚举,预览输出的错误码。 +检测曝光模式是否支持,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +**参数:** -## PreviewOutputError +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 | -预览输出错误对象。 +**返回值:** -**系统能力:** SystemCapability.Multimedia.Camera.Core +| 名称 | 说明 | +| ----------------- |--------------------------------- | +| Promise | 使用Promise的方式获取支持的曝光模式。 | -| 名称 | 类型 | 说明 | -| ---- | ------------------------------------------------- | ---------------------- | -| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | PreviewOutput中的错误码。 | +**示例:** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log(`Promise returned with exposure mode supported : ${isSupported}`); +}) +``` -## camera.createPhotoOutput +### getExposureMode -createPhotoOutput(surfaceId: string, callback: AsyncCallback): void +getExposureMode(callback: AsyncCallback): void -获取PhotoOutput实例,通过注册回调函数获取结果。 +获取当前曝光模式,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的Surface ID。 | -| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ---------------------------------------- | +| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | 是 | 回调函数,用于获取当前曝光模式。 | **示例:** ```js -camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => { +cameraInput.getExposureMode((err, exposureMode) => { if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; + console.log(`Failed to get the exposure mode ${err.message}`); + return ; } - console.log('Callback returned with the PhotoOutput instance.'); -}); + console.log(`Callback returned with current exposure mode: ${exposureMode}`); +}) ``` -## camera.createPhotoOutput +### getExposureMode -createPhotoOutput(surfaceId: string): Promise +getExposureMode(): Promise -获取PhotoOutput实例,通过Promise获取结果。 +获取当前曝光模式,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获取的Surface ID。 | - **返回值:** -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput实例。 | +| 名称 | 说明 | +| --------------------------------------- |------------------------------- | +| Promise<[ExposureMode](#exposuremode)\> | 使用Promise的方式获取当前曝光模式。 | **示例:** ```js -camera.createPhotoOutput("surfaceId").then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); +cameraInput.getExposureMode().then((exposureMode) => { + console.log(`Promise returned with current exposure mode : ${exposureMode}`); }) ``` -## ImageRotation - -枚举,图片旋转角度。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -| 名称 | 值 | 说明 | -| ------------ | ---- | --------------- | -| ROTATION_0 | 0 | 图片旋转0度。 | -| ROTATION_90 | 90 | 图片旋转90度。 | -| ROTATION_180 | 180 | 图片旋转180度。 | -| ROTATION_270 | 270 | 图片旋转270度。 | - -## QualityLevel - -枚举,图片质量。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -| 名称 | 值 | 说明 | -| -------------------- | ---- | -------------- | -| QUALITY_LEVEL_HIGH | 0 | 图片质量高。 | -| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。 | -| QUALITY_LEVEL_LOW | 2 | 图片质量差。 | +### setExposureMode -## PhotoCaptureSetting +setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void -拍摄照片的设置。 +设置曝光模式,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------- | ---- | -------------- | -| quality | [QualityLevel](#qualitylevel) | 否 | 图片质量。 | -| rotation | [ImageRotation](#imagerotation) | 否 | 图片旋转角度。 | +**参数:** +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ----------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | 曝光模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取设置结果。 | -## PhotoOutput +**示例:** -照片输出类。 +```js +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log(`Failed to set the exposure mode ${err.message}`); + return ; + } + console.log('Callback returned with the successful execution of setExposureMode'); +}) +``` -### capture +### setExposureMode -capture(callback: AsyncCallback): void +setExposureMode(aeMode: ExposureMode): Promise -拍照,通过注册回调函数获取结果。 +设置曝光模式,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** +**返回值:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 说明 | +| ----------------- |---------------------------- | +| Promise | 使用Promise的方式获取设置结果。 | **示例:** ```js -photoOutput.capture((err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => { + console.log('Promise returned with the successful execution of setExposureMode.'); +}) ``` -### capture +### getMeteringPoint -capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void +getMeteringPoint(callback: AsyncCallback): void -根据拍照设置拍照,通过注册回调函数获取结果。 +查询曝光区域中心点,通过注册回调函数获取结果。(该接口目前为预留) **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------- | ---- | ------------------------ | -| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ------------------------ | +| callback | AsyncCallback<[Point](#point)\>| 是 | 回调函数,用于获取当前曝光点。 | **示例:** ```js -let settings:PhotoCaptureSetting = { - quality = 1, - rotation = 0 -} -photoOutput.capture(settings, (err) => { +cameraInput.getMeteringPoint((err, exposurePoint) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; + console.log(`Failed to get the current exposure point ${err.message}`); + return ; } - console.log('Callback invoked to indicate the photo capture request success.'); -}); + console.log(`Callback returned with current exposure point: ${exposurePoint}`); +}) ``` -### capture +### getMeteringPoint -capture(setting?: PhotoCaptureSetting): Promise +getMeteringPoint(): Promise -根据拍照设置拍照,通过Promise获取结果。 +查询曝光区域中心点,通过Promise获取结果。(该接口目前为预留) **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| ------- | ------------------------------------------- | ---- | ---------- | -| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - +| 名称 | 说明 | +| ------------------------- |----------------------------- | +| Promise<[Point](#point)\> | 使用Promise的方式获取当前曝光点。 | **示例:** ```js -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); +cameraInput.getMeteringPoint().then((exposurePoint) => { + console.log(`Promise returned with current exposure point : ${exposurePoint}`); }) ``` -### release +### setMeteringPoint -release(callback: AsyncCallback): void +setMeteringPoint(point: Point, callback: AsyncCallback): void -释放PhotoOutput实例,通过注册回调函数获取结果。 +设置曝光区域中心点,通过注册回调函数获取结果。(该接口目前为预留) **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------- | -------------------------------| ---- | ------------------- | +| exposurePoint | [Point](#point) | 是 | 曝光点。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -photoOutput.release((err) => { +const Point1 = {x: 1, y: 1}; + +cameraInput.setMeteringPoint(Point1,(err) => { if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; + console.log(`Failed to set the exposure point ${err.message}`); + return ; } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); + console.log('Callback returned with the successful execution of setMeteringPoint'); +}) ``` -### release +### setMeteringPoint -release(): Promise +setMeteringPoint(point: Point): Promise -释放PhotoOutput实例,通过Promise获取结果。 +设置曝光区域中心点,通过Promise获取结果。(该接口目前为预留) + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | -------------------------------| ---- | ------------------- | +| exposurePoint | [Point](#point) | 是 | 曝光点。 | + +**返回值:** + +| 名称 | 说明 | +| ----------------- |------------------------ | +| Promise | 使用Promise的方式返回结果。 | + +**示例:** + +```js +const Point2 = {x: 2, y: 2}; + +cameraInput.setMeteringPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setMeteringPoint'); +}) +``` + +### getExposureBiasRange + +getExposureBiasRange(callback: AsyncCallback\>): void + +查询曝光补偿范围,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取补偿范围的数组。 | + +**示例:** + +```js +cameraInput.getExposureBiasRange((err, biasRangeArray) => { + if (err) { + console.log(`Failed to get the array of compenstation range ${err.message}`); + return ; + } + console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); +}) +``` + +### getExposureBiasRange + +getExposureBiasRange(): Promise\> + +查询曝光补偿范围,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 名称 | 说明 | +| ----------------- |-------------------------------------- | +| Promise\> | 使用Promise的方式获取曝光补偿范围。 | + +**示例:** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log(`Promise returned with exposure mode supported : ${isSupported}`); +}) +``` + +### setExposureBias + +setExposureBias(exposureBias: number, callback: AsyncCallback): void + +设置曝光补偿,通过注册回调函数获取结果。 + +进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange)查询支持的范围。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------------| ---- | ------------------- | +| exposureBias | number | 是 | 曝光补偿。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +cameraInput.setExposureBias(-4,(err) => { + if (err) { + console.log(`Failed to set the exposure bias ${err.message}`); + return ; + } + console.log('Callback returned with the successful execution of setExposureBias'); +}) +``` + +### setExposureBias + +setExposureBias(exposureBias: number): Promise + +设置曝光补偿,通过Promise获取结果。 + +进行设置之前,建议先通过方法[getExposureBiasRange](#getexposurebiasrange)查询支持的范围。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------------- | --------- | ---- | --------- | +| exposureBias | number | 是 | 曝光补偿。 | + +**返回值:** + +| 名称 | 说明 | +| ----------------- |------------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +cameraInput.setExposureBias(-4).then(() => { + console.log('Promise returned with the successful execution of setExposureBias.'); +}) +``` + +### getExposureValue + +getExposureValue(callback: AsyncCallback): void + +查询当前曝光值,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------| ---- | --------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取曝光值。 | + +**示例:** + +```js +cameraInput.getExposureValue((err, exposureValue) => { + if (err) { + console.log(`Failed to get the exposure value ${err.message}`); + return ; + } + console.log(`Callback returned with the exposure value: ${exposureValue}`); +}) +``` + +### getExposureValue + +getExposureValue(): Promise + +查询当前曝光值,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 名称 | 说明 | +| ----------------- |-------------------------- | +| Promise | 使用Promise的方式获取曝光值。 | + +**示例:** + +```js +cameraInput.getExposureValue().then((exposureValue) => { + console.log(`Promise returned with exposure value: ${exposureValude}`); +}) +``` + +### isFocusModeSupported + +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void + +检测对焦模式是否支持,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该焦距模式。 | + +**示例:** + +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { + if (err) { + console.error(`Failed to check whether the focus mode is supported. ${err.message}`); + return; + } + console.log(`Callback returned with the focus mode support status: ${status}`); +}) +``` + +### isFocusModeSupported + +isFocusModeSupported(afMode: FocusMode): Promise + +检测对焦模式是否支持,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ----------------------- | ---- | ------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | + +**示例:** + +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { + console.log(`Promise returned with focus mode support status ${status}.`); +}) +``` + +### setFocusMode + +setFocusMode(afMode: FocusMode, callback: AsyncCallback): void + +设置对焦模式,通过注册回调函数获取结果。 + +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ------------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { + if (err) { + console.error(`Failed to set the focus mode ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of setFocusMode.'); +}) +``` + +### setFocusMode + +setFocusMode(afMode: FocusMode): Promise + +设置对焦模式,通过Promise获取结果。 + +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ----------------------- | ---- | ------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFocusMode.'); +}) +``` + +### getFocusMode + +getFocusMode(callback: AsyncCallback): void + +获取当前的对焦模式,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 | + +**示例:** + +```js +cameraInput.getFocusMode((err, afMode) => { + if (err) { + console.error(`Failed to get the focus mode ${err.message}`); + return; + } + console.log(`Callback returned with current focus mode: ${afMode}`); +}) +``` + +### getFocusMode + +getFocusMode(): Promise + +获取当前的对焦模式,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------------------------------- | +| Promise | 使用Promise的方式获取当前的焦距模式。 | + +**示例:** + +```js +cameraInput.getFocusMode().then((afMode) => { + console.log(`Promise returned with current focus mode : ${afMode}`); +}) +``` + +### setFocusPoint + +setFocusPoint(point: Point, callback: AsyncCallback): void + +设置焦点,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ------------------- | +| point | [Point](#point) | 是 | 焦点。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +const Point1 = {x: 1, y: 1}; + +cameraInput.setFocusPoint(Point1, (err) => { + if (err) { + console.error(`Failed to set the focus point ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of setFocusPoint.'); +}) +``` + +### setFocusPoint + +setFocusPoint(point: Point): Promise + +设置焦点,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ------------------- | +| point | [Point](#point) | 是 | 焦点。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +const Point2 = {x: 2, y: 2}; + +cameraInput.setFocusPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setFocusPoint.'); +}) +``` + +### getFocusPoint + +getFocusPoint(callback: AsyncCallback): void + +查询焦点,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ----------------------- | +| callback | AsyncCallback<[Point](#point)\> | 是 | 回调函数,用于获取当前焦点。 | + +**示例:** + +```js +cameraInput.getFocusPoint((err, point) => { + if (err) { + console.error(`Failed to get the current focus point ${err.message}`); + return; + } + console.log('Callback returned with the current focus point: ' + JSON.stringify(point)); +}) +``` + +### getFocusPoint + +getFocusPoint(): Promise + +查询焦点,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| --------------- | --------------------------- | +| Promise | 使用Promise的方式获取当前焦点。 | + +**示例:** + +```js +cameraInput.getFocusPoint().then((point) => { + console.log('Promise returned with the current focus point: ' + JSON.stringify(point)); +}) +``` + +### getFocalLength + +getFocalLength(callback: AsyncCallback): void + +查询焦距值,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取当前焦距。 | + +**示例:** + +```js +cameraInput.getFocalLength((err, focalLength) => { + if (err) { + console.error(`Failed to get the current focal length ${err.message}`); + return; + } + console.log(`Callback returned with the current focal length: ${focalLength}`); +}) +``` + +### getFocalLength + +getFocalLength(): Promise + +查询焦距值,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ----------------------- | +| Promise | 使用Promise的方式获取焦距。 | + +**示例:** + +```js +cameraInput.getFocalLength().then((focalLength) => { + console.log(`Promise returned with the current focal length: ${focalLength}`); +}) +``` + +### getZoomRatioRange + +getZoomRatioRange\(callback: AsyncCallback\>\): void + +获取支持的变焦范围,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------ | ---- | ------------------- | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取可变焦距比范围,返回的数组包括其最小值和最大值。 | + +**示例:** + +```js +cameraInput.getZoomRatioRange((err, zoomRatioRange) => { + if (err) { + console.error(`Failed to get the zoom ratio range. ${err.message}`); + return; + } + console.log(`Callback returned with zoom ratio range: ${zoomRatioRange.length}`); +}) +``` + +### getZoomRatioRange + +getZoomRatioRange\(\): Promise\> + +获取支持的变焦范围,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------ | --------------------------- | +| Promise\> | 使用Promise的方式获取当前的可变焦距比范围,返回的数组包括其最小值和最大值。 | + +**示例:** + +```js +cameraInput.getZoomRatioRange().then((zoomRatioRange) => { + console.log(`Promise returned with zoom ratio range: ${zoomRatioRange.length}`); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number, callback: AsyncCallback): void + +设置变焦比,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| --------- | -------------------- | ---- | ------------------- | +| zoomRatio | number | 是 | 可变焦距比。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +cameraInput.setZoomRatio(1, (err) => { + if (err) { + console.error(`Failed to set the zoom ratio value ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of setZoomRatio.'); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number): Promise + +设置变焦比,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | --------- | +| zoomRatio | number | 是 | 可变焦距比。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +cameraInput.setZoomRatio(1).then(() => { + console.log('Promise returned with the successful execution of setZoomRatio.'); +}) +``` + +### getZoomRatio + +getZoomRatio(callback: AsyncCallback): void + +获取当前的变焦比,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +cameraInput.getZoomRatio((err, zoomRatio) => { + if (err) { + console.error(`Failed to get the zoom ratio ${err.message}`); + return; + } + console.log(`Callback returned with current zoom ratio: ${zoomRatio}`); +}) +``` + +### getZoomRatio + +getZoomRatio(): Promise + +获取当前的变焦比,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +cameraInput.getZoomRatio().then((zoomRatio) => { + console.log(`Promise returned with current zoom ratio : ${zoomRatio}`); +}) +``` + +### isVideoStabilizationModeSupported + +isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void + +查询是否支持指定的视频防抖模式,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ------------------------------ | +| vsMode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 视频防抖模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回视频防抖模式是否支持。 | + +**示例:** + +```js +captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => { + if (err) { + console.error(`Failed to check whether video stabilization mode supported. ${err.message}`); + return; + } + console.log(`Callback returned with the successful execution of isVideoStabilizationModeSupported: ${status}`); +}) +``` + +### isVideoStabilizationModeSupported + +isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise + +查询是否支持指定的视频防抖模式,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回视频防抖模式是否支持。 | + +**示例:** + +```js +captureSession.isVideoStabilizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => { + console.log(`Promise returned with video stabilization mode supported: ${isSupported}`); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(callback: AsyncCallback): void + +查询当前正在使用的视频防抖模式,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback | 是 | 回调函数,返回视频防抖是否正在使用。 | + +**示例:** + +```js +captureSession.getActiveVideoStabilizationMode((err, vsMode) => { + if (err) { + console.error(`Failed to get active video stabilization mode ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.'); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(): Promise + +查询当前正在使用的视频防抖模式,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ------------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回视频防抖当前是否正在使用。 | + +**示例:** + +```js +captureSession.getActiveVideoStabilizationMode().then((vsMode) => { + console.log(`Promise returned with the current video stabilization mode: ${vsMode}`); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void + +设置视频防抖模式,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | --------------------- | +| mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需要设置的视频防抖模式。 | +| callback | AsyncCallback | 是 | 回调函数。 | + +**示例:** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => { + if (err) { + console.error(`Failed to set the video stabilization mode ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode): Promise + +设置视频防抖,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | --------------------- | +| mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需要设置的视频防抖模式。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回设置的视频防抖模式的结果。 | + +**示例:** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF).then(() => { + console.log('Promise returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### on('focusStateChange') + +on(type: 'focusStateChange', callback: AsyncCallback): void + +监听焦距的状态变化,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------ | +| type | string | 是 | 监听事件,固定为'focusStateChange',即焦距状态变化事件。 | +| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取焦距状态。 | + +**示例:** + +```js +cameraInput.on('focusStateChange', (focusState) => { + console.log(`Focus state : ${focusState}`); +}) +``` + +### on('exposureStateChange') + +on(type: 'exposureStateChange', callback: AsyncCallback): void + +监听曝光的状态变化,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ---------------------------------------------- | +| type | string | 是 | 监听事件,固定为'exposureStateChange',即曝光状态变化事件。| +| callback | AsyncCallback<[ExposureState](#exposurestate)\> | 是 | 回调函数,用于获取曝光状态。 | + +**示例:** + +```js +cameraInput.on('exposureStateChange', (exposureState) => { + console.log(`Exposuer state : ${exposureState}`); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback): void + +监听拍照会话的错误事件,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | +| type | string | 是 | 监听事件,固定为'error',即拍照会话错误事件。 | +| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获取错误信息。 | + +**示例:** + +```js +captureSession.on('error', (captureSessionError) => { + console.log(`Capture session error code: ${captureSessionError.code}`); +}) +``` + +## CaptureSessionErrorCode + +枚举,会话错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ----------------------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 0 | 资源不足。 | +| ERROR_TIMEOUT | 1 | 超时。 | + +## CaptureSessionError + +会话错误码。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 说明 | +| ---- | ------------------------------------------- | -------------------------- | +| code | [CaptureSessionError](#capturesessionerror) | CaptureSession中的错误码。 | + +## CameraOutput + +会话中[CaptureSession](#capturesession)使用的输出信息,output的基类。 + +### release + +release(callback: AsyncCallback): void + +释放输出资源,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.release((err) => { + if (err) { + console.error(`Failed to release the PreviewOutput instance ${err.message}`); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); +}); +``` + +### release + +release(): Promise + +释放输出资源,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +previewOutput.release().then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +}) +``` + +## PreviewOutput + +预览输出类。继承[CameraOutput](#cameraoutput) + +### addDeferredSurface + +addDeferredSurface(surfaceId: string, callback: AsyncCallback): void + +在previewOutput生成之后添加surface,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------------------------------------------------------- | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)组件获取的SurfaceID。| +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.addDeferredSurface('surfaceId', (err) => { + if (err) { + console.error(`Failed to add deferredSurface. ${err.message}`); + return; + } + console.log('Callback returned with deferredSurface added.'); +}) +``` + +### addDeferredSurface + +addDeferredSurface(surfaceId: string): Promise + +在previewOutput生成之后添加surface,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -----------| ---- | ------------------------------------------------------------------------------ | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)组件获取的SurfaceID。| + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +previewOutput.addDeferredSurface('surfaceId').then(() => { + console.log('Promise returned with deferredSurface added.'); +}) +``` + +### start + +start(callback: AsyncCallback): void + +开始输出预览流,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.start((err) => { + if (err) { + console.error(`Failed to start the previewOutput. ${err.message}`); + return; + } + console.log('Callback returned with previewOutput started.'); +}) +``` + +### start + +start(): Promise + +开始输出预览流,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +previewOutput.start().then(() => { + console.log('Promise returned with previewOutput started.'); +}) +``` + +### stop + +stop(callback: AsyncCallback): void + +停止输出预览流,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.stop((err) => { + if (err) { + console.error(`Failed to stop the previewOutput. ${err.message}`); + return; + } + console.log('Callback returned with previewOutput stopped.'); +}) +``` + +### stop + +stop(): Promise + +停止输出预览流,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +previewOutput.stop().then(() => { + console.log('Callback returned with previewOutput stopped.'); +}) +``` + +### on('frameStart') + +on(type: 'frameStart', callback: AsyncCallback): void + +监听预览帧启动,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | --------------------------------------- | +| type | string | 是 | 监听事件,固定为'frameStart',即帧启动事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.on('frameStart', () => { + console.log('Preview frame started'); +}) +``` + +### on('frameEnd') + +on(type: 'frameEnd', callback: AsyncCallback): void + +监听预览帧结束,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------------- | +| type | string | 是 | 监听事件,固定为'frameEnd',即帧结束事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +previewOutput.on('frameEnd', () => { + console.log('Preview frame ended'); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback): void + +监听预览输出的错误事件,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------------- | ---- | ------------------------ | +| type | string | 是 | 监听事件,固定为'error',即预览输出错误事件。| +| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获取错误信息。 | + +**示例:** + +```js +previewOutput.on('error', (previewOutputError) => { + console.log(`Preview output error code: ${previewOutputError.code}`); +}) +``` + +## PreviewOutputErrorCode + +枚举,预览输出错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | + +## PreviewOutputError + +预览输出错误码。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 说明 | +| ---- | ------------------------------------------------- | ---------------------- | +| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | PreviewOutput中的错误码。 | + +## ImageRotation + +枚举,图片旋转角度。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ------------ | ---- | ------------- | +| ROTATION_0 | 0 | 图片旋转0度。 | +| ROTATION_90 | 90 | 图片旋转90度。 | +| ROTATION_180 | 180 | 图片旋转180度。 | +| ROTATION_270 | 270 | 图片旋转270度。 | + +## Location + +图片地理位置信息。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 必填 |说明 | +| ------------ | ------ | --- |------------ | +| latitude | number | 是 |纬度(度)。 | +| longitude | number | 是 |经度(度)。 | +| altitude | number | 是 |海拔(米)。 | + +## QualityLevel + +枚举,图片质量。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| -------------------- | ---- | ------------ | +| QUALITY_LEVEL_HIGH | 0 | 图片质量高。 | +| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。 | +| QUALITY_LEVEL_LOW | 2 | 图片质量差。 | + + +## PhotoCaptureSetting + +拍摄照片的设置。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 必填 | 默认值 | 说明 | +| -------- | ------------------------------- | ---- | ----------------- | -----------------| +| quality | [QualityLevel](#qualitylevel) | 否 | QUALITY_LEVEL_HIGH| 图片质量。 | +| rotation | [ImageRotation](#imagerotation) | 否 | ROTATION_0 | 图片旋转角度。 | +| location | [Location](#location) | 否 | (0,0,0) | 图片地理位置信息。 | + +## PhotoOutput + +拍照会话中使用的输出信息。 + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(callback: AsyncCallback): void + +获取默认拍照参数,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[PhotoCaptureSetting](#photocapturesetting)\> | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +photoOutput.getDefaultCaptureSetting((err, photocapturesetting) => { + if (err) { + console.error(`Failed to get the defaultCaptureSetting. ${err.message}`); + return; + } + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(): Promise + +获取默认拍照参数,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------- | ----------------------- | +| Promise<[PhotoCaptureSetting](#photocapturesetting)\> | 使用Promise的方式获取结果。 | + +**示例:** + +```js +photoOutput.getDefaultCaptureSetting().then((photocapturesetting) => { + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### capture + +capture(callback: AsyncCallback): void + +以默认设置触发一次拍照,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +photoOutput.capture((err) => { + if (err) { + console.error(`Failed to capture the photo ${err.message}`); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture + +capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void + +以指定参数触发一次拍照,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | -------------------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +let settings:PhotoCaptureSetting = { + quality = 1, + rotation = 0 +} +photoOutput.capture(settings, (err) => { + if (err) { + console.error(`Failed to capture the photo ${err.message}`); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture + +capture(setting?: PhotoCaptureSetting): Promise + +以指定参数触发一次拍照,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------------- | ---- | -------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise | 使用Promise的方式获取结果。 | + + +**示例:** + +```js +photoOutput.capture().then(() => { + console.log('Promise returned to indicate that photo capture request success.'); +}) +``` + +### isMirrorSupported + +isMirrorSupported(callback: AsyncCallback): void + +查询是否支持镜像拍照,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | -------------------------- | +| callback | AsyncCallback | 是 | 回调函数,返回是否支持镜像拍照。 | + +**示例:** + +```js +captureSession.isMirrorSupported((err, isSupported) => { + if (err) { + console.error(`Failed to check mirror is supported ${err.message}`); + return; + } + console.log('Callback returned with the successful execution of isMirrorSupported.'); +}) +``` + +### isMirrorSupported + +isMirrorSupported(): Promise + +查询是否支持镜像拍照,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------- | +| Promise | 使用Promise的方式获取结果,返回是否支持自拍结果。 | + +**示例:** + +```js +captureSession.isMirrorSupported().then((isSupported) => { + console.log(`Promise returned with mirror supported: ${isSupported}`); +}) +``` + +### on('captureStart') + +on(type: 'captureStart', callback: AsyncCallback): void + +监听拍照开始,通过注册回调函数获取Capture ID。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------ | +| type | string | 是 | 监听事件,固定为'captureStart',即拍照启动事件。 | +| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | + +**示例:** + +```js +photoOutput.on('captureStart', (err, captureId) => { + console.log(`photo capture stated, captureId : ${captureId}`); +}) +``` + +### on('frameShutter') + +on(type: 'frameShutter', callback: AsyncCallback): void + +监听拍照帧输出捕获,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | --- | ------------------------------------ | +| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | +| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获取相关信息。 | + +**示例:** + +```js +photoOutput.on('frameShutter', (err, frameShutterInfo) => { + console.log(`photo capture end, captureId : ${frameShutterInfo.captureId}`); + console.log(`Timestamp for frame : ${frameShutterInfo.timestamp}`); +}) +``` + +### on('captureEnd') + +on(type: 'captureEnd', callback: AsyncCallback): void + +监听拍照结束,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | +| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获取相关信息。 | + +**示例:** + +```js +photoOutput.on('captureEnd', (err, captureEndInfo) => { + console.log(`photo capture end, captureId : ${captureEndInfo.captureId}`); + console.log(`frameCount : ${captureEndInfo.frameCount}`); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback): void + +监听拍照输出发生错误,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ----------------------------------- | +| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 | +| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | + +**示例:** + +```js +photoOutput.on('error', (err, photoOutputError) => { + console.log(`Photo output error code: ${photoOutputError.code}`); +}) +``` + +## FrameShutterInfo + +拍照帧输出信息。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------- | +| captureId | number | 是 | 拍照的ID。 | +| timestamp | number | 是 | 快门时间戳。 | + +## CaptureEndInfo + +拍照停止信息。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ---------| +| captureId | number | 是 | 拍照的ID。 | +| frameCount | number | 是 | 帧数。 | + +## PhotoOutputErrorCode + +枚举,拍照输出错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 值 | 说明 | +| ----------------------------- | ---- | --------------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 1 | 资源不足。 | +| ERROR_TIMEOUT | 2 | 超时。 | + +## PhotoOutputError + +拍照输出错误码。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| 名称 | 类型 | 说明 | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | PhotoOutput中的错误码。 | + +## VideoOutput + +录像会话中使用的输出信息。 + +### start + +start(callback: AsyncCallback): void + +启动录制,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +videoOutput.start((err) => { + if (err) { + console.error(`Failed to start the video output ${err.message}`); + return; + } + console.log('Callback invoked to indicate the video output start success.'); +}); +``` + +### start + +start(): Promise + +启动录制,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise | 使用Promise的方式获取结果。 | **示例:** ```js -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); +videoOutput.start().then(() => { + console.log('Promise returned to indicate that start method execution success.'); }) ``` -### on('captureStart') +### stop -on(type: 'captureStart', callback: AsyncCallback): void +stop(callback: AsyncCallback): void -监听拍照启动,通过注册回调函数获取Capture ID。 +结束录制,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :--------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监听事件,固定为'captureStart',即拍照启动事件。 | -| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -photoOutput.on('captureStart', (err, captureId) => { - console.log('photo capture stated, captureId : ' + captureId); +videoOutput.stop((err) => { + if (err) { + console.error(`Failed to stop the video output ${err.message}`); + return; + } + console.log('Callback invoked to indicate the video output stop success.'); +}); +``` + +### stop + +stop(): Promise + +结束录制,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +videoOutput.stop().then(() => { + console.log('Promise returned to indicate that stop method execution success.'); +}) +``` + +### getFrameRateRange + +getFrameRateRange(callback: AsyncCallback\>): void + +获取帧率范围,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +videoOutput.getFrameRateRange((err) => { + if (err) { + console.error(`Failed to get the frameRateRange ${err.message}`); + return; + } + console.log('getFrameRateRange success.'); +}); +``` + +### getFrameRateRange + +getFrameRateRange(): Promise\> + +获取帧率范围,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise\> | 使用Promise的方式获取结果。 | + +**示例:** + +```js +videoOutput.getFrameRateRange().then(() => { + console.log('getFrameRateRange success.'); }) +``` + +### setFrameRateRange + +setFrameRateRange(minFrameRate: number, maxFrameRate: number, callback: AsyncCallback\>): void + +获取帧率范围,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ----------------------------- | ---- | ------------------- | +| minFrameRate | number | 是 | 最小帧率。 | +| maxFrameRate | number | 是 | 最大帧率。 | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +videoOutput.setFrameRateRange(minFrameRate, maxFrameRate,(err) => { + if (err) { + console.error(`Failed to set the frameRateRange ${err.message}`); + return; + } + console.log('setFrameRateRange success.'); +}); ``` -### on('frameShutter') +### setFrameRateRange -on(type: 'frameShutter', callback: AsyncCallback): void +setFrameRateRange(minFrameRate: number, maxFrameRate: number): Promise\> -监听快门,通过注册回调函数获取结果。 +获取帧率范围,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | -| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获取相关信息。 | +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ----------------------------- | ---- | ------------------- | +| minFrameRate | number | 是 | 最小帧率。 | +| maxFrameRate | number | 是 | 最大帧率。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise\> | 使用Promise的方式获取结果。 | **示例:** ```js -photoOutput.on('frameShutter', (err, frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +videoOutput.setFrameRateRange(minFrameRate, maxFrameRate).then(() => { + console.log('setFrameRateRange success.'); +}) +``` + +### on('frameStart') + +on(type: 'frameStart', callback: AsyncCallback): void + +监听录像开始,通过注册回调函数获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ----------------------------------------- | +| type | string | 是 | 监听事件,固定为'frameStart',即视频帧开启事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | + +**示例:** + +```js +videoOutput.on('frameStart', () => { + console.log('Video frame started'); }) ``` -### on('captureEnd') +### on('frameEnd') -on(type: 'captureEnd', callback: AsyncCallback): void +on(type: 'frameEnd', callback: AsyncCallback): void -监听拍照停止,通过注册回调函数获取结果。 +监听录像结束,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------------------------------------ | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | -| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获取相关信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ------------------------------------------ | +| type | string | 是 | 监听事件,固定为'frameEnd',即视频帧结束事件 。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -photoOutput.on('captureEnd', (err, captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); +videoOutput.on('frameEnd', () => { + console.log('Video frame ended'); }) ``` ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(type: 'error', callback: ErrorCallback): void -监听拍照的错误事件,通过注册回调函数获取结果。 +监听录像输出发生错误,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :---------------------------------------------------- | :--- | :---------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即拍照错误事件。 | -| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | -------------------------------------- | +| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 | +| callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | **示例:** ```js -photoOutput.on('error', (err, photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); +videoOutput.on('error', (VideoOutputError) => { + console.log(`Video output error code: ${VideoOutputError.code}`); }) ``` -## FrameShutterInfo +## VideoOutputErrorCode -快门事件信息。 +枚举,录像输出错误类型。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | ----------------------------- | -| captureId | number | 是 | CaptureId,本次拍摄动作的ID。 | -| timestamp | number | 是 | 时间戳。 | +| 名称 | 值 | 说明 | +| --------------------- | ---- | ------------ | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。| -## CaptureEndInfo +## VideoOutputError -拍照停止信息。 +录像输出错误码。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ----------------------------- | -| captureId | number | 是 | CaptureId,本次拍摄动作的ID。 | -| frameCount | number | 是 | 帧计数。 | +| 名称 | 类型 | 说明 | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | VideoOutput中的错误码。 | -## PhotoOutputErrorCode +## MetadataObjectType -枚举,拍照输出的错误码。 +枚举,metadata流。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ----------------- | +| FACE_DETECTION | 0 | metadata对象类型。 | -## PhotoOutputError +## Rect -拍照输出错误对象。 +矩形定义。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 类型 | 说明 | -| ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | PhotoOutput中的错误码。 | +| 名称 | 类型 | 说明 | +| -------- | ------ | -------------------- | +| topLeftX | number | 矩形区域左上角x坐标。 | +| topLeftY | number | 矩形区域左上角y坐标。 | +| width | number | 矩形宽。 | +| height | number | 矩形高。 | -## camera.createVideoOutput +## MetadataObject -createVideoOutput(surfaceId: string, callback: AsyncCallback): void +相机元能力信息,[CameraInput](#camerainput)相机信息中的数据来源。 -获取VideoOutput实例,通过注册回调函数获取结果。 +### getType + +getType(callback: AsyncCallback): void + +查询metadata对象类型,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | -| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获取VideoOutput实例。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | --- | -------------------- | +| callback | AsyncCallback<[MetadataObjectType](#metadataobjecttype)\> | 是 | 回调函数,用于获取结果。 | **示例:** ```js -camera.createVideoOutput(("surfaceId"), (err, videoOutput) => { +metadataObject.getType((err, metadataObjectType) => { if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); + console.error(`Failed to get type. ${err.message}`); return; } - console.log('Callback returned with the VideoOutput instance'); -}); + console.log('Callback returned with an array of metadataObjectType.'); +}) ``` -## camera.createVideoOutput +### getType -createVideoOutput(surfaceId: string): Promise +getType(): Promise -获取VideoOutput实例,通过Promise获取结果。 +查询metadata对象类型,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**参数:** - -| 名称 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | - **返回值:** -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[VideoOutput](#videooutput)\> | 使用Promise的方式获取VideoOutput实例。 | +| 类型 | 说明 | +| --------------------------------------------------- | --------------------------- | +| Promise<[MetadataObjectType](#metadataobjecttype)\> | 使用Promise的方式获取结果。 | **示例:** ```js -camera.createVideoOutput("surfaceId" -).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); +metadataObject.getType().then((metadataObjectType) => { + console.log('Callback returned with an array of metadataObjectType.'); }) ``` -## VideoOutput - -视频输出类。 - -### start +### getTimestamp -start(callback: AsyncCallback): void +getTimestamp(callback: AsyncCallback): void -开始拍摄视频,通过注册回调函数获取结果。 +查询metadata时间戳,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -videoOutput.start((err) => { +metadataObject.getTimestamp((err) => { if (err) { - console.error('Failed to start the video output ${err.message}'); + console.error(`Failed to get timestamp. ${err.message}`); return; } - console.log('Callback invoked to indicate the video output start success.'); -}); + console.log('Callback returned with timestamp getted.'); +}) ``` -### start +### getTimestamp -start(): Promise +getTimestamp(): Promise -开始拍摄视频,通过Promise获取结果。 +查询metadata时间戳,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise | 使用Promise的方式获取结果。 | **示例:** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); +metadataObject.getTimestamp().then(() => { + console.log('Callback returned with timestamp getted.'); }) ``` -### stop +### getBoundingBox -stop(callback: AsyncCallback): void +getBoundingBox(callback: AsyncCallback): void -停止拍摄视频,通过注册回调函数获取结果。 +查询metadata的边界框,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[Rect](#rect)\> | 是 | 回调函数,用于获取结果。 | **示例:** ```js -videoOutput.stop((err) => { +metadataObject.getBoundingBox((err, rect) => { if (err) { - console.error('Failed to stop the video output ${err.message}'); + console.error(`Failed to get boundingBox. ${err.message}`); return; } - console.log('Callback invoked to indicate the video output stop success.'); -}); + console.log('Callback returned with boundingBox getted.'); +}) ``` -### stop +### getBoundingBox -stop(): Promise +getBoundingBox(): Promise -停止拍摄视频,通过Promise获取结果。 +查询metadata的边界框,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<[Rect](#rect)\> | 使用Promise的方式获取结果。 | **示例:** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); +metadataObject.getBoundingBox().then((rect) => { + console.log('Callback returned with boundingBox getted.'); }) ``` -### release +## MetadataFaceObject -release(callback: AsyncCallback): void +metadata的人脸对象。继承[MetadataObject](#metadataobject) + +## MetadataOutput + +metadata流。继承[CameraOutput](#cameraoutput) + +### start + +start(callback: AsyncCallback): void -释放VideoOutput实例,通过注册回调函数获取结果。 +开始输出metadata,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -videoOutput.release((err) => { +metadataOutput.start((err) => { if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); + console.error(`Failed to start metadataOutput. ${err.message}`); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); + console.log('Callback returned with metadataOutput started.'); +}) ``` -### release +### start -release(): Promise +start(): Promise -释放VideoOutput实例,通过Promise获取结果。 +开始输出metadata,通过Promise获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise | 使用Promise的方式获取结果。 | - +| 类型 | 说明 | +| ---------------------- | ------------------------ | +| Promise | 使用Promise的方式获取结果。 | **示例:** ```js -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); +metadataOutput.start().then(() => { + console.log('Callback returned with metadataOutput started.'); }) ``` -### on('frameStart') +### stop -on(type: 'frameStart', callback: AsyncCallback): void +stop(callback: AsyncCallback): void -监听视频帧开启,通过注册回调函数获取结果。 +停止输出metadata,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameStart',即视频帧开启事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** ```js -videoOutput.on('frameStart', () => { - console.log('Video frame started'); +metadataOutput.stop((err) => { + if (err) { + console.error(`Failed to stop the metadataOutput. ${err.message}`); + return; + } + console.log('Callback returned with metadataOutput stopped.'); }) ``` -### on('frameEnd') +### stop -on(type: 'frameEnd', callback: AsyncCallback): void +stop(): Promise + +停止输出metadata,通过Promise获取结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise | 使用Promise的方式获取结果。 | + +**示例:** + +```js +metadataOutput.stop().then(() => { + console.log('Callback returned with metadataOutput stopped.'); +}) +``` + +### on('metadataObjectsAvailable') -监听视频帧结束,通过注册回调函数获取结果。 +on(type: 'metadataObjectsAvailable', callback: AsyncCallback\>): void + +监听检测到的metadata对象,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监听事件,固定为'frameEnd',即视频帧结束事件。 | -| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ------------------------------------ | +| type | string | 是 | 监听事件,固定为'metadataObjectsAvailable',即metadata对象。 | +| callback | Callback\> | 是 | 回调函数,用于获取错误信息。 | **示例:** ```js -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); +metadataOutput.on('metadataObjectsAvailable', (metadataObject) => { + console.log(`metadata output error code: ${metadataObject.code}`); }) ``` ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(tuype: 'error', callback: ErrorCallback): void -监听视频输出的错误事件,通过注册回调函数获取结果。 +监听metadata流的错误,通过注册回调函数获取结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -| :------- | :----------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监听事件,固定为'error',即视频输出错误事件。 | -| callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获取错误信息。 | +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | --------------------------------------- | +| type | string | 是 | 监听事件,固定为'error',即metadata流的错误。 | +| callback | Callback<[MetadataOutputError](#metadataoutputerror)\> | 是 | 回调函数,用于获取错误信息。 | **示例:** ```js -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); +metadataOutput.on('error', (metadataOutputError) => { + console.log(`Metadata output error code: ${metadataOutputError.code}`); }) ``` -## VideoOutputErrorCode +## MetadataOutputErrorCode -枚举,视频输出的错误码。 +枚举,metadata输出错误类型。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| 名称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +| 名称 | 值 | 说明 | +| ------------------------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 0 | 资源不足。 | -## VideoOutputError +## MetadataOutputError -视频输出错误对象。 +metadata输出错误码。 **系统能力:** SystemCapability.Multimedia.Camera.Core | 名称 | 类型 | 说明 | | ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | VideoOutput中的错误码。 | \ No newline at end of file +| code | [MetadataOutputErrorCode](#metadataoutputerrorcode) | MetadataOutput中的错误码。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index f4529508bb648f132586a2b3988fb8d9eda51bbb..7f03c0e62f5e943c3803ebb3327489cdb3030184 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -227,7 +227,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ ```js //公共事件相关信息 -var options = { +let options = { code: 0, //公共事件的初始代码 data: "initial data",//公共事件的初始数据 isOrdered: true //有序公共事件 @@ -279,7 +279,7 @@ function PublishAsUserCallBack(err) { } //指定发送的用户 -var userId = 100; +let userId = 100; //发布公共事件 CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack); @@ -311,7 +311,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca ```js //公共事件相关信息 -var options = { +let options = { code: 0, //公共事件的初始代码 data: "initial data",//公共事件的初始数据 } @@ -326,7 +326,7 @@ function PublishAsUserCallBack(err) { } //指定发送的用户 -var userId = 100; +let userId = 100; //发布公共事件 CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack); @@ -353,10 +353,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 //订阅者信息 -var subscribeInfo = { +let subscribeInfo = { events: ["event"] }; @@ -398,10 +398,10 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\): **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 //订阅者信息 -var subscribeInfo = { +let subscribeInfo = { events: ["event"] }; @@ -549,7 +549,7 @@ getCode(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取有序公共事件的结果代码回调 function getCodeCallback(err, Code) { @@ -579,7 +579,7 @@ getCode(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.getCode().then((Code) => { console.info("getCode " + JSON.stringify(Code)); @@ -606,7 +606,7 @@ setCode(code: number, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //设置有序公共事件的结果代码回调 function setCodeCallback(err) { @@ -642,7 +642,7 @@ setCode(code: number): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.setCode(1).then(() => { console.info("setCode"); @@ -668,7 +668,7 @@ getData(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取有序公共事件的结果数据回调 function getDataCallback(err, Data) { @@ -698,7 +698,7 @@ getData(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.getData().then((Data) => { console.info("getData " + JSON.stringify(Data)); @@ -725,7 +725,7 @@ setData(data: string, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //设置有序公共事件的结果数据回调 function setDataCallback(err) { @@ -761,7 +761,7 @@ setData(data: string): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.setData("publish_data_changed").then(() => { console.info("setData"); @@ -789,7 +789,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //设置有序公共事件的结果代码和结果数据回调 function setCodeDataCallback(err) { @@ -826,7 +826,7 @@ setCodeAndData(code: number, data: string): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.setCodeAndData(1, "publish_data_changed").then(() => { console.info("setCodeAndData"); @@ -854,7 +854,7 @@ isOrderedCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取当前公共事件是否为有序事件的回调 function isOrderedCallback(err, isOrdered) { @@ -886,7 +886,7 @@ isOrderedCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.isOrderedCommonEvent().then((isOrdered) => { console.info("isOrdered " + JSON.stringify(isOrdered)); @@ -914,7 +914,7 @@ isStickyCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取当前公共事件是否为粘性事件的回调 function isStickyCallback(err, isSticky) { @@ -946,7 +946,7 @@ isStickyCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.isStickyCommonEvent().then((isSticky) => { console.info("isSticky " + JSON.stringify(isSticky)); @@ -972,7 +972,7 @@ abortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //取消当前有序公共事件的回调 function abortCallback(err) { @@ -1002,7 +1002,7 @@ abortCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.abortCommonEvent().then(() => { console.info("abortCommonEvent"); @@ -1028,7 +1028,7 @@ clearAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //清除当前公共事件取消状态的回调 function clearAbortCallback(err) { @@ -1058,7 +1058,7 @@ clearAbortCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.clearAbortCommonEvent().then(() => { console.info("clearAbortCommonEvent"); @@ -1084,7 +1084,7 @@ getAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取当前有序公共事件是否取消的回调 function getAbortCallback(err, AbortCommonEvent) { @@ -1114,7 +1114,7 @@ getAbortCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.getAbortCommonEvent().then((AbortCommonEvent) => { console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent)); @@ -1140,7 +1140,7 @@ getSubscribeInfo(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //获取订阅者信息回调 function getSubscribeInfoCallback(err, SubscribeInfo) { @@ -1170,7 +1170,7 @@ getSubscribeInfo(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.getSubscribeInfo().then((SubscribeInfo) => { console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); @@ -1196,7 +1196,7 @@ finishCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 //结束当前有序公共事件的回调 function finishCommonEventCallback(err) { @@ -1226,7 +1226,7 @@ finishCommonEvent(): Promise\ **示例:** ```js -var subscriber; //创建成功的订阅者对象 +let subscriber; //创建成功的订阅者对象 subscriber.finishCommonEvent().then(() => { console.info("FinishCommonEvent"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md b/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md index 889243b124f1d3a8213e2bd40faaab66a9e26cc8..5689f51f42b6eff47d583430da83dc53ddc650ff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @@ -23,7 +23,7 @@ import cryptoFramework from "@ohos.security.cryptoFramework" | INVALID_PARAMS | 401 | 非法入参。 | | NOT_SUPPORT | 801 | 操作不支持。 | | ERR_OUT_OF_MEMORY | 17620001 | 内存错误。 | -| ERR_EXTERNAL_ERROR | 17620002 | 运行时外部错误。 | +| ERR_RUNTIME_ERROR | 17620002 | 运行时外部错误。 | | ERR_CRYPTO_OPERATION | 17630001 | 调用三方算法库API出错。 | | ERR_CERT_SIGNATURE_FAILURE | 17630002 | 证书签名验证错误。 | | ERR_CERT_NOT_YET_VALID | 17630003 | 证书尚未生效。 | @@ -916,7 +916,7 @@ promiseGenerateRand.then(randData => { | ------- | ------ | ---- | ---- | ---------------------- | | iv | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数iv,长度为12字节| | aad | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数aad,长度为8字节| -| authTag | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数authTag,长度为16字节。
采用GCM模式加密时,需要获取[doFinal()](#dofinal-2)输出的[DataBlob](#datablob),将其作为解密时[GcmParamsSpec](#gcmparamsspec)中的authTag| +| authTag | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数authTag,长度为16字节。
采用GCM模式加密时,需要获取[doFinal()](#dofinal-2)输出的[DataBlob](#datablob),将其末尾16字节作为解密时[GcmParamsSpec](#gcmparamsspec)中的authTag | ## CcmParamsSpec @@ -928,7 +928,7 @@ promiseGenerateRand.then(randData => { | ------- | -------- | ---- | ---- | -------------------------------| | iv | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数iv,长度为7字节 | | aad | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数aad,长度为8字节 | -| authTag | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数authTag,长度为12字节。
采用CCM模式加密时,需要获取[doFinal()](#dofinal-2)输出的[DataBlob](#datablob),将其作为解密时[CcmParamsSpec](#ccmparamsspec)中的authTag | +| authTag | [DataBlob](#datablob) | 是 | 是 | 指明加解密参数authTag,长度为12字节。
采用CCM模式加密时,需要获取[doFinal()](#dofinal-2)输出的[DataBlob](#datablob),将其末尾12字节作为解密时[CcmParamsSpec](#ccmparamsspec)中的authTag | ## CryptoMode @@ -1102,7 +1102,7 @@ key.clearMem(); createSymKeyGenerator(algName : string) : SymKeyGenerator -通过指定算法名称的字符串,获取相应的对称密钥生成器实例。 +通过指定算法名称的字符串,获取相应的对称密钥生成器实例。支持的对称密钥参数详见框架概述“[密钥生成规格](../../security/cryptoFramework-overview.md#密钥生成规格)”一节中“生成密钥的字符串”。 **系统能力:** SystemCapability.Security.CryptoFramework @@ -1118,6 +1118,13 @@ createSymKeyGenerator(algName : string) : SymKeyGenerator | ----------------------------------- | -------------------------- | | [SymKeyGenerator](#symkeygenerator) | 返回对称密钥生成器的对象。 | +**示例:** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); +``` + ## SymKeyGenerator 对称密钥生成器。在使用该类的方法前,需要先使用[createSymKeyGenerator](#cryptoframeworkcreatesymkeygenerator)方法构建一个symKeyGenerator实例。 @@ -1367,7 +1374,7 @@ keyGenPromise.then( keyPair => { ### convertKey convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\) : void -异步获取指定数据生成非对称密钥,通过注册回调函数获取结果。 +异步获取指定数据生成非对称密钥,通过注册回调函数获取结果。详情请看下方**密钥转换说明** **系统能力:** SystemCapability.Security.CryptoFramework @@ -1397,7 +1404,7 @@ asyKeyGenerator.convertKey(pubKey, priKey, (err, keyPair) => { ### convertKey convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\ -异步获取指定数据生成非对称密钥,通过Promise获取结果。 +异步获取指定数据生成非对称密钥,通过Promise获取结果。详情请看下方**密钥转换说明** **系统能力:** SystemCapability.Security.CryptoFramework @@ -1428,10 +1435,18 @@ keyGenPromise.then( keyPair => { }); ``` +**密钥转换说明** + +1. RSA二进制密钥数据,按keysize(32位) ,nsize(keysize/8), esize(e实际长度),dsize(keysize/8),nval(大数n的二进制数据),eval(大数e的二进制数据),dval(大数d的二进制数据)拼接形成。 +2. RSA二进制密钥数据中,nsize和dsize为密钥位数/8,esize为具体的实际长度。 +3. RSA私钥数据需要包含keysize,nsize,esize,dsize,nval,eval,dval的全部数据,公钥材料中dsize设置为0,缺省dval的数据。 +4. RSA二进制密钥数据中,keysize、nsize、esize和dsize为32位二进制数据,数据的大小端格式请按设备CPU默认格式,密钥材料(nval、eval、dval)统一为大端格式。 +5. convertKey接口中,公钥和私钥二进制数据为可选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。 + ## cryptoFramework.createCipher createCipher(transformation : string) : Cipher -通过指定算法名称,获取相应的[Cipher](#cipher)实例。 +通过指定算法名称,获取相应的[Cipher](#cipher)实例。支持的算法名参数详见框架概述“[加解密规格](../../security/cryptoFramework-overview.md#加解密规格)”一节中的“指定算法名称字符串”。 **系统能力:** SystemCapability.Security.CryptoFramework @@ -1465,7 +1480,7 @@ try { ## Cipher -提供加解密的算法操作功能,按序调用本类中的[init()](#init-2)、[update()](#update-4)、[doFinal()](#dofinal-2)方法,可以实现对称加密/对称解密/非对称加密/非对称解密。 +提供加解密的算法操作功能,按序调用本类中的[init()](#init-2)、[update()](#update-4)、[doFinal()](#dofinal-2)方法,可以实现对称加密/对称解密/非对称加密/非对称解密。完整的加解密流程示例可参考开发指导中的“[使用加解密操作](../../security/cryptoFramework-guidelines.md#使用加解密操作)”一节。 ### 属性 @@ -1630,7 +1645,7 @@ cipher.update(data).then((output) => { doFinal(data : DataBlob, callback : AsyncCallback\) : void -最后结束加密或者解密数据操作,通过注册回调函数获取加密或者解密数据。如果在本次加解密过程中已经使用[update](#update-4)传入过数据,可以在doFinal的data参数处传入null。
根据对称加解密的模式不同,doFinal的输出可能不同。
对于GCM和CCM模式的对称加密,在doFinal完成后需要将其结果暂存作为解密时的authTag。
对于其他模式的对称加解密,存在两种情况(1)update输出一部分加解密结果,doFinal输出剩余加解密结果;(2)update输出加解密结果全部由update输出,doFinal输出空。 +最后结束加密或者解密数据操作,通过注册回调函数获取加密或者解密数据。如果在本次加解密过程中已经使用[update](#update-4)传入过数据,可以在doFinal的data参数处传入null。
根据对称加解密的模式不同,doFinal的输出可能不同:
对于GCM和CCM模式的对称加密,doFinal的结果是剩余密文和authTag的拼接,即末尾的16字节(GCM模式)或12字节(CCM模式)是authTag(因此如果doFinal的data参数传入null,则doFinal的结果就是authTag)。在doFinal完成后需要将authTag暂存,填入解密时的[GcmParamsSpec](#gcmparamsspec)或[CcmParamsSpec](#ccmparamsspec)。
对于其他模式的对称加解密,根据不同的模式特点,存在两种情况(1)update输出一部分加解密结果,doFinal输出剩余加解密结果;(2)加解密结果全部由update输出,doFinal输出空。 **系统能力:** SystemCapability.Security.CryptoFramework @@ -1662,7 +1677,7 @@ cipher.doFinal(data, (err, output) => { doFinal(data : DataBlob) : Promise\ -最后结束加密或者解密数据操作,通过Promise获取结果。如果在本次加解密过程中已经使用update传入过数据,可以在doFinal的data参数处传入null。 +最后结束加密或者解密数据操作,通过Promise获取结果。如果在本次加解密过程中已经使用[update](#update-4)传入过数据,可以在doFinal的data参数处传入null。
根据对称加解密的模式不同,doFinal的输出可能不同:
对于GCM和CCM模式的对称加密,doFinal的结果是剩余密文和authTag的拼接,即末尾的16字节(GCM模式)或12字节(CCM模式)是authTag(因此如果doFinal的data参数传入null,则doFinal的结果就是authTag)。在doFinal完成后需要将authTag暂存,填入解密时的[GcmParamsSpec](#gcmparamsspec)或[CcmParamsSpec](#ccmparamsspec)。
对于其他模式的对称加解密,根据不同的模式特点,存在两种情况(1)update输出一部分加解密结果,doFinal输出剩余加解密结果;(2)加解密结果全部由update输出,doFinal输出空。 **系统能力:** SystemCapability.Security.CryptoFramework @@ -2183,7 +2198,7 @@ createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | ------------------ | -| inStream | EncodingBlob | 是 | X509证书序列化数据 | +| inStream | [EncodingBlob](#encodingblob) | 是 | X509证书序列化数据 | | callback | AsyncCallback\ | 否 | 回调函数。表示X509证书对象 | @@ -2220,7 +2235,7 @@ createX509Cert(inStream : EncodingBlob) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------ | ---- | ------------------ | -| inStream | EncodingBlob | 是 | X509证书序列化数据 | +| inStream | [EncodingBlob](#encodingblob) | 是 | X509证书序列化数据 | **返回值**: @@ -2263,7 +2278,7 @@ verify(key : PubKey, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | ------------------ | -| key | PubKey | 是 | 用于验签的公钥对象 | +| key | [PubKey](#pubkey) | 是 | 用于验签的公钥对象 | | callback | AsyncCallback\) | 否 | 回调函数。使用AsyncCallback的第一个error参数判断是否验签成功,error为null表示成功,不为null表示失败 | @@ -2309,7 +2324,7 @@ verify(key : PubKey) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------ | -| key | PubKey | 是 | 用于验签的公钥对象 | +| key | [PubKey](#pubkey) | 是 | 用于验签的公钥对象 | **返回值**: @@ -2355,7 +2370,7 @@ getEncoded(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | 否 | 回调函数。表示X509证书序列化数据 | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 否 | 回调函数。表示X509证书序列化数据 | **示例**: @@ -2398,7 +2413,7 @@ getEncoded() : Promise\ | 类型 | 说明 | | ------------ | ---------------------- | -| Promise\ | 表示X509证书序列化数据 | +| Promise\<[EncodingBlob](#encodingblob)> | 表示X509证书序列化数据 | **示例**: @@ -2679,7 +2694,7 @@ getIssuerName() : DataBlob | 类型 | 说明 | | -------- | ---------------------- | -| DataBlob | 表示X509证书颁发者名称 | +| [DataBlob](#datablob) | 表示X509证书颁发者名称 | **示例**: @@ -2715,7 +2730,7 @@ getSubjectName() : DataBlob | 类型 | 说明 | | -------- | -------------------- | -| DataBlob | 表示X509证书主体名称 | +| [DataBlob](#datablob) | 表示X509证书主体名称 | **示例**: @@ -2823,7 +2838,7 @@ getSignature() : DataBlob | 类型 | 说明 | | -------- | -------------------- | -| DataBlob | 表示X509证书签名数据 | +| [DataBlob](#datablob) | 表示X509证书签名数据 | **示例**: @@ -2887,15 +2902,15 @@ cryptoFramework.createX509Cert(encodingBlob, function (error, x509Cert) { getSignatureAlgOid() : string -表示获取X509证书签名算法OID。 +表示获取X509证书签名算法的对象标志符OID(Object Identifier)。OID是由国际标准组织(ISO)的名称注册机构分配。 **系统能力**:SystemCapability.Security.CryptoFramework **返回值**: -| 类型 | 说明 | -| ------ | ----------------------- | -| string | 表示X509证书签名算法OID | +| 类型 | 说明 | +| ------ | --------------------------------- | +| string | 表示X509证书签名算法对象标志符OID | **示例**: @@ -2931,7 +2946,7 @@ getSignatureAlgParams() : DataBlob | 类型 | 说明 | | -------- | ------------------------ | -| DataBlob | 表示X509证书签名算法参数 | +| [DataBlob](#datablob) | 表示X509证书签名算法参数 | **示例**: @@ -2967,7 +2982,7 @@ getKeyUsage() : DataBlob | 类型 | 说明 | | -------- | -------------------- | -| DataBlob | 表示X509证书秘钥用途 | +| [DataBlob](#datablob) | 表示X509证书秘钥用途 | **示例**: @@ -3003,7 +3018,7 @@ getExtKeyUsage() : DataArray | 类型 | 说明 | | --------- | ------------------------ | -| DataArray | 表示X509证书扩展秘钥用途 | +| [DataArray](#dataarray) | 表示X509证书扩展秘钥用途 | **示例**: @@ -3075,7 +3090,7 @@ getSubjectAltNames() : DataArray | 类型 | 说明 | | --------- | ------------------------ | -| DataArray | 表示X509证书主体可选名称 | +| [DataArray](#dataarray) | 表示X509证书主体可选名称 | **示例**: @@ -3111,7 +3126,7 @@ getIssuerAltNames() : DataArray | 类型 | 说明 | | --------- | -------------------------- | -| DataArray | 表示X509证书颁发者可选名称 | +| [DataArray](#dataarray) | 表示X509证书颁发者可选名称 | **示例**: @@ -3147,7 +3162,7 @@ createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------------------------- | -| inStream | EncodingBlob | 是 | 表示证书吊销列表序列化数据 | +| inStream | [EncodingBlob](#encodingblob) | 是 | 表示证书吊销列表序列化数据 | | callback | AsyncCallback\ | 否 | 回调函数。表示证书吊销列表对象 | @@ -3184,7 +3199,7 @@ createX509Crl(inStream : EncodingBlob) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------ | ---- | -------------------------- | -| inStream | EncodingBlob | 是 | 表示证书吊销列表序列化数据 | +| inStream | [EncodingBlob](#encodingblob) | 是 | 表示证书吊销列表序列化数据 | **返回值**: @@ -3227,7 +3242,7 @@ isRevoked(cert : X509Cert, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------------------- | -| cert | X509Cert | 是 | 表示被检查的证书对象 | +| cert | [X509Cert](#x509cert) | 是 | 表示被检查的证书对象 | | callback | AsyncCallback\ | 否 | 回调函数。表示证书吊销状态,true表示已吊销,false表示未吊销 | @@ -3482,7 +3497,7 @@ verify(key : PubKey) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------------- | -| key | PubKey | 是 | 表示用于验签的公钥对象 | +| key | [PubKey](#pubkey) | 是 | 表示用于验签的公钥对象 | **返回值**: @@ -3564,7 +3579,7 @@ getIssuerName() : DataBlob | 类型 | 说明 | | -------- | ------------------------------ | -| DataBlob | 表示X509证书吊销列表颁发者名称 | +| [DataBlob](#datablob) | 表示X509证书吊销列表颁发者名称 | **示例**: @@ -3937,7 +3952,7 @@ getTbsInfo(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | 否 | 回调函数。表示证书吊销列表的tbsCertList信息 | +| callback | AsyncCallback\<[DataBlob](#datablob)> | 否 | 回调函数。表示证书吊销列表的tbsCertList信息 | **示例**: @@ -3980,7 +3995,7 @@ getTbsInfo() : Promise\ | 类型 | 说明 | | -------- | --------------------------------- | -| Promise\ | 表示证书吊销列表的tbsCertList信息 | +| Promise\<[DataBlob](#datablob)> | 表示证书吊销列表的tbsCertList信息 | **示例**: @@ -4018,7 +4033,7 @@ getSignature() : DataBlob | 类型 | 说明 | | -------- | ------------------------------ | -| DataBlob | 表示X509证书吊销列表的签名数据 | +| [DataBlob](#datablob) | 表示X509证书吊销列表的签名数据 | **示例**: @@ -4082,15 +4097,15 @@ cryptoFramework.createX509Crl(encodingBlob, function (error, x509Crl) { getSignatureAlgOid() : string -表示获取X509证书吊销列表签名的算法OID。 +表示获取X509证书吊销列表签名算法的对象标志符OID(Object Identifier)。OID是由国际标准组织(ISO)的名称注册机构分配。 **系统能力**:SystemCapability.Security.CryptoFramework **返回值**: -| 类型 | 说明 | -| ------ | ----------------------------------- | -| string | 表示X509证书吊销列表签名的算法OID。 | +| 类型 | 说明 | +| ------ | --------------------------------------------- | +| string | 表示X509证书吊销列表签名算法的对象标志符OID。 | **示例**: @@ -4126,7 +4141,7 @@ getSignatureAlgParams() : DataBlob | 类型 | 说明 | | -------- | ---------------------------------- | -| DataBlob | 表示X509证书吊销列表签名的算法参数 | +| [DataBlob](#datablob) | 表示X509证书吊销列表签名的算法参数 | **示例**: @@ -4160,9 +4175,9 @@ createCertChainValidator(algorithm :string) : CertChainValidator **参数**: -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------ | ---- | -------------------- | -| algorithm | string | 是 | 表示证书链校验器算法 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------------------ | +| algorithm | string | 是 | 表示证书链校验器算法。当前仅支持输入“PKIX” | **返回值**: @@ -4187,6 +4202,7 @@ let validator = cryptoFramework.createCertChainValidator("PKIX"); validate(certChain : CertChainData, callback : AsyncCallback\) : void 表示校验X509证书链。 +由于端侧系统时间不可信,证书链校验不包含对证书有效时间的校验。如果需要检查证书的时间有效性,可使用X509证书的[checkValidityWithDate](#checkvaliditywithdate)方法进行检查。详见[证书规格](../../security/cryptoFramework-overview.md#证书规格) **系统能力**:SystemCapability.Security.CryptoFramework @@ -4194,7 +4210,7 @@ validate(certChain : CertChainData, callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------- | ---- | ------------------------ | -| certChain | CertChainData | 是 | 表示X509证书链序列化数据 | +| certChain | [CertChainData](#certchaindata) | 是 | 表示X509证书链序列化数据 | | callback | AsyncCallback\ | 否 | 回调函数。使用AsyncCallback的第一个error参数判断是否校验成功,error为null表示成功,error不为null表示失败 | @@ -4228,6 +4244,7 @@ validator.validate(certChainData, function (error, data) { validate(certChain : CertChainData) : Promise\ 表示校验X509证书链。 +由于端侧系统时间不可信,证书链校验不包含对证书有效时间的校验。如果需要检查证书的时间有效性,可使用X509证书的[checkValidityWithDate](#checkvaliditywithdate)方法进行检查。详见[证书规格](../../security/cryptoFramework-overview.md#证书规格) **系统能力**:SystemCapability.Security.CryptoFramework @@ -4235,7 +4252,7 @@ validate(certChain : CertChainData) : Promise\ | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------- | ---- | ------------------------ | -| certChain | CertChainData | 是 | 表示X509证书链序列化数据。使用AsyncCallback的第一个error参数判断是否校验成功,error为null表示成功,error不为null表示失败 | +| certChain | [CertChainData](#certchaindata) | 是 | 表示X509证书链序列化数据。 | **返回值**: @@ -4305,7 +4322,7 @@ getEncoded(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | 否 | 回调函数。表示被吊销证书的序列化数据 | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | 否 | 回调函数。表示被吊销证书的序列化数据 | **示例**: @@ -4336,7 +4353,7 @@ getEncoded() : Promise\ | 类型 | 说明 | | ------------ | -------------------------- | -| Promise\ | 表示被吊销证书的序列化数据 | +| Promise\<[EncodingBlob](#encodingblob)> | 表示被吊销证书的序列化数据 | **示例**: @@ -4388,7 +4405,7 @@ getCertIssuer(callback : AsyncCallback\) : void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | 否 | 回调函数。表示被吊销证书的颁发者信息 | +| callback | AsyncCallback\<[DataBlob](#datablob)> | 否 | 回调函数。表示被吊销证书的颁发者信息 | **示例**: @@ -4419,7 +4436,7 @@ getCertIssuer() : Promise\ | 类型 | 说明 | | -------- | -------------------------- | -| Promise\ | 表示被吊销证书的颁发者信息 | +| Promise\<[DataBlob](#datablob)> | 表示被吊销证书的颁发者信息 | **示例**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index 9e00ebc9246a773e58de2f7d10c7dfbcbe0086b0..a6f6fa765108af8a4db7b5b195fbe0bd9f678654 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -22,7 +22,7 @@ ## 导入模块 -``` +```js import deviceManager from '@ohos.distributedHardware.deviceManager'; ``` @@ -42,15 +42,19 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager | callback | AsyncCallback<[DeviceManager](#devicemanager)> | 是 | DeviceManager实例创建时调用的回调,返回设备管理器对象实例。 | - 示例: - ``` - deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => { + ```js + try { + deviceManager.createDeviceManager("ohos.samples.jshelloworld", (err, data) => { if (err) { - console.info("createDeviceManager err:" + JSON.stringify(err)); - return; + console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message); + return; } console.info("createDeviceManager success"); let dmInstance = data; - }); + }); + } catch(err) { + console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message); + } ``` ## DeviceInfo @@ -216,7 +220,11 @@ release(): void - 示例: ```js - dmInstance.release(); + try { + dmInstance.release(); + } catch (err) { + console.error("release errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -235,7 +243,11 @@ getTrustedDeviceListSync(): Array<DeviceInfo> - 示例: ```js - var deviceInfoList = dmInstance.getTrustedDeviceListSync(); + try { + var deviceInfoList = dmInstance.getTrustedDeviceListSync(); + } catch (err) { + console.error("getTrustedDeviceListSync errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -254,11 +266,17 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi - 示例: ```js - dmInstance.getTrustedDeviceList((err, data) => { - console.log("getTrustedDeviceList err: " + JSON.stringify(err)); + try { + dmInstance.getTrustedDeviceList((err, data) => { + if (err) { + console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message); + return; + } console.log('get trusted device info: ' + JSON.stringify(data)); - } - ); + }); + } catch (err) { + console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### getTrustedDeviceList8+ @@ -276,11 +294,15 @@ getTrustedDeviceList(): Promise<Array<DeviceInfo>> - 示例: ```js - dmInstance.getTrustedDeviceList().then((data) => { + try { + dmInstance.getTrustedDeviceList().then((data) => { console.log('get trusted device info: ' + JSON.stringify(data)); - }).catch((err) => { - console.log("getTrustedDeviceList err: " + JSON.stringify(err)); - }); + }).catch((err) => { + console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message); + }); + } catch (err) { + console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### getLocalDeviceInfoSync8+ @@ -298,7 +320,11 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) - 示例: ```js - var deviceInfo = dmInstance.getLocalDeviceInfoSync(); + try { + var deviceInfo = dmInstance.getLocalDeviceInfoSync(); + } catch (err) { + console.error("getLocalDeviceInfoSync errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -317,11 +343,17 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void - 示例: ```js - dmInstance.getLocalDeviceInfo((err, data) => { - console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); - console.log('get local device info: ' + JSON.stringify(data)); + try { + dmInstance.getLocalDeviceInfo((err, data) => { + if (err) { + console.error("getLocalDeviceInfo errCode:" + err.code + ",errMessage:" + err.message); + return; } - ); + console.log('get local device info: ' + JSON.stringify(data)); + }); + } catch (err) { + console.error("getLocalDeviceInfo errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### getLocalDeviceInfo8+ @@ -339,11 +371,15 @@ getLocalDeviceInfo(): Promise<DeviceInfo> - 示例: ```js - dmInstance.getLocalDeviceInfo().then((data) => { + try { + dmInstance.getLocalDeviceInfo().then((data) => { console.log('get local device info: ' + JSON.stringify(data)); - }).catch((err) => { - console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); - }); + }).catch((err) => { + console.error("getLocalDeviceInfo errCode:" + err.code + ",errMessage:" + err.message); + }); + } catch (err) { + console.error("getLocalDeviceInfo errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### startDeviceDiscovery8+
@@ -372,7 +408,11 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void "isWakeRemote": false, "capability": 1 }; - dmInstance.startDeviceDiscovery(subscribeInfo); // 当有设备发现时,通过deviceFound回调通知给应用程序 + try { + dmInstance.startDeviceDiscovery(subscribeInfo); // 当有设备发现时,通过deviceFound回调通知给应用程序 + } catch (err) { + console.error("startDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### startDeviceDiscovery9+
@@ -411,7 +451,11 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void } ] }; - dmInstance.startDeviceDiscovery(subscribeInfo, JSON.stringify(filterOptions)); // 当有设备发现时,通过deviceFound回调通知给应用程序 + try { + dmInstance.startDeviceDiscovery(subscribeInfo, JSON.stringify(filterOptions)); // 当有设备发现时,通过deviceFound回调通知给应用程序 + } catch (err) { + console.error("startDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### stopDeviceDiscovery @@ -430,7 +474,11 @@ stopDeviceDiscovery(subscribeId: number): void - 示例: ```js // 入参需要和startDeviceDiscovery接口传入的subscribeId配对使用 - dmInstance.stopDeviceDiscovery(subscribeId); + try { + dmInstance.stopDeviceDiscovery(subscribeId); + } catch (err) { + console.error("stopDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### publishDeviceDiscovery9+
@@ -456,7 +504,11 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void "freq": 2, // 高频率 "ranging": 1 // 支持发现时测距 }; - dmInstance.publishDeviceDiscovery(publishInfo); // 当有发布结果时,通过回调通知给应用程序 + try { + dmInstance.publishDeviceDiscovery(publishInfo); // 当有发布结果时,通过回调通知给应用程序 + } catch (err) { + console.error("publishDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### unPublishDeviceDiscovery9+
@@ -475,7 +527,11 @@ unPublishDeviceDiscovery(publishId: number): void - 示例: ```js // 入参需要和publishDeviceDiscovery接口传入的publishId配对使用 - dmInstance.unPublishDeviceDiscovery(publishId); + try { + dmInstance.unPublishDeviceDiscovery(publishId); + } catch (err) { + console.error("unPublishDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### authenticateDevice @@ -505,14 +561,18 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async "authType": 1, // 认证类型: 1 - 无账号PIN码认证 "extraInfo": {} } - dmInstance.authenticateDevice(deviceInfo, authParam, (err, data) => { + try { + dmInstance.authenticateDevice(deviceInfo, authParam, (err, data) => { if (err) { - console.info(TAG + "authenticateDevice err:" + JSON.stringify(err)); + console.error("authenticateDevice errCode:" + err.code + ",errMessage:" + err.message); return; } console.info(TAG + "authenticateDevice result:" + JSON.stringify(data)); token = data.pinToken; - }); + }); + } catch (err) { + console.error("authenticateDevice errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### unAuthenticateDevice8+ @@ -530,7 +590,11 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void - 示例: ```js - dmInstance.unAuthenticateDevice(deviceInfo); + try { + dmInstance.unAuthenticateDevice(deviceInfo); + } catch (err) { + console.error("unAuthenticateDevice errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -555,13 +619,17 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le "token": xxxxxx, "extraInfo": {} } - dmInstance.verifyAuthInfo(authInfo, (err, data) => { + try { + dmInstance.verifyAuthInfo(authInfo, (err, data) => { if (err) { - console.info(TAG + "verifyAuthInfo err:" + JSON.stringify(err)); + console.error("verifyAuthInfo errCode:" + err.code + ",errMessage:" + err.message); return; } console.info(TAG + "verifyAuthInfo result:" + JSON.stringify(data)); - }); + }); + } catch (err) { + console.error("verifyAuthInfo errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -581,10 +649,13 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange - 示例: ```js - dmInstance.on('deviceStateChange', (data) => { - console.info("deviceStateChange on:" + JSON.stringify(data)); - } - ); + try { + dmInstance.on('deviceStateChange', (data) => { + console.info("deviceStateChange on:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceStateChange errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -604,10 +675,13 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang - 示例: ```js - dmInstance.off('deviceStateChange', (data) => { - console.info('deviceStateChange' + JSON.stringify(data)); - } - ); + try { + dmInstance.off('deviceStateChange', (data) => { + console.info('deviceStateChange' + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceStateChange errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -627,10 +701,13 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev - 示例: ```js - dmInstance.on('deviceFound', (data) => { - console.info("deviceFound:" + JSON.stringify(data)); - } - ); + try { + dmInstance.on('deviceFound', (data) => { + console.info("deviceFound:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceFound errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### off('deviceFound') @@ -649,10 +726,13 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D - 示例: ```js - dmInstance.off('deviceFound', (data) => { - console.info('deviceFound' + JSON.stringify(data)); - } - ); + try { + dmInstance.off('deviceFound', (data) => { + console.info('deviceFound' + JSON.stringify(data)); + }); + } catch (err) { + console.error("deviceFound errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### on('discoverFail') @@ -671,10 +751,13 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu - 示例: ```js - dmInstance.on('discoverFail', (data) => { - this.log("discoverFail on:" + JSON.stringify(data)); - } - ); + try { + dmInstance.on('discoverFail', (data) => { + console.info("discoverFail on:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("discoverFail errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### off('discoverFail') @@ -693,10 +776,13 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: - 示例: ```js - dmInstance.off('deviceFound', (data) => { - console.info('deviceFound' + JSON.stringify(data)); - } - ); + try { + dmInstance.off('discoverFail', (data) => { + console.info('discoverFail' + JSON.stringify(data)); + }); + } catch (err) { + console.error("discoverFail errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### on('publishSuccess')9+ @@ -715,10 +801,13 @@ on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): voi - 示例: ```js - dmInstance.on('publishSuccess', (data) => { - console.info("publishSuccess:" + JSON.stringify(data)); - } - ); + try { + dmInstance.on('publishSuccess', (data) => { + console.info("publishSuccess:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("publishSuccess errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### off('publishSuccess')9+ @@ -737,10 +826,13 @@ off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): v - 示例: ```js - dmInstance.off('publishSuccess', (data) => { - console.info('publishSuccess' + JSON.stringify(data)); - } - ); + try { + dmInstance.off('publishSuccess', (data) => { + console.info('publishSuccess' + JSON.stringify(data)); + }); + } catch (err) { + console.error("publishSuccess errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### on('publishFail')9+ @@ -759,10 +851,13 @@ on(type: 'publishFail', callback: Callback<{ publishId: number, reason: numbe - 示例: ```js - dmInstance.on('publishFail', (data) => { - this.log("publishFail on:" + JSON.stringify(data)); - } - ); + try { + dmInstance.on('publishFail', (data) => { + console.info("publishFail on:" + JSON.stringify(data)); + }); + } catch (err) { + console.error("publishFail errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### off('publishFail')9+ @@ -781,10 +876,13 @@ off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: num - 示例: ```js - dmInstance.off('publishFail', (data) => { - console.info('publishFail' + JSON.stringify(data)); - } - ); + try { + dmInstance.off('publishFail', (data) => { + console.info('publishFail' + JSON.stringify(data)); + }); + } catch (err) { + console.error("publishFail errCode:" + err.code + ",errMessage:" + err.message); + } ``` ### on('serviceDie') @@ -803,10 +901,13 @@ on(type: 'serviceDie', callback: () => void): void - 示例: ```js - dmInstance.on("serviceDie", () => { - console.info("serviceDie on"); - } - ); + try { + dmInstance.on("serviceDie", () => { + console.info("serviceDie on"); + }); + } catch (err) { + console.error("serviceDie errCode:" + err.code + ",errMessage:" + err.message); + } ``` @@ -826,8 +927,11 @@ off(type: 'serviceDie', callback?: () => void): void - 示例: ```js - dmInstance.off("serviceDie", () => { - console.info("serviceDie off"); - } - ); + try { + dmInstance.off("serviceDie", () => { + console.info("serviceDie off"); + }); + } catch (err) { + console.error("serviceDie errCode:" + err.code + ",errMessage:" + err.message); + } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 233e4da08e39a0d93482ba0b73a315499b2fd341..91d9a4e985f3e52912d1ebd31d70bcda83389d7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -11,7 +11,6 @@ import display from '@ohos.display'; ``` - ## DisplayState 显示设备的状态枚举。 @@ -65,61 +64,6 @@ import display from '@ohos.display'; | boundingRects | Array\<[Rect](#rect9)> | 是 | 否 | 挖孔、刘海等区域的边界矩形。 | | waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | 是 | 否 | 瀑布屏曲面部分显示区域。 | -## display.getDefaultDisplay - -getDefaultDisplay(callback: AsyncCallback<Display>): void - -获取当前默认的display对象,使用callback异步回调。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[Display](#display)> | 是 | 回调函数。返回当前默认的display对象。 | - -**示例:** - -```js -var displayClass = null; -display.getDefaultDisplay((err, data) => { - if (err.code) { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); - displayClass = data; -}); -``` - -## display.getDefaultDisplay - -getDefaultDisplay(): Promise<Display> - -获取当前默认的display对象,使用Promise异步回调。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------- | ---------------------------------------------- | -| Promise<[Display](#display)> | Promise对象。返回当前默认的display对象。 | - -**示例:** - -```js -var displayClass = null; -let promise = display.getDefaultDisplay(); -promise.then((data) => { - displayClass = data; - console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); -}); -``` - ## display.getDefaultDisplaySync9+ getDefaultDisplaySync(): Display @@ -134,15 +78,27 @@ getDefaultDisplaySync(): Display | ------------------------------| ----------------------------------------------| | [Display](#display) | 返回默认的display对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var displayClass = display.getDefaultDisplaySync(); +try { + let displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +}; ``` -## display.getAllDisplay +## display.getAllDisplays9+ -getAllDisplay(callback: AsyncCallback<Array<Display>>): void +getAllDisplays(callback: AsyncCallback<Array<Display>>): void 获取当前所有的display对象,使用callback异步回调。 @@ -150,14 +106,24 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | ------------------------------- | -| callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调函数。返回当前所有的display对象。 | +| callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调函数。返回当前所有的display对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | **示例:** ```js -display.getAllDisplay((err, data) => { +let displayClass = null; +display.getAllDisplays((err, data) => { + displayClass = data; if (err.code) { console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); return; @@ -166,9 +132,9 @@ display.getAllDisplay((err, data) => { }); ``` -## display.getAllDisplay +## display.getAllDisplays9+ -getAllDisplay(): Promise<Array<Display>> +getAllDisplays(): Promise<Array<Display>> 获取当前所有的display对象,使用Promise异步回调。 @@ -176,15 +142,25 @@ getAllDisplay(): Promise<Array<Display>> **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | ----------------------------------------------- | ------------------------------------------------------- | | Promise<Array<[Display](#display)>> | Promise对象。返回当前所有的display对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -let promise = display.getAllDisplay(); +let displayClass = null; +let promise = display.getAllDisplays(); promise.then((data) => { + displayClass = data; console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); }).catch((err) => { console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); @@ -195,7 +171,7 @@ promise.then((data) => { hasPrivateWindow(displayId: number): boolean -查询指定display对象上是否有可见的隐私窗口。可通过[setPrivacyMode](js-apis-window.md#setprivacymode7)接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。 +查询指定display对象上是否有可见的隐私窗口。可通过[setWindowPrivacyMode()](js-apis-window.md#setwindowprivacymode9)接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。 **系统接口:** 此接口为系统接口。 @@ -213,28 +189,38 @@ hasPrivateWindow(displayId: number): boolean | -------------------------------- |-----------------------------------------------------------------------| |boolean | 查询的display对象上是否有可见的隐私窗口。
true表示此display对象上有可见的隐私窗口,false表示此display对象上没有可见的隐私窗口。
| +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -var displayClass = null; -display.getDefaultDisplay((err, data) => { - if (err.code) { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); +let displayClass = null; +try { + displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); return; - } - console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); - displayClass = data; -}); +}; -var ret = display.hasPrivateWindow(displayClass.id); +try { + let ret = display.hasPrivateWindow(displayClass.id); +} catch (exception) { + console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); +}; if (ret == undefined) { - console.log("Failed to check has privateWindow or not."); + console.log("Failed to check has privateWindow or not."); } if (ret) { console.log("There has privateWindow."); } else if (!ret) { console.log("There has no privateWindow."); -} +}; ``` ## display.on('add'|'remove'|'change') @@ -255,10 +241,14 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void **示例:** ```js -var callback = (data) => { +let callback = (data) => { console.info('Listening enabled. Data: ' + JSON.stringify(data)); } -display.on("add", callback); +try { + display.on("add", callback); +} catch (exception) { + console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); +}; ``` ## display.off('add'|'remove'|'change') @@ -279,13 +269,139 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void **示例:** ```js -display.off("remove"); +try { + display.off("remove"); +} catch (exception) { + console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); +}; +``` + +## display.getDefaultDisplay(deprecated) + +getDefaultDisplay(callback: AsyncCallback<Display>): void + +获取当前默认的display对象,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[Display](#display)> | 是 | 回调函数。返回当前默认的display对象。 | + +**示例:** + +```js +let displayClass = null; +display.getDefaultDisplay((err, data) => { + if (err.code) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); + displayClass = data; +}); +``` + +## display.getDefaultDisplay(deprecated) + +getDefaultDisplay(): Promise<Display> + +获取当前默认的display对象,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | ---------------------------------------------- | +| Promise<[Display](#display)> | Promise对象。返回当前默认的display对象。 | + +**示例:** + +```js +let displayClass = null; +let promise = display.getDefaultDisplay(); +promise.then((data) => { + displayClass = data; + console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); +}); +``` + +## display.getAllDisplay(deprecated) + +getAllDisplay(callback: AsyncCallback<Array<Display>>): void + +获取当前所有的display对象,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调函数。返回当前所有的display对象。 | + +**示例:** + +```js +display.getAllDisplay((err, data) => { + if (err.code) { + console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); +}); +``` + +## display.getAllDisplay(deprecated) + +getAllDisplay(): Promise<Array<Display>> + +获取当前所有的display对象,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9-1)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------- | ------------------------------------------------------- | +| Promise<Array<[Display](#display)>> | Promise对象。返回当前所有的display对象。 | + +**示例:** + +```js +let promise = display.getAllDisplay(); +promise.then((data) => { + console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); +}); ``` ## Display 屏幕实例。描述display对象的属性和方法。 -下列API示例中都需先使用[getAllDisplay()](#displaygetalldisplay)、[getDefaultDisplay()](#displaygetdefaultdisplay)、[getDefaultDisplaySync()](#displaygetdefaultdisplaysync)中的任一方法获取到Display实例,再通过此实例调用对应方法。 +下列API示例中都需先使用[getAllDisplays()](#displaygetalldisplays9)、[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)中的任一方法获取到Display实例,再通过此实例调用对应方法。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -312,20 +428,36 @@ getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------------------- | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | 是 | 回调函数。当获取信息成功,err为undefined,data为获取到的CutoutInfo对象;否则err为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +try { + let displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +}; + displayClass.getCutoutInfo((err, data) => { if (err.code) { - console.error('Failed to get cutoutInfo. Cause: ' + JSON.stringify(err)); + console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); return; } console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); -}) +}); ``` ### getCutoutInfo9+ getCutoutInfo(): Promise<CutoutInfo> @@ -340,11 +472,25 @@ getCutoutInfo(): Promise<CutoutInfo> | ------------------- | ------------------------- | | Promise<[CutoutInfo](#cutoutinfo9)> | Promise对象,返回描述不可用屏幕区域的CutoutInfo对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +try { + let displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +}; + let promise = displayClass.getCutoutInfo(); promise.then((data) => { console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); }); -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index f907332874dfe0cdc8d8362a33f75e59008fb93f..bede5e9af50dea33ea37468b028d05b6d16e8e06 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -562,7 +562,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi 订阅服务状态变更通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -593,7 +593,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v 取消订阅服务状态变更通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -680,7 +680,7 @@ KVStore常量。 表示数据库模式,可以在创建或打开数据库时创建Schema对象并将它们放入[Options](#options)中。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | 名称 | 类型 | 说明 | | --- | ---- | ----------------------- | @@ -695,13 +695,13 @@ constructor() 用于创建Schema实例的构造函数。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore ## FieldNode8+ ## 表示 Schema 实例的节点,提供定义存储在数据库中的值的方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | 名称 | 类型 | 说明 | | --- | ---- | ----------------------- | @@ -715,7 +715,7 @@ constructor(name: string) 用于创建带有string字段FieldNode实例的构造函数。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -729,7 +729,7 @@ appendChild(child: FieldNode): boolean 在当前 FieldNode 中添加一个子节点。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-emitter.md b/zh-cn/application-dev/reference/apis/js-apis-emitter.md index 989bd312f6990d5fcf39b278710939057ef2e1de..7c422e7985c55146344c7b2a165f8c8adea58cd6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-emitter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-emitter.md @@ -26,10 +26,10 @@ on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | 是 | 持续订阅的事件 | -| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | --------------------------------------- | +| event | [InnerEvent](#innerevent) | 是 | 持续订阅的事件,其中EventPriority不生效 | +| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | **示例:** @@ -53,10 +53,10 @@ once(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdat **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | 是 | 单次订阅的事件 | -| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | --------------------------------------- | +| event | [InnerEvent](#innerevent) | 是 | 单次订阅的事件,其中EventPriority不生效 | +| callback | Callback\<[EventData](#eventdata)\> | 是 | 接收订阅事件时的回调处理 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md index 174ec0ebb77cd895952b59a0939689749c7da52d..1895a0eb1687b281cd3f8fe211f26f850f284f9d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md @@ -60,20 +60,24 @@ write(info: SysEventInfo, callback: AsyncCallback<void>): void ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}, (err, val) => { - // do something here. -}) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }, (err, val) => { + // do something here. + }) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` @@ -102,26 +106,30 @@ write(info: SysEventInfo): Promise<void> ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}).then( - (val) => { - // do something here. - } -).catch( - (err) => { - // do something here. - } -) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` ## RuleType @@ -177,32 +185,30 @@ addWatcher(watcher: Watcher): number | ------ | ----------------------------- | ---- | ------------------------ | | watcher | [Watcher](#watcher) | 是 | 系统事件订阅者对象。 | -**返回值:** - -| 类型 | 说明 | -| ------- | -------------------------------------------------- | -| number | 系统事件订阅结果。
- 0表示订阅成功。
- 负值表示订阅失败。 | - **示例:** ```js import hiSysEvent from '@ohos.hiSysEvent'; let watcher = { - rules: [{ - domain: "RELIABILITY", - name: "STACK", - tag: "STABILITY", - ruleType: hiSysEvent.RuleType.WHOLE_WORD, - }], - onEvent: (info) => { - // do something here. - }, - onServiceDied: () => { - // do something here. - } + rules: [{ + domain: "RELIABILITY", + name: "STACK", + tag: "STABILITY", + ruleType: hiSysEvent.RuleType.WHOLE_WORD, + }], + onEvent: (info) => { + // do something here. + }, + onServiceDied: () => { + // do something here. + } +} +try { + hiSysEvent.addWatcher(watcher) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); } -let ret = hiSysEvent.addWatcher(watcher) ``` ## hiSysEvent.removeWatcher @@ -221,33 +227,31 @@ removeWatcher(watcher: Watcher): number | ------ | ------------- | ---- | ------------------------ | | watcher | [Watcher](#watcher) | 是 | 系统事件订阅者对象。 | -**返回值:** - -| 类型 | 说明 | -| ------- | ----------------------------------------------------------- | -| number | 取消订阅系统事件的结果。
- 0表示取消订阅成功。
- 负值表示取消订阅失败。 | - **示例:** ```js import hiSysEvent from '@ohos.hiSysEvent'; let watcher = { - rules: [{ - domain: "RELIABILITY", - name: "STACK", - tag: "STABILITY", - ruleType: hiSysEvent.RuleType.WHOLE_WORD, - }], - onEvent: (info) => { - // do something here. - }, - onServiceDied: () => { - // do something here. - } + rules: [{ + domain: "RELIABILITY", + name: "STACK", + tag: "STABILITY", + ruleType: hiSysEvent.RuleType.WHOLE_WORD, + }], + onEvent: (info) => { + // do something here. + }, + onServiceDied: () => { + // do something here. + } +} +try { + let ret = hiSysEvent.addWatcher(watcher) + hiSysEvent.removeWatcher(watcher) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); } -let ret = hiSysEvent.addWatcher(watcher) -hiSysEvent.removeWatcher(watcher) ``` ## QueryArg @@ -281,7 +285,7 @@ hiSysEvent.removeWatcher(watcher) | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| onQuery | function | 是 | 返回查询到的系统事件的回调方法(infos: [SysEventInfo](#syseventinfo)[], seqs: number[]) => void。 | +| onQuery | function | 是 | 返回查询到的系统事件的回调方法(infos: [SysEventInfo](#syseventinfo)[]) => void。 | | onComplete | function | 是 | 查询结果统计的回调方法(reason: number, total: number) => void。 | ## hiSysEvent.query @@ -302,44 +306,42 @@ query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): number | rules | [QueryRule](#queryrule)[] | 是 | 查询规则数组,每次查询可配置多个查询规则。 | | querier | [Querier](#querier) | 是 | 查询者对象,包含查询结果及结束的相关回调。 | -**返回值:** - -| 类型 | 说明 | -| ------- | ----------------------------------------------------------- | -| number | 系统事件查询的结果。
- 0表示查询成功.
- 负值表示查询失败。 | - **示例:** ```js import hiSysEvent from '@ohos.hiSysEvent'; -hiSysEvent.write({ - domain: "RELIABILITY", - name: "STACK", - eventType: hiSysEvent.EventType.FAULT, - params: { - PID: 487, - UID: 103, - PACKAGE_NAME: "com.ohos.hisysevent.test", - PROCESS_NAME: "syseventservice", - MSG: "no msg." - } -}, (err, val) => { - // do something here. -}) -hiSysEvent.query({ - beginTime: -1, - endTime: -1, - maxEvents: 5, -}, [{ - domain: "RELIABILITY", - names: ["STACK"], -}], { - onQuery: function (infos, seqs) { - // do something here. - }, - onComplete: function(reason, total) { - // do something here. - } -}) +try { + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 487, + UID: 103, + PACKAGE_NAME: "com.ohos.hisysevent.test", + PROCESS_NAME: "syseventservice", + MSG: "no msg." + } + }, (err, val) => { + // do something here. + }) + hiSysEvent.query({ + beginTime: -1, + endTime: -1, + maxEvents: 5, + }, [{ + domain: "RELIABILITY", + names: ["STACK"], + }], { + onQuery: function (infos) { + // do something here. + }, + onComplete: function(reason, total) { + // do something here. + } + }) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index dab4a75c0a4ee4f5079cfd0fcce5497b76be0abc..32319b0f5e36631db7f00257255834b220947330 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -52,7 +52,7 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | 是 | 回调函数。异步返回VideoPlayer实例,可用于管理和播放视频媒体。 | +| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | 是 | 回调函数。异步返回VideoPlayer实例,失败时返回null。可用于管理和播放视频媒体。 | **示例:** @@ -79,9 +79,9 @@ createVideoPlayer(): Promise<[VideoPlayer](#videoplayer8)> **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ----------------------------------- | -| Promise<[VideoPlayer](#videoplayer8)> | Promise对象。异步返回VideoPlayer实例,可用于管理和播放视频媒体。 | +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------------------------------ | +| Promise<[VideoPlayer](#videoplayer8)> | Promise对象。异步返回VideoPlayer实例,失败时返回null。可用于管理和播放视频媒体。 | **示例:** @@ -111,9 +111,9 @@ createAudioRecorder(): AudioRecorder **返回值:** -| 类型 | 说明 | -| ------------------------------- | ----------------------------------------- | -| [AudioRecorder](#audiorecorder) | 返回AudioRecorder类实例,失败时返回null。 | +| 类型 | 说明 | +| ------------------------------- | ------------------------------------------------------------ | +| [AudioRecorder](#audiorecorder) | 返回AudioRecorder类实例,失败时返回null。可用于录制音频媒体。 | **示例:** @@ -134,7 +134,7 @@ createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | 是 | 回调函数。异步返回VideoRecorder实例,可用于录制视频媒体。 | +| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | 是 | 回调函数。异步返回VideoRecorder实例,失败时返回null。可用于录制视频媒体。 | **示例:** @@ -162,9 +162,9 @@ createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> **返回值:** -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | Promise对象。异步返回VideoRecorder实例,可用于录制视频媒体。 | +| 类型 | 说明 | +| ----------------------------------------- | ------------------------------------------------------------ | +| Promise<[VideoRecorder](#videorecorder9)> | Promise对象。异步返回VideoRecorder实例,失败时返回null。可用于录制视频媒体。 | **示例:** @@ -361,9 +361,9 @@ seek(timeMs: number): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------ | -| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms)。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------------------------------------------------------- | +| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms),取值范围[0, duration]。 | **示例:** @@ -426,9 +426,9 @@ getTrackDescription(callback: AsyncCallback>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | -------------------------- | -| callback | AsyncCallback> | 是 | 获取音频轨道信息回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| callback | AsyncCallback> | 是 | 音频轨道信息MediaDescription数组回调方法。 | **示例:** @@ -462,9 +462,9 @@ getTrackDescription(): Promise> **返回值:** -| 类型 | 说明 | -| ------------------------------------------------------ | ------------------------------- | -| Promise> | 获取音频轨道信息Promise返回值。 | +| 类型 | 说明 | +| ------------------------------------------------------ | ----------------------------------------------- | +| Promise> | 音频轨道信息MediaDescription数组Promise返回值。 | **示例:** @@ -496,7 +496,7 @@ for (let i = 0; i < arrayDescription.length; i++) { on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferinginfotype8), value: number) => void): void -开始订阅音频缓存更新事件。 +开始订阅音频缓存更新事件。仅网络播放支持该订阅事件。 **系统能力:** SystemCapability.Multimedia.Media.AudioPlayer @@ -593,7 +593,7 @@ audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 on(type: 'timeUpdate', callback: Callback\): void -开始订阅音频播放时间更新事件。 +开始订阅音频播放时间更新事件。处于播放状态时,每隔1s上报一次该事件。 **系统能力:** SystemCapability.Multimedia.Media.AudioPlayer @@ -1013,10 +1013,10 @@ seek(timeMs: number, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | ---- | ------------------------------------ | -| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms)。 | -| callback | function | 是 | 跳转到指定播放位置的回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | ------------------------------------------------------------ | +| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms),取值范围为[0, duration]。 | +| callback | function | 是 | 跳转到指定播放位置的回调方法。 | **示例:** @@ -1041,11 +1041,11 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------ | -| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms)。 | -| mode | [SeekMode](#seekmode8) | 是 | 跳转模式。 | -| callback | function | 是 | 跳转到指定播放位置的回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms),取值范围为[0, duration]。 | +| mode | [SeekMode](#seekmode8) | 是 | 跳转模式。 | +| callback | function | 是 | 跳转到指定播放位置的回调方法。 | **示例:** @@ -1071,16 +1071,16 @@ seek(timeMs: number, mode?:SeekMode): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------------- | ---- | ------------------------------------ | -| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms)。 | -| mode | [SeekMode](#seekmode8) | 否 | 跳转模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------- | ---- | ------------------------------------------------------------ | +| timeMs | number | 是 | 指定的跳转时间节点,单位毫秒(ms),取值范围为[0, duration]。 | +| mode | [SeekMode](#seekmode8) | 否 | 跳转模式。 | **返回值:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 跳转到指定播放位置的Promise返回值。 | +| 类型 | 说明 | +| -------------- | ------------------------------------------- | +| Promise\ | 跳转到指定播放位置的Promise返回值,单位ms。 | **示例:** @@ -1219,9 +1219,9 @@ getTrackDescription(callback: AsyncCallback>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | -------------------------- | -| callback | AsyncCallback> | 是 | 获取视频轨道信息回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| callback | AsyncCallback> | 是 | 视频轨道信息MediaDescription数组回调方法。 | **示例:** @@ -1255,9 +1255,9 @@ getTrackDescription(): Promise> **返回值:** -| 类型 | 说明 | -| ------------------------------------------------------ | ------------------------------- | -| Promise> | 获取视频轨道信息Promise返回值。 | +| 类型 | 说明 | +| ------------------------------------------------------ | ----------------------------------------------- | +| Promise> | 视频轨道信息MediaDescription数组Promise返回值。 | **示例:** @@ -1331,9 +1331,9 @@ setSpeed(speed:number): Promise\ **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------- | -| Promise\ | 通过Promise获取设置结果。 | +| 类型 | 说明 | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | 播放速度Promise返回值,具体见[PlaybackSpeed](#playbackspeed8)。 | **示例:** @@ -1388,13 +1388,13 @@ selectBitrate(bitrate:number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | -------------------------------------------- | -| bitrate | number | 是 | 指定码率播放,用于hls多码率场景,单位为bps。 | +| bitrate | number | 是 | 指定播放码率,用于hls多码率场景,单位为bps。 | **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------- | -| Promise\ | 通过Promise获取设置结果。 | +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise\ | 指定播放码率Promise返回值。 | **示例:** @@ -1434,7 +1434,7 @@ videoPlayer.on('playbackCompleted', () => { on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void -开始监听视频缓存更新事件。 +开始监听视频缓存更新事件。仅网络播放支持该订阅事件。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index da1b64893711283291529e72b1f4c255f8f29cf3..454ff579051073954699875f933493f999809aad 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -34,7 +34,11 @@ publish(request: NotificationRequest, callback: AsyncCallback\): void ```js //publish回调 function publishCallback(err) { - console.info("==========================>publishCallback=======================>"); + if (err.code) { + console.info("publish failed " + JSON.stringify(err)); + } else { + console.info("publish success"); + } } //通知Request对象 var notificationRequest = { @@ -83,7 +87,7 @@ var notificationRequest = { } } Notification.publish(notificationRequest).then(() => { - console.info("==========================>publishCallback=======================>"); + console.info("publish sucess"); }); ``` @@ -113,7 +117,11 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\publishCallback=======================>"); + if (err.code) { + console.info("publish failed " + JSON.stringify(err)); + } else { + console.info("publish success"); + } } // 接收通知的用户ID var userId = 1 @@ -169,7 +177,7 @@ var notificationRequest = { var userId = 1 Notification.publish(notificationRequest, userId).then(() => { - console.info("==========================>publishCallback=======================>"); + console.info("publish sucess"); }); ``` @@ -195,7 +203,11 @@ cancel(id: number, label: string, callback: AsyncCallback\): void ```js //cancel回调 function cancelCallback(err) { - console.info("==========================>cancelCallback=======================>"); + if (err.code) { + console.info("cancel failed " + JSON.stringify(err)); + } else { + console.info("cancel success"); + } } Notification.cancel(0, "label", cancelCallback) ``` @@ -221,7 +233,7 @@ cancel(id: number, label?: string): Promise\ ```js Notification.cancel(0).then(() => { - console.info("==========================>cancelCallback=======================>"); + console.info("cancel sucess"); }); ``` @@ -247,7 +259,11 @@ cancel(id: number, callback: AsyncCallback\): void ```js //cancel回调 function cancelCallback(err) { - console.info("==========================>cancelCallback=======================>"); + if (err.code) { + console.info("cancel failed " + JSON.stringify(err)); + } else { + console.info("cancel success"); + } } Notification.cancel(0, cancelCallback) ``` @@ -273,7 +289,11 @@ cancelAll(callback: AsyncCallback\): void ```js //cancel回调 function cancelAllCallback(err) { - console.info("==========================>cancelAllCallback=======================>"); + if (err.code) { + console.info("cancelAll failed " + JSON.stringify(err)); + } else { + console.info("cancelAll success"); + } } Notification.cancelAll(cancelAllCallback) ``` @@ -292,7 +312,7 @@ cancelAll(): Promise\ ```js Notification.cancelAll().then(() => { - console.info("==========================>cancelAllCallback=======================>"); + console.info("cancelAll sucess"); }); ``` @@ -322,7 +342,11 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void ```js //addslot回调 function addSlotCallBack(err) { - console.info("==========================>addSlotCallBack=======================>"); + if (err.code) { + console.info("addSlot failed " + JSON.stringify(err)); + } else { + console.info("addSlot success"); + } } //通知slot对象 var notificationSlot = { @@ -359,7 +383,7 @@ var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.addSlot(notificationSlot).then(() => { - console.info("==========================>addSlotCallback=======================>"); + console.info("addSlot sucess"); }); ``` @@ -385,7 +409,11 @@ addSlot(type: SlotType, callback: AsyncCallback\): void ```js //addslot回调 function addSlotCallBack(err) { - console.info("==========================>addSlotCallBack=======================>"); + if (err.code) { + console.info("addSlot failed " + JSON.stringify(err)); + } else { + console.info("addSlot success"); + } } Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) ``` @@ -410,7 +438,7 @@ addSlot(type: SlotType): Promise\ ```js Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { - console.info("==========================>addSlotCallback=======================>"); + console.info("addSlot sucess"); }); ``` @@ -440,7 +468,11 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi ```js //addSlots回调 function addSlotsCallBack(err) { - console.info("==========================>addSlotsCallBack=======================>"); + if (err.code) { + console.info("addSlots failed " + JSON.stringify(err)); + } else { + console.info("addSlots success"); + } } //通知slot对象 var notificationSlot = { @@ -485,7 +517,7 @@ var notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray).then(() => { - console.info("==========================>addSlotCallback=======================>"); + console.info("addSlots sucess"); }); ``` @@ -511,7 +543,11 @@ getSlot(slotType: SlotType, callback: AsyncCallback\): void ```js //getSlot回调 function getSlotCallback(err,data) { - console.info("==========================>getSlotCallback=======================>"); + if (err.code) { + console.info("getSlot failed " + JSON.stringify(err)); + } else { + console.info("getSlot success"); + } } var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.getSlot(slotType, getSlotCallback) @@ -544,7 +580,7 @@ getSlot(slotType: SlotType): Promise\ ```js var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.getSlot(slotType).then((data) => { - console.info("==========================>getSlotCallback=======================>"); + console.info("getSlot sucess, data: " + JSON.stringify(data)); }); ``` @@ -569,7 +605,11 @@ getSlots(callback: AsyncCallback>): void ```js //getSlots回调 function getSlotsCallback(err,data) { - console.info("==========================>getSlotsCallback=======================>"); + if (err.code) { + console.info("getSlots failed " + JSON.stringify(err)); + } else { + console.info("getSlots success"); + } } Notification.getSlots(getSlotsCallback) ``` @@ -594,7 +634,7 @@ getSlots(): Promise\> ```js Notification.getSlots().then((data) => { - console.info("==========================>getSlotsCallback=======================>"); + console.info("getSlots sucess, data: " + JSON.stringify(data)); }); ``` @@ -620,7 +660,11 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\): void ```js //removeSlot回调 function removeSlotCallback(err) { - console.info("==========================>removeSlotCallback=======================>"); + if (err.code) { + console.info("removeSlot failed " + JSON.stringify(err)); + } else { + console.info("removeSlot success"); + } } var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType,removeSlotCallback) @@ -647,7 +691,7 @@ removeSlot(slotType: SlotType): Promise\ ```js var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType).then(() => { - console.info("==========================>removeSlotCallback=======================>"); + console.info("removeSlot sucess"); }); ``` @@ -671,7 +715,11 @@ removeAllSlots(callback: AsyncCallback\): void ```js function removeAllCallBack(err) { - console.info("================>removeAllCallBack=======================>"); + if (err.code) { + console.info("removeAllSlots failed " + JSON.stringify(err)); + } else { + console.info("removeAllSlots success"); + } } Notification.removeAllSlots(removeAllCallBack) ``` @@ -690,7 +738,7 @@ removeAllSlots(): Promise\ ```js Notification.removeAllSlots().then(() => { - console.info("==========================>removeAllCallBack=======================>"); + console.info("removeAllSlots sucess"); }); ``` @@ -721,10 +769,14 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ```js //subscribe回调 function subscribeCallback(err) { - console.info("==========================>subscribeCallback=======================>"); + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe success"); + } } function onConsumeCallback(data) { - console.info("==========================>onConsumeCallback=======================>"); + console.info("Consume callback: " + JSON.stringify(data)); } var subscriber = { onConsume: onConsumeCallback @@ -760,10 +812,14 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): ```js function subscribeCallback(err) { - console.info("==========================>subscribeCallback=======================>"); + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe success"); + } } function onConsumeCallback(data) { - console.info("==========================>onConsumeCallback=======================>"); + console.info("Consume callback: " + JSON.stringify(data)); } var subscriber = { onConsume: onConsumeCallback @@ -796,13 +852,17 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ```js function onConsumeCallback(data) { - console.info("==========================>onConsumeCallback=======================>"); + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe success"); + } } var subscriber = { onConsume: onConsumeCallback }; Notification.subscribe(subscriber).then(() => { - console.info("==========================>subscribeCallback=======================>"); + console.info("subscribe sucess"); }); ``` @@ -831,13 +891,17 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\) ```js function unsubscribeCallback(err) { - console.info("==========================>unsubscribeCallback=======================>"); + if (err.code) { + console.info("unsubscribe failed " + JSON.stringify(err)); + } else { + console.info("unsubscribe success"); + } } -function onConsumeCallback(data) { - console.info("==========================>onConsumeCallback=======================>"); +function onCancelCallback(data) { + console.info("Cancel callback: " + JSON.stringify(data)); } var subscriber = { - onConsume: onConsumeCallback + onCancel: onCancelCallback } Notification.unsubscribe(subscriber, unsubscribeCallback); ``` @@ -865,14 +929,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\ **示例:** ```js -function onConsumeCallback(data) { - console.info("==========================>onConsumeCallback=======================>"); +function onCancelCallback(data) { + console.info("Cancel callback: " + JSON.stringify(data)); } var subscriber = { - onConsume: onConsumeCallback + onCancel: onCancelCallback }; Notification.unsubscribe(subscriber).then(() => { - console.info("==========================>unsubscribeCallback=======================>"); + console.info("unsubscribe sucess"); }); ``` @@ -902,7 +966,11 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac ```js function enableNotificationCallback(err) { - console.info("==========================>enableNotificationCallback=======================>"); + if (err.code) { + console.info("enableNotification failed " + JSON.stringify(err)); + } else { + console.info("enableNotification success"); + } } var bundle = { bundle: "bundleName1", @@ -938,7 +1006,7 @@ var bundle = { bundle: "bundleName1", } Notification.enableNotification(bundle, false).then(() => { - console.info("==========================>enableNotificationCallback=======================>"); + console.info("enableNotification sucess"); }); ``` @@ -967,7 +1035,11 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): ```js function isNotificationEnabledCallback(err, data) { - console.info("==========================>isNotificationEnabledCallback=======================>"); + if (err.code) { + console.info("isNotificationEnabled failed " + JSON.stringify(err)); + } else { + console.info("isNotificationEnabled success"); + } } var bundle = { bundle: "bundleName1", @@ -1008,7 +1080,7 @@ var bundle = { bundle: "bundleName1", } Notification.isNotificationEnabled(bundle).then((data) => { - console.info("==========================>isNotificationEnabledCallback=======================>"); + console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); }); ``` @@ -1036,7 +1108,11 @@ isNotificationEnabled(callback: AsyncCallback\): void ```js function isNotificationEnabledCallback(err, data) { - console.info("==========================>isNotificationEnabledCallback=======================>"); + if (err.code) { + console.info("isNotificationEnabled failed " + JSON.stringify(err)); + } else { + console.info("isNotificationEnabled success"); + } } Notification.isNotificationEnabled(isNotificationEnabledCallback); @@ -1072,7 +1148,7 @@ isNotificationEnabled(): Promise\ ```js Notification.isNotificationEnabled().then((data) => { - console.info("==========================>isNotificationEnabledCallback=======================>"); + console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); }); ``` @@ -1102,7 +1178,11 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\displayBadgeCallback=======================>"); + if (err.code) { + console.info("displayBadge failed " + JSON.stringify(err)); + } else { + console.info("displayBadge success"); + } } var bundle = { bundle: "bundleName1", @@ -1138,7 +1218,7 @@ var bundle = { bundle: "bundleName1", } Notification.displayBadge(bundle, false).then(() => { - console.info("==========================>displayBadgeCallback=======================>"); + console.info("displayBadge sucess"); }); ``` @@ -1167,7 +1247,11 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void ```js function isBadgeDisplayedCallback(err, data) { - console.info("==========================>isBadgeDisplayedCallback=======================>"); + if (err.code) { + console.info("isBadgeDisplayed failed " + JSON.stringify(err)); + } else { + console.info("isBadgeDisplayed success"); + } } var bundle = { bundle: "bundleName1", @@ -1208,7 +1292,7 @@ var bundle = { bundle: "bundleName1", } Notification.isBadgeDisplayed(bundle).then((data) => { - console.info("==========================>isBadgeDisplayedCallback=======================>"); + console.info("isBadgeDisplayed sucess, data: " + JSON.stringify(data)); }); ``` @@ -1238,7 +1322,11 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal ```js function setSlotByBundleCallback(err) { - console.info("==========================>setSlotByBundleCallback=======================>"); + if (err.code) { + console.info("setSlotByBundle failed " + JSON.stringify(err)); + } else { + console.info("setSlotByBundle success"); + } } var bundle = { bundle: "bundleName1", @@ -1280,7 +1368,7 @@ var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.setSlotByBundle(bundle, notificationSlot).then(() => { - console.info("==========================>setSlotByBundleCallback=======================>"); + console.info("setSlotByBundle sucess"); }); ``` @@ -1309,7 +1397,11 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallbackgetSlotsByBundleCallback=======================>"); + if (err.code) { + console.info("getSlotsByBundle failed " + JSON.stringify(err)); + } else { + console.info("getSlotsByBundle success"); + } } var bundle = { bundle: "bundleName1", @@ -1350,7 +1442,7 @@ var bundle = { bundle: "bundleName1", } Notification.getSlotsByBundle(bundle).then((data) => { - console.info("==========================>getSlotsByBundleCallback=======================>"); + console.info("getSlotsByBundle sucess, data: " + JSON.stringify(data)); }); ``` @@ -1379,7 +1471,11 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): voi ```js function getSlotNumByBundleCallback(err, data) { - console.info("==========================>getSlotNumByBundleCallback=======================>"); + if (err.code) { + console.info("getSlotNumByBundle failed " + JSON.stringify(err)); + } else { + console.info("getSlotNumByBundle success"); + } } var bundle = { bundle: "bundleName1", @@ -1420,7 +1516,7 @@ var bundle = { bundle: "bundleName1", } Notification.getSlotNumByBundle(bundle).then((data) => { - console.info("==========================>getSlotNumByBundleCallback=======================>"); + console.info("getSlotNumByBundle sucess, data: " + JSON.stringify(data)); }); ``` @@ -1451,7 +1547,11 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ```js function removeCallback(err) { - console.info("==========================>removeCallback=======================>"); + if (err.code) { + console.info("remove failed " + JSON.stringify(err)); + } else { + console.info("remove success"); + } } var bundle = { bundle: "bundleName1", @@ -1498,7 +1598,7 @@ var notificationKey = { } var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; Notification.remove(bundle, notificationKey, reason).then(() => { - console.info("==========================>removeCallback=======================>"); + console.info("remove sucess"); }); ``` @@ -1530,7 +1630,11 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\): var hashCode = 'hashCode' function removeCallback(err) { - console.info("==========================>removeCallback=======================>"); + if (err.code) { + console.info("remove failed " + JSON.stringify(err)); + } else { + console.info("remove success"); + } } var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; Notification.remove(hashCode, reason, removeCallback); @@ -1563,7 +1667,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\ var hashCode = 'hashCode' var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; Notification.remove(hashCode, reason).then(() => { - console.info("==========================>removeCallback=======================>"); + console.info("remove sucess"); }); ``` @@ -1592,7 +1696,11 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\): void ```js function removeAllCallback(err) { - console.info("==========================>removeAllCallback=======================>"); + if (err.code) { + console.info("removeAll failed " + JSON.stringify(err)); + } else { + console.info("removeAll success"); + } } var bundle = { bundle: "bundleName1", @@ -1624,7 +1732,11 @@ removeAll(callback: AsyncCallback\): void ```js function removeAllCallback(err) { - console.info("==========================>removeAllCallback=======================>"); + if (err.code) { + console.info("removeAll failed " + JSON.stringify(err)); + } else { + console.info("removeAll success"); + } } Notification.removeAll(removeAllCallback); @@ -1654,7 +1766,7 @@ removeAll(bundle?: BundleOption): Promise\ ```js Notification.removeAll().then(() => { - console.info("==========================>removeAllCallback=======================>"); + console.info("removeAll sucess"); }); ``` @@ -1681,7 +1793,11 @@ removeAll(userId: number, callback: AsyncCallback\): void ```js function removeAllCallback(err) { - console.info("==========================>removeAllCallback=======================>"); + if (err.code) { + console.info("removeAll failed " + JSON.stringify(err)); + } else { + console.info("removeAll success"); + } } var userId = 1 @@ -1711,7 +1827,11 @@ removeAll(userId: number): Promise\ ```js function removeAllCallback(err) { - console.info("==========================>removeAllCallback=======================>"); + if (err.code) { + console.info("removeAll failed " + JSON.stringify(err)); + } else { + console.info("removeAll success"); + } } var userId = 1 @@ -1742,7 +1862,11 @@ getAllActiveNotifications(callback: AsyncCallback>) ```js function getAllActiveNotificationsCallback(err, data) { - console.info("==========================>getAllActiveNotificationsCallback=======================>"); + if (err.code) { + console.info("getAllActiveNotifications failed " + JSON.stringify(err)); + } else { + console.info("getAllActiveNotifications success"); + } } Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); @@ -1772,7 +1896,7 @@ getAllActiveNotifications(): Promise\ { - console.info("==========================>getAllActiveNotificationsCallback=======================>"); + console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data)); }); ``` @@ -1796,7 +1920,11 @@ getActiveNotificationCount(callback: AsyncCallback\): void ```js function getActiveNotificationCountCallback(err, data) { - console.info("==========================>getActiveNotificationCountCallback=======================>"); + if (err.code) { + console.info("getActiveNotificationCount failed " + JSON.stringify(err)); + } else { + console.info("getActiveNotificationCount success"); + } } Notification.getActiveNotificationCount(getActiveNotificationCountCallback); @@ -1822,7 +1950,7 @@ getActiveNotificationCount(): Promise\ ```js Notification.getActiveNotificationCount().then((data) => { - console.info("==========================>getActiveNotificationCountCallback=======================>"); + console.info("getActiveNotificationCount sucess, data: " + JSON.stringify(data)); }); ``` @@ -1846,7 +1974,11 @@ getActiveNotifications(callback: AsyncCallback>): v ```js function getActiveNotificationsCallback(err, data) { - console.info("==========================>getActiveNotificationsCallback=======================>"); + if (err.code) { + console.info("getActiveNotifications failed " + JSON.stringify(err)); + } else { + console.info("getActiveNotifications success"); + } } Notification.getActiveNotifications(getActiveNotificationsCallback); @@ -1872,7 +2004,7 @@ getActiveNotifications(): Promise\ { - console.info("==========================>getActiveNotificationsCallback=======================>"); + console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data)); }); ``` @@ -1897,7 +2029,11 @@ cancelGroup(groupName: string, callback: AsyncCallback\): void ```js function cancelGroupCallback(err) { - console.info("==========================>cancelGroupCallback=======================>"); + if (err.code) { + console.info("cancelGroup failed " + JSON.stringify(err)); + } else { + console.info("cancelGroup success"); + } } var groupName = "GroupName"; @@ -1926,7 +2062,7 @@ cancelGroup(groupName: string): Promise\ ```js var groupName = "GroupName"; Notification.cancelGroup(groupName).then(() => { - console.info("==========================>cancelGroupPromise=======================>"); + console.info("cancelGroup sucess"); }); ``` @@ -1956,7 +2092,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall ```js function removeGroupByBundleCallback(err) { - console.info("==========================>removeGroupByBundleCallback=======================>"); + if (err.code) { + console.info("removeGroupByBundle failed " + JSON.stringify(err)); + } else { + console.info("removeGroupByBundle success"); + } } var bundleOption = {bundle: "Bundle"}; @@ -1992,7 +2132,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ var bundleOption = {bundle: "Bundle"}; var groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName).then(() => { - console.info("==========================>removeGroupByBundlePromise=======================>"); + console.info("removeGroupByBundle sucess"); }); ``` @@ -2021,7 +2161,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\): vo ```js function setDoNotDisturbDateCallback(err) { - console.info("==========================>setDoNotDisturbDateCallback=======================>"); + if (err.code) { + console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); + } else { + console.info("setDoNotDisturbDate success"); + } } var doNotDisturbDate = { @@ -2062,7 +2206,7 @@ var doNotDisturbDate = { end: new Date(2021, 11, 15, 18, 0) } Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { - console.info("==========================>setDoNotDisturbDatePromise=======================>"); + console.info("setDoNotDisturbDate sucess"); }); ``` @@ -2091,7 +2235,11 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb ```js function setDoNotDisturbDateCallback(err) { - console.info("==========================>setDoNotDisturbDateCallback=======================>"); + if (err.code) { + console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); + } else { + console.info("setDoNotDisturbDate success"); + } } var doNotDisturbDate = { @@ -2138,7 +2286,7 @@ var doNotDisturbDate = { var userId = 1 Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { - console.info("==========================>setDoNotDisturbDatePromise=======================>"); + console.info("setDoNotDisturbDate sucess"); }); ``` @@ -2165,7 +2313,11 @@ getDoNotDisturbDate(callback: AsyncCallback\): void ```js function getDoNotDisturbDateCallback(err,data) { - console.info("==========================>getDoNotDisturbDateCallback=======================>"); + if (err.code) { + console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); + } else { + console.info("getDoNotDisturbDate success"); + } } Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); @@ -2195,7 +2347,7 @@ getDoNotDisturbDate(): Promise\ ```js Notification.getDoNotDisturbDate().then((data) => { - console.info("==========================>getDoNotDisturbDatePromise=======================>"); + console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); }); ``` @@ -2223,7 +2375,11 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\) ```js function getDoNotDisturbDateCallback(err,data) { - console.info("==========================>getDoNotDisturbDateCallback=======================>"); + if (err.code) { + console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); + } else { + console.info("getDoNotDisturbDate success"); + } } var userId = 1 @@ -2263,7 +2419,7 @@ getDoNotDisturbDate(userId: number): Promise\ var userId = 1 Notification.getDoNotDisturbDate(userId).then((data) => { - console.info("==========================>getDoNotDisturbDatePromise=======================>"); + console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); }); ``` @@ -2290,7 +2446,11 @@ supportDoNotDisturbMode(callback: AsyncCallback\): void ```js function supportDoNotDisturbModeCallback(err,data) { - console.info("==========================>supportDoNotDisturbModeCallback=======================>"); + if (err.code) { + console.info("supportDoNotDisturbMode failed " + JSON.stringify(err)); + } else { + console.info("supportDoNotDisturbMode success"); + } } Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); @@ -2320,7 +2480,7 @@ supportDoNotDisturbMode(): Promise\ ```js Notification.supportDoNotDisturbMode().then((data) => { - console.info("==========================>supportDoNotDisturbModePromise=======================>"); + console.info("supportDoNotDisturbMode sucess, data: " + JSON.stringify(data)); }); ``` @@ -2346,7 +2506,11 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\): voi ```javascript var templateName = 'process'; function isSupportTemplateCallback(err, data) { - console.info("isSupportTemplateCallback"); + if (err.code) { + console.info("isSupportTemplate failed " + JSON.stringify(err)); + } else { + console.info("isSupportTemplate success"); + } } Notification.isSupportTemplate(templateName, isSupportTemplateCallback); @@ -2380,7 +2544,7 @@ isSupportTemplate(templateName: string): Promise\ var templateName = 'process'; Notification.isSupportTemplate(templateName).then((data) => { - console.info("isSupportTemplateCallback"); + console.info("isSupportTemplate success, data: " + JSON.stringify(data)); }); ``` @@ -2404,7 +2568,11 @@ requestEnableNotification(callback: AsyncCallback\): void ```javascript function requestEnableNotificationCallback() { - console.log('------------- requestEnabledNotification --------------'); + if (err.code) { + console.info("requestEnableNotification failed " + JSON.stringify(err)); + } else { + console.info("requestEnableNotification success"); + } }; Notification.requestEnableNotification(requestEnableNotificationCallback); @@ -2425,7 +2593,7 @@ requestEnableNotification(): Promise\ ```javascript Notification.requestEnableNotification() .then(() => { - console.info("requestEnableNotification "); + console.info("requestEnableNotification sucess"); }); ``` @@ -2453,7 +2621,11 @@ enableDistributed(enable: boolean, callback: AsyncCallback\): void ```javascript function enabledNotificationCallback() { - console.log('----------- enableDistributed ------------'); + if (err.code) { + console.info("enableDistributed failed " + JSON.stringify(err)); + } else { + console.info("enableDistributed success"); + } }; var enable = true @@ -2488,7 +2660,7 @@ var enable = true Notification.enableDistributed(enable) .then(() => { - console.log('-------- enableDistributed ----------'); + console.info("enableDistributed sucess"); }); ``` @@ -2511,7 +2683,11 @@ isDistributedEnabled(callback: AsyncCallback\): void ```javascript function isDistributedEnabledCallback() { - console.log('----------- isDistributedEnabled ------------'); + if (err.code) { + console.info("isDistributedEnabled failed " + JSON.stringify(err)); + } else { + console.info("isDistributedEnabled success"); + } }; Notification.isDistributedEnabled(isDistributedEnabledCallback); @@ -2538,7 +2714,7 @@ isDistributedEnabled(): Promise\ ```javascript Notification.isDistributedEnabled() .then((data) => { - console.log('-------- isDistributedEnabled ----------'); + console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data)); }); ``` @@ -2567,7 +2743,11 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async ```javascript function enableDistributedByBundleCallback() { - console.log('----------- enableDistributedByBundle ------------'); + if (err.code) { + console.info("enableDistributedByBundle failed " + JSON.stringify(err)); + } else { + console.info("enableDistributedByBundle success"); + } }; var bundle = { @@ -2611,7 +2791,7 @@ var enable = true Notification.enableDistributedByBundle(bundle, enable) .then(() => { - console.log('-------- enableDistributedByBundle ----------'); + console.info("enableDistributedByBundle sucess"); }); ``` @@ -2638,7 +2818,11 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\ { - console.log('-------- isDistributedEnabledByBundle ----------', data); + console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data)); }); ``` @@ -2710,7 +2894,11 @@ getDeviceRemindType(callback: AsyncCallback\): void ```javascript function getDeviceRemindTypeCallback(data) { - console.log('----------- getDeviceRemindType ------------', data); + if (err.code) { + console.info("getDeviceRemindType failed " + JSON.stringify(err)); + } else { + console.info("getDeviceRemindType success"); + } }; Notification.getDeviceRemindType(getDeviceRemindTypeCallback); @@ -2741,7 +2929,7 @@ getDeviceRemindType(): Promise\ ```javascript Notification.getDeviceRemindType() .then((data) => { - console.log('-------- getDeviceRemindType ----------', data); + console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data)); }); ``` @@ -2772,7 +2960,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ```js //publishAsBundle回调 function publishAsBundleCallback(err) { - console.info("==========================>publishAsBundleCallback=======================>"); + if (err.code) { + console.info("publishAsBundle failed " + JSON.stringify(err)); + } else { + console.info("publishAsBundle success"); + } } // 被代理应用的包名 let representativeBundle = "com.example.demo" @@ -2836,7 +3028,7 @@ var notificationRequest = { } Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { - console.info("==========================>publishAsBundleCallback=======================>"); + console.info("publishAsBundle sucess"); }); ``` @@ -2868,7 +3060,11 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac ```js //cancelAsBundle function cancelAsBundleCallback(err) { - console.info("==========================>cancelAsBundleCallback=======================>"); + if (err.code) { + console.info("cancelAsBundle failed " + JSON.stringify(err)); + } else { + console.info("cancelAsBundle success"); + } } // 被代理应用的包名 let representativeBundle = "com.example.demo" @@ -2909,7 +3105,7 @@ let representativeBundle = "com.example.demo" let userId = 100 Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { - console.info("==========================>cancelAsBundleCallback=======================>"); + console.info("cancelAsBundle success"); }); ``` @@ -2939,7 +3135,11 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca ```js //enableNotificationSlot function enableSlotCallback(err) { - console.log('===================>enableSlotCallback==================>'); + if (err.code) { + console.info("enableNotificationSlot failed " + JSON.stringify(err)); + } else { + console.info("enableNotificationSlot success"); + } }; Notification.enableNotificationSlot( @@ -2977,7 +3177,7 @@ Notification.enableNotificationSlot( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION, true).then(() => { - console.log('====================>enableNotificationSlot====================>'); + console.info("enableNotificationSlot sucess"); }); ``` @@ -3006,7 +3206,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ```js //isNotificationSlotEnabled function getEnableSlotCallback(err, data) { - console.log('===================>getEnableSlotCallback=================='); + if (err.code) { + console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); + } else { + console.info("isNotificationSlotEnabled success"); + } }; Notification.isNotificationSlotEnabled( @@ -3048,7 +3252,7 @@ Notification.isNotificationSlotEnabled( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION ).then((data) => { - console.log('====================>isNotificationSlotEnabled====================>'); + console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); }); ``` @@ -3080,7 +3284,11 @@ let userId = 100; let enable = true; function setSyncNotificationEnabledWithoutAppCallback(err) { - console.log('setSyncNotificationEnabledWithoutAppCallback'); + if (err.code) { + console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); + } else { + console.info("setSyncNotificationEnabledWithoutApp success"); + } } Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback); @@ -3119,11 +3327,11 @@ let userId = 100; let enable = true; Notification.setSyncNotificationEnabledWithoutApp(userId, enable) - .then((data) => { - console.log('setSyncNotificationEnabledWithoutApp'); + .then(() => { + console.info('setSyncNotificationEnabledWithoutApp'); }) .catch((err) => { - console.log('setSyncNotificationEnabledWithoutApp, err:', err); + console.info('setSyncNotificationEnabledWithoutApp, err:', err); }); ``` @@ -3154,9 +3362,9 @@ let userId = 100; function getSyncNotificationEnabledWithoutAppCallback(data, err) { if (err) { - console.log('getSyncNotificationEnabledWithoutAppCallback, err' + err); + console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err); } else { - console.log('getSyncNotificationEnabledWithoutAppCallback, data' + data); + console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data); } } @@ -3195,10 +3403,10 @@ let userId = 100; Notification.getSyncNotificationEnabledWithoutApp(userId) .then((data) => { - console.log('getSyncNotificationEnabledWithoutApp, data:', data); + console.info('getSyncNotificationEnabledWithoutApp, data:', data); }) .catch((err) => { - console.log('getSyncNotificationEnabledWithoutApp, err:', err); + console.info('getSyncNotificationEnabledWithoutApp, err:', err); }); ``` @@ -3242,7 +3450,7 @@ function onConsumeCallback(data) { let wantAgent = data.wantAgent; wantAgent .getWant(wantAgent) .then((data1) => { - console.log('===> getWant success want:' + JSON.stringify(data1)); + console.info('===> getWant success want:' + JSON.stringify(data1)); }) .catch((err) => { console.error('===> getWant failed because' + JSON.stringify(err)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 8a1c6c8a25aafb7ee71ee4c7905fc667b95b4411..62b255c8acf353c63f5a7afa07a10243ad7797e8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -25,12 +25,24 @@ import pasteboard from '@ohos.pasteboard'; | MIMETYPE_TEXT_URI7+ | string | 是 | 否 | URI内容的MIME类型定义。 | | MIMETYPE_PIXELMAP9+ | string | 是 | 否 | PixelMap内容的MIME类型定义。 | +## ValueType9+ -## pasteboard.createPlainTextData +用于表示允许的数据字段类型。 -createPlainTextData(text: string): PasteData +**系统能力:** 以下各项对应的系统能力均为SystemCapability.MiscServices.Pasteboard -构建一个纯文本剪贴板内容对象。 +| 类型 | 说明 | +| -------- | -------- | +| string | 表示string的类型。 | +| image.PixelMap | 表示[image.PixelMap](js-apis-image.md#pixelmap7)的类型。 | +| Want | 表示[Want](js-apis-application-Want.md)的类型。 | +| ArrayBuffer | 表示ArrayBuffer的类型。 | + +## pasteboard.createData9+ + +createData(mimeType: string, value: ValueType): PasteData + +构建一个自定义类型的剪贴板内容对象。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -38,26 +50,27 @@ createPlainTextData(text: string): PasteData | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| text | string | 是 | 纯文本内容。 | +| mimeType | string | 是 | 自定义数据的MIME类型。 | +| value | [ValueType](#valuetype9) | 是 | 自定义数据内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteData](#pastedata) | 剪贴板内容对象。 | +| [PasteData](#pastedata) | 剪贴板内容对象。 | **示例:** -```js -var pasteData = pasteboard.createPlainTextData("content"); -``` - + ```js + var dataXml = 'aStringValueType'; + var pasteData = pasteboard.createData('app/xml', dataXml); + ``` -## pasteboard.createHtmlData7+ +## pasteboard.createRecord9+ -createHtmlData(htmlText: string): PasteData +createRecord(mimeType: string, value: ValueType):PasteDataRecord; -构建一个HTML剪贴板内容对象。 +创建一条自定义数据内容条目。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -65,58 +78,62 @@ createHtmlData(htmlText: string): PasteData | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| htmlText | string | 是 | HTML内容。 | +| mimeType | string | 是 | 自定义数据的MIME类型。 | +| value | [ValueType](#valuetype9) | 是 | 自定义数据内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteData](#pastedata) | 剪贴板内容对象。 | +| [PasteDataRecord](#pastedatarecord7) | 一条新建的自定义数据内容条目。 | **示例:** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -``` - + ```js + var dataXml = 'aStringValueType'; + var pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); + ``` -## pasteboard.createWantData7+ +## pasteboard.getSystemPasteboard -createWantData(want: Want): PasteData +getSystemPasteboard(): SystemPasteboard -构建一个Want剪贴板内容对象。 +获取系统剪贴板对象。 **系统能力:** SystemCapability.MiscServices.Pasteboard -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | 是 | Want内容。 | - **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteData](#pastedata) | 剪贴板内容对象。 | +| [SystemPasteboard](#systempasteboard) | 系统剪贴板对象。 | **示例:** ```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var pasteData = pasteboard.createWantData(object); +var systemPasteboard = pasteboard.getSystemPasteboard(); ``` +## ShareOption9+ + +可粘贴数据的范围类型枚举。 -## pasteboard.createUriData7+ +**系统能力:** SystemCapability.MiscServices.Pasteboard -createUriData(uri: string): PasteData +| 名称 | 说明 | +| ----- | ----------------------- | +| InApp |表示仅允许同应用内粘贴。 | +| LocalDevice |表示允许在此设备中任何应用内粘贴。 | +| CrossDevice |表示允许跨设备在任何应用内粘贴。 | -构建一个URI剪贴板内容对象。 +## pasteboard.createHtmlData(deprecated) + +createHtmlData(htmlText: string): PasteData + +构建一个HTML剪贴板内容对象。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createData](#pasteboardcreatedata9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -124,7 +141,7 @@ createUriData(uri: string): PasteData | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| uri | string | 是 | URI内容。 | +| htmlText | string | 是 | HTML内容。 | **返回值:** @@ -135,15 +152,18 @@ createUriData(uri: string): PasteData **示例:** ```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +var pasteData = pasteboard.createHtmlData(html); ``` +## pasteboard.createWantData(deprecated) -## pasteboard.createPixelMapData9+ - -createPixelMapData(pixelMap: image.PixelMap): PasteData +createWantData(want: Want): PasteData -构建一个PixelMap剪贴板内容对象。 +构建一个Want剪贴板内容对象。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createData](#pasteboardcreatedata9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -151,7 +171,7 @@ createPixelMapData(pixelMap: image.PixelMap): PasteData | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | PixelMap内容。 | +| want | [Want](js-apis-application-Want.md) | 是 | Want内容。 | **返回值:** @@ -162,26 +182,21 @@ createPixelMapData(pixelMap: image.PixelMap): PasteData **示例:** ```js -import image from '@ohos.multimedia.image'; - -var buffer = new ArrayBuffer(128) -var opt = { - size: { height: 3, width: 5 }, - pixelFormat: 3, - editable: true, - alphaType: 1, - scaleMode: 1 -} -image.createPixelMap(buffer, opt).then((pixelMap) => { - var pasteData = pasteboard.createPixelMapData(pixelMap); -}) +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +var pasteData = pasteboard.createWantData(object); ``` -## pasteboard.createData9+ +## pasteboard.createPlainTextData(deprecated) -createData(mimeType: string, value: ArrayBuffer): PasteData; +createPlainTextData(text: string): PasteData -构建一个自定义类型的剪贴板内容对象。 +构建一个纯文本剪贴板内容对象。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createData](#pasteboardcreatedata9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -189,28 +204,28 @@ createData(mimeType: string, value: ArrayBuffer): PasteData; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| mimeType | string | 是 | 自定义数据的MIME类型。 | -| value | ArrayBuffer | 是 | 自定义数据内容。 | +| text | string | 是 | 纯文本内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteData](#pastedata) | 剪贴板内容对象。 | +| [PasteData](#pastedata) | 剪贴板内容对象。 | **示例:** - ```js - var dataXml = new ArrayBuffer(256) - var pasteData = pasteboard.createData('app/xml', dataXml) - ``` - +```js +var pasteData = pasteboard.createPlainTextData("content"); +``` -## pasteboard.createPlainTextRecord7+ +## pasteboard.createUriData(deprecated) -createPlainTextRecord(text: string): PasteDataRecord +createUriData(uri: string): PasteData -创建一条纯文本内容条目。 +构建一个URI剪贴板内容对象。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createData](#pasteboardcreatedata9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -218,26 +233,27 @@ createPlainTextRecord(text: string): PasteDataRecord | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| text | string | 是 | 纯文本内容。 | +| uri | string | 是 | URI内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteDataRecord](#pastedatarecord7) | 一条新建的纯文本内容条目。 | +| [PasteData](#pastedata) | 剪贴板内容对象。 | **示例:** ```js -var record = pasteboard.createPlainTextRecord("hello"); +var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); ``` - - -## pasteboard.createHtmlTextRecord7+ +## pasteboard.createHtmlTextRecord(deprecated) createHtmlTextRecord(htmlText: string): PasteDataRecord 创建一条HTML内容的条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createRecord](#pasteboardcreaterecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -260,12 +276,14 @@ var html = "\n" + "\n" + "\n" + "7+ +## pasteboard.createWantRecord(deprecated) createWantRecord(want: Want): PasteDataRecord 创建一条Want内容条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createRecord](#pasteboardcreaterecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -291,39 +309,14 @@ var object = { var record = pasteboard.createWantRecord(object); ``` +## pasteboard.createPlainTextRecord(deprecated) -## pasteboard.createUriRecord7+ - -createUriRecord(uri: string): PasteDataRecord - -创建一条URI内容的条目。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| uri | string | 是 | URI内容。 | - -**返回值:** - -| 类型 | 说明 | -| -------- | -------- | -| [PasteDataRecord](#pastedatarecord7) | 一条新建的URI内容条目。 | - -**示例:** - -```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); -``` - - -## pasteboard.createPixelMapRecord9+ - -createPixelMapRecord(pixelMap: image.PixelMap): PasteDataRecord +createPlainTextRecord(text: string): PasteDataRecord -创建一条PixelMap内容的条目。 +创建一条纯文本内容条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createRecord](#pasteboardcreaterecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -331,37 +324,28 @@ createPixelMapRecord(pixelMap: image.PixelMap): PasteDataRecord | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | PixelMap内容。 | +| text | string | 是 | 纯文本内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [PasteDataRecord](#pastedatarecord7) | 一条新建的PixelMap内容条目。 | +| [PasteDataRecord](#pastedatarecord7) | 一条新建的纯文本内容条目。 | **示例:** ```js -import image from '@ohos.multimedia.image'; - -var buffer = new ArrayBuffer(128) -var opt = { - size: { height: 3, width: 5 }, - pixelFormat: 3, - editable: true, - alphaType: 1, - scaleMode: 1 -} -image.createPixelMap(buffer, opt).then((pixelMap) => { - var record = pasteboard.createPixelMapRecord(pixelMap); -}) +var record = pasteboard.createPlainTextRecord("hello"); ``` -## pasteboard.createRecord9+ +## pasteboard.createUriRecord(deprecated) -createRecord(mimeType: string, value: ArrayBuffer):PasteDataRecord; +createUriRecord(uri: string): PasteDataRecord -创建一条自定义数据内容条目。 +创建一条URI内容的条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.createRecord](#pasteboardcreaterecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -369,55 +353,20 @@ createRecord(mimeType: string, value: ArrayBuffer):PasteDataRecord; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| mimeType | string | 是 | 自定义数据的MIME类型。 | -| value | ArrayBuffer | 是 | 自定义数据内容。 | - -**返回值:** - -| 类型 | 说明 | -| -------- | -------- | -| [PasteDataRecord](#pastedatarecord7) | 一条新建的自定义数据内容条目。 | - -**示例:** - - ```js - var dataXml = new ArrayBuffer(256) - var pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); - ``` - - -## pasteboard.getSystemPasteboard - -getSystemPasteboard(): SystemPasteboard - -获取系统剪贴板对象。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard +| uri | string | 是 | URI内容。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| [SystemPasteboard](#systempasteboard) | 系统剪贴板对象。 | +| [PasteDataRecord](#pastedatarecord7) | 一条新建的URI内容条目。 | **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); ``` -## ShareOption9+ - -可粘贴数据的范围类型枚举。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -| 名称 | 说明 | -| ----- | ----------------------- | -| InApp |表示仅允许同应用内粘贴。 | -| LocalDevice |表示允许在此设备中任何应用内粘贴。 | -| CrossDevice |表示允许跨设备在任何应用内粘贴。 | - ## PasteDataProperty7+ @@ -434,12 +383,10 @@ var systemPasteboard = pasteboard.getSystemPasteboard(); | localOnly7+ | boolean | 是 | 是 | 配置剪贴板内容是否为“仅在本地”。默认值为true。
- 配置为true时,表示内容仅在本地,不会在设备之间传递。
- 配置为false时,表示内容将在设备间传递。 | | shareOption9+ | [ShareOption](#shareoption9) | 是 | 是 | 指示剪贴板数据可以粘贴到的范围,如果未设置或设置不正确,则默认值为CrossDevice。 | - ## PasteDataRecord7+ 对于剪贴板中内容记录的抽象定义,称之为条目。剪贴板内容部分由一个或者多个条目构成,例如一条文本内容、一份HTML、一个URI或者一个Want。 - ### 属性 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -454,10 +401,36 @@ var systemPasteboard = pasteboard.getSystemPasteboard(); | pixelMap9+ | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 否 | PixelMap内容。 | | data9+ | {[mimeType: string]: ArrayBuffer} | 是 | 否 | 自定义数据内容。 | +### convertToTextV99+ -### convertToText7+ +convertToTextV9(callback: AsyncCallback<string>): void -convertToText(): Promise<string> +将一个PasteData中的内容强制转换为文本内容,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<string> | 是 | 回调函数,当转换成功,err为undefined,data为强制转换的文本内容;否则返回错误信息。 | + +**示例:** + +```js +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); +record.convertToTextV9((err, data) => { + if (err) { + console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); +}); +``` + +### convertToTextV99+ + +convertToTextV9(): Promise<string> 将一个PasteData中的内容强制转换为文本内容,使用Promise异步回调。 @@ -473,19 +446,21 @@ convertToText(): Promise<string> ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); -record.convertToText().then((data) => { +record.convertToTextV9().then((data) => { console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); }).catch((err) => { console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); }); ``` - -### convertToText7+ +### convertToText(deprecated) convertToText(callback: AsyncCallback<string>): void 将一个PasteData中的内容强制转换为文本内容,使用callback异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[convertToTextV9](#converttotextv99)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -508,26 +483,49 @@ record.convertToText((err, data) => { }); ``` +### convertToText(deprecated) -## PasteData - -剪贴板内容对象。 +convertToText(): Promise<string> -在调用PasteData的接口前,需要先获取一个PasteData对象。 +将一个PasteData中的内容强制转换为文本内容,使用Promise异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[convertToTextV9](#converttotextv99-1)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard +**返回值:** -### getPrimaryText - - -getPrimaryText(): string +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | Promise对象,返回强制转换的文本内容。 | +**示例:** -获取首个条目的纯文本内容。 +```js +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); +record.convertToText().then((data) => { + console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); +}); +``` + +## PasteData + +剪贴板内容对象。 + +在调用PasteData的接口前,需要先获取一个PasteData对象。 **系统能力:** SystemCapability.MiscServices.Pasteboard +### getPrimaryText + +getPrimaryText(): string + +获取首个条目的纯文本内容。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard **返回值:** @@ -542,7 +540,6 @@ var pasteData = pasteboard.createPlainTextData("hello"); var plainText = pasteData.getPrimaryText(); ``` - ### getPrimaryHtml7+ getPrimaryHtml(): string @@ -565,7 +562,6 @@ var pasteData = pasteboard.createHtmlData(html); var htmlText = pasteData.getPrimaryHtml(); ``` - ### getPrimaryWant7+ getPrimaryWant(): Want @@ -591,7 +587,6 @@ var pasteData = pasteboard.createWantData(object); var want = pasteData.getPrimaryWant(); ``` - ### getPrimaryUri7+ getPrimaryUri(): string @@ -613,7 +608,6 @@ var pasteData = pasteboard.createUriData("dataability:///com.example.myapplicati var uri = pasteData.getPrimaryUri(); ``` - ### getPrimaryPixelMap9+ getPrimaryPixelMap(): image.PixelMap @@ -647,36 +641,11 @@ image.createPixelMap(buffer, opt).then((pixelMap) => { }) ``` +### addRecord7+ -### addTextRecord7+ - -addTextRecord(text: string): void - -向当前剪贴板内容中添加一条纯文本条目,并将MIME_TEXT_PLAIN添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 - -剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| text | string | 是 | 纯文本内容。 | - -**示例:** - -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addTextRecord("good"); -``` - - -### addHtmlRecord7+ - -addHtmlRecord(htmlText: string): void +addRecord(record: PasteDataRecord): void -向当前剪贴板内容中添加一条HTML内容条目,并将MIMETYPE_TEXT_HTML添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 +向当前剪贴板内容中添加一条条目,同时也会将条目类型添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 @@ -686,106 +655,21 @@ addHtmlRecord(htmlText: string): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| htmlText | string | 是 | HTML内容。 | +| record | [PasteDataRecord](#pastedatarecord7) | 是 | 待添加的条目。 | **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); +var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); +var textRecord = pasteboard.createPlainTextRecord("hello"); var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -pasteData.addHtmlRecord(html); -``` - - -### addWantRecord7+ - -addWantRecord(want: Want): void - -向当前剪贴板内容中添加一条Want条目,并将MIMETYPE_TEXT_WANT添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 - -剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | 是 | Want对象内容。 | - -**示例:** - -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -pasteData.addWantRecord(object); -``` - - -### addUriRecord7+ - -addUriRecord(uri: string): void - -向当前剪贴板内容中添加一条URI条目,并将MIMETYPE_TEXT_URI添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 - -剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| uri | string | 是 | URI内容。 | - -**示例:** - -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addUriRecord("dataability:///com.example.myapplication1/user.txt"); -``` - -### addPixelMapRecord9+ - -addPixelMapRecord(pixelMap: image.PixelMap): void - -向当前剪贴板内容中添加一条pixelMap条目,并将MIMETYPE_PIXELMAP添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 - -剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| pixelMap | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | PixelMap内容。 | - -**示例:** - -```js -import image from '@ohos.multimedia.image'; - -var buffer = new ArrayBuffer(128) -var opt = { - size: { height: 3, width: 5 }, - pixelFormat: 3, - editable: true, - alphaType: 1, - scaleMode: 1 -} -image.createPixelMap(buffer, opt).then((pixelMap) => { - var record = pasteboard.createPlainTextData("hello").addPixelMapRecord(pixelMap); -}) +var htmlRecord = pasteboard.createHtmlTextRecord(html); +pasteData.addRecord(textRecord); +pasteData.addRecord(htmlRecord); ``` - - ### addRecord9+ -addRecord(mimeType: string, value: ArrayBuffer): void +addRecord(mimeType: string, value: ValueType): void 向当前剪贴板内容中添加一条自定义数据内容条目,同时也会将自定义数据类型添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 @@ -798,45 +682,23 @@ addRecord(mimeType: string, value: ArrayBuffer): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | mimeType | string | 是 | 自定义数据的MIME类型。 | -| value | ArrayBuffer | 是 | 自定义数据内容。 | +| value | [ValueType](#valuetype9) | 是 | 自定义数据内容。 | + +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900002 | The number of record exceeds the maximum limit. | **示例:** ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); - var dataXml = new ArrayBuffer(256) + var dataXml = 'aStringValueType'; pasteData.addRecord('app/xml', dataXml); ``` - -### addRecord7+ - -addRecord(record: PasteDataRecord): void - -向当前剪贴板内容中添加一条条目,同时也会将条目类型添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 - -剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 - -**系统能力:** SystemCapability.MiscServices.Pasteboard - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| record | [PasteDataRecord](#pastedatarecord7) | 是 | 待添加的条目。 | - -**示例:** - -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); -var textRecord = pasteboard.createPlainTextRecord("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var htmlRecord = pasteboard.createHtmlTextRecord(html); -pasteData.addRecord(textRecord); -pasteData.addRecord(htmlRecord); -``` - - ### getMimeTypes7+ getMimeTypes(): Array<string> @@ -858,7 +720,6 @@ var pasteData = pasteboard.createPlainTextData("hello"); var types = pasteData.getMimeTypes(); ``` - ### getPrimaryMimeType7+ getPrimaryMimeType(): string @@ -880,7 +741,6 @@ var pasteData = pasteboard.createPlainTextData("hello"); var type = pasteData.getPrimaryMimeType(); ``` - ### getProperty7+ getProperty(): PasteDataProperty @@ -902,7 +762,6 @@ var pasteData = pasteboard.createPlainTextData("hello"); var property = pasteData.getProperty(); ``` - ### setProperty9+ setProperty(property: PasteDataProperty): void @@ -926,10 +785,9 @@ prop.shareOption = pasteboard.ShareOption.InApp; pasteData.setProperty(prop); ``` +### getRecord9+ -### getRecordAt7+ - -getRecordAt(index: number): PasteDataRecord +getRecord(index: number): PasteDataRecord 获取剪贴板内容中指定下标的条目。 @@ -947,14 +805,20 @@ getRecordAt(index: number): PasteDataRecord | -------- | -------- | | [PasteDataRecord](#pastedatarecord7) | 指定下标的条目。 | +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900001 | The index is out of range. | + **示例:** ```js var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteData.getRecordAt(0); +var record = pasteData.getRecord(0); ``` - ### getRecordCount7+ getRecordCount(): number @@ -976,7 +840,6 @@ var pasteData = pasteboard.createPlainTextData("hello"); var count = pasteData.getRecordCount(); ``` - ### getTag7+ getTag(): string @@ -998,12 +861,11 @@ var pasteData = pasteboard.createPlainTextData("hello"); var tag = pasteData.getTag(); ``` +### hasType9+ -### hasMimeType7+ +hasType(mimeType: string): boolean -hasMimeType(mimeType: string): boolean - -检查剪贴板内容中是否有指定的数据类型。 +检查剪贴板内容中是否有指定的MIME数据类型。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -1023,13 +885,12 @@ hasMimeType(mimeType: string): boolean ```js var pasteData = pasteboard.createPlainTextData("hello"); -var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); +var hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` +### removeRecord9+ -### removeRecordAt7+ - -removeRecordAt(index: number): boolean +removeRecord(index: number): void 移除剪贴板内容中指定下标的条目。 @@ -1041,23 +902,23 @@ removeRecordAt(index: number): boolean | -------- | -------- | -------- | -------- | | index | number | 是 | 指定的下标。 | -**返回值:** +**错误码:** -| 类型 | 说明 | +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | | -------- | -------- | -| boolean | 成功移除返回true,失败返回false。 | +| 12900001 | The index is out of range. | **示例:** ```js var pasteData = pasteboard.createPlainTextData("hello"); -var isRemove = pasteData.removeRecordAt(0); +pasteData.removeRecord(0); ``` +### replaceRecord9+ -### replaceRecordAt7+ - -replaceRecordAt(index: number, record: PasteDataRecord): boolean +replaceRecord(index: number, record: PasteDataRecord): void 替换剪贴板内容中指定下标的条目。 @@ -1068,38 +929,59 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | index | number | 是 | 指定的下标。 | -| record | [PasteDataRecord](#pastedatarecord7) | 是 | 替换后的条目。 | +| record | [PasteDataRecord](#pastedatarecord7) | 是 | 新条目的内容。 | -**返回值:** +**错误码:** -| 类型 | 说明 | +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | | -------- | -------- | -| boolean | 成功替换返回true,失败返回false。 | +| 12900001 | The index is out of range. | **示例:** ```js var pasteData = pasteboard.createPlainTextData("hello"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); -var isReplace = pasteData.replaceRecordAt(0, record); +pasteData.replaceRecord(0, record); ``` +### addHtmlRecord(deprecated) -## SystemPasteboard +addHtmlRecord(htmlText: string): void + +向当前剪贴板内容中添加一条HTML内容条目,并将MIMETYPE_TEXT_HTML添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 -系统剪贴板对象。 +剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[addRecord](#addrecord9)替代。 -在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。 +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| htmlText | string | 是 | HTML内容。 | + +**示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +var pasteData = pasteboard.createPlainTextData("hello"); +var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +pasteData.addHtmlRecord(html); ``` +### addWantRecord(deprecated) -### setPasteData +addWantRecord(want: Want): void -setPasteData(data: PasteData, callback: AsyncCallback<void>): void +向当前剪贴板内容中添加一条Want条目,并将MIMETYPE_TEXT_WANT添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 -将数据写入系统剪贴板,使用callback异步回调。 +剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[addRecord](#addrecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -1107,62 +989,108 @@ setPasteData(data: PasteData, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| data | [PasteData](#pastedata) | 是 | PasteData对象。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当写入成功,err为undefined,否则为错误对象。 | +| want | [Want](js-apis-application-Want.md) | 是 | Want对象内容。 | **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.setPasteData(pasteData, (err, data) => { - if (err) { - console.error('Failed to set PasteData. Cause: ' + err.message); - return; - } - console.info('Succeeded in setting PasteData.'); -}); +var pasteData = pasteboard.createPlainTextData("hello"); +var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" +}; +pasteData.addWantRecord(object); ``` +### addTextRecord(deprecated) -### setPasteData +addTextRecord(text: string): void -setPasteData(data: PasteData): Promise<void> +向当前剪贴板内容中添加一条纯文本条目,并将MIME_TEXT_PLAIN添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 -将数据写入系统剪贴板,使用Promise异步回调。 +剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[addRecord](#addrecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard **参数:** -| 参数名 | 类型 | 说明 | -| -------- | -------- | -------- | -| data | [PasteData](#pastedata) | PasteData对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| text | string | 是 | 纯文本内容。 | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +pasteData.addTextRecord("good"); +``` + +### addUriRecord(deprecated) + +addUriRecord(uri: string): void + +向当前剪贴板内容中添加一条URI条目,并将MIMETYPE_TEXT_URI添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 + +剪贴板内容中添加的条目达到数量上限512后,后续的添加操作无效。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[addRecord](#addrecord9)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | URI内容。 | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +pasteData.addUriRecord("dataability:///com.example.myapplication1/user.txt"); +``` +### getRecordAt(deprecated) + +getRecordAt(index: number): PasteDataRecord + +获取剪贴板内容中指定下标的条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[getRecord](#getrecord9)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| index | number | 是 | 指定条目的下标。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| Promise<void> | 无返回结果的Promise对象。 | +| [PasteDataRecord](#pastedatarecord7) | 指定下标的条目。 | **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.setPasteData(pasteData).then((data) => { - console.info('Succeeded in setting PasteData.'); -}).catch((err) => { - console.error('Failed to set PasteData. Cause: ' + err.message); -}); +var pasteData = pasteboard.createPlainTextData("hello"); +var record = pasteData.getRecordAt(0); ``` +### hasMimeType(deprecated) -### getPasteData - -getPasteData( callback: AsyncCallback<PasteData>): void +hasMimeType(mimeType: string): boolean -读取系统剪贴板内容,使用callback异步回调。 +检查剪贴板内容中是否有指定的数据类型。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[hasType](#hastype9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -1170,47 +1098,90 @@ getPasteData( callback: AsyncCallback<PasteData>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[PasteData](#pastedata)> | 是 | 回调函数。当读取成功,err为undefined,data为返回的系统剪贴板数据;否则返回错误对象。 | +| mimeType | string | 是 | 待查询的数据类型。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | 有指定的数据类型返回true,否则返回false。 | **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData((err, pasteData) => { - if (err) { - console.error('Failed to get PasteData. Cause: ' + err.message); - return; - } - var text = pasteData.getPrimaryText(); -}); +var pasteData = pasteboard.createPlainTextData("hello"); +var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` +### removeRecordAt(deprecated) +removeRecordAt(index: number): boolean -### getPasteData +移除剪贴板内容中指定下标的条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[removeRecord](#removerecord9)替代。 -getPasteData(): Promise<PasteData> +**系统能力:** SystemCapability.MiscServices.Pasteboard -读取系统剪贴板内容,使用Promise异步回调。 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| index | number | 是 | 指定的下标。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | 成功移除返回true,失败返回false。 | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("hello"); +var isRemove = pasteData.removeRecordAt(0); +``` +### replaceRecordAt(deprecated) + +replaceRecordAt(index: number, record: PasteDataRecord): boolean + +替换剪贴板内容中指定下标的条目。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[replaceRecord](#replacerecord9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| index | number | 是 | 指定的下标。 | +| record | [PasteDataRecord](#pastedatarecord7) | 是 | 替换后的条目。 | + **返回值:** | 类型 | 说明 | | -------- | -------- | -| Promise<[PasteData](#pastedata)> | Promise对象,返回系统剪贴板数据。 | +| boolean | 成功替换返回true,失败返回false。 | **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData().then((pasteData) => { - var text = pasteData.getPrimaryText(); -}).catch((err) => { - console.error('Failed to get PasteData. Cause: ' + err.message); -}) +var pasteData = pasteboard.createPlainTextData("hello"); +var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); +var isReplace = pasteData.replaceRecordAt(0, record); ``` +## SystemPasteboard + +系统剪贴板对象。 + +在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。 + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +``` ### on('update')7+ @@ -1237,7 +1208,6 @@ var listener = () => { systemPasteboard.on('update', listener); ``` - ### off('update')7+ off(type: 'update', callback?: () =>void ): void @@ -1262,10 +1232,202 @@ let listener = () => { systemPasteboard.off('update', listener); ``` +### clearData9+ -### hasPasteData7+ +clearData(callback: AsyncCallback<void>): void -hasPasteData(callback: AsyncCallback<boolean>): void +清空系统剪贴板内容,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | 是 | 回调函数。当成功清空时,err为undefined;否则为错误对象。 | + +**示例:** + +```js +systemPasteboard.clearData((err, data) => { + if (err) { + console.error('Failed to clear the pasteboard. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in clearing the pasteboard.'); +}); +``` + +### clearData9+ + +clearData(): Promise<void> + +清空系统剪贴板内容,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +systemPasteboard.clearData().then((data) => { + console.info('Succeeded in clearing the pasteboard.'); +}).catch((err) => { + console.error('Failed to clear the pasteboard. Cause: ' + JSON.stringify(err)); +}); +``` + +### setData9+ + +setData(data: PasteData, callback: AsyncCallback<void>): void + +将数据写入系统剪贴板,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| data | [PasteData](#pastedata) | 是 | PasteData对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当写入成功,err为undefined,否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900003 | Another copy or paste is in progress. | +| 12900004 | Replication is prohibited. | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setData(pasteData, (err, data) => { + if (err) { + console.error('Failed to set PasteData. Cause: ' + err.message); + return; + } + console.info('Succeeded in setting PasteData.'); +}); +``` + +### setData9+ + +setData(data: PasteData): Promise<void> + +将数据写入系统剪贴板,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| data | [PasteData](#pastedata) | PasteData对象。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900003 | Another copy or paste is in progress. | +| 12900004 | Replication is prohibited. | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setData(pasteData).then((data) => { + console.info('Succeeded in setting PasteData.'); +}).catch((err) => { + console.error('Failed to set PasteData. Cause: ' + err.message); +}); +``` + +### getData9+ + +getData( callback: AsyncCallback<PasteData>): void + +读取系统剪贴板内容,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[PasteData](#pastedata)> | 是 | 回调函数。当读取成功,err为undefined,data为返回的系统剪贴板数据;否则返回错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900003 | Another copy or paste is in progress. | + +**示例:** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getData((err, pasteData) => { + if (err) { + console.error('Failed to get PasteData. Cause: ' + err.message); + return; + } + var text = pasteData.getPrimaryText(); +}); +``` + +### getData9+ + +getData(): Promise<PasteData> + +读取系统剪贴板内容,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<[PasteData](#pastedata)> | Promise对象,返回系统剪贴板数据。 | + +**错误码:** + +以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12900003 | Another copy or paste is in progress. | + +**示例:** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getData().then((pasteData) => { + var text = pasteData.getPrimaryText(); +}).catch((err) => { + console.error('Failed to get PasteData. Cause: ' + err.message); +}) +``` + +### hasData9+ + +hasData(callback: AsyncCallback<boolean>): void 判断系统剪贴板中是否有内容,使用callback异步回调。 @@ -1280,7 +1442,7 @@ hasPasteData(callback: AsyncCallback<boolean>): void **示例:** ```js -systemPasteboard.hasPasteData((err, data) => { +systemPasteboard.hasData((err, data) => { if (err) { console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); return; @@ -1289,10 +1451,9 @@ systemPasteboard.hasPasteData((err, data) => { }); ``` +### hasData9+ -### hasPasteData7+ - -hasPasteData(): Promise<boolean> +hasData(): Promise<boolean> 判断系统剪贴板中是否有内容,使用Promise异步回调。 @@ -1307,19 +1468,21 @@ hasPasteData(): Promise<boolean> **示例:** ```js -systemPasteboard.hasPasteData().then((data) => { +systemPasteboard.hasData().then((data) => { console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); }).catch((err) => { console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); }); ``` - -### clear7+ +### clear(deprecated) clear(callback: AsyncCallback<void>): void 清空系统剪贴板内容,使用callback异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.clearData](#cleardata9)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -1334,19 +1497,21 @@ clear(callback: AsyncCallback<void>): void ```js systemPasteboard.clear((err, data) => { if (err) { - console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); + console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); return; } console.info('Succeeded in clearing the PasteData.'); }); ``` - -### clear7+ +### clear(deprecated) clear(): Promise<void> 清空系统剪贴板内容,使用Promise异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[pasteboard.clearData](#cleardata9-1)替代。 **系统能力:** SystemCapability.MiscServices.Pasteboard @@ -1364,4 +1529,184 @@ systemPasteboard.clear().then((data) => { }).catch((err) => { console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); }); -``` \ No newline at end of file +``` + +### getPasteData(deprecated) + +getPasteData( callback: AsyncCallback<PasteData>): void + +读取系统剪贴板内容,使用callback异步回调。 +> **说明:** +> +> 从 API Version 6 开始支持,从 API Version 9 开始废弃,建议使用[getData](#getdata9)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[PasteData](#pastedata)> | 是 | 回调函数。当读取成功,err为undefined,data为返回的系统剪贴板数据;否则返回错误对象。 | + +**示例:** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getPasteData((err, pasteData) => { + if (err) { + console.error('Failed to get PasteData. Cause: ' + err.message); + return; + } + var text = pasteData.getPrimaryText(); +}); +``` + +### getPasteData(deprecated) + +getPasteData(): Promise<PasteData> + +读取系统剪贴板内容,使用Promise异步回调。 +> **说明:** +> +> 从 API Version 6 开始支持,从 API Version 9 开始废弃,建议使用[getData](#getdata9-1)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<[PasteData](#pastedata)> | Promise对象,返回系统剪贴板数据。 | + +**示例:** + +```js +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getPasteData().then((pasteData) => { + var text = pasteData.getPrimaryText(); +}).catch((err) => { + console.error('Failed to get PasteData. Cause: ' + err.message); +}) +``` + +### hasPasteData(deprecated) + +hasPasteData(callback: AsyncCallback<boolean>): void + +判断系统剪贴板中是否有内容,使用callback异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[hasData](#hasdata9)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | 是 | 返回true表示系统剪贴板中有内容,返回false表示系统剪贴板中没有内容。 | + +**示例:** + +```js +systemPasteboard.hasPasteData((err, data) => { + if (err) { + console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); +}); +``` + +### hasPasteData(deprecated) + +hasPasteData(): Promise<boolean> + +判断系统剪贴板中是否有内容,使用Promise异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[hasData](#hasdata9-1)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<boolean> | 返回true表示系统剪贴板中有内容,返回false表示系统剪贴板中没有内容。 | + +**示例:** + +```js +systemPasteboard.hasPasteData().then((data) => { + console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); +}); +``` + +### setPasteData(deprecated) + +setPasteData(data: PasteData, callback: AsyncCallback<void>): void + +将数据写入系统剪贴板,使用callback异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[setData](#setdata9)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| data | [PasteData](#pastedata) | 是 | PasteData对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当写入成功,err为undefined,否则为错误对象。 | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setPasteData(pasteData, (err, data) => { + if (err) { + console.error('Failed to set PasteData. Cause: ' + err.message); + return; + } + console.info('Succeeded in setting PasteData.'); +}); +``` +### setPasteData(deprecated) + +setPasteData(data: PasteData): Promise<void> + +将数据写入系统剪贴板,使用Promise异步回调。 +> **说明:** +> +> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[setData](#setdata9-1)替代。 + +**系统能力:** SystemCapability.MiscServices.Pasteboard + +**参数:** + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| data | [PasteData](#pastedata) | PasteData对象。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +var pasteData = pasteboard.createPlainTextData("content"); +var systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.setPasteData(pasteData).then((data) => { + console.info('Succeeded in setting PasteData.'); +}).catch((err) => { + console.error('Failed to set PasteData. Cause: ' + err.message); +}); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md index eb9615b1b4a6aeb117ebddd843efd605b5e179c1..18e7cbe45dc5a92acf7ab759b1c2819ac2da9f1b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @@ -496,7 +496,7 @@ try { ## PermissionActiveStatus -表示权限使用状态类型的枚举。 +表示权限使用状态变化类型的枚举。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken @@ -508,11 +508,13 @@ try { ## ActiveChangeResponse +表示某次权限使用状态变化的详情。 + **系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken | 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | ---------------------- | ---- | ---- | --------------------- | -| tokenId | number | 是 | 否 | 调用方的应用身份标识 | -| permissionName | string | 是 | 否 | 使用状态发生变化的权限名 | +| tokenId | number | 是 | 否 | 被订阅的应用身份标识 | +| permissionName | string | 是 | 否 | 权限使用状态发生变化的权限名 | | deviceId | string | 是 | 否 | 设备号 | -| activeStatus | [PermissionActiveStatus](#permissionactivestatus) | 是 | 否 | 权限使用状态类型 | +| activeStatus | [PermissionActiveStatus](#permissionactivestatus) | 是 | 否 | 权限使用状态变化类型 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index c187b3366cd892a42d791471a64fbf7d6ff23c9e..b1ad40aa1b6748ad6a11598526aae234055b3a09 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -27,7 +27,7 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void 获取当前应用的资源管理对象,使用callback形式返回ResourceManager对象。 -此接口仅可在FA模型下使用。 +**模型约束**:此接口仅可在FA模型下使用。 **系统能力**:SystemCapability.Global.ResourceManager @@ -60,7 +60,7 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage 获取指定应用的资源管理对象,使用callback形式返回ResourceManager对象。 -此接口仅可在FA模型下使用。 +**模型约束**:此接口仅可在FA模型下使用。 **系统能力**:SystemCapability.Global.ResourceManager @@ -83,7 +83,7 @@ getResourceManager(): Promise<ResourceManager> 获取当前应用的资源管理对象,使用Promise形式返回ResourceManager对象。 -此接口仅可在FA模型下使用。 +**模型约束**:此接口仅可在FA模型下使用。 **系统能力**:SystemCapability.Global.ResourceManager @@ -114,7 +114,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 获取指定应用的资源管理对象,使用Promise形式返回ResourceManager对象。 -此接口仅可在FA模型下使用。 +**模型约束**:此接口仅可在FA模型下使用。 **系统能力**:SystemCapability.Global.ResourceManager @@ -261,10 +261,9 @@ resourceManager.getResourceManager((error, mgr) => { > > - 资源文件在工程的resources目录中定义,id可通过$r(资源地址).id的方式获取,例如$r('app.string.test').id。 +### getStringValue9+ -### getString - -getString(resId: number, callback: AsyncCallback<string>): void +getStringValue(resId: number, callback: AsyncCallback<string>): void 用户获取指定资源ID对应的字符串,使用callback形式返回字符串。 @@ -276,23 +275,35 @@ getString(resId: number, callback: AsyncCallback<string>): void | resId | number | 是 | 资源ID值 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | -**示例:** +**错误码:** + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + +**示例Stage:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getString($r('app.string.test').id, (error, value) => { + try { + this.context.getStringValue($r('app.string.test').id, (error, value) => { if (error != null) { console.log("error is " + error); } else { let str = value; } }); - }); + } catch (error) { + console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getString +### getStringValue9+ -getString(resId: number): Promise<string> +getStringValue(resId: number): Promise<string> 用户获取指定资源ID对应的字符串,使用Promise形式返回字符串。 @@ -308,21 +319,31 @@ getString(resId: number): Promise<string> | --------------------- | ----------- | | Promise<string> | 资源ID值对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getString($r('app.string.test').id).then(value => { - let str = value; - }).catch(error => { - console.log("getstring promise error is " + error); - }); - }); + try { + this.context.resourceManager.getStringValue($r('app.string.test').id).then(value => { + let str = value; + }).catch(error => { + console.log("getStringValue promise error is " + error); + }); + } catch (error) { + console.error(`promise getStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getString9+ +### getStringValue9+ -getString(resource: Resource, callback: AsyncCallback<string>): void +getStringValue(resource: Resource, callback: AsyncCallback<string>): void 用户获取指定resource对象对应的字符串,使用callback形式返回字符串。 @@ -334,6 +355,14 @@ getString(resource: Resource, callback: AsyncCallback<string>): void | resource | [Resource](#resource9) | 是 | 资源信息 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -341,18 +370,24 @@ getString(resource: Resource, callback: AsyncCallback<string>): void moduleName: "entry", id: $r('app.string.test').id }; - this.context.resourceManager.getString(resource, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let str = value; - } - }); + tyr { + this.context.resourceManager.getStringValue(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + } catch (error) { + console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` -### getString9+ -getString(resource: Resource): Promise<string> +### getStringValue9+ + +getStringValue(resource: Resource): Promise<string> 用户获取指定resource对象对应的字符串,使用Promise形式返回字符串。 @@ -368,6 +403,14 @@ getString(resource: Resource): Promise<string> | --------------------- | ---------------- | | Promise<string> | resource对象对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -375,16 +418,21 @@ getString(resource: Resource): Promise<string> moduleName: "entry", id: $r('app.string.test').id }; - this.context.resourceManager.getString(resource).then(value => { + try { + this.context.resourceManager.getStringValue(resource).then(value => { let str = value; - }).catch(error => { - console.log("getstring promise error is " + error); - }); + }).catch(error => { + console.log("getStringValue promise error is " + error); + }); + } catch (error) { + console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getStringArray -getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void +### getStringArrayValue9+ + +getStringArrayValue(resId: number, callback: AsyncCallback<Array<string>>): void 用户获取指定资源ID对应的字符串数组,使用callback形式返回字符串数组。 @@ -396,23 +444,33 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>> | resId | number | 是 | 资源ID值 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getStringArray($r('app.strarray.test').id, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let strArray = value; - } - }); - }); + try { + this.context.resourceManager.getStringArrayValue($r('app.strarray.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let strArray = value; + } + }); + } catch (error) { + console.error(`callback getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getStringArray +### getStringArrayValue9+ -getStringArray(resId: number): Promise<Array<string>> +getStringArrayValue(resId: number): Promise<Array<string>> 用户获取指定资源ID对应的字符串数组,使用Promise形式返回字符串数组。 @@ -428,20 +486,30 @@ getStringArray(resId: number): Promise<Array<string>> | ---------------------------------- | ------------- | | Promise<Array<string>> | 资源ID值对应的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getStringArray($r('app.strarray.test').id).then(value => { - let strArray = value; - }).catch(error => { - console.log("getStringArray promise error is " + error); - }); - }); + try { + this.context.resourceManager.getStringArrayValue($r('app.strarray.test').id).then(value => { + let strArray = value; + }).catch(error => { + console.log("getStringArrayValue promise error is " + error); + }); + } catch (error) { + console.error(`promise getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getStringArray9+ +### getStringArrayValue9+ -getStringArray(resource: Resource, callback: AsyncCallback<Array<string>>): void +getStringArrayValue(resource: Resource, callback: AsyncCallback<Array<string>>): void 用户获取指定resource对象对应的字符串数组,使用callback形式返回回字符串数组。 @@ -453,6 +521,14 @@ getStringArray(resource: Resource, callback: AsyncCallback<Array<string> | resource | [Resource](#resource9) | 是 | 资源信息 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -460,18 +536,22 @@ getStringArray(resource: Resource, callback: AsyncCallback<Array<string> moduleName: "entry", id: $r('app.strarray.test').id }; - this.context.resourceManager.getStringArray(resource, (error, value) => { + try { + this.context.resourceManager.getStringArrayValue(resource, (error, value) => { if (error != null) { console.log("error is " + error); } else { let strArray = value; } - }); + }); + } catch (error) { + console.error(`callback getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getStringArray9+ +### getStringArrayValue9+ -getStringArray(resource: Resource): Promise<Array<string>> +getStringArrayValue(resource: Resource): Promise<Array<string>> 用户获取指定resource对象对应的字符串数组,使用Promise形式返回字符串数组。 @@ -487,6 +567,14 @@ getStringArray(resource: Resource): Promise<Array<string>> | ---------------------------------- | ------------------ | | Promise<Array<string>> | resource对象对应的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -494,16 +582,21 @@ getStringArray(resource: Resource): Promise<Array<string>> moduleName: "entry", id: $r('app.strarray.test').id }; - this.context.resourceManager.getStringArray(resource).then(value => { + try { + this.context.resourceManager.getStringArrayValue(resource).then(value => { let strArray = value; - }).catch(error => { - console.log("getStringArray promise error is " + error); - }); + }).catch(error => { + console.log("getStringArray promise error is " + error); + }); + } catch (error) { + console.error(`promise getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMedia -getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void +### getMediaContent + +getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void 用户获取指定资源ID对应的媒体文件内容,使用callback形式返回字节数组。 @@ -515,23 +608,32 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void | resId | number | 是 | 资源ID值 | | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getMedia($r('app.media.test').id, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let media = value; - } - }); - }); + try { + this.context.resourceManager.getMediaContent($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + } catch (error) { + console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMedia +### getMediaContent -getMedia(resId: number): Promise<Uint8Array> +getMediaContent(resId: number): Promise<Uint8Array> 用户获取指定资源ID对应的媒体文件内容,使用Promise形式返回字节数组。 @@ -547,20 +649,29 @@ getMedia(resId: number): Promise<Uint8Array> | ------------------------- | -------------- | | Promise<Uint8Array> | 资源ID值对应的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getMedia($r('app.media.test').id).then(value => { + try { + mgr.getMediaContent($r('app.media.test').id).then(value => { let media = value; }).catch(error => { - console.log("getMedia promise error is " + error); + console.log("getMediaContent promise error is " + error); }); - }); + } catch (error) { + console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMedia9+ +### getMediaContent9+ -getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void +getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>): void 用户获取指定resource对象对应的媒体文件内容,使用callback形式返回字节数组。 @@ -572,6 +683,13 @@ getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void | resource | [Resource](#resource9) | 是 | 资源信息 | | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts let resource = { @@ -579,18 +697,22 @@ getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void moduleName: "entry", id: $r('app.media.test').id }; - this.context.resourceManager.getMedia(resource, (error, value) => { - if (error != null) { + try { + this.context.resourceManager.getMediaContent(resource, (error, value) => { + if (error != null) { console.log("error is " + error); - } else { + } else { let media = value; - } - }); + } + }); + } catch (error) { + console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMedia9+ +### getMediaContent9+ -getMedia(resource: Resource): Promise<Uint8Array> +getMediaContent(resource: Resource): Promise<Uint8Array> 用户获取指定resource对象对应的媒体文件内容,使用Promise形式返回字节数组。 @@ -606,6 +728,13 @@ getMedia(resource: Resource): Promise<Uint8Array> | ------------------------- | ------------------- | | Promise<Uint8Array> | resource对象对应的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts let resource = { @@ -613,16 +742,21 @@ getMedia(resource: Resource): Promise<Uint8Array> moduleName: "entry", id: $r('app.media.test').id }; - this.context.resourceManager.getMedia(resource).then(value => { + try { + this.context.resourceManager.getMediaContent(resource).then(value => { let media = value; - }).catch(error => { - console.log("getMedia promise error is " + error); - }); + }).catch(error => { + console.log("getMediaContent promise error is " + error); + }); + } catch (error) { + console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMediaBase64 -getMediaBase64(resId: number, callback: AsyncCallback<string>): void +### getMediaContentBase64 + +getMediaContentBase64(resId: number, callback: AsyncCallback<string>): void 用户获取指定资源ID对应的图片资源Base64编码,使用callback形式返回字符串。 @@ -634,23 +768,32 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void | resId | number | 是 | 资源ID值 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getMediaBase64($r('app.media.test').id, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let media = value; - } - }); - }); + try { + mgr.getMediaContentBase64($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + } catch (error) { + console.error(`callback getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMediaBase64 +### getMediaContentBase64 -getMediaBase64(resId: number): Promise<string> +getMediaContentBase64(resId: number): Promise<string> 用户获取指定资源ID对应的图片资源Base64编码,使用Promise形式返回字符串。 @@ -666,20 +809,29 @@ getMediaBase64(resId: number): Promise<string> | --------------------- | -------------------- | | Promise<string> | 资源ID值对应的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getMediaBase64($r('app.media.test').id).then(value => { - let media = value; - }).catch(error => { - console.log("getMediaBase64 promise error is " + error); - }); - }); + try { + mgr.getMediaContentBase64($r('app.media.test').id).then(value => { + let media = value; + }).catch(error => { + console.log("getMediaContentBase64 promise error is " + error); + }); + } catch (error) { + console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMediaBase649+ +### getMediaContentBase649+ -getMediaBase64(resource: Resource, callback: AsyncCallback<string>): void +getMediaContentBase64(resource: Resource, callback: AsyncCallback<string>): void 用户获取指定resource对象对应的图片资源Base64编码,使用callback形式返回字符串。 @@ -691,6 +843,13 @@ getMediaBase64(resource: Resource, callback: AsyncCallback<string>): void | resource | [Resource](#resource9) | 是 | 资源信息 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts let resource = { @@ -698,18 +857,22 @@ getMediaBase64(resource: Resource, callback: AsyncCallback<string>): void moduleName: "entry", id: $r('app.media.test').id }; - this.context.resourceManager.getMediaBase64(resource, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let media = value; - } - }); + try { + this.context.resourceManager.getMediaContentBase64(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + } catch (error) { + console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getMediaBase649+ +### getMediaContentBase649+ -getMediaBase64(resource: Resource): Promise<string> +getMediaContentBase64(resource: Resource): Promise<string> 用户获取指定resource对象对应的图片资源Base64编码,使用Promise形式返回字符串。 @@ -725,6 +888,13 @@ getMediaBase64(resource: Resource): Promise<string> | --------------------- | ------------------------- | | Promise<string> | resource对象对应的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | + **示例:** ```ts let resource = { @@ -732,11 +902,15 @@ getMediaBase64(resource: Resource): Promise<string> moduleName: "entry", id: $r('app.media.test').id }; - this.context.resourceManager.getMediaBase64(resource).then(value => { - let media = value; - }).catch(error => { - console.log("getMediaBase64 promise error is " + error); - }); + try { + this.context.resourceManager.getMediaContentBase64(resource).then(value => { + let media = value; + }).catch(error => { + console.log("getMediaContentBase64 promise error is " + error); + }); + } catch (error) { + console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`) + } ``` @@ -848,9 +1022,9 @@ getDeviceCapability(): Promise<DeviceCapability> ``` -### getPluralString +### getPluralStringValue -getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void +getPluralStringValue(resId: number, num: number, callback: AsyncCallback<string>): void 根据指定数量获取指定ID字符串表示的单复数字符串,使用callback形式返回字符串。 @@ -863,23 +1037,33 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string> | num | number | 是 | 数量值 | | callback | AsyncCallback<string> | 是 | 异步回调,返回根据指定数量获取指定ID字符串表示的单复数字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let str = value; - } - }); - }); + try { + this.context.resourceManager.getPluralStringValue($r("app.plural.test").id, 1, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + } catch (error) { + console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getPluralString +### getPluralStringValue -getPluralString(resId: number, num: number): Promise<string> +getPluralStringValue(resId: number, num: number): Promise<string> 根据指定数量获取对指定ID字符串表示的单复数字符串,使用Promise形式返回字符串。 @@ -896,20 +1080,30 @@ getPluralString(resId: number, num: number): Promise<string> | --------------------- | ------------------------- | | Promise<string> | 根据提供的数量获取对应ID字符串表示的单复数字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getPluralString($r("app.plural.test").id, 1).then(value => { - let str = value; - }).catch(error => { - console.log("getPluralString promise error is " + error); - }); - }); + try { + this.context.resourceManager.getPluralStringValue($r("app.plural.test").id, 1).then(value => { + let str = value; + }).catch(error => { + console.log("getPluralStringValue promise error is " + error); + }); + } catch (error) { + console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getPluralString9+ +### getPluralStringValue9+ -getPluralString(resource: Resource, num: number, callback: AsyncCallback<string>): void +getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback<string>): void 根据指定数量获取指定resource对象表示的单复数字符串,使用callback形式返回字符串。 @@ -922,6 +1116,14 @@ getPluralString(resource: Resource, num: number, callback: AsyncCallback<stri | num | number | 是 | 数量值 | | callback | AsyncCallback<string> | 是 | 异步回调,返回根据指定数量获取指定resource对象表示的单复数字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -929,13 +1131,18 @@ getPluralString(resource: Resource, num: number, callback: AsyncCallback<stri moduleName: "entry", id: $r('app.plural.test').id }; - this.context.resourceManager.getPluralString(resource, 1, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let str = value; - } - }); + try { + this.context.resourceManager.getPluralStringValue(resource, 1, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + } catch (error) { + console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` ### getPluralString9+ @@ -957,6 +1164,14 @@ getPluralString(resource: Resource, num: number): Promise<string> | --------------------- | ------------------------------ | | Promise<string> | 根据提供的数量获取对应resource对象表示的单复数字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -964,16 +1179,21 @@ getPluralString(resource: Resource, num: number): Promise<string> moduleName: "entry", id: $r('app.plural.test').id }; - this.context.resourceManager.getPluralString(resource, 1).then(value => { - let str = value; - }).catch(error => { - console.log("getPluralString promise error is " + error); - }); + try { + this.context.resourceManager.getPluralString(resource, 1).then(value => { + let str = value; + }).catch(error => { + console.log("getPluralString promise error is " + error); + }); + } catch (error) { + console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getRawFile8+ -getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void +### getRawFileContent9+ + +getRawFileContent(path: string, callback: AsyncCallback<Uint8Array>): void 用户获取resources/rawfile目录下对应的rawfile文件内容,使用callback形式返回字节数组。 @@ -985,22 +1205,31 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void | path | string | 是 | rawfile文件路径 | | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的rawfile文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFile("test.xml", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let rawFile = value; - } - }); - }); + try { + this.context.resourceManager.getRawFileContent("test.xml", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let rawFile = value; + } + }); + } catch (error) { + console.error(`callback getRawFileContent failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` -### getRawFile8+ +### getRawFileContent9+ -getRawFile(path: string): Promise<Uint8Array> +getRawFileContent(path: string): Promise<Uint8Array> 用户获取resources/rawfile目录下对应的rawfile文件内容,使用Promise形式返回字节数组。 @@ -1016,20 +1245,29 @@ getRawFile(path: string): Promise<Uint8Array> | ------------------------- | ----------- | | Promise<Uint8Array> | rawfile文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | + **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFile("test.xml").then(value => { - let rawFile = value; - }).catch(error => { - console.log("getRawFile promise error is " + error); - }); - }); + try { + this.context.resourceManager.getRawFileContent("test.xml").then(value => { + let rawFile = value; + }).catch(error => { + console.log("getRawFileContent promise error is " + error); + }); + } catch (error) { + console.error(`promise getRawFileContent failed, error code: ${error.code}, message: ${error.message}.`) + } ``` -### getRawFileDescriptor8+ -getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void +### getRawFd9+ + +getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void 用户获取resources/rawfile目录下对应rawfile文件的descriptor,使用callback形式返回。 @@ -1039,26 +1277,34 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor& | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------------------------- | | path | string | 是 | rawfile文件路径 | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | +| callback | AsyncCallback<[getRawFd](#getrawfd9)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFileDescriptor("test.xml", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let fd = value.fd; - let offset = value.offset; - let length = value.length; - } - }); + try { + this.context.resourceManager.getRawFd("test.xml", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + } + }); + } catch(error => { + console.log("getRawFd callback error is " + error); }); ``` -### getRawFileDescriptor8+ +### getRawFd9+ -getRawFileDescriptor(path: string): Promise<RawFileDescriptor> +getRawFd(path: string): Promise<RawFileDescriptor> 用户获取resources/rawfile目录下对应rawfile文件的descriptor,使用Promise形式返回。 @@ -1072,19 +1318,27 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor> **返回值:** | 类型 | 说明 | | ---------------------------------------- | ------------------- | -| Promise<[RawFileDescriptor](#rawfiledescriptor8)> | rawfile文件descriptor | +| Promise<[getRawFd](#getrawfd9-1)> | rawfile文件descriptor | + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | **示例:** ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.getRawFileDescriptor("test.xml").then(value => { - let fd = value.fd; - let offset = value.offset; - let length = value.length; - }).catch(error => { - console.log("getRawFileDescriptor promise error is " + error); - }); - }); + try { + this.context.resourceManager.getRawFd("test.xml").then(value => { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + }).catch(error => { + console.log("getRawFd promise error is " + error); + }); + } catch (error) { + console.log("getRawFd promise error is " + error); + }; ``` ### closeRawFileDescriptor8+ @@ -1141,55 +1395,140 @@ closeRawFileDescriptor(path: string): Promise<void> }); ``` -### release7+ - -release() - -用户释放创建的resourceManager。 -**系统能力**:SystemCapability.Global.ResourceManager +### closeRawFd9+ -**示例:** - ```ts - resourceManager.getResourceManager((error, mgr) => { - mgr.release(); - }); - ``` +closeRawFd(path: string, callback: AsyncCallback<void>): void -### getStringByName9+ +用户关闭resources/rawfile目录下rawfile文件的descriptor,使用callback形式返回。 -getStringByName(resName: string, callback: AsyncCallback<string>): void +**系统能力**:SystemCapability.Global.ResourceManager -用户获取指定资源名称对应的字符串,使用callback形式返回字符串。 +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<void> | 是 | 异步回调 | -**系统能力**:SystemCapability.Global.ResourceManager +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | --------------- | -| resName | string | 是 | 资源名称 | -| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | -**示例:** +**示例:** ```ts - this.context.resourceManager.getStringByName("test", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let string = value; - } - }); + try { + mgr.closeRawFd("test.xml", (error, value) => { + if (error != null) { + console.log("error is " + error); + } + }); + } catch (error) { + console.error(`callback closeRawFd failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` -### getStringByName9+ +### closeRawFd8+ -getStringByName(resName: string): Promise<string> +closeRawFd(path: string): Promise<void> -用户获取指定资源名称对应的字符串,使用Promise形式返回字符串。 +用户关闭resources/rawfile目录下rawfile文件的descriptor,使用Promise形式返回。 **系统能力**:SystemCapability.Global.ResourceManager -**参数:** +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | + +**返回值:** +| 类型 | 说明 | +| ------------------- | ---- | +| Promise<void> | 无返回值 | + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001005 | The resource not found by path. | + +**示例:** + ```ts + try { + mgr.closeRawFd("test.xml").then(value => { + let result = value; + }).catch(error => { + console.log("closeRawFd promise error is " + error); + }); + } catch (error) { + console.error(`promise closeRawFd failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + +### release7+ + +release() + +用户释放创建的resourceManager。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.release(); + }); + ``` + +### getStringByName9+ + +getStringByName(resName: string, callback: AsyncCallback<string>): void + +用户获取指定资源名称对应的字符串,使用callback形式返回字符串。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------- | +| resName | string | 是 | 资源名称 | +| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + +**示例:** + ```ts + try { + this.context.resourceManager.getStringByName("test", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let string = value; + } + }); + } catch (error) { + console.error(`callback getStringByName failed, error code: ${error.code}, message: ${error.message}.`) + } + + ``` + +### getStringByName9+ + +getStringByName(resName: string): Promise<string> + +用户获取指定资源名称对应的字符串,使用Promise形式返回字符串。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1199,13 +1538,25 @@ getStringByName(resName: string): Promise<string> | --------------------- | ---------- | | Promise<string> | 资源名称对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getStringByName("test").then(value => { - let string = value; - }).catch(error => { - console.log("getStringByName promise error is " + error); - }); + try { + this.context.resourceManager.getStringByName("test").then(value => { + let string = value; + }).catch(error => { + console.log("getStringByName promise error is " + error); + }); + } catch (error) { + console.error(`promise getStringByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getStringArrayByName9+ @@ -1222,15 +1573,27 @@ getStringArrayByName(resName: string, callback: AsyncCallback<Array<string | resName | string | 是 | 资源名称 | | callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getStringArrayByName("test", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let strArray = value; - } - }); + try { + this.context.resourceManager.getStringArrayByName("test", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let strArray = value; + } + }); + } catch (error) { + console.error(`callback getStringArrayByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getStringArrayByName9+ @@ -1251,13 +1614,25 @@ getStringArrayByName(resName: string): Promise<Array<string>> | ---------------------------------- | ------------ | | Promise<Array<string>> | 资源名称对应的字符串数组 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getStringArrayByName("test").then(value => { - let strArray = value; - }).catch(error => { - console.log("getStringArrayByName promise error is " + error); - }); + try { + this.context.resourceManager.getStringArrayByName("test").then(value => { + let strArray = value; + }).catch(error => { + console.log("getStringArrayByName promise error is " + error); + }); + } catch (error) { + console.error(`promise getStringArrayByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getMediaByName9+ @@ -1274,15 +1649,27 @@ getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void | resName | string | 是 | 资源名称 | | callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getMediaByName("test", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let media = value; - } - }); + try { + this.context.resourceManager.getMediaByName("test", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + } catch (error) { + console.error(`callback getMediaByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getMediaByName9+ @@ -1303,13 +1690,25 @@ getMediaByName(resName: string): Promise<Uint8Array> | ------------------------- | ------------- | | Promise<Uint8Array> | 资源名称对应的媒体文件内容 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getMediaByName("test").then(value => { - let media = value; - }).catch(error => { - console.log("getMediaByName promise error is " + error); - }); + try { + this.context.resourceManager.getMediaByName("test").then(value => { + let media = value; + }).catch(error => { + console.log("getMediaByName promise error is " + error); + }); + } catch (error) { + console.error(`promise getMediaByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getMediaBase64ByName9+ @@ -1326,15 +1725,27 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): vo | resName | string | 是 | 资源名称 | | callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getMediaBase64ByName("test", (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let media = value; - } - }); + try { + this.context.resourceManager.getMediaBase64ByName("test", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + } catch (error) { + console.error(`callback getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getMediaBase64ByName9+ @@ -1355,13 +1766,25 @@ getMediaBase64ByName(resName: string): Promise<string> | --------------------- | ------------------- | | Promise<string> | 资源名称对应的图片资源Base64编码 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getMediaBase64ByName("test").then(value => { - let media = value; - }).catch(error => { - console.log("getMediaBase64ByName promise error is " + error); - }); + try { + this.context.resourceManager.getMediaBase64ByName("test").then(value => { + let media = value; + }).catch(error => { + console.log("getMediaBase64ByName promise error is " + error); + }); + } catch (error) { + console.error(`promise getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getPluralStringByName9+ @@ -1379,15 +1802,28 @@ getPluralStringByName(resName: string, num: number, callback: AsyncCallback<s | num | number | 是 | 数量值 | | callback | AsyncCallback<string> | 是 | 异步回调,返回根据传入的数量值获取资源名称对应的字符串资源 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getPluralStringByName("test", 1, (error, value) => { - if (error != null) { - console.log("error is " + error); - } else { - let str = value; - } - }); + try { + this.context.resourceManager.getPluralStringByName("test", 1, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + } catch (error) { + console.error(`callback getPluralStringByName failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` ### getPluralStringByName9+ @@ -1409,13 +1845,25 @@ getPluralStringByName(resName: string, num: number): Promise<string> | --------------------- | ---------------------- | | Promise<string> | 根据传入的数量值获取资源名称对应的字符串资源 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getPluralStringByName("test", 1).then(value => { + try { + this.context.resourceManager.getPluralStringByName("test", 1).then(value => { let str = value; - }).catch(error => { + }).catch(error => { console.log("getPluralStringByName promise error is " + error); - }); + }); + } catch (error) { + console.error(`promise getPluralStringByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getStringSync9+ @@ -1438,7 +1886,11 @@ getStringSync(resId: number): string **示例:** ```ts - this.context.resourceManager.getStringSync($r('app.string.test').id); + try { + this.context.resourceManager.getStringSync($r('app.string.test').id); + } catch (error) { + console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getStringSync9+ @@ -1459,6 +1911,14 @@ getStringSync(resource: Resource): string | ------ | ---------------- | | string | resource对象对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -1466,7 +1926,11 @@ getStringSync(resource: Resource): string moduleName: "entry", id: $r('app.string.test').id }; - this.context.resourceManager.getStringSync(resource); + try { + this.context.resourceManager.getStringSync(resource); + } catch (error) { + console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getStringByNameSync9+ @@ -1487,9 +1951,21 @@ getStringByNameSync(resName: string): string | ------ | ---------- | | string | 资源名称对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getStringByNameSync("test"); + try { + this.context.resourceManager.getStringByNameSync("test"); + } catch (error) { + console.error(`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getBoolean9+ @@ -1510,9 +1986,21 @@ getBoolean(resId: number): boolean | ------- | ------------ | | boolean | 资源ID值对应的布尔结果 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id); + try { + this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id); + } catch (error) { + console.error(`getBoolean failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getBoolean9+ @@ -1532,6 +2020,14 @@ getBoolean(resource: Resource): boolean | ------- | ----------------- | | boolean | resource对象对应的布尔结果 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -1539,7 +2035,11 @@ getBoolean(resource: Resource): boolean moduleName: "entry", id: $r('app.boolean.boolean_test').id }; - this.context.resourceManager.getBoolean(resource); + try { + this.context.resourceManager.getBoolean(resource); + } catch (error) { + console.error(`getBoolean failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getBooleanByName9+ @@ -1560,9 +2060,21 @@ getBooleanByName(resName: string): boolean | ------- | ----------- | | boolean | 资源名称对应的布尔结果 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getBooleanByName("boolean_test"); + try { + this.context.resourceManager.getBooleanByName("boolean_test"); + } catch (error) { + console.error(`getBooleanByName failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getNumber9+ @@ -1583,10 +2095,27 @@ getNumber(resId: number): number | ------ | ---------- | | number | 资源ID值对应的数值 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts - this.context.resourceManager.getNumber($r('app.integer.integer_test').id); - this.context.resourceManager.getNumber($r('app.float.float_test').id); + try { + this.context.resourceManager.getNumber($r('app.integer.integer_test').id); + } catch (error) { + console.error(`getNumber failed, error code: ${error.code}, message: ${error.message}.`) + } + + try { + this.context.resourceManager.getNumber($r('app.float.float_test').id); + } catch (error) { + console.error(`getNumber failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getNumber9+ @@ -1607,6 +2136,14 @@ getNumber(resource: Resource): number | ------ | --------------- | | number | resource对象对应的数值 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | The resId invalid. | +| 9001002 | The resource not found by resId. | +| 9001006 | The resource re-ref too much. | + **示例:** ```ts let resource = { @@ -1614,7 +2151,11 @@ getNumber(resource: Resource): number moduleName: "entry", id: $r('app.integer.integer_test').id }; - this.context.resourceManager.getNumber(resource); + try { + this.context.resourceManager.getNumber(resource); + } catch (error) { + console.error(`getNumber failed, error code: ${error.code}, message: ${error.message}.`) + } ``` ### getNumberByName9+ @@ -1635,8 +2176,464 @@ getNumberByName(resName: string): number | ------ | --------- | | number | 资源名称对应的数值 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001003 | The resName invalid. | +| 9001004 | The resource not found by resName. | +| 9001006 | The resource re-ref too much. | + +**示例:** + ```ts + try { + this.context.resourceManager.getNumberByName("integer_test"); + } catch (error) { + console.error(`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`) + } + + try { + this.context.resourceManager.getNumberByName("float_test"); + } catch (error) { + console.error(`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + + +### getString(deprecated) + +getString(resId: number, callback: AsyncCallback<string>): void + +用户获取指定资源ID对应的字符串,使用callback形式返回字符串。 + +从API version 9开始不再维护,建议使用[getStringValue](#getstringvalue9)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------- | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的字符串 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getString($r('app.string.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + }); + ``` + + +### getString(deprecated) + +getString(resId: number): Promise<string> + +用户获取指定资源ID对应的字符串,使用Promise形式返回字符串。 + +从API version 9开始不再维护,建议使用[getStringValue](#getstringvalue9-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | + +**返回值:** +| 类型 | 说明 | +| --------------------- | ----------- | +| Promise<string> | 资源ID值对应的字符串 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getString($r('app.string.test').id).then(value => { + let str = value; + }).catch(error => { + console.log("getstring promise error is " + error); + }); + }); + ``` + + +### getStringArray(deprecated) + +getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void + +用户获取指定资源ID对应的字符串数组,使用callback形式返回字符串数组。 + +从API version 9开始不再维护,建议使用[getStringArrayValue](#getstringarrayvalue9)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------- | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<Array<string>> | 是 | 异步回调,用于返回获取的字符串数组 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getStringArray($r('app.strarray.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let strArray = value; + } + }); + }); + ``` + + +### getStringArray(deprecated) + +getStringArray(resId: number): Promise<Array<string>> + +用户获取指定资源ID对应的字符串数组,使用Promise形式返回字符串数组。 + +从API version 9开始不再维护,建议使用[getStringArrayValue](#getstringarrayvalue9-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | + +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ------------- | +| Promise<Array<string>> | 资源ID值对应的字符串数组 | + **示例:** ```ts - this.context.resourceManager.getNumberByName("integer_test"); - this.context.resourceManager.getNumberByName("float_test"); + resourceManager.getResourceManager((error, mgr) => { + mgr.getStringArray($r('app.strarray.test').id).then(value => { + let strArray = value; + }).catch(error => { + console.log("getStringArray promise error is " + error); + }); + }); + ``` + + +### getMedia(deprecated) + +getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void + +用户获取指定资源ID对应的媒体文件内容,使用callback形式返回字节数组。 + +从API version 9开始不再维护,建议使用[getMediaContent](#getmediacontent)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ------------------ | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的媒体文件内容 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getMedia($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + }); + ``` + + +### getMedia(deprecated) + +getMedia(resId: number): Promise<Uint8Array> + +用户获取指定资源ID对应的媒体文件内容,使用Promise形式返回字节数组。 + +从API version 9开始不再维护,建议使用[getMediaContent](#getmediacontent-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | + +**返回值:** +| 类型 | 说明 | +| ------------------------- | -------------- | +| Promise<Uint8Array> | 资源ID值对应的媒体文件内容 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getMedia($r('app.media.test').id).then(value => { + let media = value; + }).catch(error => { + console.log("getMedia promise error is " + error); + }); + }); + ``` + + +### getMediaBase64(deprecated) + +getMediaBase64(resId: number, callback: AsyncCallback<string>): void + +用户获取指定资源ID对应的图片资源Base64编码,使用callback形式返回字符串。 + +从API version 9开始不再维护,建议使用[getMediaContentBase64](#getmediacontentbase64)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------ | +| resId | number | 是 | 资源ID值 | +| callback | AsyncCallback<string> | 是 | 异步回调,用于返回获取的图片资源Base64编码 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getMediaBase64($r('app.media.test').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + }); + ``` + + +### getMediaBase64(deprecated) + +getMediaBase64(resId: number): Promise<string> + +用户获取指定资源ID对应的图片资源Base64编码,使用Promise形式返回字符串。 + +从API version 9开始不再维护,建议使用[getMediaContentBase64](#getmediacontentbase64-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | + +**返回值:** +| 类型 | 说明 | +| --------------------- | -------------------- | +| Promise<string> | 资源ID值对应的图片资源Base64编码 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getMediaBase64($r('app.media.test').id).then(value => { + let media = value; + }).catch(error => { + console.log("getMediaBase64 promise error is " + error); + }); + }); + ``` + + +### getPluralString(deprecated) + +getPluralString(resId: number, num: number): Promise<string> + +根据指定数量获取对指定ID字符串表示的单复数字符串,使用Promise形式返回字符串。 + +从API version 9开始不再维护,建议使用[getPluralStringValue](#getpluralstringvalue)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----- | +| resId | number | 是 | 资源ID值 | +| num | number | 是 | 数量值 | + +**返回值:** +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<string> | 根据提供的数量获取对应ID字符串表示的单复数字符串 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getPluralString($r("app.plural.test").id, 1).then(value => { + let str = value; + }).catch(error => { + console.log("getPluralString promise error is " + error); + }); + }); + ``` + + +### getPluralString(deprecated) + +getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void + +根据指定数量获取指定ID字符串表示的单复数字符串,使用callback形式返回字符串。 + +从API version 9开始不再维护,建议使用[getPluralStringValue](#getpluralstringvalue-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------- | +| resId | number | 是 | 资源ID值 | +| num | number | 是 | 数量值 | +| callback | AsyncCallback<string> | 是 | 异步回调,返回根据指定数量获取指定ID字符串表示的单复数字符串 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + }); + ``` + + +### getRawFile(deprecated) + +getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void + +用户获取resources/rawfile目录下对应的rawfile文件内容,使用callback形式返回字节数组。 + +从API version 9开始不再维护,建议使用[getRawFileContent](#getrawfilecontent9)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ----------------------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<Uint8Array> | 是 | 异步回调,用于返回获取的rawfile文件内容 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFile("test.xml", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let rawFile = value; + } + }); + }); + ``` + + +### getRawFile(deprecated) + +getRawFile(path: string): Promise<Uint8Array> + +用户获取resources/rawfile目录下对应的rawfile文件内容,使用Promise形式返回字节数组。 + +从API version 9开始不再维护,建议使用[getRawFileContent](#getrawfilecontent9-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | + +**返回值:** +| 类型 | 说明 | +| ------------------------- | ----------- | +| Promise<Uint8Array> | rawfile文件内容 | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFile("test.xml").then(value => { + let rawFile = value; + }).catch(error => { + console.log("getRawFile promise error is " + error); + }); + }); + ``` + + +### getRawFileDescriptor(deprecated) + +getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void + +用户获取resources/rawfile目录下对应rawfile文件的descriptor,使用callback形式返回。 + +从API version 9开始不再维护,建议使用[getRawFd](#getrawfd9)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------- | +| path | string | 是 | rawfile文件路径 | +| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | 是 | 异步回调,用于返回获取的rawfile文件的descriptor | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFileDescriptor("test.xml", (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + } + }); + }); + ``` + +### getRawFileDescriptor(deprecated) + +getRawFileDescriptor(path: string): Promise<RawFileDescriptor> + +用户获取resources/rawfile目录下对应rawfile文件的descriptor,使用Promise形式返回。 + +从API version 9开始不再维护,建议使用[getRawFd](#getrawfd9-1)代替。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| path | string | 是 | rawfile文件路径 | + +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise<[RawFileDescriptor](#rawfiledescriptor8)> | rawfile文件descriptor | + +**示例:** + ```ts + resourceManager.getResourceManager((error, mgr) => { + mgr.getRawFileDescriptor("test.xml").then(value => { + let fd = value.fd; + let offset = value.offset; + let length = value.length; + }).catch(error => { + console.log("getRawFileDescriptor promise error is " + error); + }); + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index 69392844ef5062addc0166ba97654389bf7a7cba..76faadea4f9f7bc62c96aa2ad1d4e1e0ec7963eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -4,78 +4,78 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块从API version 9开始支持异常返回功能。 ## 导入模块 - ``` import rpc from '@ohos.rpc'; ``` -## MessageParcel - -在RPC过程中,发送方可以使用MessageParcel提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageParcel提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。 +## MessageSequence9+ + 在RPC过程中,发送方可以使用MessageSequence提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageSequence提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。 ### create -create(): MessageParcel + create(): MessageSequence -静态方法,创建MessageParcel对象。 + 静态方法,创建MessageSequence对象。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | MessageParcel | 返回创建的MessageParcel对象。 | + | 类型 | 说明 | + | --------------- | ------------------------------- | + | MessageSequence | 返回创建的MessageSequence对象。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); console.log("RpcClient: data is " + data); ``` - ### reclaim reclaim(): void -释放不再使用的MessageParcel对象。 +释放不再使用的MessageSequence对象。 **系统能力**:SystemCapability.Communication.IPC.Core **示例:** ``` - let reply = rpc.MessageParcel.create(); + let reply = rpc.MessageSequence.create(); reply.reclaim(); ``` - ### writeRemoteObject -writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean +writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void - 序列化远程对象并将其写入MessageParcel对象。 +序列化远程对象并将其写入MessageSequence对象。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | object | [IRemoteObject](#iremoteobject) | 是 | 要序列化并写入MessageParcel的远程对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | ----------------------------------------- | + | object | [IRemoteObject](#iremoteobject) | 是 | 要序列化并写入MessageSequence的远程对象。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果操作成功,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900008 | proxy or remote object is invalid | + | 1900009 | write data to message sequence failed | **示例:** @@ -89,36 +89,50 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; + try { + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); + } catch(error) { + console.info("Rpc register deathRecipient fail, errorCode " + error.code); + console.info("Rpc register deathRecipient fail, errorMessage " + error.message); } isObjectDead(): boolean { return false; } } - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let testRemoteObject = new TestRemoteObject("testObject"); - data.writeRemoteObject(testRemoteObject); + try { + data.writeRemoteObject(testRemoteObject); + } catch(error) { + console.info("Rpc write remote object fail, errorCode " + error.code); + console.info("Rpc write remote object fail, errorMessage " + error.message); + } ``` - ### readRemoteObject readRemoteObject(): IRemoteObject -从MessageParcel读取远程对象。此方法用于反序列化MessageParcel对象以生成IRemoteObject。远程对象按写入MessageParcel的顺序读取。 +从MessageSequence读取远程对象。此方法用于反序列化MessageSequence对象以生成IRemoteObject。远程对象按写入MessageSequence的顺序读取。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------------------- | ------------------ | | [IRemoteObject](#iremoteobject) | 读取到的远程对象。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | + | 1900010 | read data from message sequence failed | + **示例:** ``` @@ -131,196 +145,221 @@ readRemoteObject(): IRemoteObject constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; + try { + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); + } catch(error) { + console.info("Rpc register deathRecipient fail, errorCode " + error.code); + console.info("Rpc register deathRecipient fail, errorMessage " + error.message); } isObjectDead(): boolean { return false; } } - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let testRemoteObject = new TestRemoteObject("testObject"); - data.writeRemoteObject(testRemoteObject); - let proxy = data.readRemoteObject(); + try { + data.writeRemoteObject(testRemoteObject); + let proxy = data.readRemoteObject(); + } catch(error) { + console.info("Rpc write remote object fail, errorCode " + error.code); + console.info("Rpc write remote object fail, errorMessage " + error.message); + } ``` - ### writeInterfaceToken -writeInterfaceToken(token: string): boolean +writeInterfaceToken(token: string): void -将接口描述符写入MessageParcel对象,远端对象可使用该信息校验本次通信。 +将接口描述符写入MessageSequence对象,远端对象可使用该信息校验本次通信。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | token | string | 是 | 字符串类型描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------ | + | token | string | 是 | 字符串类型描述符。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果操作成功,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeInterfaceToken("aaa"); - console.log("RpcServer: writeInterfaceToken is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeInterfaceToken("aaa"); + } catch(error) { + console.info("rpc write interface fail, errorCode " + error.code); + console.info("rpc write interface fail, errorMessage " + error.message); + } ``` - ### readInterfaceToken readInterfaceToken(): string -从MessageParcel中读取接口描述符,接口描述符按写入MessageParcel的顺序读取,本地对象可使用该信息检验本次通信。 +从MessageSequence中读取接口描述符,接口描述符按写入MessageSequence的顺序读取,本地对象可使用该信息检验本次通信。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------------ | | string | 返回读取到的接口描述符。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ----- | + | 1900010 | read data from message sequence failed | + + **示例:** ``` class Stub extends rpc.RemoteObject { onRemoteRequest(code, data, reply, option) { - let interfaceToken = data.readInterfaceToken(); - console.log("RpcServer: interfaceToken is " + interfaceToken); + try { + let interfaceToken = data.readInterfaceToken(); + console.log("RpcServer: interfaceToken is " + interfaceToken); + } catch(error) { + console.info("RpcServer: read interfaceToken failed, errorCode " + error.code); + console.info("RpcServer: read interfaceToken failed, errorMessage " + error.message); + } return true; } } ``` - ### getSize getSize(): number -获取当前MessageParcel的数据大小。 +获取当前MessageSequence的数据大小。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 获取的MessageParcel的数据大小。以字节为单位。 | + | 类型 | 说明 | + | ------ | ----------------------------------------------- | + | number | 获取的MessageSequence的数据大小。以字节为单位。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let size = data.getSize(); console.log("RpcClient: size is " + size); ``` - ### getCapacity getCapacity(): number -获取当前MessageParcel的容量。 +获取当前MessageSequence的容量。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 获取的MessageParcel的容量大小。以字节为单位。 | + | 类型 | 说明 | + | ------ | ----- | + | number | 获取的MessageSequence的容量大小。以字节为单位。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let result = data.getCapacity(); console.log("RpcClient: capacity is " + result); ``` - ### setSize -setSize(size: number): boolean +setSize(size: number): void -设置MessageParcel实例中包含的数据大小。 +设置MessageSequence实例中包含的数据大小。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | size | number | 是 | MessageParcel实例的数据大小。以字节为单位。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | boolean | 设置成功返回true,否则返回false。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------ | + | size | number | 是 | MessageSequence实例的数据大小。以字节为单位。 | **示例:** ``` - let data = rpc.MessageParcel.create(); - let setSize = data.setSize(16); - console.log("RpcClient: setSize is " + setSize); + let data = rpc.MessageSequence.create(); + try { + data.setSize(16); + console.log("RpcClient: setSize is " + setSize); + } catch(error) { + console.info("rpc set size of MessageSequence fail, errorCode " + error.code); + console.info("rpc set size of MessageSequence fail, errorMessage " + error.message); + } ``` - ### setCapacity -setCapacity(size: number): boolean +setCapacity(size: number): void -设置MessageParcel实例的存储容量。 +设置MessageSequence实例的存储容量。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | size | number | 是 | MessageParcel实例的存储容量。以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | --------------------------------------------- | + | size | number | 是 | MessageSequence实例的存储容量。以字节为单位。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 设置成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------ | + | 1900011 | parcel memory alloc failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.setCapacity(100); - console.log("RpcClient: setCapacity is " + result); + let data = rpc.MessageSequence.create(); + try { + data.setCapacity(100); + console.log("RpcClient: setCapacity is " + result); + } catch(error) { + console.info("rpc memory alloc fail, errorCode " + error.code); + console.info("rpc memory alloc fail, errorMessage " + error.message); + } ``` - ### getWritableBytes getWritableBytes(): number -获取MessageParcel的可写字节空间。 +获取MessageSequence的可写字节空间。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** | 类型 | 说明 | - | -------- | -------- | - | number | 获取到的MessageParcel的可写字节空间。以字节为单位。 | + | ------ | ------ | + | number | 获取到的MessageSequence的可写字节空间。以字节为单位。 | **示例:** @@ -334,20 +373,19 @@ getWritableBytes(): number } ``` - ### getReadableBytes getReadableBytes(): number -获取MessageParcel的可读字节空间。 +获取MessageSequence的可读字节空间。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** | 类型 | 说明 | - | -------- | -------- | - | number | 获取到的MessageParcel的可读字节空间。以字节为单位。 | + | ------ | ------- | + | number | 获取到的MessageSequence的可读字节空间。以字节为单位。 | **示例:** @@ -361,57 +399,54 @@ getReadableBytes(): number } ``` - ### getReadPosition getReadPosition(): number -获取MessageParcel的读位置。 +获取MessageSequence的读位置。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** | 类型 | 说明 | - | -------- | -------- | - | number | 返回MessageParcel实例中的当前读取位置。 | + | ------ | ------ | + | number | 返回MessageSequence实例中的当前读取位置。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let readPos = data.getReadPosition(); console.log("RpcClient: readPos is " + readPos); ``` - ### getWritePosition getWritePosition(): number -获取MessageParcel的写位置。 +获取MessageSequence的写位置。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** | 类型 | 说明 | - | -------- | -------- | - | number | 返回MessageParcel实例中的当前写入位置。 | + | ------ | ----- | + | number | 返回MessageSequence实例中的当前写入位置。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); data.writeInt(10); let bwPos = data.getWritePosition(); console.log("RpcClient: bwPos is " + bwPos); ``` - ### rewindRead -rewindRead(pos: number): boolean +rewindRead(pos: number): void 重新偏移读取位置到指定的位置。 @@ -420,32 +455,30 @@ rewindRead(pos: number): boolean **参数:** | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | pos | number | 是 | 开始读取数据的目标位置。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果读取位置发生更改,则返回true;否则返回false。 | + | ------ | ------ | ---- | ------- | + | pos | number | 是 | 开始读取数据的目标位置。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); data.writeInt(12); - data.writeString("parcel"); + data.writeString("sequence"); let number = data.readInt(); console.log("RpcClient: number is " + number); - data.rewindRead(0); + try { + data.rewindRead(0); + } catch(error) { + console.info("rpc rewind read data fail, errorCode " + error.code); + console.info("rpc rewind read data fail, errorMessage " + error.message); + } let number2 = data.readInt(); console.log("RpcClient: rewindRead is " + number2); ``` - ### rewindWrite -rewindWrite(pos: number): boolean +rewindWrite(pos: number): void 重新偏移写位置到指定的位置。 @@ -454,532 +487,721 @@ rewindWrite(pos: number): boolean **参数:** | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | pos | number | 是 | 开始写入数据的目标位置。 | - -**返回值:** - - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果写入位置更改,则返回true;否则返回false。 | + | ------ | ------ | ---- | ----- | + | pos | number | 是 | 开始写入数据的目标位置。 | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); data.writeInt(4); - data.rewindWrite(0); + try { + data.rewindWrite(0); + } catch(error) { + console.info("rpc rewind read data fail, errorCode " + error.code); + console.info("rpc rewind read data fail, errorMessage " + error.message); + } data.writeInt(5); let number = data.readInt(); console.log("RpcClient: rewindWrite is: " + number); ``` - ### writeByte -writeByte(val: number): boolean +writeByte(val: number): void -将字节值写入MessageParcel实例。 +将字节值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | + | 参数名 | 类型 | 必填 | 说明 | + | ----- | ------ | ---- | ----- | | val | number | 是 | 要写入的字节值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回成功,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeByte(2); - console.log("RpcClient: writeByte is: " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeByte(2); + } catch(error) { + console.info("rpc write byte fail, errorCode " + error.code); + console.info("rpc write byte fail, errorMessage" + error.message); + } ``` - ### readByte readByte(): number -从MessageParcel实例读取字节值。 +从MessageSequence实例读取字节值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ----- | | number | 返回字节值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeByte(2); - console.log("RpcClient: writeByte is: " + result); - let ret = data.readByte(); - console.log("RpcClient: readByte is: " + ret); + let data = rpc.MessageSequence.create(); + try { + data.writeByte(2); + } catch(error) { + console.info("rpc write byte fail, errorCode " + error.code); + console.info("rpc write byte fail, errorMessage" + error.message); + } + try { + let ret = data.readByte(); + console.log("RpcClient: readByte is: " + ret); + } catch(error) { + console.info("rpc write byte fail, errorCode " + error.code); + console.info("rpc write byte fail, errorMessage" + error.message); + } ``` - ### writeShort -writeShort(val: number): boolean +writeShort(val: number): void -将短整数值写入MessageParcel实例。 +将短整数值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | --- | --- | | val | number | 是 | 要写入的短整数值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------ | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeShort(8); - console.log("RpcClient: writeShort is: " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeShort(8); + } catch(error) { + console.info("rpc write short fail, errorCode " + error.code); + console.info("rpc write short fail, errorMessage" + error.message); + } ``` - ### readShort readShort(): number -从MessageParcel实例读取短整数值。 +从MessageSequence实例读取短整数值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------------- | | number | 返回短整数值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeShort(8); - console.log("RpcClient: writeShort is: " + result); - let ret = data.readShort(); - console.log("RpcClient: readShort is: " + ret); + let data = rpc.MessageSequence.create(); + try { + data.writeShort(8); + } catch(error) { + console.info("rpc write short fail, errorCode " + error.code); + console.info("rpc write short fail, errorMessage" + error.message); + } + try { + let ret = data.readShort(8); + } catch(error) { + console.info("rpc read short fail, errorCode " + error.code); + console.info("rpc read short fail, errorMessage" + error.message); + } + console.log("RpcClient: readByte is: " + ret); ``` - ### writeInt -writeInt(val: number): boolean +writeInt(val: number): void -将整数值写入MessageParcel实例。 +将整数值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | number | 是 | 要写入的整数值。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的整数值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回成功,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeInt(10); - console.log("RpcClient: writeInt is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeInt(10); + } catch(error) { + console.info("rpc write int fail, errorCode " + error.code); + console.info("rpc write int fail, errorMessage" + error.message); + } ``` - ### readInt readInt(): number -从MessageParcel实例读取整数值。 +从MessageSequence实例读取整数值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------ | | number | 返回整数值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeInt(10); - console.log("RpcClient: writeInt is " + result); - let ret = data.readInt(); + let data = rpc.MessageSequence.create(); + try { + data.writeInt(10); + } catch(error) { + console.info("rpc write int fail, errorCode " + error.code); + console.info("rpc write int fail, errorMessage" + error.message); + } + try { + let ret = data.readInt(); + } catch(error) { + console.info("rpc read int fail, errorCode " + error.code); + console.info("rpc read int fail, errorMessage" + error.message); + } console.log("RpcClient: readInt is " + ret); ``` - ### writeLong -writeLong(val: number): boolean +writeLong(val: number): void -将长整数值写入MessageParcel实例。 +将长整数值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | number | 是 | 要写入的长整数值 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的长整数值 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeLong(10000); - console.log("RpcClient: writeLong is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeLong(10000); + } catch(error) { + console.info("rpc write long fail, errorCode " + error.code); + console.info("rpc write long fail, errorMessage" + error.message); + } ``` - ### readLong readLong(): number -从MessageParcel实例中读取长整数值。 +从MessageSequence实例中读取长整数值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------------- | | number | 返回长整数值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeLong(10000); - console.log("RpcClient: writeLong is " + result); - let ret = data.readLong(); + let data = rpc.MessageSequence.create(); + try { + data.writeLong(10000); + } catch(error) { + console.info("rpc write long fail, errorCode " + error.code); + console.info("rpc write long fail, errorMessage" + error.message); + } + try { + let ret = data.readLong(); + } catch(error) { + console.info("rpc read long fail, errorCode " + error.code); + console.info("rpc read long fail, errorMessage" + error.message); + } console.log("RpcClient: readLong is " + ret); ``` - ### writeFloat -writeFloat(val: number): boolean +writeFloat(val: number): void -将浮点值写入MessageParcel实例。 +将浮点值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | + | ----- | ---- | ---- | ----- | | val | number | 是 | 要写入的浮点值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900010 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeFloat(1.2); - console.log("RpcClient: writeFloat is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeFloat(1.2); + } catch(error) { + console.info("rpc write float fail, errorCode " + error.code); + console.info("rpc write float fail, errorMessage" + error.message); + } ``` - ### readFloat readFloat(): number -从MessageParcel实例中读取浮点值。 +从MessageSequence实例中读取浮点值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------ | | number | 返回浮点值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeFloat(1.2); - console.log("RpcClient: writeFloat is " + result); - let ret = data.readFloat(); + let data = rpc.MessageSequence.create(); + try { + data.writeFloat(1.2); + } catch(error) { + console.info("rpc write float fail, errorCode " + error.code); + console.info("rpc write float fail, errorMessage" + error.message); + } + try { + let ret = data.readFloat(); + } catch(error) { + console.info("rpc read float fail, errorCode " + error.code); + console.info("rpc read float fail, errorMessage" + error.message); + } console.log("RpcClient: readFloat is " + ret); ``` - ### writeDouble -writeDouble(val: number): boolean +writeDouble(val: number): void -将双精度浮点值写入MessageParcel实例。 +将双精度浮点值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | number | 是 | 要写入的双精度浮点值。 | + | ------ | ------ | ---- | ------ | + | val number | 是 | 要写入的双精度浮点值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeDouble(10.2); - console.log("RpcClient: writeDouble is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeDouble(10.2); + } catch(error) { + console.info("rpc read float fail, errorCode " + error.code); + console.info("rpc read float fail, errorMessage" + error.message); + } ``` - ### readDouble readDouble(): number -从MessageParcel实例读取双精度浮点值。 +从MessageSequence实例读取双精度浮点值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------ | | number | 返回双精度浮点值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeDouble(10.2); - console.log("RpcClient: writeDouble is " + result); - let ret = data.readDouble(); + let data = rpc.MessageSequence.create(); + try { + data.writeDouble(10.2); + } catch(error) { + console.info("rpc write double fail, errorCode " + error.code); + console.info("rpc write double fail, errorMessage" + error.message); + } + try { + let ret = data.readDouble(); + } catch(error) { + console.info("rpc read double fail, errorCode " + error.code); + console.info("rpc read double fail, errorMessage" + error.message); + } console.log("RpcClient: readDouble is " + ret); ``` - ### writeBoolean -writeBoolean(val: boolean): boolean +writeBoolean(val: boolean): void -将布尔值写入MessageParcel实例。 +将布尔值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | boolean | 是 | 要写入的布尔值。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------- | ---- | ---------------- | + | val | boolean | 是 | 要写入的布尔值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeBoolean(false); - console.log("RpcClient: writeBoolean is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeBoolean(false); + } catch(error) { + console.info("rpc write boolean fail, errorCode " + error.code); + console.info("rpc write boolean fail, errorMessage" + error.message); + } ``` - ### readBoolean readBoolean(): boolean -从MessageParcel实例读取布尔值。 +从MessageSequence实例读取布尔值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | -------------------- | | boolean | 返回读取到的布尔值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeBoolean(false); - console.log("RpcClient: writeBoolean is " + result); - let ret = data.readBoolean(); + let data = rpc.MessageSequence.create(); + try { + data.writeBoolean(false); + } catch(error) { + console.info("rpc write boolean fail, errorCode " + error.code); + console.info("rpc write boolean fail, errorMessage" + error.message); + } + try { + let ret = data.readBoolean(); + } catch(error) { + console.info("rpc read boolean fail, errorCode " + error.code); + console.info("rpc read boolean fail, errorMessage" + error.message); + } console.log("RpcClient: readBoolean is " + ret); ``` - ### writeChar -writeChar(val: number): boolean +writeChar(val: number): void -将单个字符值写入MessageParcel实例。 +将单个字符值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | number | 是 | 要写入的单个字符值。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | val | number | 是 | 要写入的单个字符值。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeChar(97); - console.log("RpcClient: writeChar is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeChar(97); + } catch(error) { + console.info("rpc write char fail, errorCode " + error.code); + console.info("rpc write char fail, errorMessage" + error.message); + } ``` - ### readChar readChar(): number -从MessageParcel实例中读取单个字符值。 +从MessageSequence实例中读取单个字符值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ---- | | number | 返回单个字符值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------ | --------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeChar(97); - console.log("RpcClient: writeChar is " + result); - let ret = data.readChar(); + let data = rpc.MessageSequence.create(); + try { + data.writeChar(97); + } catch(error) { + console.info("rpc write char fail, errorCode " + error.code); + console.info("rpc write char fail, errorMessage" + error.message); + } + try { + let ret = data.readChar(); + } catch(error) { + console.info("rpc read char fail, errorCode " + error.code); + console.info("rpc read char fail, errorMessage" + error.message); + } console.log("RpcClient: readChar is " + ret); ``` - ### writeString -writeString(val: string): boolean +writeString(val: string): void -将字符串值写入MessageParcel实例。 +将字符串值写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | string | 是 | 要写入的字符串值,其长度应小于40960字节。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ----------------------------------------- | + | val | string | 是 | 要写入的字符串值,其长度应小于40960字节。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeString('abc'); - console.log("RpcClient: writeString is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeString('abc'); + } catch(error) { + console.info("rpc write string fail, errorCode " + error.code); + console.info("rpc write string fail, errorMessage" + error.message); + } ``` - ### readString readString(): string -从MessageParcel实例读取字符串值。 +从MessageSequence实例读取字符串值。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------------- | | string | 返回字符串值。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeString('abc'); - console.log("RpcClient: writeString is " + result); - let ret = data.readString(); + let data = rpc.MessageSequence.create(); + try { + data.writeString('abc'); + } catch(error) { + console.info("rpc write string fail, errorCode " + error.code); + console.info("rpc write string fail, errorMessage" + error.message); + } + try { + let ret = data.readString(); + } catch(error) { + console.info("rpc read string fail, errorCode " + error.code); + console.info("rpc read string fail, errorMessage" + error.message); + } console.log("RpcClient: readString is " + ret); ``` +### writeParcelable -### writeSequenceable - -writeSequenceable(val: Sequenceable): boolean +writeParcelable(val: Parcelable): void -将自定义序列化对象写入MessageParcel实例。 +将自定义序列化对象写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | val | [Sequenceable](#sequenceable) | 是 | 要写入的可序列对象。 | + | ------ | --------- | ---- | ------ | + | val | Parcelable | 是 | 要写入的可序列对象。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -991,43 +1213,49 @@ writeSequenceable(val: Sequenceable): boolean this.num = num; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } - let sequenceable = new MySequenceable(1, "aaa"); - let data = rpc.MessageParcel.create(); - let result = data.writeSequenceable(sequenceable); - console.log("RpcClient: writeSequenceable is " + result); + let parcelable = new MyParcelable(1, "aaa"); + let data = rpc.MessageSequence.create(); + try { + data.writeParcelable(parcelable); + } catch(error) { + console.info("rpc write parcelable fail, errorCode " + error.code); + console.info("rpc write parcelable fail, errorMessage" + error.message); + } ``` +### readParcelable -### readSequenceable - -readSequenceable(dataIn: Sequenceable) : boolean +readParcelable(dataIn: Parcelable) : void -从MessageParcel实例中读取成员变量到指定的对象(dataIn)。 +从MessageSequence实例中读取成员变量到指定的对象(dataIn)。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | [Sequenceable](#sequenceable) | 是 | 需要从MessageParcel读取成员变量的对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------- | ---- | ----------------------------------------- | + | dataIn | Parcelable | 是 | 需要从MessageSequence读取成员变量的对象。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果反序列成功,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **示例:** @@ -1039,749 +1267,1093 @@ readSequenceable(dataIn: Sequenceable) : boolean this.num = num; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } - let sequenceable = new MySequenceable(1, "aaa"); - let data = rpc.MessageParcel.create(); - let result = data.writeSequenceable(sequenceable); - console.log("RpcClient: writeSequenceable is " + result); - let ret = new MySequenceable(0, ""); - let result2 = data.readSequenceable(ret); - console.log("RpcClient: writeSequenceable is " + result2); + let parcelable = new MyParcelable(1, "aaa"); + let data = rpc.MessageSequence.create(); + data.writeParcelable(parcelable); + let ret = new MyParcelable(0, ""); + try { + data.readParcelable(ret); + }catch{ + console.info("rpc read parcelable fail, errorCode " + error.code); + console.info("rpc read parcelable fail, errorMessage" + error.message); + } ``` - ### writeByteArray -writeByteArray(byteArray: number[]): boolean +writeByteArray(byteArray: number[]): void -将字节数组写入MessageParcel实例。 +将字节数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | byteArray | number[] | 是 | 要写入的字节数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | ------------------ | + | byteArray | number[] | 是 | 要写入的字节数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let ByteArrayVar = [1, 2, 3, 4, 5]; - let result = data.writeByteArray(ByteArrayVar); - console.log("RpcClient: writeByteArray is " + result); + try { + data.writeByteArray(ByteArrayVar); + } catch(error) { + console.info("rpc write byteArray fail, errorCode " + error.code); + console.info("rpc write byteArray fail, errorMessage" + error.message); + } ``` - ### readByteArray readByteArray(dataIn: number[]) : void -从MessageParcel实例读取字节数组。 +从MessageSequence实例读取字节数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的字节数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | 是 | 要读取的字节数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let ByteArrayVar = [1, 2, 3, 4, 5]; - let result = data.writeByteArray(ByteArrayVar); - console.log("RpcClient: writeByteArray is " + result); - let array = new Array(5); - data.readByteArray(array); + try { + data.writeByteArray(ByteArrayVar); + } catch(error) { + console.info("rpc write byteArray fail, errorCode " + error.code); + console.info("rpc write byteArray fail, errorMessage" + error.message); + } + try { + let array = new Array(5); + data.readByteArray(array); + } catch(error) { + console.info("rpc write byteArray fail, errorCode " + error.code); + console.info("rpc write byteArray fail, errorMessage" + error.message); + } ``` - ### readByteArray readByteArray(): number[] -从MessageParcel实例中读取字节数组。 +从MessageSequence实例中读取字节数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | -------------- | | number[] | 返回字节数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let ByteArrayVar = [1, 2, 3, 4, 5]; - let result = data.writeByteArray(ByteArrayVar); - console.log("RpcClient: writeByteArray is " + result); - let array = data.readByteArray(); - console.log("RpcClient: readByteArray is " + array); + try { + data.writeByteArray(ByteArrayVar); + console.log("RpcClient: readByteArray is " + array); + } catch(error) { + console.info("rpc write byteArray fail, errorCode " + error.code); + console.info("rpc write byteArray fail, errorMessage" + error.message); + } + try { + let array = data.readByteArray(); + } catch(error) { + console.info("rpc read byteArray fail, errorCode " + error.code); + console.info("rpc read byteArray fail, errorMessage" + error.message); + } ``` - ### writeShortArray -writeShortArray(shortArray: number[]): boolean +writeShortArray(shortArray: number[]): void -将短整数数组写入MessageParcel实例。 +将短整数数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | shortArray | number[] | 是 | 要写入的短整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | -------- | ---- | -------------------- | + | shortArray | number[] | 是 | 要写入的短整数数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ----- | ----- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeShortArray([11, 12, 13]); - console.log("RpcClient: writeShortArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeShortArray([11, 12, 13]); + } catch(error) { + console.info("rpc read byteArray fail, errorCode " + error.code); + console.info("rpc read byteArray fail, errorMessage" + error.message); + } ``` - ### readShortArray readShortArray(dataIn: number[]) : void -从MessageParcel实例中读取短整数数组。 +从MessageSequence实例中读取短整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的短整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | 是 | 要读取的短整数数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------ | ------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeShortArray([11, 12, 13]); - console.log("RpcClient: writeShortArray is " + result); - let array = new Array(3); - data.readShortArray(array); + let data = rpc.MessageSequence.create(); + try { + data.writeShortArray([11, 12, 13]); + } catch(error) { + console.info("rpc write shortArray fail, errorCode " + error.code); + console.info("rpc write shortArray fail, errorMessage" + error.message); + } + try { + let array = new Array(3); + data.readShortArray(array); + } catch(error) { + console.info("rpc read shortArray fail, errorCode " + error.code); + console.info("rpc read shortArray fail, errorMessage" + error.message); + } ``` - ### readShortArray readShortArray(): number[] -从MessageParcel实例中读取短整数数组。 +从MessageSequence实例中读取短整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ---------------- | | number[] | 返回短整数数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeShortArray([11, 12, 13]); - console.log("RpcClient: writeShortArray is " + result); - let array = data.readShortArray(); - console.log("RpcClient: readShortArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeShortArray([11, 12, 13]); + } catch(error) { + console.info("rpc write shortArray fail, errorCode " + error.code); + console.info("rpc write shortArray fail, errorMessage" + error.message); + } + try { + let array = data.readShortArray(); + console.log("RpcClient: readShortArray is " + array); + } catch(error) { + console.info("rpc read shortArray fail, errorCode " + error.code); + console.info("rpc read shortArray fail, errorMessage" + error.message); + } ``` - ### writeIntArray -writeIntArray(intArray: number[]): boolean +writeIntArray(intArray: number[]): void -将整数数组写入MessageParcel实例。 +将整数数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | intArray | number[] | 是 | 要写入的整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | ---- | ------------------ | + | intArray | number[] | 是 | 要写入的整数数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ----- | --------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeIntArray([100, 111, 112]); - console.log("RpcClient: writeIntArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeIntArray([100, 111, 112]); + } catch(error) { + console.info("rpc write intArray fail, errorCode " + error.code); + console.info("rpc write intArray fail, errorMessage" + error.message); + } ``` - ### readIntArray readIntArray(dataIn: number[]) : void -从MessageParcel实例中读取整数数组。 +从MessageSequence实例中读取整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | 是 | 要读取的整数数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeIntArray([100, 111, 112]); - console.log("RpcClient: writeIntArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeIntArray([100, 111, 112]); + } catch(error) { + console.info("rpc write intArray fail, errorCode " + error.code); + console.info("rpc write intArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readIntArray(array); + try { + data.readIntArray(array); + } catch(error) { + console.info("rpc read intArray fail, errorCode " + error.code); + console.info("rpc read intArray fail, errorMessage" + error.message); + } ``` - ### readIntArray readIntArray(): number[] -从MessageParcel实例中读取整数数组。 +从MessageSequence实例中读取整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | -------------- | | number[] | 返回整数数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ----- | ------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeIntArray([100, 111, 112]); - console.log("RpcClient: writeIntArray is " + result); - let array = data.readIntArray(); - console.log("RpcClient: readIntArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeIntArray([100, 111, 112]); + } catch(error) { + console.info("rpc write intArray fail, errorCode " + error.code); + console.info("rpc write intArray fail, errorMessage" + error.message); + } + try { + let array = data.readIntArray(); + console.log("RpcClient: readIntArray is " + array); + } catch(error) { + console.info("rpc read intArray fail, errorCode " + error.code); + console.info("rpc read intArray fail, errorMessage" + error.message); + } ``` - ### writeLongArray -writeLongArray(longArray: number[]): boolean +writeLongArray(longArray: number[]): void -将长整数数组写入MessageParcel实例。 +将长整数数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | longArray | number[] | 是 | 要写入的长整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | -------------------- | + | longArray | number[] | 是 | 要写入的长整数数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ----- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeLongArray([1111, 1112, 1113]); - console.log("RpcClient: writeLongArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeLongArray([1111, 1112, 1113]); + }cathc(error){ + console.info("rpc write longArray fail, errorCode " + error.code); + console.info("rpc write longArray fail, errorMessage" + error.message); + } ``` - ### readLongArray readLongArray(dataIn: number[]) : void -从MessageParcel实例读取长整数数组。 +从MessageSequence实例读取长整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的长整数数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | 是 | 要读取的长整数数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------ | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeLongArray([1111, 1112, 1113]); - console.log("RpcClient: writeLongArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeLongArray([1111, 1112, 1113]); + } catch(error) { + console.info("rpc write longArray fail, errorCode " + error.code); + console.info("rpc write longArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readLongArray(array); + try { + data.readLongArray(array); + } catch(error) { + console.info("rpc read longArray fail, errorCode " + error.code); + console.info("rpc read longArray fail, errorMessage" + error.message); + } ``` - ### readLongArray readLongArray(): number[] -从MessageParcel实例中读取长整数数组。 +从MessageSequence实例中读取长整数数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ---------------- | | number[] | 返回长整数数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeLongArray([1111, 1112, 1113]); - console.log("RpcClient: writeLongArray is " + result); - let array = data.readLongArray(); - console.log("RpcClient: readLongArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeLongArray([1111, 1112, 1113]); + } catch(error) { + console.info("rpc write longArray fail, errorCode " + error.code); + console.info("rpc write longArray fail, errorMessage" + error.message); + } + try { + let array = data.readLongArray(); + console.log("RpcClient: readLongArray is " + array); + } catch(error) { + console.info("rpc read longArray fail, errorCode " + error.code); + console.info("rpc read longArray fail, errorMessage" + error.message); + } ``` - ### writeFloatArray -writeFloatArray(floatArray: number[]): boolean +writeFloatArray(floatArray: number[]): void -将浮点数组写入MessageParcel实例。 +将浮点数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | floatArray | number[] | 是 | 要写入的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | + | floatArray | number[] | 是 | 要写入的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeFloatArray([1.2, 1.3, 1.4]); - console.log("RpcClient: writeFloatArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeFloatArray([1.2, 1.3, 1.4]); + } catch(error) { + console.info("rpc write floatArray fail, errorCode " + error.code); + console.info("rpc write floatArray fail, errorMessage" + error.message); + } ``` - ### readFloatArray readFloatArray(dataIn: number[]) : void -从MessageParcel实例中读取浮点数组。 +从MessageSequence实例中读取浮点数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ----------------------------------------------------------------------------------------------------------------------- | + | dataIn | number[] | 是 | 要读取的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeFloatArray([1.2, 1.3, 1.4]); - console.log("RpcClient: writeFloatArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeFloatArray([1.2, 1.3, 1.4]); + }cath(error){ + console.info("rpc write floatArray fail, errorCode " + error.code); + console.info("rpc write floatArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readFloatArray(array); + try { + data.readFloatArray(array); + } catch(error) { + console.info("rpc read floatArray fail, errorCode " + error.code); + console.info("rpc read floatArray fail, errorMessage" + error.message); + } ``` - ### readFloatArray readFloatArray(): number[] -从MessageParcel实例中读取浮点数组。 +从MessageSequence实例中读取浮点数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | -------------- | | number[] | 返回浮点数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeFloatArray([1.2, 1.3, 1.4]); - console.log("RpcClient: writeFloatArray is " + result); - let array = data.readFloatArray(); - console.log("RpcClient: readFloatArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeFloatArray([1.2, 1.3, 1.4]); + } catch(error) { + console.info("rpc write floatArray fail, errorCode " + error.code); + console.info("rpc write floatArray fail, errorMessage" + error.message); + } + try { + let array = data.readFloatArray(); + console.log("RpcClient: readFloatArray is " + array); + } catch(error) { + console.info("rpc read floatArray fail, errorCode " + error.code); + console.info("rpc read floatArray fail, errorMessage" + error.message); + } ``` - ### writeDoubleArray -writeDoubleArray(doubleArray: number[]): boolean +writeDoubleArray(doubleArray: number[]): void -将双精度浮点数组写入MessageParcel实例。 +将双精度浮点数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | doubleArray | number[] | 是 | 要写入的双精度浮点数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | -------- | ---- | ------------------------ | + | doubleArray | number[] | 是 | 要写入的双精度浮点数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeDoubleArray([11.1, 12.2, 13.3]); - console.log("RpcClient: writeDoubleArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeDoubleArray([11.1, 12.2, 13.3]); + } catch(error) { + console.info("rpc write doubleArray fail, errorCode " + error.code); + console.info("rpc write doubleArray fail, errorMessage" + error.message); + } ``` - ### readDoubleArray readDoubleArray(dataIn: number[]) : void -从MessageParcel实例中读取双精度浮点数组。 +从MessageSequence实例中读取双精度浮点数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的双精度浮点数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------------ | + | dataIn | number[] | 是 | 要读取的双精度浮点数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeDoubleArray([11.1, 12.2, 13.3]); - console.log("RpcClient: writeDoubleArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeDoubleArray([11.1, 12.2, 13.3]); + } catch(error) { + console.info("rpc write doubleArray fail, errorCode " + error.code); + console.info("rpc write doubleArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readDoubleArray(array); + try { + data.readDoubleArray(array); + } catch(error) { + console.info("rpc read doubleArray fail, errorCode " + error.code); + console.info("rpc read doubleArray fail, errorMessage" + error.message); + } ``` - ### readDoubleArray readDoubleArray(): number[] -从MessageParcel实例读取双精度浮点数组。 +从MessageSequence实例读取双精度浮点数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | -------------------- | | number[] | 返回双精度浮点数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeDoubleArray([11.1, 12.2, 13.3]); - console.log("RpcClient: writeDoubleArray is " + result); - let array = data.readDoubleArray(); - console.log("RpcClient: readDoubleArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeDoubleArray([11.1, 12.2, 13.3]); + } catch(error) { + console.info("rpc write doubleArray fail, errorCode " + error.code); + console.info("rpc write doubleArray fail, errorMessage" + error.message); + } + try { + let array = data.readDoubleArray(); + console.log("RpcClient: readDoubleArray is " + array); + } catch(error) { + console.info("rpc read doubleArray fail, errorCode " + error.code); + console.info("rpc read doubleArray fail, errorMessage" + error.message); + } ``` - ### writeBooleanArray -writeBooleanArray(booleanArray: boolean[]): boolean +writeBooleanArray(booleanArray: boolean[]): void -将布尔数组写入MessageParcel实例。 +将布尔数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | booleanArray | boolean[] | 是 | 要写入的布尔数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------------ | --------- | ---- | ------------------ | + | booleanArray | boolean[] | 是 | 要写入的布尔数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeBooleanArray([false, true, false]); - console.log("RpcClient: writeBooleanArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeBooleanArray([false, true, false]); + } catch(error) { + console.info("rpc write booleanArray fail, errorCode " + error.code); + console.info("rpc write booleanArray fail, errorMessage" + error.message); + } ``` - ### readBooleanArray readBooleanArray(dataIn: boolean[]) : void -从MessageParcel实例中读取布尔数组。 +从MessageSequence实例中读取布尔数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | boolean[] | 是 | 要读取的布尔数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | --------- | ---- | ------------------ | + | dataIn | boolean[] | 是 | 要读取的布尔数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeBooleanArray([false, true, false]); - console.log("RpcClient: writeBooleanArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeBooleanArray([false, true, false]); + } catch(error) { + console.info("rpc write booleanArray fail, errorCode " + error.code); + console.info("rpc write booleanArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readBooleanArray(array); + try { + data.readBooleanArray(array); + } catch(error) { + console.info("rpc read booleanArray fail, errorCode " + error.code); + console.info("rpc read booleanArray fail, errorMessage" + error.message); + } ``` - ### readBooleanArray readBooleanArray(): boolean[] -从MessageParcel实例中读取布尔数组。 +从MessageSequence实例中读取布尔数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------- | -------------- | | boolean[] | 返回布尔数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + +**示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeBooleanArray([false, true, false]); - console.log("RpcClient: writeBooleanArray is " + result); - let array = data.readBooleanArray(); - console.log("RpcClient: readBooleanArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeBooleanArray([false, true, false]); + } catch(error) { + console.info("rpc write booleanArray fail, errorCode " + error.code); + console.info("rpc write booleanArray fail, errorMessage" + error.message); + } + try { + let array = data.readBooleanArray(); + console.log("RpcClient: readBooleanArray is " + array); + } catch(error) { + console.info("rpc read booleanArray fail, errorCode " + error.code); + console.info("rpc read booleanArray fail, errorMessage" + error.message); + } ``` - ### writeCharArray -writeCharArray(charArray: number[]): boolean +writeCharArray(charArray: number[]): void -将单个字符数组写入MessageParcel实例。 +将单个字符数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | charArray | number[] | 是 | 要写入的单个字符数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | ---------------------- | + | charArray | number[] | 是 | 要写入的单个字符数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------ | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeCharArray([97, 98, 88]); - console.log("RpcClient: writeCharArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeCharArray([97, 98, 88]); + } catch(error) { + console.info("rpc write charArray fail, errorCode " + error.code); + console.info("rpc write charArray fail, errorMessage" + error.message); + } ``` - ### readCharArray readCharArray(dataIn: number[]) : void -从MessageParcel实例中读取单个字符数组。 +从MessageSequence实例中读取单个字符数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | 要读取的单个字符数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ---------------------- | + | dataIn | number[] | 是 | 要读取的单个字符数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeCharArray([97, 98, 99]); - console.log("RpcClient: writeCharArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeCharArray([97, 98, 88]); + } catch(error) { + console.info("rpc write charArray fail, errorCode " + error.code); + console.info("rpc write charArray fail, errorMessage" + error.message); + } let array = new Array(3); - data.readCharArray(array); + try { + data.readCharArray(array); + } catch(error) { + console.info("rpc read charArray fail, errorCode " + error.code); + console.info("rpc read charArray fail, errorMessage" + error.message); + } ``` - ### readCharArray readCharArray(): number[] -从MessageParcel实例读取单个字符数组。 +从MessageSequence实例读取单个字符数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ------------------ | | number[] | 返回单个字符数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeCharArray([97, 98, 99]); - console.log("RpcClient: writeCharArray is " + result); - let array = data.readCharArray(); - console.log("RpcClient: readCharArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeCharArray([97, 98, 88]); + } catch(error) { + console.info("rpc write charArray fail, errorCode " + error.code); + console.info("rpc write charArray fail, errorMessage" + error.message); + } + let array = new Array(3); + try { + let array = data.readCharArray(); + console.log("RpcClient: readCharArray is " + array); + } catch(error) { + console.info("rpc read charArray fail, errorCode " + error.code); + console.info("rpc read charArray fail, errorMessage" + error.message); + } ``` - ### writeStringArray -writeStringArray(stringArray: string[]): boolean +writeStringArray(stringArray: string[]): void -将字符串数组写入MessageParcel实例。 +将字符串数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | stringArray | string[] | 是 | 要写入的字符串数组,数组单个元素的长度应小于40960字节。 | + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | -------- | ---- | ------------------------------------------------------- | + | stringArray | string[] | 是 | 要写入的字符串数组,数组单个元素的长度应小于40960字节。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeStringArray(["abc", "def"]); - console.log("RpcClient: writeStringArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeStringArray(["abc", "def"]); + } catch(error) { + console.info("rpc write stringArray fail, errorCode " + error.code); + console.info("rpc write stringArray fail, errorMessage" + error.message); + } ``` - ### readStringArray readStringArray(dataIn: string[]) : void -从MessageParcel实例读取字符串数组。 +从MessageSequence实例读取字符串数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | string[] | 是 | 要读取的字符串数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | string[] | 是 | 要读取的字符串数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeStringArray(["abc", "def"]); - console.log("RpcClient: writeStringArray is " + result); + let data = rpc.MessageSequence.create(); + try { + data.writeStringArray(["abc", "def"]); + } catch(error) { + console.info("rpc write stringArray fail, errorCode " + error.code); + console.info("rpc write stringArray fail, errorMessage" + error.message); + } let array = new Array(2); - data.readStringArray(array); + try { + data.readStringArray(array); + } catch(error) { + console.info("rpc read stringArray fail, errorCode " + error.code); + console.info("rpc read stringArray fail, errorMessage" + error.message); + } ``` - ### readStringArray readStringArray(): string[] -从MessageParcel实例读取字符串数组。 +从MessageSequence实例读取字符串数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ---------------- | | string[] | 返回字符串数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let data = rpc.MessageParcel.create(); - let result = data.writeStringArray(["abc", "def"]); - console.log("RpcClient: writeStringArray is " + result); - let array = data.readStringArray(); - console.log("RpcClient: readStringArray is " + array); + let data = rpc.MessageSequence.create(); + try { + data.writeStringArray(["abc", "def"]); + } catch(error) { + console.info("rpc write stringArray fail, errorCode " + error.code); + console.info("rpc write stringArray fail, errorMessage" + error.message); + } + try { + let array = data.readStringArray(); + console.log("RpcClient: readStringArray is " + array); + } catch(error) { + console.info("rpc read stringArray fail, errorCode " + error.code); + console.info("rpc read stringArray fail, errorMessage" + error.message); + } ``` - -### writeNoException8+ +### writeNoException writeNoException(): void -向MessageParcel写入“指示未发生异常”的信息。 +向MessageSequence写入“指示未发生异常”的信息。 **系统能力**:SystemCapability.Communication.IPC.Core +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | + **示例:** ``` @@ -1794,19 +2366,20 @@ writeNoException(): void constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } onRemoteRequest(code, data, reply, option) { if (code === 1) { console.log("RpcServer: onRemoteRequest called"); - reply.writeNoException(); + try { + reply.writeNoException(); + } catch(error) { + console.info("rpc write no exception fail, errorCode " + error.code); + console.info("rpc write no exception fail, errorMessage" + error.message); + } return true; } else { console.log("RpcServer: unknown code: " + code); @@ -1816,15 +2389,22 @@ writeNoException(): void } ``` - -### readException8+ +### readException readException(): void -从MessageParcel中读取异常。 +从MessageSequence中读取异常。 **系统能力**:SystemCapability.Communication.IPC.Core +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` @@ -1848,147 +2428,171 @@ readException(): void }; FA.connectAbility(want, connect); let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); + let reply = rpc.MessageSequence.create(); data.writeInt(1); data.writeString("hello"); - proxy.sendRequestAsync(1, data, reply, option) + proxy.sendMessageRequest(1, data, reply, option) .then(function(errCode) { if (errCode === 0) { - console.log("sendRequestAsync got result"); - reply.readException(); + console.log("sendMessageRequest got result"); + try { + reply.readException(); + } catch(error) { + console.info("rpc read exception fail, errorCode " + error.code); + console.info("rpc read no exception fail, errorMessage" + error.message); + } let msg = reply.readString(); console.log("RPCTest: reply msg: " + msg); } else { - console.log("RPCTest: sendRequestAsync failed, errCode: " + errCode); + console.log("RPCTest: sendMessageRequest failed, errCode: " + errCode); } }).catch(function(e) { - console.log("RPCTest: sendRequestAsync got exception: " + e.message); + console.log("RPCTest: sendMessageRequest got exception: " + e.message); }).finally (() => { - console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); + console.log("RPCTest: sendMessageRequest ends, reclaim parcel"); data.reclaim(); reply.reclaim(); }); ``` +### writeParcelableArray -### writeSequenceableArray - -writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean +writeParcelableArray(parcelableArray: Parcelable[]): void -将可序列化对象数组写入MessageParcel实例。 +将可序列化对象数组写入MessageSequence实例。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | sequenceableArray | Sequenceable[] | 是 | 要写入的可序列化对象数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------------- | ------------ | ---- | -------------------------- | + | parcelableArray | Parcelable[] | 是 | 要写入的可序列化对象数组。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 写入成功返回true,否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - class MySequenceable { + class MyParcelable { num: number; str: string; constructor(num, str) { this.num = num; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } - let sequenceable = new MySequenceable(1, "aaa"); - let sequenceable2 = new MySequenceable(2, "bbb"); - let sequenceable3 = new MySequenceable(3, "ccc"); - let a = [sequenceable, sequenceable2, sequenceable3]; - let data = rpc.MessageParcel.create(); - let result = data.writeSequenceableArray(a); - console.log("RpcClient: writeSequenceableArray is " + result); + let parcelable = new MyParcelable(1, "aaa"); + let parcelable2 = new MyParcelable(2, "bbb"); + let parcelable3 = new MyParcelable(3, "ccc"); + let a = [parcelable, parcelable2, parcelable3]; + let data = rpc.MessageSequence.create(); + try { + data.writeParcelableArray(a); + } catch(error) { + console.info("rpc write parcelable array fail, errorCode " + error.code); + console.info("rpc write parcelable array fail, errorMessage" + error.message); + } ``` +### readParcelableArray -### readSequenceableArray8+ - -readSequenceableArray(sequenceableArray: Sequenceable[]): void +readParcelableArray(parcelableArray: Parcelable[]): void -从MessageParcel实例读取可序列化对象数组。 +从MessageSequence实例读取可序列化对象数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | sequenceableArray | Sequenceable[] | 是 | 要读取的可序列化对象数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------------- | ------------ | ---- | -------------------------- | + | parcelableArray | Parcelable[] | 是 | 要读取的可序列化对象数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **示例:** ``` - class MySequenceable { + class MyParcelable { num: number; str: string; constructor(num, str) { this.num = num; this.str = str; } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); return true; } } - let sequenceable = new MySequenceable(1, "aaa"); - let sequenceable2 = new MySequenceable(2, "bbb"); - let sequenceable3 = new MySequenceable(3, "ccc"); - let a = [sequenceable, sequenceable2, sequenceable3]; - let data = rpc.MessageParcel.create(); - let result = data.writeSequenceableArray(a); - console.log("RpcClient: writeSequenceableArray is " + result); - let b = [new MySequenceable(0, ""), new MySequenceable(0, ""), new MySequenceable(0, "")]; - data.readSequenceableArray(b); + let parcelable = new MyParcelable(1, "aaa"); + let parcelable2 = new MyParcelable(2, "bbb"); + let parcelable3 = new MyParcelable(3, "ccc"); + let a = [parcelable, parcelable2, parcelable3]; + let data = rpc.MessageSequence.create(); + let result = data.writeParcelableArray(a); + console.log("RpcClient: writeParcelableArray is " + result); + let b = [new MyParcelable(0, ""), new MyParcelable(0, ""), new MyParcelable(0, "")]; + try { + data.readParcelableArray(b); + } catch(error) { + console.info("rpc read parcelable array fail, errorCode " + error.code); + console.info("rpc read parcelable array fail, errorMessage" + error.message); + } + data.readParcelableArray(b); ``` +### writeRemoteObjectArray -### writeRemoteObjectArray8+ - -writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean +writeRemoteObjectArray(objectArray: IRemoteObject[]): void -将IRemoteObject对象数组写入MessageParcel。 +将IRemoteObject对象数组写入MessageSequence。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | --------------- | ---- | ---------------------------------------------- | + | objectArray | IRemoteObject[] | 是 | 要写入MessageSequence的IRemoteObject对象数组。 | - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | objectArray | IRemoteObject[] | 是 | 要写入MessageParcel的IRemoteObject对象数组。 | +**错误码:** -**返回值:** +以下错误码的详细介绍请参见ohos.rpc错误码 - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果IRemoteObject对象数组成功写入MessageParcel,则返回true;如果对象为null或数组写入MessageParcel失败,则返回false。 | + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2001,14 +2605,10 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean class TestRemoteObject extends rpc.RemoteObject { constructor(descriptor) { super(descriptor); - this.attachLocalInterface(this, descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; + this.modifyLocalInterface(this, descriptor); } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -2017,25 +2617,38 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean } } let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; - let data = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); let result = data.writeRemoteObjectArray(a); + try { + data.writeRemoteObjectArray(a); + } catch(error) { + console.info("rpc write remote object array fail, errorCode " + error.code); + console.info("rpc write remote object array fail, errorMessage" + error.message); + } console.log("RpcClient: writeRemoteObjectArray is " + result); ``` - -### readRemoteObjectArray8+ +### readRemoteObjectArray readRemoteObjectArray(objects: IRemoteObject[]): void -从MessageParcel读取IRemoteObject对象数组。 +从MessageSequence读取IRemoteObject对象数组。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | objects | IRemoteObject[] | 是 | 从MessageParcel读取的IRemoteObject对象数组。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | --------------- | ---- | ---------------------------------------------- | + | objects | IRemoteObject[] | 是 | 从MessageSequence读取的IRemoteObject对象数组。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2048,14 +2661,10 @@ readRemoteObjectArray(objects: IRemoteObject[]): void class TestRemoteObject extends rpc.RemoteObject { constructor(descriptor) { super(descriptor); - this.attachLocalInterface(this, descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; + this.modifyLocalInterface(this, descriptor); } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -2064,27 +2673,40 @@ readRemoteObjectArray(objects: IRemoteObject[]): void } } let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; - let data = rpc.MessageParcel.create(); - let result = data.writeRemoteObjectArray(a); + let data = rpc.MessageSequence.create(); + data.writeRemoteObjectArray(a); let b = new Array(3); + try { + data.readRemoteObjectArray(b); + } catch(error) { + console.info("rpc read remote object array fail, errorCode " + error.code); + console.info("rpc read remote object array fail, errorMessage" + error.message); + } data.readRemoteObjectArray(b); ``` - -### readRemoteObjectArray8+ +### readRemoteObjectArray readRemoteObjectArray(): IRemoteObject[] -从MessageParcel读取IRemoteObject对象数组。 +从MessageSequence读取IRemoteObject对象数组。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | --------------- | --------------------------- | | IRemoteObject[] | 返回IRemoteObject对象数组。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` @@ -2096,14 +2718,10 @@ readRemoteObjectArray(): IRemoteObject[] class TestRemoteObject extends rpc.RemoteObject { constructor(descriptor) { super(descriptor); - this.attachLocalInterface(this, descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; + this.modifyLocalInterface(this, descriptor); } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -2112,10 +2730,14 @@ readRemoteObjectArray(): IRemoteObject[] } } let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; - let data = rpc.MessageParcel.create(); - let result = data.writeRemoteObjectArray(a); - console.log("RpcClient: readRemoteObjectArray is " + result); - let b = data.readRemoteObjectArray(); + let data = rpc.MessageSequence.create(); + data.writeRemoteObjectArray(a); + try { + let b = data.readRemoteObjectArray(); + } catch(error) { + console.info("rpc read remote object array fail, errorCode " + error.code); + console.info("rpc read remote object array fail, errorMessage" + error.message); + } console.log("RpcClient: readRemoteObjectArray is " + b); ``` @@ -2130,9 +2752,9 @@ static closeFileDescriptor(fd: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 要关闭的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | fd | number | 是 | 要关闭的文件描述符。 | **示例:** @@ -2140,11 +2762,15 @@ static closeFileDescriptor(fd: number): void import fileio from '@ohos.fileio'; let filePath = "path/to/file"; let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - rpc.MessageParcel.closeFileDescriptor(fd); + try { + rpc.MessageSequence.closeFileDescriptor(fd); + } catch(error) { + console.info("rpc close file descriptor fail, errorCode " + error.code); + console.info("rpc close file descriptor fail, errorMessage" + error.message); + } ``` - -### dupFileDescriptor8+ +### dupFileDescriptor static dupFileDescriptor(fd: number) :number @@ -2154,681 +2780,3704 @@ static dupFileDescriptor(fd: number) :number **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 表示已存在的文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | fd | number | 是 | 表示已存在的文件描述符。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------------------- | | number | 返回新的文件描述符。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900013 | call os dup function failed | + **示例:** ``` import fileio from '@ohos.fileio'; let filePath = "path/to/file"; let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let newFd = rpc.MessageParcel.dupFileDescriptor(fd); + try { + let newFd = rpc.MessageSequence.dupFileDescriptor(fd); + } catch(error) { + console.info("rpc dup file descriptor fail, errorCode " + error.code); + console.info("rpc dup file descriptor fail, errorMessage" + error.message); + } ``` - -### containFileDescriptors8+ +### containFileDescriptors containFileDescriptors(): boolean -检查此MessageParcel对象是否包含文件描述符。 +检查此MessageSequence对象是否包含文件描述符。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果此MessageParcel对象包含文件描述符,则返回true;否则返回false。 | + | 类型 | 说明 | + | ------- | -------------------------------------------------------------------- | + | boolean | 如果此MessageSequence对象包含文件描述符,则返回true;否则返回false。 | **示例:** + ``` import fileio from '@ohos.fileio'; - let parcel = new rpc.MessageParcel(); + let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; - let r1 = parcel.containFileDescriptors(); + let r1 = sequence.containFileDescriptors(); let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); - console.log("RpcTest: parcel writeFd result is : " + writeResult); - let containFD = parcel.containFileDescriptors(); - console.log("RpcTest: parcel after write fd containFd result is : " + containFD); + try { + sequence.writeFileDescriptor(fd); + } catch(error) { + console.info("rpc write file descriptor fail, errorCode " + error.code); + console.info("rpc write file descriptor fail, errorMessage" + error.message); + } + try { + let containFD = sequence.containFileDescriptors(); + } catch(error) { + console.info("rpc contain file descriptor fail, errorCode " + error.code); + console.info("rpc contain file descriptor fail, errorMessage" + error.message); + } + console.log("RpcTest: sequence after write fd containFd result is : " + containFD); ``` +### writeFileDescriptor -### writeFileDescriptor8+ - -writeFileDescriptor(fd: number): boolean +writeFileDescriptor(fd: number): void -写入文件描述符到MessageParcel。 +写入文件描述符到MessageSequence。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | fd | number | 是 | 文件描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------ | + | fd | number | 是 | 文件描述符。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果操作成功,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------ | + | 1900009 | write data to message sequence failed | **示例:** ``` import fileio from '@ohos.fileio'; - let parcel = new rpc.MessageParcel(); + let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); - console.log("RpcTest: parcel writeFd result is : " + writeResult); + try { + sequence.writeFileDescriptor(fd); + } catch(error) { + console.info("rpc write file descriptor fail, errorCode " + error.code); + console.info("rpc write file descriptor fail, errorMessage" + error.message); + } ``` -### readFileDescriptor8+ +### readFileDescriptor readFileDescriptor(): number -从MessageParcel中读取文件描述符。 +从MessageSequence中读取文件描述符。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ---------------- | | number | 返回文件描述符。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` import fileio from '@ohos.fileio'; - let parcel = new rpc.MessageParcel(); + let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); - let readFD = parcel.readFileDescriptor(); - console.log("RpcTest: parcel read fd is : " + readFD); + try { + sequence.writeFileDescriptor(fd); + } catch(error) { + console.info("rpc write file descriptor fail, errorCode " + error.code); + console.info("rpc write file descriptor fail, errorMessage" + error.message); + } + try { + let readFD = sequence.readFileDescriptor(); + } catch(error) { + console.info("rpc read file descriptor fail, errorCode " + error.code); + console.info("rpc read file descriptor fail, errorMessage" + error.message); + } ``` -### writeAshmem8+ +### writeAshmem -writeAshmem(ashmem: Ashmem): boolean +writeAshmem(ashmem: Ashmem): void -将指定的匿名共享对象写入此MessageParcel。 +将指定的匿名共享对象写入此MessageSequence。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | ashmem | Ashmem | 是 | 要写入MessageParcel的匿名共享对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------------------- | + | ashmem | Ashmem | 是 | 要写入MessageSequence的匿名共享对象。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果匿名共享对象成功写入此MessageParcel,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** ``` - let parcel = new rpc.MessageParcel(); - let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); - let isWriteSuccess = parcel.writeAshmem(ashmem); - console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); + let sequence = new rpc.MessageSequence(); + try { + let ashmem = rpc.Ashmem.create("ashmem", 1024); + } catch(error) { + console.info("rpc create ashmem fail, errorCode " + error.code); + console.info("rpc creat ashmem fail, errorMessage" + error.message); + } + try { + sequence.writeAshmem(ashmem); + } catch(error) { + console.info("rpc write ashmem fail, errorCode " + error.code); + console.info("rpc write ashmem fail, errorMessage" + error.message); + } ``` -### readAshmem8+ +### readAshmem readAshmem(): Ashmem -从MessageParcel读取匿名共享对象。 +从MessageSequence读取匿名共享对象。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------ | | Ashmem | 返回匿名共享对象。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let parcel = new rpc.MessageParcel(); - let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); - let isWriteSuccess = parcel.writeAshmem(ashmem); - console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); - let readAshmem = parcel.readAshmem(); + let sequence = new rpc.MessageSequence(); + try { + let ashmem = rpc.Ashmem.create("ashmem", 1024); + } catch(error) { + console.info("rpc create ashmem fail, errorCode " + error.code); + console.info("rpc creat ashmem fail, errorMessage" + error.message); + } + try { + sequence.writeAshmem(ashmem); + } catch(error) { + console.info("rpc write ashmem fail, errorCode " + error.code); + console.info("rpc write ashmem fail, errorMessage" + error.message); + } + try { + let readAshmem = sequence.readAshmem(); + } catch(error) { + console.info("rpc read ashmem fail, errorCode " + error.code); + console.info("rpc read ashmem fail, errorMessage" + error.message); + } console.log("RpcTest: read ashmem to result is : " + readAshmem); ``` -### getRawDataCapacity8+ +### getRawDataCapacity getRawDataCapacity(): number -获取MessageParcel可以容纳的最大原始数据量。 +获取MessageSequence可以容纳的最大原始数据量。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回MessageParcel可以容纳的最大原始数据量,即128 Mb。 | + | 类型 | 说明 | + | ------ | ------------------------------------------------------------ | + | number | 返回MessageSequence可以容纳的最大原始数据量,即128 Mb。 | **示例:** ``` - let parcel = new rpc.MessageParcel(); - let result = parcel.getRawDataCapacity(); - console.log("RpcTest: parcel get RawDataCapacity result is : " + result); + let sequence = new rpc.MessageSequence(); + let result = sequence.getRawDataCapacity(); + console.log("RpcTest: sequence get RawDataCapacity result is : " + result); ``` -### writeRawData8+ +### writeRawData -writeRawData(rawData: number[], size: number): boolean +writeRawData(rawData: number[], size: number): void -将原始数据写入MessageParcel对象。 +将原始数据写入MessageSequence对象。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | rawData | number[] | 是 | 要写入的原始数据。 | - | size | number | 是 | 发送的原始数据大小,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | -------- | ---- | ---------------------------------- | + | rawData | number[] | 是 | 要写入的原始数据。 | + | size | number | 是 | 发送的原始数据大小,以字节为单位。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果操作成功,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------ | + | 1900009 | write data to message sequence failed | **示例:** ``` - let parcel = new rpc.MessageParcel(); + let sequence = new rpc.MessageSequence(); let arr = [1, 2, 3, 4, 5]; - let isWriteSuccess = parcel.writeRawData(arr, arr.length); - console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); + try { + sequence.writeRawData(arr, arr.length); + } catch(error) { + console.info("rpc write rawdata fail, errorCode " + error.code); + console.info("rpc write rawdata fail, errorMessage" + error.message); + } ``` -### readRawData8+ +### readRawData readRawData(size: number): number[] -从MessageParcel读取原始数据。 +从MessageSequence读取原始数据。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | size | number | 是 | 要读取的原始数据的大小。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | size | number | 是 | 要读取的原始数据的大小。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ------------------------------ | | number[] | 返回原始数据(以字节为单位)。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900010 | read data from message sequence failed | + **示例:** ``` - let parcel = new rpc.MessageParcel(); + let sequence = new rpc.MessageSequence(); let arr = [1, 2, 3, 4, 5]; - let isWriteSuccess = parcel.writeRawData(arr, arr.length); - console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); - let result = parcel.readRawData(5); - console.log("RpcTest: parcel read raw data result is : " + result); + try { + sequence.writeRawData(arr, arr.length); + } catch(error) { + console.info("rpc write rawdata fail, errorCode " + error.code); + console.info("rpc write rawdata fail, errorMessage" + error.message); + } + try { + let result = sequence.readRawData(5); + } catch(error) { + console.info("rpc read rawdata fail, errorCode " + error.code); + console.info("rpc read rawdata fail, errorMessage" + error.message); + } + console.log("RpcTest: sequence read raw data result is : " + result); ``` -## Sequenceable +## MessageParcel(deprecated) -在进程间通信(IPC)期间,将类的对象写入MessageParcel并从MessageParcel中恢复它们。 +在RPC过程中,发送方可以使用MessageParcel提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageParcel提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。建议后续使用MessageSequence类替代。 +### create -### marshalling - -marshalling(dataOut: MessageParcel): boolean +create(): MessageParcel -将此可序列对象封送到MessageParcel中。 +静态方法,创建MessageParcel对象。 **系统能力**:SystemCapability.Communication.IPC.Core -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataOut | [MessageParcel](#messageparcel) | 是 | 可序列对象将被封送到的MessageParcel对象。 | - **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果封送成功,则返回true;否则返回false。 | + | 类型 | 说明 | + | ------------- | ----------------------------- | + | MessageParcel | 返回创建的MessageParcel对象。 | **示例:** ``` - class MySequenceable { - num: number; - str: string; - constructor(num, str) { - this.num = num; - this.str = str; - } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); - return true; - } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); - return true; - } - } - let sequenceable = new MySequenceable(1, "aaa"); let data = rpc.MessageParcel.create(); - let result = data.writeSequenceable(sequenceable); - console.log("RpcClient: writeSequenceable is " + result); - let ret = new MySequenceable(0, ""); - let result2 = data.readSequenceable(ret); - console.log("RpcClient: readSequenceable is " + result2); + console.log("RpcClient: data is " + data); ``` +### reclaim -### unmarshalling +reclaim(): void -unmarshalling(dataIn: MessageParcel) : boolean +释放不再使用的MessageParcel对象。 -从MessageParcel中解封此可序列对象。 +**系统能力**:SystemCapability.Communication.IPC.Core + +**示例:** + + ``` + let reply = rpc.MessageParcel.create(); + reply.reclaim(); + ``` + +### writeRemoteObject + +writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean + +序列化远程对象并将其写入MessageParcel对象。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dataIn | [MessageParcel](#messageparcel) | 是 | 已将可序列对象封送到其中的MessageParcel对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | --------------------------------------- | + | object | [IRemoteObject](#iremoteobject) | 是 | 要序列化并写入MessageParcel的远程对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果可序列化成功,则返回true;否则返回false。 | + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果操作成功,则返回true;否则返回false。 | **示例:** ``` - class MySequenceable { - num: number; - str: string; - constructor(num, str) { - this.num = num; - this.str = str; + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); } - marshalling(messageParcel) { - messageParcel.writeInt(this.num); - messageParcel.writeString(this.str); + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { return true; } - unmarshalling(messageParcel) { - this.num = messageParcel.readInt(); - this.str = messageParcel.readString(); + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { return true; } + isObjectDead(): boolean { + return false; + } } - let sequenceable = new MySequenceable(1, "aaa"); let data = rpc.MessageParcel.create(); - let result = data.writeSequenceable(sequenceable); - console.log("RpcClient: writeSequenceable is " + result); - let ret = new MySequenceable(0, ""); - let result2 = data.readSequenceable(ret); - console.log("RpcClient: readSequenceable is " + result2); + let testRemoteObject = new TestRemoteObject("testObject"); + data.writeRemoteObject(testRemoteObject); ``` +### readRemoteObject -## IRemoteBroker - -远端对象的代理持有者。用于获取代理对象。 - - -### asObject - -asObject(): IRemoteObject +readRemoteObject(): IRemoteObject -需派生类实现,获取代理或远端对象。 +从MessageParcel读取远程对象。此方法用于反序列化MessageParcel对象以生成IRemoteObject。远程对象按写入MessageParcel的顺序读取。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | [IRemoteObject](#iremoteobject) | 如果调用者是[RemoteObject](#ashmem8)对象,则直接返回本身;如果调用者是[RemoteProxy](#remoteproxy)对象,则返回它的持有者[IRemoteObject](#iremoteobject)。 | + | 类型 | 说明 | + | ------------------------------- | ------------------ | + | [IRemoteObject](#iremoteobject) | 读取到的远程对象。 | **示例:** ``` - class TestAbility extends rpc.RemoteObject { - asObject() { - return this; + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); } } - ``` - -**示例:** - - ``` - class TestProxy { - remote: rpc.RemoteObject; - constructor(remote) { - this.remote = remote; + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); } - asObject() { - return this.remote; + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; } } + let data = rpc.MessageParcel.create(); + let testRemoteObject = new TestRemoteObject("testObject"); + data.writeRemoteObject(testRemoteObject); + let proxy = data.readRemoteObject(); ``` +### writeInterfaceToken -## DeathRecipient +writeInterfaceToken(token: string): boolean -用于订阅远端对象的死亡通知。当被订阅该通知的远端对象死亡时,本端可收到消息,调用[onRemoteDied](#onremotedied)接口。远端对象死亡可以为远端对象所在进程死亡,远端对象所在设备关机或重启,当远端对象与本端对象属于不同设备时,也可为远端对象离开组网时。 +将接口描述符写入MessageParcel对象,远端对象可使用该信息校验本次通信。 +**系统能力**:SystemCapability.Communication.IPC.Core -### onRemoteDied +**参数:** -onRemoteDied(): void + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------ | + | token | string | 是 | 字符串类型描述符。 | -在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 +**返回值:** -**系统能力**:SystemCapability.Communication.IPC.Core + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果操作成功,则返回true;否则返回false。 | **示例:** ``` - class MyDeathRecipient { - onRemoteDied() { - console.log("server died"); - } - } + let data = rpc.MessageParcel.create(); + let result = data.writeInterfaceToken("aaa"); + console.log("RpcServer: writeInterfaceToken is " + result); ``` -## SendRequestResult8+ - -发送请求的响应结果。 +### readInterfaceToken -**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 +readInterfaceToken(): string - | 参数 | 值 | 说明 | -| -------- | -------- | -------- | -| errCode | number | 错误码。 | -| code | number | 消息代码。 | -| data | MessageParcel | 发送给对端进程的MessageParcel对象。 | -| reply | MessageParcel | 对端进程返回的MessageParcel对象。 | +从MessageParcel中读取接口描述符,接口描述符按写入MessageParcel的顺序读取,本地对象可使用该信息检验本次通信。 +**系统能力**:SystemCapability.Communication.IPC.Core -## IRemoteObject +**返回值:** -该接口可用于查询或获取接口描述符、添加或删除死亡通知、转储对象状态到特定文件、发送消息。 + | 类型 | 说明 | + | ------ | ------------------------ | + | string | 返回读取到的接口描述符。 | +**示例:** -### queryLocalInterface + ``` + class Stub extends rpc.RemoteObject { + onRemoteRequestEx(code, data, reply, option) { + let interfaceToken = data.readInterfaceToken(); + console.log("RpcServer: interfaceToken is " + interfaceToken); + return true; + } + } + ``` -queryLocalInterface(descriptor: string): IRemoteBroker -查询接口。 +### getSize -**系统能力**:SystemCapability.Communication.IPC.Core +getSize(): number -**参数:** +获取当前MessageParcel的数据大小。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | descriptor | string | 是 | 接口描述符的字符串。 | +**系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 | - + | 类型 | 说明 | + | ------ | --------------------------------------------- | + | number | 获取的MessageParcel的数据大小。以字节为单位。 | -### sendRequest(deprecated) +**示例:** -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean + ``` + let data = rpc.MessageParcel.create(); + let size = data.getSize(); + console.log("RpcClient: size is " + size); + ``` -> **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9)替代。 -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 +### getCapacity -**系统能力**:SystemCapability.Communication.IPC.Core +getCapacity(): number -**参数:** +获取当前MessageParcel的容量。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | +**系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回一个布尔值,true表示成功,false表示失败。| + | 类型 | 说明 | + | ------ | --------------------------------------------- | + | number | 获取的MessageParcel的容量大小。以字节为单位。 | +**示例:** -### sendRequest8+(deprecated) + ``` + let data = rpc.MessageParcel.create(); + let result = data.getCapacity(); + console.log("RpcClient: capacity is " + result); + ``` -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> -> **说明:** -> 从 API Version 9 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9)替代。 +### setSize -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 +setSize(size: number): boolean + +设置MessageParcel实例中包含的数据大小。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------------------------- | + | size | number | 是 | MessageParcel实例的数据大小。以字节为单位。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 设置成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let setSize = data.setSize(16); + console.log("RpcClient: setSize is " + setSize); + ``` -### sendRequestAsync9+ -sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +### setCapacity + +setCapacity(size: number): boolean -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequestAsync返回时兑现,回复内容在reply报文里。 +设置MessageParcel实例的存储容量。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------------------------- | + | size | number | 是 | MessageParcel实例的存储容量。以字节为单位。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 设置成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.setCapacity(100); + console.log("RpcClient: setCapacity is " + result); + ``` + + +### getWritableBytes + +getWritableBytes(): number + +获取MessageParcel的可写字节空间。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | --------------------------------------------------- | + | number | 获取到的MessageParcel的可写字节空间。以字节为单位。 | + +**示例:** + + ``` + class Stub extends rpc.RemoteObject { + onRemoteRequestEx(code, data, reply, option) { + let getWritableBytes = data.getWritableBytes(); + console.log("RpcServer: getWritableBytes is " + getWritableBytes); + return true; + } + } + ``` + + +### getReadableBytes + +getReadableBytes(): number + +获取MessageParcel的可读字节空间。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | --------------------------------------------------- | + | number | 获取到的MessageParcel的可读字节空间。以字节为单位。 | + +**示例:** + + ``` + class Stub extends rpc.RemoteObject { + onRemoteRequest(code, data, reply, option) { + let result = data.getReadableBytes(); + console.log("RpcServer: getReadableBytes is " + result); + return true; + } + } + ``` + + +### getReadPosition + +getReadPosition(): number + +获取MessageParcel的读位置。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | --------------------------------------- | + | number | 返回MessageParcel实例中的当前读取位置。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let readPos = data.getReadPosition(); + console.log("RpcClient: readPos is " + readPos); + ``` + + +### getWritePosition + +getWritePosition(): number + +获取MessageParcel的写位置。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | --------------------------------------- | + | number | 返回MessageParcel实例中的当前写入位置。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + data.writeInt(10); + let bwPos = data.getWritePosition(); + console.log("RpcClient: bwPos is " + bwPos); + ``` + + +### rewindRead + +rewindRead(pos: number): boolean + +重新偏移读取位置到指定的位置。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | pos | number | 是 | 开始读取数据的目标位置。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ------------------------------------------------- | + | boolean | 如果读取位置发生更改,则返回true;否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + data.writeInt(12); + data.writeString("parcel"); + let number = data.readInt(); + console.log("RpcClient: number is " + number); + data.rewindRead(0); + let number2 = data.readInt(); + console.log("RpcClient: rewindRead is " + number2); + ``` + + +### rewindWrite + +rewindWrite(pos: number): boolean + +重新偏移写位置到指定的位置。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | pos | number | 是 | 开始写入数据的目标位置。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果写入位置更改,则返回true;否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + data.writeInt(4); + data.rewindWrite(0); + data.writeInt(5); + let number = data.readInt(); + console.log("RpcClient: rewindWrite is: " + number); + ``` + + +### writeByte + +writeByte(val: number): boolean + +将字节值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的字节值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回成功,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeByte(2); + console.log("RpcClient: writeByte is: " + result); + ``` + + +### readByte + +readByte(): number + +从MessageParcel实例读取字节值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ------------ | + | number | 返回字节值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeByte(2); + console.log("RpcClient: writeByte is: " + result); + let ret = data.readByte(); + console.log("RpcClient: readByte is: " + ret); + ``` + + +### writeShort + +writeShort(val: number): boolean + +将短整数值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------ | + | val | number | 是 | 要写入的短整数值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeShort(8); + console.log("RpcClient: writeShort is: " + result); + ``` + + +### readShort + +readShort(): number + +从MessageParcel实例读取短整数值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | -------------- | + | number | 返回短整数值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeShort(8); + console.log("RpcClient: writeShort is: " + result); + let ret = data.readShort(); + console.log("RpcClient: readShort is: " + ret); + ``` + + +### writeInt + +writeInt(val: number): boolean + +将整数值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的整数值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回成功,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeInt(10); + console.log("RpcClient: writeInt is " + result); + ``` + + +### readInt + +readInt(): number + +从MessageParcel实例读取整数值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ------------ | + | number | 返回整数值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeInt(10); + console.log("RpcClient: writeInt is " + result); + let ret = data.readInt(); + console.log("RpcClient: readInt is " + ret); + ``` + + +### writeLong + +writeLong(val: number): boolean + +将长整数值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的长整数值 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeLong(10000); + console.log("RpcClient: writeLong is " + result); + ``` + + +### readLong + +readLong(): number + +从MessageParcel实例中读取长整数值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | -------------- | + | number | 返回长整数值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeLong(10000); + console.log("RpcClient: writeLong is " + result); + let ret = data.readLong(); + console.log("RpcClient: readLong is " + ret); + ``` + + +### writeFloat + +writeFloat(val: number): boolean + +将浮点值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------- | + | val | number | 是 | 要写入的浮点值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeFloat(1.2); + console.log("RpcClient: writeFloat is " + result); + ``` + + +### readFloat + +readFloat(): number + +从MessageParcel实例中读取浮点值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ------------ | + | number | 返回浮点值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeFloat(1.2); + console.log("RpcClient: writeFloat is " + result); + let ret = data.readFloat(); + console.log("RpcClient: readFloat is " + ret); + ``` + + +### writeDouble + +writeDouble(val: number): boolean + +将双精度浮点值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------------- | + | val | number | 是 | 要写入的双精度浮点值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeDouble(10.2); + console.log("RpcClient: writeDouble is " + result); + ``` + + +### readDouble + +readDouble(): number + +从MessageParcel实例读取双精度浮点值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ------------------ | + | number | 返回双精度浮点值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeDouble(10.2); + console.log("RpcClient: writeDouble is " + result); + let ret = data.readDouble(); + console.log("RpcClient: readDouble is " + ret); + ``` + +### writeBoolean + +writeBoolean(val: boolean): boolean + +将布尔值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------- | ---- | ---------------- | + | val | boolean | 是 | 要写入的布尔值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeBoolean(false); + console.log("RpcClient: writeBoolean is " + result); + ``` + + +### readBoolean + +readBoolean(): boolean + +从MessageParcel实例读取布尔值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------- | -------------------- | + | boolean | 返回读取到的布尔值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeBoolean(false); + console.log("RpcClient: writeBoolean is " + result); + let ret = data.readBoolean(); + console.log("RpcClient: readBoolean is " + ret); + ``` + + +### writeChar + +writeChar(val: number): boolean + +将单个字符值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | val | number | 是 | 要写入的单个字符值。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeChar(97); + console.log("RpcClient: writeChar is " + result); + ``` + + +### readChar + +readChar(): number + +从MessageParcel实例中读取单个字符值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------- | + | number | 返回单个字符值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeChar(97); + console.log("RpcClient: writeChar is " + result); + let ret = data.readChar(); + console.log("RpcClient: readChar is " + ret); + ``` + + +### writeString + +writeString(val: string): boolean + +将字符串值写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core +**参数:** + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ----------------------------------------- | + | val | string | 是 | 要写入的字符串值,其长度应小于40960字节。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeString('abc'); + console.log("RpcClient: writeString is " + result); + ``` + + +### readString + +readString(): string + +从MessageParcel实例读取字符串值。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | -------------- | + | string | 返回字符串值。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeString('abc'); + console.log("RpcClient: writeString is " + result); + let ret = data.readString(); + console.log("RpcClient: readString is " + ret); + ``` + + +### writeSequenceable + +writeSequenceable(val: Sequenceable): boolean + +将自定义序列化对象写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------- | ---- | -------------------- | + | val | [Sequenceable](#sequenceable) | 是 | 要写入的可序列对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceable(sequenceable); + console.log("RpcClient: writeSequenceable is " + result); + ``` + + +### readSequenceable + +readSequenceable(dataIn: Sequenceable) : boolean + +从MessageParcel实例中读取成员变量到指定的对象(dataIn)。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------- | ---- | --------------------------------------- | + | dataIn | [Sequenceable](#sequenceable) | 是 | 需要从MessageParcel读取成员变量的对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ------------------------------------------- | + | boolean | 如果反序列成功,则返回true;否则返回false。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceable(sequenceable); + console.log("RpcClient: writeSequenceable is " + result); + let ret = new MySequenceable(0, ""); + let result2 = data.readSequenceable(ret); + console.log("RpcClient: writeSequenceable is " + result2); + ``` + + +### writeByteArray + +writeByteArray(byteArray: number[]): boolean + +将字节数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | ------------------ | + | byteArray | number[] | 是 | 要写入的字节数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let ByteArrayVar = [1, 2, 3, 4, 5]; + let result = data.writeByteArray(ByteArrayVar); + console.log("RpcClient: writeByteArray is " + result); + ``` + + +### readByteArray + +readByteArray(dataIn: number[]) : void + +从MessageParcel实例读取字节数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | 是 | 要读取的字节数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let ByteArrayVar = [1, 2, 3, 4, 5]; + let result = data.writeByteArray(ByteArrayVar); + console.log("RpcClient: writeByteArray is " + result); + let array = new Array(5); + data.readByteArray(array); + ``` + + +### readByteArray + +readByteArray(): number[] + +从MessageParcel实例中读取字节数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------------- | + | number[] | 返回字节数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let ByteArrayVar = [1, 2, 3, 4, 5]; + let result = data.writeByteArray(ByteArrayVar); + console.log("RpcClient: writeByteArray is " + result); + let array = data.readByteArray(); + console.log("RpcClient: readByteArray is " + array); + ``` + + +### writeShortArray + +writeShortArray(shortArray: number[]): boolean + +将短整数数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | -------- | ---- | -------------------- | + | shortArray | number[] | 是 | 要写入的短整数数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeShortArray([11, 12, 13]); + console.log("RpcClient: writeShortArray is " + result); + ``` + + +### readShortArray + +readShortArray(dataIn: number[]) : void + +从MessageParcel实例中读取短整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | 是 | 要读取的短整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeShortArray([11, 12, 13]); + console.log("RpcClient: writeShortArray is " + result); + let array = new Array(3); + data.readShortArray(array); + ``` + + +### readShortArray + +readShortArray(): number[] + +从MessageParcel实例中读取短整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | ---------------- | + | number[] | 返回短整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeShortArray([11, 12, 13]); + console.log("RpcClient: writeShortArray is " + result); + let array = data.readShortArray(); + console.log("RpcClient: readShortArray is " + array); + ``` + + +### writeIntArray + +writeIntArray(intArray: number[]): boolean + +将整数数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | ---- | ------------------ | + | intArray | number[] | 是 | 要写入的整数数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeIntArray([100, 111, 112]); + console.log("RpcClient: writeIntArray is " + result); + ``` + + +### readIntArray + +readIntArray(dataIn: number[]) : void + +从MessageParcel实例中读取整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------ | + | dataIn | number[] | 是 | 要读取的整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeIntArray([100, 111, 112]); + console.log("RpcClient: writeIntArray is " + result); + let array = new Array(3); + data.readIntArray(array); + ``` + + +### readIntArray + +readIntArray(): number[] + +从MessageParcel实例中读取整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------------- | + | number[] | 返回整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeIntArray([100, 111, 112]); + console.log("RpcClient: writeIntArray is " + result); + let array = data.readIntArray(); + console.log("RpcClient: readIntArray is " + array); + ``` + + +### writeLongArray + +writeLongArray(longArray: number[]): boolean + +将长整数数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | -------------------- | + | longArray | number[] | 是 | 要写入的长整数数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeLongArray([1111, 1112, 1113]); + console.log("RpcClient: writeLongArray is " + result); + ``` + + +### readLongArray + +readLongArray(dataIn: number[]) : void + +从MessageParcel实例读取长整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | number[] | 是 | 要读取的长整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeLongArray([1111, 1112, 1113]); + console.log("RpcClient: writeLongArray is " + result); + let array = new Array(3); + data.readLongArray(array); + ``` + + +### readLongArray + +readLongArray(): number[] + +从MessageParcel实例中读取长整数数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | ---------------- | + | number[] | 返回长整数数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeLongArray([1111, 1112, 1113]); + console.log("RpcClient: writeLongArray is " + result); + let array = data.readLongArray(); + console.log("RpcClient: readLongArray is " + array); + ``` + + +### writeFloatArray + +writeFloatArray(floatArray: number[]): boolean + +将浮点数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | -------- | ---- | --- | + | floatArray | number[] | 是 | 要写入的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeFloatArray([1.2, 1.3, 1.4]); + console.log("RpcClient: writeFloatArray is " + result); + ``` + + +### readFloatArray + +readFloatArray(dataIn: number[]) : void + +从MessageParcel实例中读取浮点数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------ | + | dataIn | number[] | 是 | 要读取的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeFloatArray([1.2, 1.3, 1.4]); + console.log("RpcClient: writeFloatArray is " + result); + let array = new Array(3); + data.readFloatArray(array); + ``` + + +### readFloatArray + +readFloatArray(): number[] + +从MessageParcel实例中读取浮点数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------------- | + | number[] | 返回浮点数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeFloatArray([1.2, 1.3, 1.4]); + console.log("RpcClient: writeFloatArray is " + result); + let array = data.readFloatArray(); + console.log("RpcClient: readFloatArray is " + array); + ``` + + +### writeDoubleArray + +writeDoubleArray(doubleArray: number[]): boolean + +将双精度浮点数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | -------- | ---- | ------------------------ | + | doubleArray | number[] | 是 | 要写入的双精度浮点数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------- | + | boolean | 写入返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeDoubleArray([11.1, 12.2, 13.3]); + console.log("RpcClient: writeDoubleArray is " + result); + ``` + + +### readDoubleArray + +readDoubleArray(dataIn: number[]) : void + +从MessageParcel实例中读取双精度浮点数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ------------------------ | + | dataIn | number[] | 是 | 要读取的双精度浮点数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeDoubleArray([11.1, 12.2, 13.3]); + console.log("RpcClient: writeDoubleArray is " + result); + let array = new Array(3); + data.readDoubleArray(array); + ``` + + +### readDoubleArray + +readDoubleArray(): number[] + +从MessageParcel实例读取双精度浮点数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | -------------------- | + | number[] | 返回双精度浮点数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeDoubleArray([11.1, 12.2, 13.3]); + console.log("RpcClient: writeDoubleArray is " + result); + let array = data.readDoubleArray(); + console.log("RpcClient: readDoubleArray is " + array); + ``` + + +### writeBooleanArray + +writeBooleanArray(booleanArray: boolean[]): boolean + +将布尔数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------------ | --------- | ---- | ------------------ | + | booleanArray | boolean[] | 是 | 要写入的布尔数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeBooleanArray([false, true, false]); + console.log("RpcClient: writeBooleanArray is " + result); + ``` + + +### readBooleanArray + +readBooleanArray(dataIn: boolean[]) : void + +从MessageParcel实例中读取布尔数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | --------- | ---- | ------------------ | + | dataIn | boolean[] | 是 | 要读取的布尔数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeBooleanArray([false, true, false]); + console.log("RpcClient: writeBooleanArray is " + result); + let array = new Array(3); + data.readBooleanArray(array); + ``` + + +### readBooleanArray + +readBooleanArray(): boolean[] + +从MessageParcel实例中读取布尔数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | --------- | -------------- | + | boolean[] | 返回布尔数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeBooleanArray([false, true, false]); + console.log("RpcClient: writeBooleanArray is " + result); + let array = data.readBooleanArray(); + console.log("RpcClient: readBooleanArray is " + array); + ``` + + +### writeCharArray + +writeCharArray(charArray: number[]): boolean + +将单个字符数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | -------- | ---- | ---------------------- | + | charArray | number[] | 是 | 要写入的单个字符数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeCharArray([97, 98, 88]); + console.log("RpcClient: writeCharArray is " + result); + ``` + + +### readCharArray + +readCharArray(dataIn: number[]) : void + +从MessageParcel实例中读取单个字符数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | ---------------------- | + | dataIn | number[] | 是 | 要读取的单个字符数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeCharArray([97, 98, 99]); + console.log("RpcClient: writeCharArray is " + result); + let array = new Array(3); + data.readCharArray(array); + ``` + + +### readCharArray + +readCharArray(): number[] + +从MessageParcel实例读取单个字符数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | ------------------ | + | number[] | 返回单个字符数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeCharArray([97, 98, 99]); + console.log("RpcClient: writeCharArray is " + result); + let array = data.readCharArray(); + console.log("RpcClient: readCharArray is " + array); + ``` + + +### writeStringArray + +writeStringArray(stringArray: string[]): boolean + +将字符串数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | -------- | ---- | ---------------- | + | stringArray | string[] | 是 | 要写入的字符串数组,数组单个元素的长度应小于40960字节。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeStringArray(["abc", "def"]); + console.log("RpcClient: writeStringArray is " + result); + ``` + + +### readStringArray + +readStringArray(dataIn: string[]) : void + +从MessageParcel实例读取字符串数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------- | + | dataIn | string[] | 是 | 要读取的字符串数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeStringArray(["abc", "def"]); + console.log("RpcClient: writeStringArray is " + result); + let array = new Array(2); + data.readStringArray(array); + ``` + + +### readStringArray + +readStringArray(): string[] + +从MessageParcel实例读取字符串数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | -------- | ---------------- | + | string[] | 返回字符串数组。 | + +**示例:** + + ``` + let data = rpc.MessageParcel.create(); + let result = data.writeStringArray(["abc", "def"]); + console.log("RpcClient: writeStringArray is " + result); + let array = data.readStringArray(); + console.log("RpcClient: readStringArray is " + array); + ``` + + +### writeNoException8+ + +writeNoException(): void + +向MessageParcel写入“指示未发生异常”的信息。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log("RpcServer: onRemoteRequest called"); + reply.writeNoException(); + return true; + } else { + console.log("RpcServer: unknown code: " + code); + return false; + } + } + } + ``` + +### readException8+ + +readException(): void + +从MessageParcel中读取异常。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**示例:** + + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + proxy.sendMessageRequest(1, data, reply, option) + .then(function(errCode) { + if (errCode === 0) { + console.log("sendMessageRequest got result"); + reply.readException(); + let msg = reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendMessageRequest failed, errCode: " + errCode); + } + }).catch(function(e) { + console.log("RPCTest: sendMessageRequest got exception: " + e.message); + }).finally (() => { + console.log("RPCTest: sendMessageRequest ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + }); + ``` + +### writeSequenceableArray + +writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean + +将可序列化对象数组写入MessageParcel实例。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ----------------- | -------------- | ---- | -------------------------- | + | sequenceableArray | Sequenceable[] | 是 | 要写入的可序列化对象数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------- | + | boolean | 写入成功返回true,否则返回false。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let sequenceable2 = new MySequenceable(2, "bbb"); + let sequenceable3 = new MySequenceable(3, "ccc"); + let a = [sequenceable, sequenceable2, sequenceable3]; + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceableArray(a); + console.log("RpcClient: writeSequenceableArray is " + result); + ``` + + +### readSequenceableArray8+ + +readSequenceableArray(sequenceableArray: Sequenceable[]): void + +从MessageParcel实例读取可序列化对象数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ----------------- | -------------- | ---- | -------------------------- | + | sequenceableArray | Sequenceable[] | 是 | 要读取的可序列化对象数组。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let sequenceable2 = new MySequenceable(2, "bbb"); + let sequenceable3 = new MySequenceable(3, "ccc"); + let a = [sequenceable, sequenceable2, sequenceable3]; + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceableArray(a); + console.log("RpcClient: writeSequenceableArray is " + result); + let b = [new MySequenceable(0, ""), new MySequenceable(0, ""), new MySequenceable(0, "")]; + data.readSequenceableArray(b); + ``` + + +### writeRemoteObjectArray8+ + +writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean + +将IRemoteObject对象数组写入MessageParcel。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | --------------- | ---- | ----- | + | objectArray | IRemoteObject[] | 是 | 要写入MessageParcel的IRemoteObject对象数组。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | -------------------------------------------------------------------------------------------------------------------- | + | boolean | 如果IRemoteObject对象数组成功写入MessageParcel,则返回true;如果对象为null或数组写入MessageParcel失败,则返回false。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + this.attachLocalInterface(this, descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + asObject(): rpc.IRemoteObject { + return this; + } + } + let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; + let data = rpc.MessageParcel.create(); + let result = data.writeRemoteObjectArray(a); + console.log("RpcClient: writeRemoteObjectArray is " + result); + ``` + + +### readRemoteObjectArray8+ + +readRemoteObjectArray(objects: IRemoteObject[]): void + +从MessageParcel读取IRemoteObject对象数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | + | ------- | --------------- | ---- | --------- | + | objects | IRemoteObject[] | 是 | 从MessageParcel读取的IRemoteObject对象数组。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + this.attachLocalInterface(this, descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + asObject(): rpc.IRemoteObject { + return this; + } + } + let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; + let data = rpc.MessageParcel.create(); + let result = data.writeRemoteObjectArray(a); + let b = new Array(3); + data.readRemoteObjectArray(b); + ``` + + +### readRemoteObjectArray8+ + +readRemoteObjectArray(): IRemoteObject[] + +从MessageParcel读取IRemoteObject对象数组。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | --------------- | -------- | + | IRemoteObject[] | 返回IRemoteObject对象数组。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + this.attachLocalInterface(this, descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + asObject(): rpc.IRemoteObject { + return this; + } + } + let a = [new TestRemoteObject("testObject1"), new TestRemoteObject("testObject2"), new TestRemoteObject("testObject3")]; + let data = rpc.MessageParcel.create(); + let result = data.writeRemoteObjectArray(a); + console.log("RpcClient: readRemoteObjectArray is " + result); + let b = data.readRemoteObjectArray(); + console.log("RpcClient: readRemoteObjectArray is " + b); + ``` + + +### closeFileDescriptor8+ + +static closeFileDescriptor(fd: number): void + +关闭给定的文件描述符。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | fd | number | 是 | 要关闭的文件描述符。 | + +**示例:** + + ``` + import fileio from '@ohos.fileio'; + let filePath = "path/to/file"; + let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + rpc.MessageParcel.closeFileDescriptor(fd); + ``` + + +### dupFileDescriptor8+ + +static dupFileDescriptor(fd: number) :number + +复制给定的文件描述符。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | fd | number | 是 | 表示已存在的文件描述符。 | + +**返回值:** + + | 类型 | 说明 | + | ------ | -------------------- | + | number | 返回新的文件描述符。 | + +**示例:** + + ``` + import fileio from '@ohos.fileio'; + let filePath = "path/to/file"; + let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let newFd = rpc.MessageParcel.dupFileDescriptor(fd); + ``` + + +### containFileDescriptors8+ + +containFileDescriptors(): boolean + +检查此MessageParcel对象是否包含文件描述符。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------- | ------------------------------------------------------------------ | + | boolean | 如果此MessageParcel对象包含文件描述符,则返回true;否则返回false。 | + +**示例:** + + ``` + import fileio from '@ohos.fileio'; + let parcel = new rpc.MessageParcel(); + let filePath = "path/to/file"; + let r1 = parcel.containFileDescriptors(); + let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let writeResult = parcel.writeFileDescriptor(fd); + console.log("RpcTest: parcel writeFd result is : " + writeResult); + let containFD = parcel.containFileDescriptors(); + console.log("RpcTest: parcel after write fd containFd result is : " + containFD); + ``` + + +### writeFileDescriptor8+ + +writeFileDescriptor(fd: number): boolean + +写入文件描述符到MessageParcel。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------ | + | fd | number | 是 | 文件描述符。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果操作成功,则返回true;否则返回false。 | + +**示例:** + + ``` + import fileio from '@ohos.fileio'; + let parcel = new rpc.MessageParcel(); + let filePath = "path/to/file"; + let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let writeResult = parcel.writeFileDescriptor(fd); + console.log("RpcTest: parcel writeFd result is : " + writeResult); + ``` + + +### readFileDescriptor8+ + +readFileDescriptor(): number + +从MessageParcel中读取文件描述符。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------- | + | number | 返回文件描述符。 | + +**示例:** + + ``` + import fileio from '@ohos.fileio'; + let parcel = new rpc.MessageParcel(); + let filePath = "path/to/file"; + let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let writeResult = parcel.writeFileDescriptor(fd); + let readFD = parcel.readFileDescriptor(); + console.log("RpcTest: parcel read fd is : " + readFD); + ``` + + +### writeAshmem8+ + +writeAshmem(ashmem: Ashmem): boolean + +将指定的匿名共享对象写入此MessageParcel。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ----------------------------------- | + | ashmem | Ashmem | 是 | 要写入MessageParcel的匿名共享对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | -------------------------------------------------------------------- | + | boolean | 如果匿名共享对象成功写入此MessageParcel,则返回true;否则返回false。 | + +**示例:** + + ``` + let parcel = new rpc.MessageParcel(); + let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); + let isWriteSuccess = parcel.writeAshmem(ashmem); + console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); + ``` + + +### readAshmem8+ + +readAshmem(): Ashmem + +从MessageParcel读取匿名共享对象。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ------------------ | + | Ashmem | 返回匿名共享对象。 | + +**示例:** + + ``` + let parcel = new rpc.MessageParcel(); + let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); + let isWriteSuccess = parcel.writeAshmem(ashmem); + console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); + let readAshmem = parcel.readAshmem(); + console.log("RpcTest: read ashmem to result is : " + readAshmem); + ``` + + +### getRawDataCapacity8+ + +getRawDataCapacity(): number + +获取MessageParcel可以容纳的最大原始数据量。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------------------------------------------------- | + | number | 返回MessageParcel可以容纳的最大原始数据量,即128 Mb。 | + +**示例:** + + ``` + let parcel = new rpc.MessageParcel(); + let result = parcel.getRawDataCapacity(); + console.log("RpcTest: parcel get RawDataCapacity result is : " + result); + ``` + + +### writeRawData8+ + +writeRawData(rawData: number[], size: number): boolean + +将原始数据写入MessageParcel对象。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | -------- | ---- | ---------------------------------- | + | rawData | number[] | 是 | 要写入的原始数据。 | + | size | number | 是 | 发送的原始数据大小,以字节为单位。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果操作成功,则返回true;否则返回false。 | + +**示例:** + + ``` + let parcel = new rpc.MessageParcel(); + let arr = [1, 2, 3, 4, 5]; + let isWriteSuccess = parcel.writeRawData(arr, arr.length); + console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); + ``` + + +### readRawData8+ + +readRawData(size: number): number[] + +从MessageParcel读取原始数据。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | size | number | 是 | 要读取的原始数据的大小。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | ------------------------------ | + | number[] | 返回原始数据(以字节为单位)。 | + +**示例:** + + ``` + let parcel = new rpc.MessageParcel(); + let arr = [1, 2, 3, 4, 5]; + let isWriteSuccess = parcel.writeRawData(arr, arr.length); + console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); + let result = parcel.readRawData(5); + console.log("RpcTest: parcel read raw data result is : " + result); + ``` + + +## Parcelable9+ + +> **说明:** +> 本类从API version 9开始启用,代替Sequenceable类。 + +在进程间通信(IPC)期间,将类的对象写入MessageSequence并从MessageSequence中恢复它们。 + +### marshalling + +marshalling(dataOut: MessageSequence): boolean + +将此可序列对象封送到MessageSequence中。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | --------------- | ---- | ------------------------------------------- | + | dataOut | MessageSequence | 是 | 可序列对象将被封送到的MessageSequence对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果封送成功,则返回true;否则返回false。 | + +**示例:** + + ``` + class MyParcelable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + } + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + } + } + let parcelable = new MyParcelable(1, "aaa"); + let data = rpc.MessageSequence.create(); + let result = data.writeParcelable(parcelable); + console.log("RpcClient: writeParcelable is " + result); + let ret = new MyParcelable(0, ""); + let result2 = data.readParcelable(ret); + console.log("RpcClient: readParcelable is " + result2); + ``` + + +### unmarshalling + +unmarshalling(dataIn: MessageSequence) : boolean + +从MessageSequence中解封此可序列对象。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | --------------- | ---- | ----------------------------------------------- | + | dataIn | MessageSequence | 是 | 已将可序列对象封送到其中的MessageSequence对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果可序列化成功,则返回true;否则返回false。 | + +**示例:** + + ``` + class MyParcelable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageSequence) { + messageSequence.writeInt(this.num); + messageSequence.writeString(this.str); + return true; + } + unmarshalling(messageSequence) { + this.num = messageSequence.readInt(); + this.str = messageSequence.readString(); + return true; + } + } + let parcelable = new MyParcelable(1, "aaa"); + let data = rpc.MessageSequence.create(); + let result = data.writeParcelable(parcelable); + console.log("RpcClient: writeParcelable is " + result); + let ret = new MyParcelable(0, ""); + let result2 = data.readParcelable(ret); + console.log("RpcClient: readParcelable is " + result2); + ``` + + +## Sequenceable(deprecated) + +在进程间通信(IPC)期间,将类的对象写入MessageParcel并从MessageParcel中恢复它们。后续使用Parcelable类替代。 + +### marshalling + +marshalling(dataOut: MessageParcel): boolean + +将此可序列对象封送到MessageParcel中。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ----------------------------------------- | + | dataOut | [MessageParcel](#messageparcel) | 是 | 可序列对象将被封送到的MessageParcel对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | ----------------------------------------- | + | boolean | 如果封送成功,则返回true;否则返回false。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceable(sequenceable); + console.log("RpcClient: writeSequenceable is " + result); + let ret = new MySequenceable(0, ""); + let result2 = data.readSequenceable(ret); + console.log("RpcClient: readSequenceable is " + result2); + ``` + + +### unmarshalling + +unmarshalling(dataIn: MessageParcel) : boolean + +从MessageParcel中解封此可序列对象。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | --------------------------------------------- | + | dataIn | [MessageParcel](#messageparcel) | 是 | 已将可序列对象封送到其中的MessageParcel对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果可序列化成功,则返回true;否则返回false。 | + +**示例:** + + ``` + class MySequenceable { + num: number; + str: string; + constructor(num, str) { + this.num = num; + this.str = str; + } + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + } + let sequenceable = new MySequenceable(1, "aaa"); + let data = rpc.MessageParcel.create(); + let result = data.writeSequenceable(sequenceable); + console.log("RpcClient: writeSequenceable is " + result); + let ret = new MySequenceable(0, ""); + let result2 = data.readSequenceable(ret); + console.log("RpcClient: readSequenceable is " + result2); + ``` + + +## IRemoteBroker + +远端对象的代理持有者。用于获取代理对象。 + +### asObject + +asObject(): IRemoteObject + +需派生类实现,获取代理或远端对象。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ---- | ----- | + | [IRemoteObject](#iremoteobject) | 如果调用者是RemoteObject对象,则直接返回本身;如果调用者是[RemoteProxy](#remoteproxy)对象,则返回它的持有者[IRemoteObject](#iremoteobject)。 | + +**示例:** + + ``` + class TestAbility extends rpc.RemoteObject { + asObject() { + return this; + } + } + ``` + +**示例:** + + ``` + class TestProxy { + remote: rpc.RemoteObject; + constructor(remote) { + this.remote = remote; + } + asObject() { + return this.remote; + } + } + ``` + +## DeathRecipient + +用于订阅远端对象的死亡通知。当被订阅该通知的远端对象死亡时,本端可收到消息,调用[onRemoteDied](#onremotedied)接口。远端对象死亡可以为远端对象所在进程死亡,远端对象所在设备关机或重启,当远端对象与本端对象属于不同设备时,也可为远端对象离开组网时。 + +### onRemoteDied + +onRemoteDied(): void + +在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + ``` + +## RequestResult9+ + +发送请求的响应结果。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 + + | 参数: | 值 | 说明 | + | ------- | --------------- | ------------------------------------- | + | errCode | number | 错误码。 | + | code | number | 消息代码。 | + | data | MessageSequence | 发送给对端进程的MessageSequence对象。 | + | reply | MessageSequence | 对端进程返回的MessageSequence对象。 | + +## SendRequestResult8+(deprecated) + +发送请求的响应结果。后续使用RequestResult类替代。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 + + | 参数: | 值 | 说明 | + | ------- | ------------- | ----------------------------------- | + | errCode | number | 错误码。 | + | code | number | 消息代码。 | + | data | MessageParcel | 发送给对端进程的MessageParcel对象。 | + | reply | MessageParcel | 对端进程返回的MessageParcel对象。 | + +## IRemoteObject + +该接口可用于查询或获取接口描述符、添加或删除死亡通知、转储对象状态到特定文件、发送消息。 + +### getLocalInterface9+ + +getLocalInterface(descriptor: string): IRemoteBroker + +查询接口。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | 是 | 接口描述符的字符串。 | + +**返回值:** + + | 类型 | 说明 | + | ------------- | --------------------------------------------- | + | IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 | + +### queryLocalInterface(deprecated) + +queryLocalInterface(descriptor: string): IRemoteBroker + +查询接口。后续使用getLocalInterface方法替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | 是 | 接口描述符的字符串。 | + +**返回值:** + + | 类型 | 说明 | + | ------------- | --------------------------------------------- | + | IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 | + + +### sendRequest(deprecated) + +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean + +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。建议使用sendMessageRequest9+替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | ---- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 返回一个布尔值,true表示成功,false表示失败。 | + + +### sendRequest8+(deprecated) + +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> + +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。后续建议使用sendMessageRequest9+替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + +**返回值:** + + | 类型 | 说明 | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。 | + + +### sendMessageRequest9+ + +sendMessageRequest(code : number, data : MessageSequence, reply : MessageSequence, options : MessageOption): Promise<RequestResult> + +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + +**返回值:** + + | 类型 | 说明 | + | ---------------------------- | ----------------------------------------- | + | Promise<RequestResult> | 返回一个期约,兑现值是requestResult实例。 | + + +### sendMessageRequest9+ + +sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void + +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | + + +### sendRequest8+(deprecated) + +sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void + +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。后续建议使用sendMessageRequest替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + + +### registerDeathRecipient9+ + +registerDeathRecipient(recipient: DeathRecipient, flags: number): void + +注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注册的回调。 | + | flags | number | 是 | 死亡通知标志。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | + + +### addDeathrecipient(deprecated) + +addDeathRecipient(recipient: DeathRecipient, flags: number): boolean + +注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。建议使用registerDeathRecipient替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注册的回调。 | + | flags | number | 是 | 死亡通知标志。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果回调注册成功,则返回true;否则返回false。 | + + +### unregisterDeathRecipient9+ + +removeDeathRecipient(recipient: DeathRecipient, flags: number): void + +注销用于接收远程对象死亡通知的回调。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的回调。 | + | flags | number | 是 | 死亡通知标志。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | + + +### removeDeathRecipient(deprecated) + +removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean + +注销用于接收远程对象死亡通知的回调。建议使用unregisterDeathRecipient替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的回调。 | + | flags | number | 是 | 死亡通知标志。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果回调成功注销,则返回true;否则返回false。 | + + +### getDescriptor9+ + +getDescriptor(): string + +获取对象的接口描述符。接口描述符为字符串。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------- | + | string | 返回接口描述符。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | + + +### getInterfaceDescriptor(deprecated) + +getInterfaceDescriptor(): string + +获取对象的接口描述符。接口描述符为字符串。建议使用getDescriptor替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------- | + | string | 返回接口描述符。 | + + +### isObjectDead + +isObjectDead(): boolean + +检查当前对象是否死亡。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------- | ------------------------------------------- | + | boolean | 如果对象已死亡,则返回true;否则返回false。 | + + +## RemoteProxy + +实现IRemoteObject代理对象。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 + +| 参数: | 值 | 说明 | +| --------------------- | ----------------------- | --------------------------------- | +| PING_TRANSACTION | 1599098439 (0x5f504e47) | 内部指令码,用于测试IPC服务正常。 | +| DUMP_TRANSACTION | 1598311760 (0x5f444d50) | 内部指令码,获取Binder内部状态。 | +| INTERFACE_TRANSACTION | 1598968902 (0x5f4e5446) | 内部指令码,获取对端接口描述符。 | +| MIN_TRANSACTION_ID | 1 (0x00000001) | 最小有效指令码。 | +| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | 最大有效指令码。 | + + +### sendRequest(deprecated) + +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean + +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。建议使用sendMessageRequest9+替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 返回一个布尔值,true表示成功,false表示失败。 | + +**示例:** + + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + let ret: boolean = proxy.sendRequest(1, data, reply, option); + if (ret) { + console.log("sendRequest got result"); + let msg = reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequest failed"); + } + console.log("RPCTest: sendRequest ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + ``` -### sendRequest8+ -sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void +### sendMessageRequest9+ -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 +sendMessageRequest(code : number, data : MessageSequence, reply : MessageSequence, options : MessageOption): Promise<RequestResult> +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | - - -### addDeathrecipient - -addDeathRecipient(recipient: DeathRecipient, flags: number): boolean - -注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 - -**系统能力**:SystemCapability.Communication.IPC.Core + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | -**参数:** +**返回值:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注册的回调。 | - | flags | number | 是 | 死亡通知标志。 | + | 类型 | 说明 | + | ---------------------------- | ----------------------------------------- | + | Promise<RequestResult> | 返回一个期约,兑现值是requestResult实例。 | -**返回值:** +**示例:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果回调注册成功,则返回true;否则返回false。 | + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageSequence.create(); + let reply = rpc.MessageSequence.create(); + data.writeInt(1); + data.writeString("hello"); + proxy.sendMessageRequest(1, data, reply, option) + .then(function(result) { + if (result.errCode === 0) { + console.log("sendMessageRequest got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendMessageRequest failed, errCode: " + result.errCode); + } + }).catch(function(e) { + console.log("RPCTest: sendMessageRequest got exception: " + e.message); + }).finally (() => { + console.log("RPCTest: sendMessageRequest ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + }); + ``` -### removeDeathRecipient +### sendRequest8+(deprecated) -removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean +sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> -注销用于接收远程对象死亡通知的回调。 +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。建议使用sendMessageRequest9+替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的回调。 | - | flags | number | 是 | 死亡通知标志。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果回调成功注销,则返回true;否则返回false。 | - - -### getInterfaceDescriptor + | 类型 | 说明 | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。 | -getInterfaceDescriptor(): string - -获取对象的接口描述符。接口描述符为字符串。 +**示例:** -**系统能力**:SystemCapability.Communication.IPC.Core + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + proxy.sendRequest(1, data, reply, option) + .then(function(result) { + if (result.errCode === 0) { + console.log("sendRequest got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); + } + }).catch(function(e) { + console.log("RPCTest: sendRequest got exception: " + e.message); + }).finally (() => { + console.log("RPCTest: sendRequest ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + }); + ``` -**返回值:** +### sendMessageRequest9+ - | 类型 | 说明 | - | -------- | -------- | - | string | 返回接口描述符。 | +sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回后的某个时机执行回调,回复内容在RequestResult的reply报文里。 -### isObjectDead +**系统能力**:SystemCapability.Communication.IPC.Core -isObjectDead(): boolean +**参数:** -检查当前对象是否死亡。 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | -**系统能力**:SystemCapability.Communication.IPC.Core -**返回值:** +**示例:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果对象已死亡,则返回true;否则返回false。 | + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + function sendRequestCallback(result) { + if (result.errCode === 0) { + console.log("sendRequest got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); + } + console.log("RPCTest: sendRequest ends, reclaim parcel"); + result.data.reclaim(); + result.reply.reclaim(); + } + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageSequence.create(); + let reply = rpc.MessageSequence.create(); + data.writeInt(1); + data.writeString("hello"); + try { + proxy.sendRequest(1, data, reply, option, sendRequestCallback); + } catch(error) { + console.info("rpc send sequence request fail, errorCode " + error.code); + console.info("rpc send sequence request fail, errorMessage " + error.message); + } + ``` -## RemoteProxy +### sendRequest8+(deprecated) -实现IRemoteObject代理对象。 +sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。建议使用sendMessageRequest替代。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 +**系统能力**:SystemCapability.Communication.IPC.Core -| 参数 | 值 | 说明 | -| --------------------- | ----------------------- | --------------------------------- | -| PING_TRANSACTION | 1599098439 (0x5f504e47) | 内部指令码,用于测试IPC服务正常。 | -| DUMP_TRANSACTION | 1598311760 (0x5f444d50) | 内部指令码,获取Binder内部状态。 | -| INTERFACE_TRANSACTION | 1598968902 (0x5f4e5446) | 内部指令码,获取对端接口描述符。 | -| MIN_TRANSACTION_ID | 1 (0x00000001) | 最小有效指令码。 | -| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | 最大有效指令码。 | +**参数:** + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | +**示例:** + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + function sendRequestCallback(result) { + if (result.errCode === 0) { + console.log("sendRequest got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); + } + console.log("RPCTest: sendRequest ends, reclaim parcel"); + result.data.reclaim(); + result.reply.reclaim(); + } + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + proxy.sendRequest(1, data, reply, option, sendRequestCallback); + ``` -### sendRequest(deprecated) -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean +### getLocalInterface9+ -> **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9-1)替代。 +getLocalInterface(interface: string): IRemoteBroker -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 +查询并获取当前接口描述符对应的本地接口对象。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | ---------------------- | + | interface | string | 是 | 需要查询的接口描述符。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回一个布尔值,true表示成功,false表示失败。| + | 类型 | 说明 | + | ------------- | ------------------------------------------ | + | IRemoteBroker | 默认返回Null,标识该接口是一个代理侧接口。 | **示例:** @@ -2841,7 +6490,7 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function(elementName) { + onDisconnect: function (elementName) { console.log("RpcClient: onDisconnect"); }, onFailed: function() { @@ -2849,53 +6498,39 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options } }; let want = { - "bundleName": "com.ohos.server", - "abilityName": "com.ohos.server.MainAbility", + "bundleName":"com.ohos.server", + "abilityName":"com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); - let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); - data.writeInt(1); - data.writeString("hello"); - let ret: boolean = proxy.sendRequest(1, data, reply, option); - if (ret) { - console.log("sendRequest got result"); - let msg = reply.readString(); - console.log("RPCTest: reply msg: " + msg); - } else { - console.log("RPCTest: sendRequest failed"); + try { + let broker = proxy.getLocalInterface("testObject"); + console.log("RpcClient: getLocalInterface is " + broker); + } catch(error) { + console.info("rpc get local interface fail, errorCode " + error.code); + console.info("rpc get local interface fail, errorMessage " + error.message); } - console.log("RPCTest: sendRequest ends, reclaim parcel"); - data.reclaim(); - reply.reclaim(); ``` -### sendRequest8+(deprecated) -sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +### queryLocalInterface(deprecated) -> **说明:** -> 从 API Version 9 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9-1)替代。 +queryLocalInterface(interface: string): IRemoteBroker -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 +查询并获取当前接口描述符对应的本地接口对象。建议使用getLocalInterface替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | ---------------------- | + | interface | string | 是 | 需要查询的接口描述符。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + | 类型 | 说明 | + | ------------- | ------------------------------------------ | + | IRemoteBroker | 默认返回Null,标识该接口是一个代理侧接口。 | **示例:** @@ -2907,7 +6542,7 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function(elementName) { + onDisconnect: function (elementName) { console.log("RpcClient: onDisconnect"); }, onFailed: function() { @@ -2915,56 +6550,37 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options } }; let want = { - "bundleName": "com.ohos.server", - "abilityName": "com.ohos.server.MainAbility", + "bundleName":"com.ohos.server", + "abilityName":"com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); - let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); - data.writeInt(1); - data.writeString("hello"); - proxy.sendRequest(1, data, reply, option) - .then(function(result) { - if (result.errCode === 0) { - console.log("sendRequest got result"); - result.reply.readException(); - let msg = result.reply.readString(); - console.log("RPCTest: reply msg: " + msg); - } else { - console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); - } - }).catch(function(e) { - console.log("RPCTest: sendRequest got exception: " + e.message); - }).finally (() => { - console.log("RPCTest: sendRequest ends, reclaim parcel"); - data.reclaim(); - reply.reclaim(); - }); + let broker = proxy.queryLocalInterface("testObject"); + console.log("RpcClient: queryLocalInterface is " + broker); ``` -### sendRequestAsync9+ -sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +### registerDeathRecipient9+ + +registerDeathRecipient(recipient: DeathRecipient, flags: number): void -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequestAsync返回时兑现,回复内容在reply报文里。 +注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注册的回调。 | + | flags | number | 是 | 死亡通知标志。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** @@ -2988,47 +6604,41 @@ sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, opt "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); - let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); - data.writeInt(1); - data.writeString("hello"); - proxy.sendRequestAsync(1, data, reply, option) - .then(function(result) { - if (result.errCode === 0) { - console.log("sendRequestAsync got result"); - result.reply.readException(); - let msg = result.reply.readString(); - console.log("RPCTest: reply msg: " + msg); - } else { - console.log("RPCTest: sendRequestAsync failed, errCode: " + result.errCode); - } - }).catch(function(e) { - console.log("RPCTest: sendRequestAsync got exception: " + e.message); - }).finally (() => { - console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); - data.reclaim(); - reply.reclaim(); - }); + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + let deathRecipient = new MyDeathRecipient(); + try { + proxy.registerDeathRecippient(deathRecipient, 0); + } catch(error) { + console.info(proxy register deathRecipient fail, errorCode " + error.code); + console.info(proxy register deathRecipient fail, errorMessage " + error.message); + } ``` -### sendRequest8+ -sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void +### addDeathRecippient(deprecated) + +addDeathRecipient(recipient : DeathRecipient, flags : number): boolean -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 +注册用于接收远程对象死亡通知的回调,增加proxy对象上的死亡通知。建议使用registerDeathRecipient替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | --------------------------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 收件人表示要注册的回调。 | + | flags | number | 是 | 死亡通知标志。保留参数。设置为0。 | + +**返回值:** + + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果回调注册成功,则返回true;否则返回false。 | **示例:** @@ -3051,48 +6661,38 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.MainAbility", }; - function sendRequestCallback(result) { - if (result.errCode === 0) { - console.log("sendRequest got result"); - result.reply.readException(); - let msg = result.reply.readString(); - console.log("RPCTest: reply msg: " + msg); - } else { - console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); + FA.connectAbility(want, connect); + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); } - console.log("RPCTest: sendRequest ends, reclaim parcel"); - result.data.reclaim(); - result.reply.reclaim(); } - FA.connectAbility(want, connect); - let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); - data.writeInt(1); - data.writeString("hello"); - proxy.sendRequest(1, data, reply, option, sendRequestCallback); + let deathRecipient = new MyDeathRecipient(); + proxy.addDeathRecippient(deathRecipient, 0); ``` +### unregisterDeathRecipient9+ -### queryLocalInterface - -queryLocalInterface(interface: string): IRemoteBroker +removeDeathRecipient(recipient: DeathRecipient, flags: number): void -查询并获取当前接口描述符对应的本地接口对象。 +注销用于接收远程对象死亡通知的回调。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | interface | string | 是 | 需要查询的接口描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | -------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的回调。 | + | flags | number | 是 | 死亡通知标志。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | IRemoteBroker | 默认返回Null,标识该接口是一个代理侧接口。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** @@ -3104,7 +6704,7 @@ queryLocalInterface(interface: string): IRemoteBroker console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function (elementName) { + onDisconnect: function(elementName) { console.log("RpcClient: onDisconnect"); }, onFailed: function() { @@ -3112,35 +6712,46 @@ queryLocalInterface(interface: string): IRemoteBroker } }; let want = { - "bundleName":"com.ohos.server", - "abilityName":"com.ohos.server.MainAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); - let broker = proxy.queryLocalInterface("testObject"); - console.log("RpcClient: queryLocalInterface is " + broker); + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + let deathRecipient = new MyDeathRecipient(); + try { + proxy.registerDeathRecippient(deathRecipient, 0); + proxy.unregisterDeathRecippient(deathRecipient, 0); + } catch(error) { + console.info(proxy register deathRecipient fail, errorCode " + error.code); + console.info(proxy register deathRecipient fail, errorMessage " + error.message); + } ``` -### addDeathRecippient +### removeDeathRecipient(deprecated) -addDeathRecipient(recipient : DeathRecipient, flags : number): boolean +removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean -注册用于接收远程对象死亡通知的回调,增加proxy对象上的死亡通知。 +注销用于接收远程对象死亡通知的回调。建议使用unregisterDeathRecipient替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | recipient | [DeathRecipient](#deathrecipient) | 是 | 收件人表示要注册的回调。 | - | flags | number | 是 | 死亡通知标志。保留参数。设置为0。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | --------------------------------- | ---- | --------------------------------- | + | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的死亡回调。 | + | flags | number | 是 | 死亡通知标志。保留参数。设置为0。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果回调注册成功,则返回true;否则返回false。 | + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 如果回调成功注销,则返回true;否则返回false。 | **示例:** @@ -3171,29 +6782,31 @@ addDeathRecipient(recipient : DeathRecipient, flags : number): boolean } let deathRecipient = new MyDeathRecipient(); proxy.addDeathRecippient(deathRecipient, 0); + proxy.removeDeathRecipient(deathRecipient, 0); ``` -### removeDeathRecipient +### getDescriptor9+ -removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean +getInterfaceDescriptor(): string -注销用于接收远程对象死亡通知的回调。 +获取对象的接口描述符。接口描述符为字符串。 **系统能力**:SystemCapability.Communication.IPC.Core -**参数:** +**返回值:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | recipient | [DeathRecipient](#deathrecipient) | 是 | 要注销的死亡回调。 | - | flags | number | 是 | 死亡通知标志。保留参数。设置为0。 | + | 类型 | 说明 | + | ------ | ---------------- | + | string | 返回接口描述符。 | -**返回值:** +**错误码:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 如果回调成功注销,则返回true;否则返回false。 | +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900008 | proxy or remote object is invalid | **示例:** @@ -3217,29 +6830,28 @@ removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean "abilityName": "com.ohos.server.MainAbility", }; FA.connectAbility(want, connect); - class MyDeathRecipient { - onRemoteDied() { - console.log("server died"); - } + try { + let descriptor = proxy.getDescriptor(); + console.log("RpcClient: descriptor is " + descriptor); + } catch(error) { + console.info("rpc get interface descriptor fail, errorCode " + error.code); + console.info("rpc get interface descriptor fail, errorMessage " + error.message); } - let deathRecipient = new MyDeathRecipient(); - proxy.addDeathRecippient(deathRecipient, 0); - proxy.removeDeathRecipient(deathRecipient, 0); ``` -### getInterfaceDescriptor +### getInterfaceDescriptor(deprecated) getInterfaceDescriptor(): string -查询当前代理对象接口的描述符。 +查询当前代理对象接口的描述符。建议使用getDescriptor替代。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------ | | string | 当前的接口描述符。 | **示例:** @@ -3279,8 +6891,8 @@ isObjectDead(): boolean **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------------------------------------------------- | | boolean | 如果对应的RemoteObject已经死亡,返回true,否则返回false。 | **示例:** @@ -3316,12 +6928,27 @@ isObjectDead(): boolean **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 - | 参数 | 值 | 说明 | -| -------- | -------- | -------- | -| TF_SYNC | 0 | 同步调用。 | -| TF_ASYNC | 1 | 异步调用。 | -| TF_ACCEPT_FDS | 0x10 | 指示[sendRequestAsync](#sendrequestasync9)接口可以返回文件描述符。 | -| TF_WAIT_TIME | 8 | 等待时间。单位秒。 | + | 参数: | 值 | 说明 | + | ------------- | ---- | ----------------------------------------------------------- | + | TF_SYNC | 0 | 同步调用。 | + | TF_ASYNC | 1 | 异步调用。 | + | TF_ACCEPT_FDS | 0x10 | 指示sendMessageRequest9+接口可以返回文件描述符。 | + | TF_WAIT_TIME | 8 | 等待时间。单位秒。 | + + +### constructor9+ + +constructor(async?: boolean); + +MessageOption构造函数。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | -------------------------------------- | + | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | ### constructor @@ -3334,10 +6961,34 @@ MessageOption构造函数。 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | - | waitTime | number | 否 | 调用rpc最长等待时间。默认 TF_WAIT_TIME。 | + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | --------------------------------------------- | + | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | + | waitTime | number | 否 | 调用rpc最长等待时间。默认 TF_WAIT_TIME。 | + + +### isAsync9+ + +isAsync(): boolean; + +获取SendMessageRequest调用中确定同步或是异步的标志。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------- | ------------------------------------ | + | boolean | 调用成功返回同步调用或异步调用标志。 | + + +### setAsync9+ + +setAsync(async: boolean): void; + +设置SendMessageRequest调用中确定同步或是异步的标志。 + +**系统能力**:SystemCapability.Communication.IPC.Core ### getFlags @@ -3350,8 +7001,8 @@ getFlags(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------------------------ | | number | 调用成功返回同步调用或异步调用标志。 | @@ -3365,9 +7016,9 @@ setFlags(flags: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | flags | number | 是 | 同步调用或异步调用标志。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------ | + | flags | number | 是 | 同步调用或异步调用标志。 | ### getWaitTime @@ -3380,8 +7031,8 @@ getWaitTime(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ----------------- | | number | rpc最长等待时间。 | @@ -3395,16 +7046,15 @@ setWaitTime(waitTime: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | waitTime | number | 是 | rpc调用最长等待时间。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | --------------------- | + | waitTime | number | 是 | rpc调用最长等待时间。 | ## IPCSkeleton 用于获取IPC上下文信息,包括获取UID和PID、获取本端和对端设备ID、检查接口调用是否在同一设备上。 - ### getContextObject static getContextObject(): IRemoteObject @@ -3415,8 +7065,8 @@ static getContextObject(): IRemoteObject **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------------------------------- | -------------------- | | [IRemoteObject](#iremoteobject) | 返回系统能力管理者。 | **示例:** @@ -3437,20 +7087,20 @@ static getCallingPid(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ----------------- | | number | 返回调用者的PID。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callerPid = rpc.IPCSkeleton.getCallingPid(); console.log("RpcServer: getCallingPid result: " + callerPid); return true; } - } + } ``` @@ -3464,15 +7114,15 @@ static getCallingUid(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ----------------- | | number | 返回调用者的UID。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callerUid = rpc.IPCSkeleton.getCallingUid(); console.log("RpcServer: getCallingUid result: " + callerUid); return true; @@ -3480,6 +7130,7 @@ static getCallingUid(): number } ``` + ### getCallingTokenId8+ static getCallingTokenId(): number; @@ -3488,17 +7139,18 @@ static getCallingTokenId(): number; **系统能力**:SystemCapability.Communication.IPC.Core -* 返回值 +* 返回值 +* | 类型 | 说明 | - | ------ | --------------------- | - | number | 返回调用者的TokenId。 | - + | ------ | --------------------- | + | number | 返回调用者的TokenId。 | + * 示例 ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); console.log("RpcServer: getCallingTokenId result: " + callerTokenId); return true; @@ -3517,15 +7169,15 @@ static getCallingDeviceID(): string **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ---------------------------- | | string | 返回调用者进程所在的设备ID。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID(); console.log("RpcServer: callerDeviceID is: " + callerDeviceID); return true; @@ -3544,15 +7196,15 @@ static getLocalDeviceID(): string **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------ | | string | 返回本地设备的ID。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID(); console.log("RpcServer: localDeviceID is: " + localDeviceID); return true; @@ -3571,15 +7223,15 @@ static isLocalCalling(): boolean **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | --------------------------------------------------------- | | boolean | 如果调用是在同一设备上进行的,则返回true,否则返回false。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let isLocalCalling = rpc.IPCSkeleton.isLocalCalling(); console.log("RpcServer: isLocalCalling is: " + isLocalCalling); return true; @@ -3588,9 +7240,9 @@ static isLocalCalling(): boolean ``` -### flushCommands +### flushCmdBuffer9+ -static flushCommands(object : IRemoteObject): number +static flushCmdBuffer(object : IRemoteObject): void 将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。 @@ -3598,15 +7250,57 @@ static flushCommands(object : IRemoteObject): number **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | object | [IRemoteObject](#iremoteobject) | 是 | 指定的RemoteProxy。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | ------------------- | + | object | [IRemoteObject](#iremoteobject) | 是 | 指定的RemoteProxy。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number); + removeDeathRecipient(recipient: MyDeathRecipient, flags: number); + isObjectDead(): boolean { + return false; + } + } + let remoteObject = new TestRemoteObject("aaa"); + try { + rpc.IPCSkeleton.flushCmdBuffer(remoteObject); + } catch(error) { + console.info(proxy set calling identity fail, errorCode " + error.code); + console.info(proxy set calling identity fail, errorMessage " + error.message); + } + ``` + + +### flushCommands(deprecated) + +static flushCommands(object : IRemoteObject): number + +将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。使用flushCmdBuffer替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | ------------------- | + | object | [IRemoteObject](#iremoteobject) | 是 | 指定的RemoteProxy。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | --------------------------------------------------------------------------------- | | number | 如果操作成功,返回0;如果输入对象为空或RemoteObject,或者操作失败,返回错误代码。 | **示例:** @@ -3636,7 +7330,6 @@ static flushCommands(object : IRemoteObject): number console.log("RpcServer: flushCommands result: " + ret); ``` - ### resetCallingIdentity static resetCallingIdentity(): string @@ -3647,15 +7340,15 @@ static resetCallingIdentity(): string **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ------------------------------------ | | string | 返回包含远程用户的UID和PID的字符串。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity(); console.log("RpcServer: callingIdentity is: " + callingIdentity); return true; @@ -3664,31 +7357,63 @@ static resetCallingIdentity(): string ``` -### setCallingIdentity +### restoreCallingIdentity9+ + +static restoreCallingIdentity(identity : string): void + +将远程用户的UID和PID替换为本地用户的UID和PID。它可以用于身份验证等场景。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------------ | + | identity | string | 是 | 标识表示包含远程用户UID和PID的字符串。由resetCallingIdentity返回。 | + +**示例:** + + ``` + class Stub extends rpc.RemoteObject { + onRemoteRequestEx(code, data, reply, option) { + let callingIdentity = null; + try { + callingIdentity = rpc.IPCSkeleton.resetCallingIdentity(); + console.log("RpcServer: callingIdentity is: " + callingIdentity); + } finally { + rpc.IPCSkeleton.restoreCallingIdentity("callingIdentity "); + } + return true; + } + } + ``` + + +### setCallingIdentity(deprecated) static setCallingIdentity(identity : string): boolean -将UID和PID恢复为远程用户的UID和PID。它通常在使用resetCallingIdentity后调用,需要resetCallingIdentity返回的远程用户的UID和PID。 +将UID和PID恢复为远程用户的UID和PID。它通常在使用resetCallingIdentity后调用,需要resetCallingIdentity返回的远程用户的UID和PID。建议使用restoreCallingIdentity替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | identity | string | 是 | 标识表示包含远程用户UID和PID的字符串。由resetCallingIdentity返回。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------------ | + | identity | string | 是 | 标识表示包含远程用户UID和PID的字符串。由resetCallingIdentity返回。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果操作成功,则返回true;否则返回false。 | **示例:** ``` class Stub extends rpc.RemoteObject { - onRemoteRequest(code, data, reply, option) { + onRemoteRequestEx(code, data, reply, option) { let callingIdentity = null; try { callingIdentity = rpc.IPCSkeleton.resetCallingIdentity(); @@ -3707,7 +7432,6 @@ static setCallingIdentity(identity : string): boolean 实现远程对象。服务提供者必须继承此类。 - ### constructor constructor(descriptor: string) @@ -3718,37 +7442,33 @@ RemoteObject构造函数。 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | descriptor | string | 是 | 接口描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | ------------ | + | descriptor | string | 是 | 接口描述符。 | ### sendRequest(deprecated) sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean -> **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9-2)替代。 - 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回一个布尔值,true表示成功,false表示失败。| - + | 类型 | 说明 | + | ------- | --------------------------------------------- | + | boolean | 返回一个布尔值,true表示成功,false表示失败。 | **示例:** @@ -3796,28 +7516,24 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> -> **说明:** -> 从 API Version 9 开始废弃,建议使用[sendRequestAsync9+](#sendrequestasync9-2)替代。 - -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。建议使用sendMessageRequest9+替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| - + | 类型 | 说明 | + | -------------------------------- | --------------------------------------------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。 | **示例:** @@ -3866,28 +7582,28 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options }); ``` -### sendRequestAsync9+ +### sendMessageRequest9+ -sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> +sendMessageRequest(code : number, data : MessageSequence, reply : MessageSequence, options : MessageOption): Promise<RequestResult> -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequestAsync返回时兑现,回复内容在reply报文里。 +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + | 类型 | 说明 | + | ---------------------------- | --------------------------------------------- | + | Promise<RequestResult> | 返回一个期约,兑现值是sendRequestResult实例。 | **示例:** @@ -3901,59 +7617,116 @@ sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, opt constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } } let testRemoteObject = new TestRemoteObject("testObject"); let option = new rpc.MessageOption(); - let data = rpc.MessageParcel.create(); - let reply = rpc.MessageParcel.create(); + let data = rpc.MessageSequence.create(); + let reply = rpc.MessageSequence.create(); data.writeInt(1); data.writeString("hello"); - testRemoteObject.sendRequestAsync(1, data, reply, option) + testRemoteObject.sendMessageRequest(1, data, reply, option) .then(function(result) { if (result.errCode === 0) { - console.log("sendRequestAsync got result"); + console.log("sendMessageRequest got result"); result.reply.readException(); let msg = result.reply.readString(); console.log("RPCTest: reply msg: " + msg); } else { - console.log("RPCTest: sendRequestAsync failed, errCode: " + result.errCode); + console.log("RPCTest: sendMessageRequest failed, errCode: " + result.errCode); } }).catch(function(e) { - console.log("RPCTest: sendRequestAsync got exception: " + e.message); + console.log("RPCTest: sendMessageRequest got exception: " + e.message); }).finally (() => { - console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); + console.log("RPCTest: sendMessageRequest ends, reclaim parcel"); data.reclaim(); reply.reclaim(); }); ``` -### sendRequest8+ -sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void +### sendMessageRequest9+ -以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 +sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void + +以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回时收到回调,回复内容在reply报文里。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | MessageSequence | 是 | 保存待发送数据的 MessageSequence对象。 | + | reply | MessageSequence | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | AsyncCallback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number); + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + } + function sendRequestCallback(result) { + if (result.errCode === 0) { + console.log("sendRequest got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequest failed, errCode: " + result.errCode); + } + console.log("RPCTest: sendRequest ends, reclaim parcel"); + result.data.reclaim(); + result.reply.reclaim(); + } + let testRemoteObject = new TestRemoteObject("testObject"); + let option = new rpc.MessageOption(); + let data = rpc.MessageSequence.create(); + let reply = rpc.MessageSequence.create(); + data.writeInt(1); + data.writeString("hello"); + testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback); + ``` + + +### sendRequest8+(deprecated) + +sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void + +以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。建议使用sendMessageRequest替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparcel) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | **示例:** @@ -4002,32 +7775,27 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ### onRemoteRequest8+(deprecated) - onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean -> **说明:** -> 从 API Version 9 开始废弃,建议使用[onRemoteRequestEx9+](#onremoterequestex9)替代。 - -sendRequestAsync请求的响应处理函数,服务端在该函数里处理请求,回复结果。 +sendMessageRequest请求的响应处理函数,服务端在该函数里处理请求,回复结果。建议使用onRemoteRequestEx9+替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 对端发送的服务请求码。 | - | data | [MessageParcel](#messageparcel) | 是 | 携带客户端调用参数的MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 写入结果的MessageParcel对象。 | - | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | --------------------------------------- | + | code | number | 是 | 对端发送的服务请求码。 | + | data | [MessageParcel](#messageparcel) | 是 | 携带客户端调用参数的MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 写入结果的MessageParcel对象。 | + | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果操作成功,则返回true;否则返回false。 | - **示例:** ```ets @@ -4049,7 +7817,6 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里处理请 isObjectDead(): boolean { return false; } - onRemoteRequest(code, data, reply, option) { if (code === 1) { console.log("RpcServer: onRemoteRequest called"); @@ -4061,34 +7828,35 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里处理请 } } ``` + ### onRemoteRequestEx9+ -onRemoteRequestEx(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean | Promise +onRemoteRequestEx(code : number, data : MessageSequence, reply: MessageSequence, options : MessageOption): boolean | Promise > **说明:** ->- 开发者应优先选择重载onRemoteRequestEx方法,其中可以自由实现同步和异步的消息处理。 ->- 开发者同时重载onRemoteRequest和onRemoteRequestEx方法时,仅onRemoteRequestEx方法生效。 +> +>* 开发者应优先选择重载onRemoteRequestEx方法,其中可以自由实现同步和异步的消息处理。 +>* 开发者同时重载onRemoteRequest和onRemoteRequestEx方法时,仅onRemoteRequestEx方法生效。 -sendRequestAsync请求的响应处理函数,服务端在该函数里同步或异步地处理请求,回复结果。 +sendMessageRequest请求的响应处理函数,服务端在该函数里同步或异步地处理请求,回复结果。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | code | number | 是 | 对端发送的服务请求码。 | - | data | [MessageParcel](#messageparcel) | 是 | 携带客户端调用参数的MessageParcel对象。 | - | reply | [MessageParcel](#messageparcel) | 是 | 写入结果的MessageParcel对象。 | - | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------- | ---- | ----------------------------------------- | + | code | number | 是 | 对端发送的服务请求码。 | + | data | MessageSequence | 是 | 携带客户端调用参数的MessageSequence对象。 | + | reply | MessageSequence | 是 | 写入结果的MessageSequence对象。 | + | option | MessageSequence(#messageoption) | 是 | 指示操作是同步还是异步。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | boolean | 若在onRemoteRequestEx中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 | - | Promise | 若在onRemoteRequestEx中异步地处理请求,则返回一个Promise对象。 | - + | 类型 | 说明 | + | ----------------- | ---------------------------------------------------------------------------------------------- | + | boolean | 若在onRemoteRequestEx中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 | + | Promise | 若在onRemoteRequestEx中异步地处理请求,则返回一个Promise对象。 | **重载onRemoteRequestEx方法同步处理请求示例:** @@ -4102,12 +7870,8 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -4122,6 +7886,7 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 } } ``` + **重载onRemoteRequestEx方法异步处理请求示例:** ```ets @@ -4134,12 +7899,8 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -4157,6 +7918,7 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 } } ``` + **同时重载onRemoteRequestEx和onRemoteRequest方法同步处理请求示例:** ```ets @@ -4169,12 +7931,8 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } @@ -4195,11 +7953,12 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 console.log("RpcServer: unknown code: " + code); return false; } - + return true; } } ``` + **同时重载onRemoteRequestEx和onRemoteRequest方法异步处理请求示例:** ```ets @@ -4212,18 +7971,14 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } onRemoteRequest(code, data, reply, option) { if (code === 1) { - console.log("RpcServer: sync onRemoteRequestEx is called"); + console.log("RpcServer: sync onRemoteRequest is called"); return true; } else { console.log("RpcServer: unknown code: " + code); @@ -4238,13 +7993,15 @@ sendRequestAsync请求的响应处理函数,服务端在该函数里同步或 console.log("RpcServer: unknown code: " + code); return false; } - await new Promise((resolve) => { + await new Promise((resolve) => { setTimeout(resolve, 100); }) return true; } } ``` + + ### getCallingUid getCallingUid(): number @@ -4253,12 +8010,137 @@ getCallingUid(): number **系统能力**:SystemCapability.Communication.IPC.Core +**返回值:** + | 类型 | 说明 | + | ------ | ----------------------- | + | number | 返回通信对端的进程Uid。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); + isObjectDead(): boolean { + return false; + } + } + let testRemoteObject = new TestRemoteObject("testObject"); + console.log("RpcServer: getCallingUid: " + testRemoteObject.getCallingUid()); + ``` + +### getCallingPid + +getCallingPid(): number + +获取通信对端的进程Pid。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**返回值:** + + | 类型 | 说明 | + | ------ | ----------------------- | + | number | 返回通信对端的进程Pid。 | + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); + isObjectDead(): boolean { + return false; + } + } + let testRemoteObject = new TestRemoteObject("testObject"); + console.log("RpcServer: getCallingPid: " + testRemoteObject.getCallingPid()); + ``` + +### getLocalInterface9+ + +getLocalInterface(descriptor: string): IRemoteBroker + +查询接口。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | -------------------- | + | descriptor | string | 是 | 接口描述符的字符串。 | + +**返回值:** + + | 类型 | 说明 | + | ------------- | --------------------------------------------- | + | IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 | + + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); + isObjectDead(): boolean { + return false; + } + } + let testRemoteObject = new TestRemoteObject("testObject"); + try { + let broker = testRemoteObject.getLocalInterface("testObject"); + } catch(error) { + console.info(rpc get local interface fail, errorCode " + error.code); + console.info(rpc get local interface fail, errorMessage " + error.message); + } + ``` + + +### queryLocalInterface(deprecated) + +queryLocalInterface(descriptor: string): IRemoteBroker + +查询并获取当前接口描述符对应的远端对象是否已经存在。建议使用getLocalInterface替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | ---------------------- | + | descriptor | string | 是 | 需要查询的接口描述符。 | + **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回通信对端的进程Uid。 | - + | 类型 | 说明 | + | ------------- | ------------------------------------------------------------------ | + | IRemoteBroker | 如果接口描述符对应的远端对象存在,则返回该远端对象,否则返回Null。 | **示例:** @@ -4283,24 +8165,31 @@ getCallingUid(): number } } let testRemoteObject = new TestRemoteObject("testObject"); - console.log("RpcServer: getCallingUid: " + testRemoteObject.getCallingUid()); + let broker = testRemoteObject.queryLocalInterface("testObject"); ``` -### getCallingPid +### getDescriptor9+ -getCallingPid(): number +getInterfaceDescriptor(): string -获取通信对端的进程Pid。 +获取对象的接口描述符。接口描述符为字符串。 **系统能力**:SystemCapability.Communication.IPC.Core **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | number | 返回通信对端的进程Pid。 | + | 类型 | 说明 | + | ------ | ---------------- | + | string | 返回接口描述符。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** @@ -4314,41 +8203,36 @@ getCallingPid(): number constructor(descriptor) { super(descriptor); } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + addDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } } let testRemoteObject = new TestRemoteObject("testObject"); - console.log("RpcServer: getCallingPid: " + testRemoteObject.getCallingPid()); + try { + let descriptor = testRemoteObject.getDescriptor(); + } catch(error) { + console.info(rpc get local interface fail, errorCode " + error.code); + console.info(rpc get local interface fail, errorMessage " + error.message); + } + console.log("RpcServer: descriptor is: " + descriptor); ``` -### queryLocalInterface +### getInterfaceDescriptor(deprecated) -queryLocalInterface(descriptor: string): IRemoteBroker +getInterfaceDescriptor(): string -查询并获取当前接口描述符对应的远端对象是否已经存在。 +查询接口描述符。建议使用getDescriptor替代。 **系统能力**:SystemCapability.Communication.IPC.Core -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | descriptor | string | 是 | 需要查询的接口描述符。 | - **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | IRemoteBroker | 如果接口描述符对应的远端对象存在,则返回该远端对象,否则返回Null。 | - + | 类型 | 说明 | + | ------ | ---------------- | + | string | 返回接口描述符。 | **示例:** @@ -4373,23 +8257,25 @@ queryLocalInterface(descriptor: string): IRemoteBroker } } let testRemoteObject = new TestRemoteObject("testObject"); - let broker = testRemoteObject.queryLocalInterface("testObject"); + let descriptor = testRemoteObject.getInterfaceDescriptor(); + console.log("RpcServer: descriptor is: " + descriptor); ``` -### getInterfaceDescriptor +### modifyLocalInterface9+ -getInterfaceDescriptor(): string +modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void -查询接口描述符。 +此接口用于把接口描述符和IRemoteBroker对象绑定。 **系统能力**:SystemCapability.Communication.IPC.Core -**返回值:** +**参数:** - | 类型 | 说明 | - | -------- | -------- | - | string | 返回接口描述符。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------- | ---- | ------------------------------------- | + | localInterface | IRemoteBroker | 是 | 将与描述符绑定的IRemoteBroker对象。 | + | descriptor | string | 是 | 用于与IRemoteBroker对象绑定的描述符。 | **示例:** @@ -4403,38 +8289,39 @@ getInterfaceDescriptor(): string class TestRemoteObject extends rpc.RemoteObject { constructor(descriptor) { super(descriptor); + try { + this.modifyLocalInterface(this, descriptor); + } catch(error) { + console.info(rpc attach local interface fail, errorCode " + error.code); + console.info(rpc attach local interface fail, errorMessage " + error.message); + } } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } + registerDeathRecipient(recipient: MyDeathRecipient, flags: number); + unregisterDeathRecipient(recipient: MyDeathRecipient, flags: number); isObjectDead(): boolean { return false; } + asObject(): rpc.IRemoteObject { + return this; + } } let testRemoteObject = new TestRemoteObject("testObject"); - let descriptor = testRemoteObject.getInterfaceDescriptor(); - console.log("RpcServer: descriptor is: " + descriptor); ``` - -### attachLocalInterface +### attachLocalInterface(deprecated) attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void -此接口用于把接口描述符和IRemoteBroker对象绑定。 +此接口用于把接口描述符和IRemoteBroker对象绑定。建议使用modifyLocalInterface替代。 **系统能力**:SystemCapability.Communication.IPC.Core **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | localInterface | IRemoteBroker | 是 | 将与描述符绑定的IRemoteBroker对象。 | - | descriptor | string | 是 | 用于与IRemoteBroker对象绑定的描述符。 | - + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------- | ---- | ------------------------------------- | + | localInterface | IRemoteBroker | 是 | 将与描述符绑定的IRemoteBroker对象。 | + | descriptor | string | 是 | 用于与IRemoteBroker对象绑定的描述符。 | **示例:** @@ -4474,17 +8361,17 @@ attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 - | 参数名 | 值 | 说明 | -| -------- | -------- | -------- | -| PROT_EXEC | 4 | 映射的内存可执行 | -| PROT_NONE | 0 | 映射的内存不可访问 | -| PROT_READ | 1 | 映射的内存可读 | -| PROT_WRITE | 2 | 映射的内存可写 | + | 参数名 | 值 | 说明 | + | ---------- | --- | ------------------ | + | PROT_EXEC | 4 | 映射的内存可执行 | + | PROT_NONE | 0 | 映射的内存不可访问 | + | PROT_READ | 1 | 映射的内存可读 | + | PROT_WRITE | 2 | 映射的内存可写 | -### createAshmem8+ +### create9+ -static createAshmem(name: string, size: number): Ashmem +static create(name: string, size: number): Ashmem 根据指定的名称和大小创建Ashmem对象。 @@ -4492,18 +8379,53 @@ static createAshmem(name: string, size: number): Ashmem **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | name | string | 是 | 名称,用于查询Ashmem信息。 | - | size | number | 是 | Ashmem的大小,以字节为单位。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------------------- | + | name | string | 是 | 名称,用于查询Ashmem信息。 | + | size | number | 是 | Ashmem的大小,以字节为单位。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ---------------------------------------------- | | Ashmem | 返回创建的Ashmem对象;如果创建失败,返回null。 | +**示例:** + + ``` + try { + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + } catch(error) { + console.info("Rpc creat ashmem fail, errorCode " + error.code); + console.info("Rpc creat ashmem fail, errorMessage " + error.message); + } + let size = ashmem.getAshmemSize(); + console.log("RpcTest: get ashemm by create : " + ashmem + " size is : " + size); + ``` + + +### createAshmem8+(deprecated) + +static createAshmem(name: string, size: number): Ashmem + +根据指定的名称和大小创建Ashmem对象。建议使用create替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------------------- | + | name | string | 是 | 名称,用于查询Ashmem信息。 | + | size | number | 是 | Ashmem的大小,以字节为单位。 | + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------------------------------------- | + | Ashmem | 返回创建的Ashmem对象;如果创建失败,返回null。 | + **示例:** ``` @@ -4513,9 +8435,9 @@ static createAshmem(name: string, size: number): Ashmem ``` -### createAshmemFromExisting8+ +### create9+ -static createAshmemFromExisting(ashmem: Ashmem): Ashmem +static create(ashmem: Ashmem): Ashmem 通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。 @@ -4523,17 +8445,58 @@ static createAshmemFromExisting(ashmem: Ashmem): Ashmem **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | ashmem | Ashmem | 是 | 已存在的Ashmem对象。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | ashmem | Ashmem | 是 | 已存在的Ashmem对象。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | ---------------------- | | Ashmem | 返回创建的Ashmem对象。 | +**示例:** + + ``` + try { + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + } catch(error) { + console.info("Rpc creat ashmem fail, errorCode " + error.code); + console.info("Rpc creat ashmem fail, errorMessage " + error.message); + } + try { + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + let ashmem2 = rpc.Ashmem.create(ashmem); + } catch(error) { + console.info("Rpc creat ashmem from existing fail, errorCode " + error.code); + console.info("Rpc creat ashmem from existing fail, errorMessage " + error.message); + } + let size = ashmem2.getAshmemSize(); + console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size); + ``` + + +### createAshmemFromExisting8+(deprecated) + +static createAshmemFromExisting(ashmem: Ashmem): Ashmem + +通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。建议使用create替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | ashmem | Ashmem | 是 | 已存在的Ashmem对象。 | + +**返回值:** + + | 类型 | 说明 | + | ------ | ---------------------- | + | Ashmem | 返回创建的Ashmem对象。 | + **示例:** ``` @@ -4555,7 +8518,7 @@ closeAshmem(): void **示例:** ``` - let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); ashmem.closeAshmem(); ``` @@ -4571,7 +8534,7 @@ unmapAshmem(): void **示例:** ``` - let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); ashmem.unmapAshmem(); ``` @@ -4586,8 +8549,8 @@ getAshmemSize(): number **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------ | -------------------------- | | number | 返回Ashmem对象的内存大小。 | **示例:** @@ -4599,9 +8562,9 @@ getAshmemSize(): number ``` -### mapAshmem8+ +### mapTypedAshmem9+ -mapAshmem(mapType: number): boolean +mapTypedAshmem(mapType: number): void 在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。 @@ -4609,14 +8572,49 @@ mapAshmem(mapType: number): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | mapType | number | 是 | 指定映射的内存区域的保护等级。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------------------------ | + | mapType | number | 是 | 指定映射的内存区域的保护等级。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | ------ | + | 1900001 | call mmap function failed | + +**示例:** + + ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + try { + ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); + } catch(error) { + console.info("Rpc map ashmem fail, errorCode " + error.code); + console.info("Rpc map ashmem fail, errorMessage " + error.message); + } + ``` + + +### mapAshmem8+(deprecated) + +mapAshmem(mapType: number): boolean + +在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。建议使用mapTypedAshmem替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------ | ---- | ------------------------------ | + | mapType | number | 是 | 指定映射的内存区域的保护等级。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果映射成功,则返回true;否则返回false。 | **示例:** @@ -4628,18 +8626,47 @@ mapAshmem(mapType: number): boolean ``` -### mapReadAndWriteAshmem8+ +### mapReadWriteAshmem9+ -mapReadAndWriteAshmem(): boolean +mapReadAndWriteAshmem(): void 在此进程虚拟地址空间上创建可读写的共享文件映射。 **系统能力**:SystemCapability.Communication.IPC.Core +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900001 | call mmap function failed | + +**示例:** + + ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + try { + ashmem.mapReadWriteAshmem(); + } catch(error) { + console.info("Rpc map read and write ashmem fail, errorCode " + error.code); + console.info("Rpc map read and write ashmem fail, errorMessage " + error.message); + } + ``` + + +### mapReadAndWriteAshmem8+(deprecated) + +mapReadAndWriteAshmem(): boolean + +在此进程虚拟地址空间上创建可读写的共享文件映射。建议使用mapReadWriteAshmem替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果映射成功,则返回true;否则返回false。 | **示例:** @@ -4651,18 +8678,47 @@ mapReadAndWriteAshmem(): boolean ``` -### mapReadOnlyAshmem8+ +### mapReadonlyAshmem9+ -mapReadOnlyAshmem(): boolean +mapReadonlyAshmem(): void 在此进程虚拟地址空间上创建只读的共享文件映射。 **系统能力**:SystemCapability.Communication.IPC.Core +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900001 | call mmap function failed | + +**示例:** + + ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + try { + ashmem.mapReadonlyAshmem(); + } catch(error) { + console.info("Rpc map read and write ashmem fail, errorCode " + error.code); + console.info("Rpc map read and write ashmem fail, errorMessage " + error.message); + } + ``` + + +### mapReadOnlyAshmem8+(deprecated) + +mapReadOnlyAshmem(): boolean + +在此进程虚拟地址空间上创建只读的共享文件映射。建议使用mapReadonlyAshmem替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果映射成功,则返回true;否则返回false。 | **示例:** @@ -4674,9 +8730,9 @@ mapReadOnlyAshmem(): boolean ``` -### setProtection8+ +### setProtectionType9+ -setProtection(protectionType: number): boolean +setProtectionType(protectionType: number): void 设置映射内存区域的保护等级。 @@ -4684,14 +8740,49 @@ setProtection(protectionType: number): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | protectionType | number | 是 | 要设置的保护类型。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | ------------------ | + | protectionType | number | 是 | 要设置的保护类型。 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | ------- | + | 1900002 | call os ioctl function failed | + +**示例:** + + ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + try { + ashmem.setProtection(ashmem.PROT_READ); + } catch(error) { + console.info("Rpc set protection type fail, errorCode " + error.code); + console.info("Rpc set protection type fail, errorMessage " + error.message); + } + ``` + + +### setProtection8+(deprecated) + +setProtection(protectionType: number): boolean + +设置映射内存区域的保护等级。建议使用setProtectionType替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | ------------------ | + | protectionType | number | 是 | 要设置的保护类型。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------- | | boolean | 如果设置成功,则返回true;否则返回false。 | **示例:** @@ -4703,9 +8794,9 @@ setProtection(protectionType: number): boolean ``` -### writeToAshmem8+ +### writeAshmem9+ -writeToAshmem(buf: number[], size: number, offset: number): boolean +writeAshmem(buf: number[], size: number, offset: number): void 将数据写入此Ashmem对象关联的共享文件。 @@ -4713,16 +8804,55 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | buf | number[] | 是 | 写入Ashmem对象的数据。 | - | size | number | 是 | 要写入的数据大小。 | - | offset | number | 是 | 要写入的数据在此Ashmem对象关联的内存区间的起始位置 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------------------------------------- | + | buf | number[] | 是 | 写入Ashmem对象的数据。 | + | size | number | 是 | 要写入的数据大小。 | + | offset | number | 是 | 要写入的数据在此Ashmem对象关联的内存区间的起始位置 | + +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | ------- | -------- | + | 1900003 | write to ashmem failed | + +**示例:** + + ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + ashmem.mapReadWriteAshmem(); + var ByteArrayVar = [1, 2, 3, 4, 5]; + try { + ashmem.writeAshmem(ByteArrayVar, 5, 0); + } catch(error) { + console.info("Rpc write to ashmem fail, errorCode " + error.code); + console.info("Rpc write to ashmem fail, errorMessage " + error.message); + } + ``` + + +### writeToAshmem8+(deprecated) + +writeToAshmem(buf: number[], size: number, offset: number): boolean + +将数据写入此Ashmem对象关联的共享文件。建议使用writeAshmem替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | -------- | ---- | -------------------------------------------------- | + | buf | number[] | 是 | 写入Ashmem对象的数据。 | + | size | number | 是 | 要写入的数据大小。 | + | offset | number | 是 | 要写入的数据在此Ashmem对象关联的内存区间的起始位置 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ------- | ----------------------------------------------------------------------------------------- | | boolean | 如果数据写入成功,则返回true;在其他情况下,如数据写入越界或未获得写入权限,则返回false。 | **示例:** @@ -4737,9 +8867,9 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean ``` -### readFromAshmem8+ +### readAshmem9+ -readFromAshmem(size: number, offset: number): number[] +readAshmem(size: number, offset: number): number[] 从此Ashmem对象关联的共享文件中读取数据。 @@ -4747,21 +8877,66 @@ readFromAshmem(size: number, offset: number): number[] **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | size | number | 是 | 要读取的数据的大小。 | - | offset | number | 是 | 要读取的数据在此Ashmem对象关联的内存区间的起始位置 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------------------------------------- | + | size | number | 是 | 要读取的数据的大小。 | + | offset | number | 是 | 要读取的数据在此Ashmem对象关联的内存区间的起始位置 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | -------- | ---------------- | | number[] | 返回读取的数据。 | +**错误码:** + +以下错误码的详细介绍请参见ohos.rpc错误码 + + | 错误码ID | 错误信息 | + | -------- | -------- | + | 1900004 | read from ashmem failed | **示例:** ``` + let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); + ashmem.mapReadWriteAshmem(); + var ByteArrayVar = [1, 2, 3, 4, 5]; + ashmem.writeAshmem(ByteArrayVar, 5, 0); + try { + let readResult = ashmem.readAshmem(5, 0); + console.log("RpcTest: read from Ashmem result is : " + readResult); + } catch(error) { + console.info("Rpc read from ashmem fail, errorCode " + error.code); + console.info("Rpc read from ashmem fail, errorMessage " + error.message); + } + ``` + + +### readFromAshmem8+(deprecated) + +readFromAshmem(size: number, offset: number): number[] + +从此Ashmem对象关联的共享文件中读取数据。建议使用readAshmem替代。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------------------------------------- | + | size | number | 是 | 要读取的数据的大小。 | + | offset | number | 是 | 要读取的数据在此Ashmem对象关联的内存区间的起始位置 | + +**返回值:** + + | 类型 | 说明 | + | -------- | ---------------- | + | number[] | 返回读取的数据。 | + +**示例:** + + ``` let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let mapResult = ashmem.mapReadAndWriteAshmem(); console.info("RpcTest map ashmem result is " + mapResult); @@ -4770,4 +8945,4 @@ readFromAshmem(size: number, offset: number): number[] console.log("RpcTest: write to Ashmem result is : " + writeResult); let readResult = ashmem.readFromAshmem(5, 0); console.log("RpcTest: read to Ashmem result is : " + readResult); - ``` + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen.md b/zh-cn/application-dev/reference/apis/js-apis-screen.md index 83ddfec6366a0e755b97eff377b99b62ebdd3276..52ba0e627bee0c69ed7503c55db4b4b9b569a296 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen.md @@ -28,6 +28,14 @@ getAllScreens(callback: AsyncCallback<Array<Screen>>): void | -------- | --------------------------------------------------- | ---- | -------------------------------------- | | callback | AsyncCallback<Array<[Screen](#screen)>> | 是 | 回调函数。返回当前获取的屏幕对象集合。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -56,6 +64,14 @@ getAllScreens(): Promise<Array<Screen>> | --------------------------------------------- | ----------------------------------------- | | Promise<Array<[Screen](#screen)>> | Promise对象。返回当前获取的屏幕对象集合。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -87,10 +103,14 @@ on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number& **示例:** ```js -var callback = (data) => { - console.info('Register the callback for screen changes. Data: ' + JSON.stringify(data)) +try { + let callback = (data) => { + console.info('Register the callback for screen changes. Data: ' + JSON.stringify(data)) + }; + screen.on('connect', callback); +} catch (exception) { + console.error('Failed to register the callback for screen changes. Code: ' + JSON.stringify(exception)); }; -screen.on("connect", callback); ``` ## screen.off('connect' | 'disconnect' | 'change') @@ -111,10 +131,14 @@ off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<numbe **示例:** ```js -var callback = (data) => { - console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data)) +try { + let callback = (data) => { + console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data)) + }; + screen.off('connect', callback); +} catch (exception) { + console.error('Failed to register the callback for screen changes. Code: ' + JSON.stringify(exception)); }; -screen.off("connect", callback); ``` ## screen.makeExpand @@ -132,18 +156,30 @@ makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number& | options | Array<[ExpandOption](#expandoption)> | 是 | 设置扩展屏幕的参数集合。 | | callback | Callback<number> | 是 | 回调函数。返回扩展屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var groupId = null; -screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => { - if (err.code) { - console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err)); - return; - } - groupId = data; - console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data)); -}); +try { + let groupId = null; + screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => { + if (err.code) { + console.error('Failed to make screens as expand-screen. Code:' + JSON.stringify(err)); + return; + } + groupId = data; + console.info('Succeeded in making screens as expand-screen. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to make screens as expand-screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.makeExpand @@ -166,14 +202,26 @@ makeExpand(options:Array<ExpandOption>): Promise<number> | --------------------- | ----------------------------------- | | Promise<number> | Promise对象。返回扩展屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => { - console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err)); -}); +try { + screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => { + console.info('Succeeded in making screens as expand-screen. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to make screens as expand-screen. Code:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to make screens as expand-screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.makeMirror @@ -192,18 +240,30 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncC | mirrorScreen | Array<number> | 是 | 镜像屏幕id集合。 | | callback | AsyncCallback<number> | 是 | 回调函数。返回镜像屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var mainScreenId = 0; -var mirrorScreenIds = [1, 2, 3]; -screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => { - if (err.code) { - console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data)); -}); +let mainScreenId = 0; +let mirrorScreenIds = [1, 2, 3]; +try { + screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => { + if (err.code) { + console.error('Failed to make screens as mirror-screen. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in making screens as mirror-screen. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to make screens as mirror-screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.makeMirror @@ -227,16 +287,28 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<numb | --------------------- | ----------------------------------- | | Promise<number> | Promise对象。返回镜像屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var mainScreenId = 0; -var mirrorScreenIds = [1, 2, 3]; -screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => { - console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err)); -}); +let mainScreenId = 0; +let mirrorScreenIds = [1, 2, 3]; +try { + screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => { + console.info('Succeeded in making screens as mirror-screen. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to make screens as mirror-screen. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to make screens as mirror-screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.createVirtualScreen @@ -256,24 +328,36 @@ createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Scre | options | [VirtualScreenOption](#virtualscreenoption) | 是 | 用于创建虚拟屏幕的参数。 | | callback | AsyncCallback<[Screen](#screen)> | 是 | 回调函数,返回创建的虚拟屏幕对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var screenClass = null; -screen.createVirtualScreen({ - name: 'screen01', - width: 1080, - height: 2340, - density: 2, - surfaceId: '' -}, (err, data) => { - if (err.code) { - console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err)); - return; - } - screenClass = data; - console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data)); -}); +let screenClass = null; +try { + screen.createVirtualScreen({ + name: 'screen01', + width: 1080, + height: 2340, + density: 2, + surfaceId: '' + }, (err, data) => { + if (err.code) { + console.error('Failed to create virtual screen. Code: ' + JSON.stringify(err)); + return; + } + screenClass = data; + console.info('Succeeded in creating virtual screen. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to create virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.createVirtualScreen @@ -298,22 +382,34 @@ createVirtualScreen(options:VirtualScreenOption): Promise<Screen> | -------------------------------- | ------------------------------------- | | Promise<[Screen](#screen)> | Promise对象。返回创建的虚拟屏幕对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var screenClass = null; -screen.createVirtualScreen({ - name: 'screen01', - width: 1080, - height: 2340, - density: 2, - surfaceId: '' -}).then((data) => { - screenClass = data; - console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err)); -}); +let screenClass = null; +try { + screen.createVirtualScreen({ + name: 'screen01', + width: 1080, + height: 2340, + density: 2, + surfaceId: '' + }).then((data) => { + screenClass = data; + console.info('Succeeded in creating virtual screen. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to create virtual screen. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to create virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.destroyVirtualScreen @@ -331,17 +427,29 @@ destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void | screenId | number | 是 | 屏幕的id。 | | callback | AsyncCallback<void> | 是 | 回调函数。当销毁虚拟屏幕成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 1400002 | This operation is not access. | + **示例:** ```js -var screenId = 1; -screen.destroyVirtualScreen(screenId, (err,data) => { - if (err.code) { - console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying virtual screen.'); -}); +let screenId = 1; +try { + screen.destroyVirtualScreen(screenId, (err,data) => { + if (err.code) { + console.error('Failed to destroy virtual screen. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying virtual screen.'); + }); +} catch (exception) { + console.error('Failed to destroy virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.destroyVirtualScreen @@ -364,15 +472,27 @@ destroyVirtualScreen(screenId:number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 1400002 | This operation is not access. | + **示例:** ```js -var screenId = 1; -screen.destroyVirtualScreen(screenId).then((data) => { - console.info('Succeeded in destroying virtual screen.'); -}).catch((err) => { - console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err)); -}); +let screenId = 1; +try { + screen.destroyVirtualScreen(screenId).then((data) => { + console.info('Succeeded in destroying virtual screen.'); + }).catch((err) => { + console.error('Failed to destroy virtual screen. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to destroy virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.setVirtualScreenSurface @@ -393,18 +513,30 @@ setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallb | surfaceId | string | 是 | surface的id。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置虚拟屏幕surface成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var screenId = 1; -var surfaceId = '2048'; -screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => { - if (err.code) { - console.error('Failed to Set surface for the virtual screen.Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting surface for the virtual screen.'); -}); +let screenId = 1; +let surfaceId = '2048'; +try { + screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => { + if (err.code) { + console.error('Failed to Set surface for the virtual screen. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting surface for the virtual screen.'); + }); +} catch (exception) { + console.error('Failed to Set surface for the virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.setVirtualScreenSurface @@ -430,16 +562,28 @@ setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js -var screenId = 1; -var surfaceId = '2048'; -screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => { - console.info('Succeeded in setting surface for the virtual screen.'); -}).catch((err) => { - console.error('Failed to Set surface for the virtual screen.Cause:' + JSON.stringify(err)); -}); +let screenId = 1; +let surfaceId = '2048'; +try { + screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => { + console.info('Succeeded in setting surface for the virtual screen.'); + }).catch((err) => { + console.error('Failed to Set surface for the virtual screen. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to Set surface for the virtual screen. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.isScreenRotationLocked @@ -515,12 +659,16 @@ setScreenRotationLocked(isLocked: boolean): Promise<void> **示例:** ```js -var isLocked = false; -screen.setScreenRotationLocked(isLocked).then((data) => { - console.info('Succeeded in setting whether to lock screen rotation'); -}).catch((err) => { - console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err)); -}); +let isLocked = false; +try { + screen.setScreenRotationLocked(isLocked).then((data) => { + console.info('Succeeded in setting whether to lock screen rotation'); + }).catch((err) => { + console.error('Failed to set whether to lock screen rotation. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set whether to lock screen rotation. Code: ' + JSON.stringify(exception)); +}; ``` ## screen.setScreenRotationLocked @@ -541,14 +689,18 @@ setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback<void>): **示例:** ```js -var isLocked = false; -screen.setScreenRotationLocked(isLocked, (err, data) => { - if (err.code) { - console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting whether to lock screen rotation.'); -}); +let isLocked = false; +try { + screen.setScreenRotationLocked(isLocked, (err, data) => { + if (err.code) { + console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting whether to lock screen rotation.'); + }); +} catch (exception) { + console.error('Failed to set whether to lock screen rotation. Code: ' + JSON.stringify(exception)); +}; ``` ## ExpandOption @@ -606,16 +758,28 @@ setOrientation(orientation: Orientation, callback: AsyncCallback<void>): v | orientation | [Orientation](#orientation) | 是 | 屏幕方向。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕方向成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => { - if (err.code) { - console.error('Failed to setOrientation VERTICAL. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting Orientation VERTICAL. data: ' + JSON.stringify(data)); -}) +try { + screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => { + if (err.code) { + console.error('Failed to set Orientation VERTICAL. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting Orientation VERTICAL. data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set Orientation VERTICAL. Code: ' + JSON.stringify(exception)); +}; ``` ### setOrientation @@ -636,15 +800,27 @@ setOrientation(orientation: Orientation): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -let promise = screenClass.setOrientation(screen.Orientation.VERTICAL); -promise.then((data) => { - console.info('Succeeded in setting Orientation VERTICAL. Data: ' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to set Orientation VERTICAL. Cause: ' + JSON.stringify(err)); -}) +try { + let promise = screenClass.setOrientation(screen.Orientation.VERTICAL); + promise.then((data) => { + console.info('Succeeded in setting Orientation VERTICAL. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to set Orientation VERTICAL. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set Orientation VERTICAL. Code: ' + JSON.stringify(exception)); +}; ``` ### setScreenActiveMode @@ -660,17 +836,29 @@ setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): voi | modeIndex | number | 是 | 模式索引。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕当前显示模式成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -var modeIndex = 0; -screenClass.setScreenActiveMode(modeIndex, (err, data) => { - if (err.code) { - console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting ScreenActiveMode 0. data: ' + JSON.stringify(data)); -}) +let modeIndex = 0; +try { + screenClass.setScreenActiveMode(modeIndex, (err, data) => { + if (err.code) { + console.error('Failed to set ScreenActiveMode 0. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting ScreenActiveMode 0. data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set ScreenActiveMode 0. Code: ' + JSON.stringify(exception)); +}; ``` ### setScreenActiveMode @@ -691,16 +879,28 @@ setScreenActiveMode(modeIndex: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -var modeIndex = 0; -let promise = screenClass.setScreenActiveMode(modeIndex); -promise.then((data) => { - console.info('Succeeded in setting ScreenActiveMode 0. Data: ' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err)); -}) +let modeIndex = 0; +try { + let promise = screenClass.setScreenActiveMode(modeIndex); + promise.then((data) => { + console.info('Succeeded in setting ScreenActiveMode 0. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to set ScreenActiveMode 0. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set ScreenActiveMode 0. Code: ' + JSON.stringify(exception)); +}; ``` ### setDensityDpi @@ -716,17 +916,29 @@ setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void; | densityDpi | number | 是 | 像素密度。支持的输入范围为80-640。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕的像素密度成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -var densityDpi = 320; -screenClass.setDensityDpi(densityDpi, (err, data) => { - if (err.code) { - console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeed in setting DensityDpi 320. data: ' + JSON.stringify(data)); -}) +let densityDpi = 320; +try { + screenClass.setDensityDpi(densityDpi, (err, data) => { + if (err.code) { + console.error('Failed to set DensityDpi 320. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeed in setting DensityDpi 320. data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set DensityDpi 320. Code: ' + JSON.stringify(exception)); +}; ``` ### setDensityDpi @@ -747,16 +959,28 @@ setDensityDpi(densityDpi: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js -var densityDpi = 320; -var promise = screenClass.setDensityDpi(densityDpi); -promise.then((data) => { - console.info('Succeeded in setting DensityDpi 320. Data: ' + JSON.stringify(data)); -}).catch((err) => { - console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err)); -}) +let densityDpi = 320; +try { + let promise = screenClass.setDensityDpi(densityDpi); + promise.then((data) => { + console.info('Succeeded in setting DensityDpi 320. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to set DensityDpi 320. Code: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set DensityDpi 320. Code: ' + JSON.stringify(exception)); +}; ``` ## Orientation diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index 903b57b281a2f7e1d8ab54da0a29fd680162feea..86d42135ec5e3a9d9926cb753d4f80f57d12e24b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -73,7 +73,7 @@ save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): **示例:** ```js - var screenshotOptions = { + let screenshotOptions = { "screenRect": { "left": 200, "top": 100, @@ -85,14 +85,18 @@ save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): "rotation": 0, "displayId": 0 }; - screenshot.save(screenshotOptions, (err, pixelMap) => { - if (err) { - console.log('Failed to save screenshot: ' + JSON.stringify(err)); - return; - } - console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 - }); + try { + screenshot.save(screenshotOptions, (err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot. Code: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 + }); + } catch (exception) { + console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception)); + }; ``` ## screenshot.save @@ -114,14 +118,18 @@ save(callback: AsyncCallback<image.PixelMap>): void **示例:** ```js - screenshot.save((err, pixelMap) => { - if (err) { - console.log('Failed to save screenshot: ' + JSON.stringify(err)); - return; - } - console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 - }); + try { + screenshot.save((err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot. Code: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 + }); + } catch (exception) { + console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception)); + }; ``` ## screenshot.save @@ -149,7 +157,7 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> **示例:** ```js - var screenshotOptions = { + let screenshotOptions = { "screenRect": { "left": 200, "top": 100, @@ -161,11 +169,15 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> "rotation": 0, "displayId": 0 }; - let promise = screenshot.save(screenshotOptions); - promise.then((pixelMap) => { - console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 - }).catch((err) => { - console.log('Failed to save screenshot: ' + JSON.stringify(err)); - }); + try { + let promise = screenshot.save(screenshotOptions); + promise.then((pixelMap) => { + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 + }).catch((err) => { + console.log('Failed to save screenshot. Code: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception)); + }; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index d03122b4a2d56f22ff57f9e5de0f13e99327cff5..90c18d897092a30423a010bb41096440571f9964 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -41,6 +41,14 @@ on(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse> | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -73,6 +81,14 @@ on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<Acceleromete | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -106,6 +122,14 @@ on(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>, option | callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -134,6 +158,14 @@ on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatureR | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -162,6 +194,14 @@ on(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>, option | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -190,6 +230,14 @@ on(type: SensorId.GRAVITY, callback: Callback<GravityResponse>,options?: O | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -222,6 +270,14 @@ on(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>,options | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 返回注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -255,6 +311,14 @@ on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncalib | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -288,6 +352,14 @@ on(type: SensorId.HALL, callback: Callback<HallResponse>, options?: Option | callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -318,6 +390,14 @@ on(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>,option | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -346,6 +426,14 @@ on(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>,options?: | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -377,6 +465,14 @@ on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAcceleromete | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -407,6 +503,14 @@ on(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse> | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -437,6 +541,14 @@ on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticFie | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -462,6 +574,14 @@ on(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>,opt **系统能力**:SystemCapability.Sensors.Sensor +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -494,6 +614,14 @@ on(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>, option **系统能力**:SystemCapability.Sensors.Sensor +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -533,6 +661,14 @@ on(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectionR | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -561,6 +697,14 @@ on(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>, option | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -590,6 +734,14 @@ on(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorResponse& | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -622,6 +774,14 @@ on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionRes | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -651,6 +811,14 @@ on(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse> | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -682,6 +850,14 @@ once(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse&g | type | [SensorId](#sensorid9) | 是 | 加速度传感器类型为ACCELEROMETER。 | | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -714,6 +890,14 @@ once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<Accelerome | type | [SensorId](#sensorid9) | 是 | 未校准加速度传感器类型为ACCELEROMETER_UNCALIBRATED。 | | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -747,6 +931,14 @@ once(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>): voi | type | [SensorId](#sensorid9) | 是 | 环境光传感器类型为AMBIENT_LIGHT。 | | callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -775,6 +967,14 @@ once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatur | type | [SensorId](#sensorid9) | 是 | 环境温度传感器类型为AMBIENT_TEMPERATURE。 | | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -803,6 +1003,14 @@ once(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>): voi | type | [SensorId](#sensorid9) | 是 | 气压计传感器类型为BAROMETER。 | | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -831,6 +1039,14 @@ once(type: SensorId.GRAVITY, callback: Callback<GravityResponse>): void | type | [SensorId](#sensorid9) | 是 | 重力传感器类型为GRAVITY。 | | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -863,6 +1079,14 @@ once(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>): voi | type | [SensorId](#sensorid9) | 是 | 陀螺仪传感器类型为GYROSCOPE。 | | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -895,6 +1119,14 @@ once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncal | type | [SensorId](#sensorid9) | 是 | 未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。 | | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -928,6 +1160,14 @@ once(type: SensorId.HALL, callback: Callback<HallResponse>): void | type | [SensorId](#sensorid9) | 是 | 霍尔传感器类型为HALL。 | | callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -958,6 +1198,14 @@ once(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>): vo | type | [SensorId](#sensorid9) | 是 | 心率传感器类型为HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -986,6 +1234,14 @@ once(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>): void | type | [SensorId](#sensorid9) | 是 | 湿度传感器类型为HUMIDITY。 | | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1016,6 +1272,14 @@ once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAccelerome | type | [SensorId](#sensorid9) | 是 | 线性加速度传感器类型为LINEAR_ACCELEROMETER。 | | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1046,6 +1310,14 @@ once(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse& | type | [SensorId](#sensorid9) | 是 | 磁场传感器类型为MAGNETIC_FIELD。 | | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1076,6 +1348,14 @@ once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticF | type | [SensorId](#sensorid9) | 是 | 未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。 | | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1109,6 +1389,14 @@ once(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>): | type | [SensorId](#sensorid9) | 是 | 方向传感器类型为ORIENTATION。 | | callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1141,6 +1429,14 @@ once(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>): voi | type | [SensorId](#sensorid9) | 是 | 计步传感器类型为PEDOMETER。 | | callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1171,6 +1467,14 @@ once(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectio | type | [SensorId](#sensorid9) | 是 | 计步检测传感器类型为PEDOMETER_DETECTION。 | | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1199,6 +1503,14 @@ once(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>): voi | type | [SensorId](#sensorid9) | 是 | 接近光传感器类型为PROXIMITY。 | | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1227,6 +1539,14 @@ once(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorRespons | type | [SensorId](#sensorid9) | 是 | 旋转矢量传感器类型为ROTATION_VECTOR。 | | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1258,6 +1578,14 @@ once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionR | type | [SensorId](#sensorid9) | 是 | 有效运动传感器类型为SIGNIFICANT_MOTION。 | | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1286,6 +1614,14 @@ once(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse& | type | [SensorId](#sensorid9) | 是 | 佩戴检测传感器类型为WEAR_DETECTION。 | | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1948,6 +2284,14 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callbac | timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | | callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getGeomagneticInfo错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -1983,6 +2327,14 @@ getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promis | ---------------------------------------------------------- | -------------- | | Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getGeomagneticInfo错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2016,6 +2368,14 @@ getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncC | currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | | callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getDeviceAltitude错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2049,6 +2409,14 @@ getDeviceAltitude(seaPressure: number, currentPressure: number): Promise<numb | --------------------- | ------------------------------------ | | Promise<number> | 返回设备所在的海拔高度(单位:米)。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getDeviceAltitude错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2079,6 +2447,14 @@ getInclination(inclinationMatrix: Array<number>, callback: AsyncCallback&l | inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | | callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getInclination错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2111,6 +2487,14 @@ try { | --------------------- | ---------------------------- | | Promise<number> | 返回地磁倾斜角,单位为弧度。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getInclination错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2143,6 +2527,14 @@ try { | preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | | callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getAngleVariation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2178,6 +2570,14 @@ getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: | ---------------------------------- | --------------------------------- | | Promise<Array<number>> | 返回z、x、y轴方向的旋转角度变化。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getAngleVariation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2210,6 +2610,14 @@ getRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback | ---------------------------------- | ------------ | | Promise<Array<number>> | 返回四元数。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getQuaternion错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2412,6 +2860,14 @@ getOrientation(rotationMatrix: Array<number>, callback: AsyncCallback | 是 | 返回传感器列表。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSensorList错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2572,6 +3060,14 @@ try { | ------- | ---------------------------------------- | ---- | ---------------- | | promise | Promise | 是 | 返回传感器列表。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSensorList错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2604,6 +3100,14 @@ getSingleSensor(type: SensorId, callback: AsyncCallback<Sensor>): void | type | [SensorId](#sensorid9) | 是 | 传感器类型。 | | callback | AsyncCallback<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSingleSensor错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js @@ -2636,6 +3140,14 @@ try { | ------- | --------------------------------- | ---- | ---------------- | | promise | Promise<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSingleSensor错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-device.md b/zh-cn/application-dev/reference/apis/js-apis-system-device.md index dec8bf99b4096f9680bdc3027d47dc035d7c4e1c..041de24dcec98a54249d43b79335721e7f97d315 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-device.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-device.md @@ -1,19 +1,18 @@ # 设备信息 +本模块提供当前设备的信息。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.deviceInfo`](js-apis-device-info.md)进行设备信息查询。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 - ``` import device from '@system.device'; ``` - ## device.getInfo getInfo(Object): void @@ -23,7 +22,7 @@ getInfo(Object): void > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 在首页的onShow生命周期之前不建议调用device.getInfo接口。 -**系统能力:** SystemCapability.Startup.SysInfo +**系统能力:** SystemCapability.Startup.SystemInfo **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md index 997ba9ae673583b42f19483365948131c457c12e..6f9afe3b538b7d1e8406ba1bbac773e8ff77093f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @@ -3,20 +3,19 @@ 系统参数(SystemParameter)是为各系统服务提供的简单易用的键值对访问接口,各个系统服务可以定义系统参数来描述该服务的状态信息,或者通过系统参数来改变系统服务的行为。其基本操作原语为get和set,通过get可以查询系统参数的值,通过set可以修改系统参数的值。 详细的系统参数设计原理及定义可参考 [系统参数](../../../device-dev/subsystems/subsys-boot-init-sysparam.md)。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 由于系统参数都是各个系统服务的内部信息和控制参数,每个系统参数都有各自不同的DAC和MAC访问控制权限,三方应用不能使用此类接口。 - ## 导入模块 ```ts -import parameter from '@ohos.systemparameter' +import systemparameter from '@ohos.systemparameter' ``` - -## parameter.getSync +## systemparameter.getSync getSync(key: string, def?: string): string @@ -41,15 +40,14 @@ getSync(key: string, def?: string): string ```ts try { - var info = parameter.getSync("const.ohos.apiversion"); + var info = systemparameter.getSync("const.ohos.apiversion"); console.log(JSON.stringify(info)); }catch(e){ console.log("getSync unexpected error: " + e); } ``` - -## parameter.get +## systemparameter.get get(key: string, callback: AsyncCallback<string>): void @@ -68,7 +66,7 @@ get(key: string, callback: AsyncCallback<string>): void ```ts try { - parameter.get("const.ohos.apiversion", function (err, data) { + systemparameter.get("const.ohos.apiversion", function (err, data) { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -79,8 +77,7 @@ try { } ``` - -## parameter.get +## systemparameter.get get(key: string, def: string, callback: AsyncCallback<string>): void @@ -100,7 +97,7 @@ get(key: string, def: string, callback: AsyncCallback<string>): void ```ts try { - parameter.get("const.ohos.apiversion", "default", function (err, data) { + systemparameter.get("const.ohos.apiversion", "default", function (err, data) { if (err == undefined) { console.log("get test.parameter.key value success:" + data) } else { @@ -112,8 +109,7 @@ try { } ``` - -## parameter.get +## systemparameter.get get(key: string, def?: string): Promise<string> @@ -138,7 +134,7 @@ get(key: string, def?: string): Promise<string> ```ts try { - var p = parameter.get("const.ohos.apiversion"); + var p = systemparameter.get("const.ohos.apiversion"); p.then(function (value) { console.log("get test.parameter.key success: " + value); }).catch(function (err) { @@ -149,8 +145,7 @@ try { } ``` - -## parameter.setSync +## systemparameter.setSync setSync(key: string, value: string): void @@ -165,18 +160,22 @@ setSync(key: string, value: string): void | key | string | 是 | 待设置的系统参数Key。 | | value | string | 是 | 待设置的系统参数值。 | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 此接口只能用于系统应用的参数设置。 +> - 所授权的系统应用需要配置对应selinux和dac规则,具体配置方法请参照系统参数指导文档:[系统参数](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md)。 + + **示例:** ```ts try { - parameter.setSync("test.parameter.key", "default"); + systemparameter.setSync("test.parameter.key", "default"); }catch(e){ console.log("set unexpected error: " + e); } ``` - -## parameter.set +## systemparameter.set set(key: string, value: string, callback: AsyncCallback<void>): void @@ -192,11 +191,15 @@ set(key: string, value: string, callback: AsyncCallback<void>): void | value | string | 是 | 待设置的系统参数值。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 此接口只能用于系统应用的参数设置。 +> - 所授权的系统应用需要配置对应selinux和dac规则,具体配置方法请参照系统参数指导文档:[系统参数](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md)。 + **示例:** ```ts try { - parameter.set("test.parameter.key", "testValue", function (err, data) { + systemparameter.set("test.parameter.key", "testValue", function (err, data) { if (err == undefined) { console.log("set test.parameter.key value success :" + data) } else { @@ -207,8 +210,7 @@ try { } ``` - -## parameter.set +## systemparameter.set set(key: string, value: string): Promise<void> @@ -229,11 +231,15 @@ set(key: string, value: string): Promise<void> | -------- | -------- | | Promise<void> | Promise示例,用于异步获取结果。 | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 此接口只能用于系统应用的参数设置。 +> - 所授权的系统应用需要配置对应selinux和dac规则,具体配置方法请参照系统参数指导文档:[系统参数](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md) + **示例:** ```ts try { - var p = para.set("test.parameter.key", "testValue"); + var p = systemparameter.set("test.parameter.key", "testValue"); p.then(function (value) { console.log("set test.parameter.key success: " + value); }).catch(function (err) { @@ -242,4 +248,4 @@ try { }catch(e){ console.log("set unexpected error: " + e); } -``` +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-uitest.md b/zh-cn/application-dev/reference/apis/js-apis-uitest.md index 0e824de04cfa4dd1de206838d519ace19d934ce2..1e6f73189bdcdcd1486b869cd1788513e5a9cddc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uitest.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uitest.md @@ -4,10 +4,13 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要 该模块提供以下功能: -- [By](#by):提供控件特征描述能力,用于控件筛选匹配查找。 -- [UiComponent](#uicomponent):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。 -- [UiDriver](#uidriver):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能能力。 -- [UiWINDOW9+](#uiwindow9):入口类,提供窗口属性获取,窗口拖动、调整窗口大小等能能力。 +- [On9+](#on9):提供控件特征描述能力,用于控件筛选匹配查找。 +- [Component9+](#component9):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。 +- [Driver9+](#driver9):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能能力。 +- [UiWindow9+](#uiwindow9):入口类,提供窗口属性获取,窗口拖动、调整窗口大小等能能力。 +- [By](#by):提供控件特征描述能力,用于控件筛选匹配查找。从API version9开始不再维护,建议使用[[On9+](#on9)](#driver9)。 +- [UiComponent](#uicomponent):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。从API version9开始不再维护,建议使用[Component9+](#component9)。 +- [UiDriver](#uidriver):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能能力。从API version9开始不再维护,建议使用[Driver9+](#driver9)。 >**说明:** > @@ -16,79 +19,52 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要 ## 导入模块 -``` -import {UiDriver, BY, MatchPattern, ResizeDirection, WindowMode, DisplayRotation, PointerMatrix} from '@ohos.uitest' -``` - -## By - -UiTest框架通过By类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。
-By提供的API能力具有以下几个特点:
1、支持单属性匹配和多属性组合匹配,例如同时指定目标控件text和id。
2、控件属性支持多种匹配模式。
3、支持控件绝对定位,相对定位,可通过[By.isBefore](#isbefore)和[By.isAfter](#isafter)等API限定邻近控件特征进行辅助定位。
By类提供的所有API均为同步接口,建议使用者通过静态构造器BY来链式创建By对象。 - ```js -BY.text('123').type('button') +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest' ``` -### text - -text(txt: string, pattern?: MatchPattern): By - -指定目标控件文本属性,支持多种匹配模式,返回By对象自身。 - -**系统能力**:SystemCapability.Test.UiTest - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------------ | ---- | --------------------------------------------------- | -| txt | string | 是 | 指定控件文本,用于匹配目标控件文本。 | -| pattern | MatchPattern | 否 | 指定的文本匹配模式,默认为[EQUALS](#matchpattern)。 | - -**返回值:** - -| 类型 | 说明 | -| --------- | ---------------------------------- | -| [By](#by) | 返回指定目标控件文本属性的By对象。 | +## On9+ -**示例:** +UiTest框架在API9中,通过On类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。
+On提供的API能力具有以下几个特点:
1、支持单属性匹配和多属性组合匹配,例如同时指定目标控件text和id。
2、控件属性支持多种匹配模式。
3、支持控件绝对定位,相对定位,可通过[ON.isBefore](#isbefore)和[ON.isAfter](#isafter)等API限定邻近控件特征进行辅助定位。
On类提供的所有API均为同步接口,建议使用者通过静态构造器ON来链式创建On对象。 ```js -let by = BY.text('123') //使用静态构造器BY创建by对象,指定目标控件的text属性。 +ON.text('123').type('button') ``` +### text9+ -### key - -key(key: string): By +text(txt: string, pattern?: MatchPattern): On -指定目标控件key值属性,返回By对象自身。 +指定目标控件文本属性,支持多种匹配模式,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ----------------- | -| key | string | 是 | 指定控件的Key值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------- | ---- | --------------------------------------------------- | +| txt | string | 是 | 指定控件文本,用于匹配目标控件文本。 | +| pattern | [MatchPattern](#matchpattern) | 否 | 指定的文本匹配模式,默认为[EQUALS](#matchpattern)。 | **返回值:** -| 类型 | 说明 | -| --------- | ----------------------------------- | -| [By](#by) | 返回指定目标控件key值属性的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------- | +| [On](#on9) | 返回指定目标控件文本属性的On对象。 | **示例:** ```js -let by = BY.key('123') //使用静态构造器BY创建by对象,指定目标控件的key值属性。 +let on = ON.text('123') //使用静态构造器ON创建On对象,指定目标控件的text属性。 ``` -### id +### id9+ -id(id: number): By +id(id: string): On -指定目标控件id属性,返回By对象自身。 +指定目标控件id属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest @@ -96,26 +72,26 @@ id(id: number): By | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------- | -| id | number | 是 | 指定控件的id值。 | +| id | string | 是 | 指定控件的id值。 | **返回值:** -| 类型 | 说明 | -| --------- | -------------------------------- | -| [By](#by) | 返回指定目标控件id属性的By对象。 | +| 类型 | 说明 | +| ---------- | -------------------------------- | +| [On](#on9) | 返回指定目标控件id属性的On对象。 | **示例:** ```js -let by = BY.id(123) //使用静态构造器BY创建by对象,指定目标控件的id属性。 +let on = ON.id(123) //使用静态构造器ON创建On对象,指定目标控件的id属性。 ``` -### type +### type9+ -type(tp: string): By +type(tp: string): On -指定目标控件的控件类型属性,返回By对象自身。 +指定目标控件的控件类型属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest @@ -127,326 +103,311 @@ type(tp: string): By **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------- | -| [By](#by) | 返回指定目标控件的控件类型属性的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------- | +| [On](#on9) | 返回指定目标控件的控件类型属性的On对象。 | **示例:** ```js -let by = BY.type('button') //使用静态构造器BY创建by对象,指定目标控件的控件类型属性。 +let on = ON.type('button') //使用静态构造器ON创建On对象,指定目标控件的控件类型属性。 ``` -### clickable +### clickable9+ -clickable(b?: boolean): By +clickable(b?: boolean): On -指定目标控件的可点击状态属性,返回By对象自身。 +指定目标控件的可点击状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | -------------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | | b | boolean | 否 | 指定控件可点击状态,true:可点击,false:不可点击。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ------------------------------------------ | -| [By](#by) | 返回指定目标控件的可点击状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ------------------------------------------ | +| [On](#on9) | 返回指定目标控件的可点击状态属性的On对象。 | **示例:** ```js -let by = BY.clickable(true) //使用静态构造器BY创建by对象,指定目标控件的可点击状态属性。 +let on = ON.clickable(true) //使用静态构造器ON创建On对象,指定目标控件的可点击状态属性。 ``` ### longClickable9+ -longClickable(b?: boolean): By +longClickable(b?: boolean): On -指定目标控件的可长按点击状态属性,返回By对象自身。 +指定目标控件的可长按点击状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | ------------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | | b | boolean | 否 | 指定控件可长按点击状态,true:可长按点击,false:不可长按点击。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------------- | -| [By](#by) | 返回指定目标控件的可长按点击状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------------- | +| [On](#on9) | 返回指定目标控件的可长按点击状态属性的On对象。 | **示例:** ```js -let by = BY.longClickable(true) //使用静态构造器BY创建by对象,指定目标控件的可长按点击状态属性。 +let on = ON.longClickable(true) //使用静态构造器ON创建On对象,指定目标控件的可长按点击状态属性。 ``` -### scrollable +### scrollable9+ -scrollable(b?: boolean): By +scrollable(b?: boolean): On -指定目标控件的可滑动状态属性,返回By对象自身。 +指定目标控件的可滑动状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | ---------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------------- | | b | boolean | 否 | 控件可滑动状态,true:可滑动,false:不可滑动。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ------------------------------------------ | -| [By](#by) | 返回指定目标控件的可滑动状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ------------------------------------------ | +| [On](#on9) | 返回指定目标控件的可滑动状态属性的On对象。 | **示例:** ```js -let by = BY.scrollable(true) //使用静态构造器BY创建by对象,指定目标控件的可滑动状态属性。 +let on = ON.scrollable(true) //使用静态构造器ON创建On对象,指定目标控件的可滑动状态属性。 ``` -### enabled +### enabled9+ -enabled(b?: boolean): By +enabled(b?: boolean): On -指定目标控件的使能状态属性,返回By对象自身。 +指定目标控件的使能状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | ------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | --------------------------------------------------------- | | b | boolean | 否 | 指定控件使能状态,true:使能,false:未使能。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------- | -| [By](#by) | 返回指定目标控件的使能状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------- | +| [On](#on9) | 返回指定目标控件的使能状态属性的On对象。 | **示例:** ```js -let by = BY.enabled(true) //使用静态构造器BY创建by对象,指定目标控件的使能状态属性。 +let on = ON.enabled(true) //使用静态构造器ON创建On对象,指定目标控件的使能状态属性。 ``` -### focused +### focused9+ -focused(b?: boolean): By +focused(b?: boolean): On -指定目标控件的获焦状态属性,返回By对象自身。 +指定目标控件的获焦状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | -------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------- | | b | boolean | 否 | 控件获焦状态,true:获焦,false:未获焦。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------- | -| [By](#by) | 返回指定目标控件的获焦状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------- | +| [On](#on9) | 返回指定目标控件的获焦状态属性的On对象。 | **示例:** ```js -let by = BY.focused(true) //使用静态构造器BY创建by对象,指定目标控件的获焦状态属性。 +let on = ON.focused(true) //使用静态构造器ON创建On对象,指定目标控件的获焦状态属性。 ``` -### selected +### selected9+ -selected(b?: boolean): By +selected(b?: boolean): On -指定目标控件的被选中状态属性,返回By对象自身。 +指定目标控件的被选中状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | -------------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | | b | boolean | 否 | 指定控件被选中状态,true:被选中,false:未被选中。默认为true。 | **返回值:** -| 类型 | 说明 | -| --------- | ------------------------------------------ | -| [By](#by) | 返回指定目标控件的被选中状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ------------------------------------------ | +| [On](#on9) | 返回指定目标控件的被选中状态属性的On对象。 | **示例:** ```js -let by = BY.selected(true) //使用静态构造器BY创建by对象,指定目标控件的被选中状态属性。 +let on = ON.selected(true) //使用静态构造器ON创建On对象,指定目标控件的被选中状态属性。 ``` ### checked9+ -checked(b?: boolean): By +checked(b?: boolean): On -指定目标控件的被勾选状态属性,返回By对象自身。 +指定目标控件的被勾选状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | --------------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | | b | boolean | 否 | 指定控件被勾选状态,true:被勾选,false:未被勾选。默认为false。 | **返回值:** -| 类型 | 说明 | -| --------- | ------------------------------------------ | -| [By](#by) | 返回指定目标控件的被勾选状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | ------------------------------------------ | +| [On](#on9) | 返回指定目标控件的被勾选状态属性的On对象。 | **示例:** ```js -let by = BY.checked(true) //使用静态构造器BY创建by对象,指定目标控件的被勾选状态属性 +let on = ON.checked(true) //使用静态构造器ON创建On对象,指定目标控件的被勾选状态属性 ``` ### checkable9+ -checkable(b?: boolean): By +checkable(b?: boolean): On -指定目标控件能否被勾选状态属性,返回By对象自身。 +指定目标控件能否被勾选状态属性,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---- | ---- | ------------------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | | b | boolean | 否 | 指定控件能否被勾选状态,true:能被勾选,false:不能被勾选。默认为false。 | **返回值:** -| 类型 | 说明 | -| --------- | -------------------------------------------- | -| [By](#by) | 返回指定目标控件能否被勾选状态属性的By对象。 | +| 类型 | 说明 | +| ---------- | -------------------------------------------- | +| [On](#on9) | 返回指定目标控件能否被勾选状态属性的On对象。 | **示例:** ```js -let by = BY.checkable(true) //使用静态构造器BY创建by对象,指定目标控件的能否被勾选状态属性。 +let on = ON.checkable(true) //使用静态构造器ON创建On对象,指定目标控件的能否被勾选状态属性。 ``` -### isBefore +### isBefore9+ -isBefore(by: By): By +isBefore(on: On): On -指定目标控件位于给出的特征属性控件之前,返回By对象自身。 +指定目标控件位于给出的特征属性控件之前,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | ---------------- | -| by | [By](#by) | 是 | 特征控件的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 特征控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------------------- | -| [By](#by) | 返回指定目标控件位于给出的特征属性控件之前的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------------------- | +| [On](#on9) | 返回指定目标控件位于给出的特征属性控件之前的On对象。 | **示例:** ```js -let by = BY.isBefore(BY.text('123')) //使用静态构造器BY创建by对象,指定目标控件位于给出的特征属性控件之前。 +let on = ON.isBefore(ON.text('123')) //使用静态构造器ON创建On对象,指定目标控件位于给出的特征属性控件之前。 ``` -### isAfter +### isAfter9+ -isAfter(by: By): By +isAfter(on: On): On -指定目标控件位于给出的特征属性控件之后,返回By对象自身。 +指定目标控件位于给出的特征属性控件之后,返回On对象自身。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | ---------------- | -| by | [By](#by) | 是 | 特征控件的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 特征控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| --------- | ---------------------------------------------------- | -| [By](#by) | 返回指定目标控件位于给出的特征属性控件之后的By对象。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------------------- | +| [On](#on9) | 返回指定目标控件位于给出的特征属性控件之后的On对象。 | **示例:** ```js -let by = BY.isAfter(BY.text('123')) //使用静态构造器BY创建by对象,指定目标控件位于给出的特征属性控件之后。 +let on = ON.isAfter(ON.text('123')) //使用静态构造器ON创建On对象,指定目标控件位于给出的特征属性控件之后。 ``` -## UiComponent +## Component9+ -UiTest中,UiComponent类代表了UI界面上的一个控件,提供控件属性获取,控件点击,滑动查找,文本注入等API。 +UiTest框架在API9中,Component类代表了UI界面上的一个控件,提供控件属性获取,控件点击,滑动查找,文本注入等API。 该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 -### Point9+ - -坐标点信息。 - -**系统能力**:SystemCapability.Test.UiTest - -| 名称 | 参数类型 | 可读 | 可写 | 描述 | -| ---- | -------- | ---- | ---- | ---------------- | -| X | number | 是 | 否 | 坐标点的横坐标。 | -| Y | number | 是 | 否 | 坐标点的纵坐标。 | +### click9+ -### Rect9+ +click(): Promise\ -控件的边框信息。 +控件对象进行点击操作。 **系统能力**:SystemCapability.Test.UiTest -| 名称 | 参数类型 | 可读 | 可写 | 描述 | -| ------- | -------- | ---- | ---- | ------------------------- | -| leftX | number | 是 | 否 | 控件边框的左上角的X坐标。 | -| topY | number | 是 | 否 | 控件边框的左上角的Y坐标。 | -| rightX | number | 是 | 否 | 控件边框的右下角的X坐标。 | -| bottomY | number | 是 | 否 | 控件边框的右下角的Y坐标。 | - -### UiComponent.click - -click(): Promise\ +**错误码:** -控件对象进行点击操作。 +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -**系统能力**:SystemCapability.Test.UiTest +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) await button.click() } ``` -### doubleClick +### doubleClick9+ doubleClick(): Promise\ @@ -454,17 +415,26 @@ doubleClick(): Promise\ **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) await button.doubleClick() } ``` -### longClick +### longClick9+ longClick(): Promise\ @@ -472,19 +442,28 @@ longClick(): Promise\ **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) await button.longClick() } ``` -### getId +### getId9+ -getId(): Promise\ +getId(): Promise\ 获取控件对象的id值。 @@ -494,43 +473,28 @@ getId(): Promise\ | 类型 | 说明 | | ---------------- | ------------------------------- | -| Promise\ | 以Promise形式返回的控件的id值。 | - -**示例:** - -```js -async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) - let num = await button.getId() -} -``` - -### getKey - -getKey(): Promise\ - -获取控件对象的key值。 +| Promise\ | 以Promise形式返回的控件的id值。 | -**系统能力**:SystemCapability.Test.UiTest +**错误码:** -**返回值:** +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| ---------------- | ------------------------------ | -| Promise\ | 以Promise形式返回控件的key值。 | +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) - let str_key = await button.getKey() + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) + let num = await button.getId() } ``` -### getText +### getText9+ getText(): Promise\ @@ -544,17 +508,26 @@ getText(): Promise\ | ---------------- | --------------------------------- | | Promise\ | 以Promise形式返回控件的文本信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) let text = await button.getText() } ``` -### getType +### getType9+ getType(): Promise\ @@ -568,12 +541,21 @@ getType(): Promise\ | ---------------- | ----------------------------- | | Promise\ | 以Promise形式返回控件的类型。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) let type = await button.getType() } ``` @@ -592,12 +574,21 @@ getBounds(): Promise\ | ------------------------ | ------------------------------------- | | Promise\<[Rect](#rect9)> | 以Promise形式返回控件对象的边框信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) let rect = await button.getBounds() } ``` @@ -616,17 +607,26 @@ getBoundsCenter(): Promise\ | -------------------------- | --------------------------------------- | | Promise\<[Point](#point9)> | 以Promise形式返回控件对象的中心点信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) let point = await button.getBoundsCenter() } ``` -### isClickable +### isClickable9+ isClickable(): Promise\ @@ -636,16 +636,25 @@ isClickable(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象可点击状态,true:可点击,false:不可点击。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) if(await button.isClickable()) { console.info('This button can be Clicked') } @@ -665,16 +674,25 @@ isLongClickable(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象能否长按点击状态,true:可长按点击,false:不可长按点击。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) if(await button.isLongClickable()) { console.info('This button can longClick') } @@ -694,16 +712,25 @@ isChecked(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象被勾选状态,true:被勾选,false:未被勾选。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let checkBox = await driver.findComponent(BY.type('Checkbox')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('Checkbox')) if(await checkBox.isChecked) { console.info('This checkBox is checked') } @@ -723,16 +750,25 @@ isCheckable(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------------- | +| 错误码ID | 错误码信息 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象能否被勾选的属性,true:可被勾选,false:不可被勾选。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 类型 | 说明 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let checkBox = await driver.findComponent(BY.type('Checkbox')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('Checkbox')) if(await checkBox.isCheckable) { console.info('This checkBox is checkable') } @@ -742,7 +778,7 @@ async function demo() { } ``` -### isScrollable +### isScrollable9+ isScrollable(): Promise\ @@ -752,16 +788,25 @@ isScrollable(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象可滑动状态,true:可滑动,false:不可滑动。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let scrollBar = await driver.findComponent(BY.scrollable(true)) + let driver = Driver.create() + let button = await driver.findComponent(ON.scrollable(true)) if(await scrollBar.isScrollable()) { console.info('This scrollBar can be operated') } @@ -772,7 +817,7 @@ async function demo() { ``` -### isEnabled +### isEnabled9+ isEnabled(): Promise\ @@ -782,16 +827,25 @@ isEnabled(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------- | +| 类型 | 说明 | +| ----------------- | ---------------------------------------------------------- | | Promise\ | 以Promise形式返回控件使能状态,true:使能,false:未使能。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) if(await button.isEnabled()) { console.info('This button can be operated') } @@ -802,7 +856,7 @@ async function demo() { ``` -### isFocused +### isFocused9+ isFocused(): Promise\ @@ -812,16 +866,25 @@ isFocused(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回控件对象是否获焦,true:获焦,false:未获焦。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) if(await button.isFocused()) { console.info('This button is focused') } @@ -831,7 +894,7 @@ async function demo() { } ``` -### isSelected +### isSelected9+ isSelected(): Promise\ @@ -841,16 +904,25 @@ isSelected(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | -------------------- | +| 类型 | 说明 | +| ----------------- | ----------------------------------------------------- | | Promise\ | 控件对象被选中的状态,true:被选中,false:未被选中。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) if(await button.isSelected()) { console.info('This button is selected') } @@ -860,7 +932,7 @@ async function demo() { } ``` -### inputText +### inputText9+ inputText(text: string): Promise\ @@ -874,12 +946,21 @@ inputText(text: string): Promise\ | ------ | ------ | ---- | ---------------- | | text | string | 是 | 输入的文本信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let text = await driver.findComponent(BY.text('hello world')) + let driver = Driver.create() + let button = await driver.findComponent(ON.text('hello world')) await text.inputText('123') } ``` @@ -892,19 +973,26 @@ clearText(): Promise\ **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let text = await driver.findComponent(BY.text('hello world')) + let driver = Driver.create() + let button = await driver.findComponent(ON.text('hello world')) await text.clearText() } ``` -### scrollSearch +### scrollSearch9+ -scrollSearch(by: By): Promise\ +scrollSearch(on: ON): Promise\ 在控件上滑动查找目标控件(适用于List等支持滑动的控件)。 @@ -912,23 +1000,32 @@ scrollSearch(by: By): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | -------------------- | -| by | [By](#by) | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ------------------------------------- | -| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的目标控件对象。 | +| 类型 | 说明 | +| ---------------------------------- | ------------------------------------- | +| Promise\<[Component](#component9)> | 以Promise形式返回找到的目标控件对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let scrollBar = await driver.findComponent(BY.type('Scroll')) - let button = await scrollBar.scrollSearch(BY.text('next page')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('Scroll')) + let button = await scrollBar.scrollSearch(ON.text('next page')) } ``` @@ -944,14 +1041,23 @@ scrollToTop(speed?: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | -| speed | number | 否 | 滑动速率,范围:200-3000,不在范围内设为默认值为600,单位:像素点/秒。 | +| speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let scrollBar = await driver.findComponent(BY.type('Scroll')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('Scroll')) await scrollBar.scrollToTop() } ``` @@ -968,21 +1074,30 @@ scrollToBottom(speed?: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | -| speed | number | 否 | 滑动速率,范围:200-3000,不在范围内设为默认值为600,单位:像素点/秒。 | +| speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let scrollBar = await driver.findComponent(BY.type('Scroll')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('Scroll')) await scrollBar.scrollToBottom() } ``` ### dragTo9+ -dragTo(target: UiComponent): Promise\ +dragTo(target: Component): Promise\ 将控件拖拽至目标控件处。 @@ -990,17 +1105,26 @@ dragTo(target: UiComponent): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------------------------- | ---- | ---------- | -| target | [UiComponent](#uicomponent) | 是 | 目标控件。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------ | ---- | ---------- | +| target | [Component](#component9) | 是 | 目标控件。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.type('button')) - let text = await driver.findComponent(BY.text('hello world')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('button')) + let text = await driver.findComponent(ON.text('hello world')) await button.dragTo(text) } ``` @@ -1019,12 +1143,21 @@ pinchOut(scale: number): Promise\ | ------ | ------ | ---- | ---------------- | | scale | number | 是 | 指定放大的比例。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let image = await driver.findComponent(BY.type('image')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('image')) await image.pinchOut(1.5) } ``` @@ -1043,121 +1176,162 @@ pinchIn(scale: number): Promise\ | ------ | ------ | ---- | ---------------- | | scale | number | 是 | 指定缩小的比例。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() - let image = await driver.findComponent(BY.type('image')) + let driver = Driver.create() + let button = await driver.findComponent(ON.type('image')) await image.pinchIn(0.5) } ``` -## UiDriver +## Driver9+ -UiDriver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等API。 -该类提供的方法除UiDriver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await调用。 +UiTest框架在API9中,Driver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等API。 +该类提供的方法除Driver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await调用。 -### create +### create9+ -static create(): UiDriver +static create(): Driver -静态方法,构造一个UiDriver对象,并返回该对象。 +静态方法,构造一个Driver对象,并返回该对象。 **系统能力**:SystemCapability.Test.UiTest **返回值:** -| 类型 | 说明 | -| -------- | ------------------------ | -| UiDriver | 返回构造的UiDriver对象。 | +| 错误码ID | 错误码信息 | +| -------- | ---------------------- | +| Driver | 返回构造的Driver对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 类型 | 说明 | +| -------- | ------------------ | +| 17000001 | Initialize failed. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() } ``` -### delayMs +### delayMs9+ delayMs(duration: number): Promise\ -UiDriver对象在给定的时间内延时。 +Driver对象在给定的时间内延时。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------ | -| duration | number | 是 | 给定的时间。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| duration | number | 是 | 给定的时间,单位:ms。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.delayMs(1000) } ``` -### findComponent +### findComponent9+ -findComponent(by: By): Promise\ +findComponent(on: On): Promise\ -在UiDriver对象中,根据给出的目标控件属性要求查找目标控件。 +在Driver对象中,根据给出的目标控件属性要求查找目标控件。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | -------------------- | -| by | [By](#by) | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| ------------------------------------- | --------------------------------- | -| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 | +| 类型 | 说明 | +| ---------------------------------- | --------------------------------- | +| Promise\<[Component](#component9)> | 以Promise形式返回找到的控件对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.findComponent(BY.text('next page')) + let driver = Driver.create() + let button = await driver.findComponent(ON.text('next page')) } ``` -### findComponents +### findComponents9+ -findComponents(by: By): Promise\> +findComponents(on: On): Promise\> -在UiDriver对象中,根据给出的目标控件属性要求查找出所有匹配控件,以列表保存。 +在Driver对象中,根据给出的目标控件属性要求查找出所有匹配控件,以列表保存。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | -------------------- | -| by | [By](#by) | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| --------------------------------------------- | --------------------------------------- | -| Promise\> | 以Promise形式返回找到的控件对象的列表。 | +| 类型 | 说明 | +| ------------------------------------------ | --------------------------------------- | +| Promise\> | 以Promise形式返回找到的控件对象的列表。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let buttonList = await driver.findComponents(BY.text('next page')) + let driver = Driver.create() + let buttonList = await driver.findComponents(ON.text('next page')) } ``` @@ -1181,90 +1355,123 @@ findWindow(filter: WindowFilter): Promise\ | -------------------------------- | ------------------------------------- | | Promise\<[UiWindow](#uiwindow9)> | 以Promise形式返回找到的目标窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) } ``` ### waitForComponent9+ -waitForComponent(by: By, time: number): Promise\ +waitForComponent(on: On, time: number): Promise\ -在UiDriver对象中,在用户给定的时间内,持续查找满足控件属性要求的目标控件。 +在Driver对象中,在用户给定的时间内,持续查找满足控件属性要求的目标控件。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | -------------------------------- | -| by | [By](#by) | 是 | 目标控件的属性要求。 | -| time | number | 是 | 查找目标控件的持续时间。单位ms。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------------------- | +| On | [On](#on9) | 是 | 目标控件的属性要求。 | +| time | number | 是 | 查找目标控件的持续时间。单位ms。 | **返回值:** -| 类型 | 说明 | -| ------------------------------------- | --------------------------------- | -| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 | +| 类型 | 说明 | +| --------------------------------- | --------------------------------- | +| Promise\<[Component](#component)> | 以Promise形式返回找到的控件对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - let button = await driver.waitForComponent(BY.text('next page'),500) + let driver = Driver.create() + let button = await driver.waitForComponent(ON.text('next page'),500) } ``` -### assertComponentExist +### assertComponentExist9+ -assertComponentExist(by: By): Promise\ +assertComponentExist(on: On): Promise\ -断言API,用于断言当前界面存在满足给出的目标控件属性的控件; 如果控件不存在,该API将抛出JS异常,使当前测试用例失败。 +断言API,用于断言当前界面存在满足给出的目标控件属性的控件。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------- | ---- | -------------------- | -| by | [By](#by) | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000003 | Component existence assertion failed. | **示例:** ```js async function demo() { - let driver = UiDriver.create() - await driver.assertComponentExist(BY.text('next page')) + let driver = Driver.create() + await driver.assertComponentExist(ON.text('next page')) } ``` -### pressBack +### pressBack9+ pressBack(): Promise\ -UiDriver对象进行点击BACK键的操作。 +Driver对象进行点击BACK键的操作。 **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.pressBack() } ``` -### triggerKey +### triggerKey9+ triggerKey(keyCode: number): Promise\ -UiDriver对象采取如下操作:通过key值找到对应键并点击。 +Driver对象采取如下操作:通过key值找到对应键并点击。 **系统能力**:SystemCapability.Test.UiTest @@ -1274,11 +1481,19 @@ UiDriver对象采取如下操作:通过key值找到对应键并点击。 | ------- | ------ | ---- | ------------- | | keyCode | number | 是 | 指定的key值。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.triggerKey(123) } ``` @@ -1287,33 +1502,41 @@ async function demo() { triggerCombineKeys(key0: number, key1: number, key2?: number): Promise\ -UiDriver对象通过给定的key值,找到对应组合键并点击。例如,Key值为(2072, 2019)时,UiDriver对象找到组合键并点击ctrl+c。 +Driver对象通过给定的key值,找到对应组合键并点击。例如,Key值为(2072, 2019)时,Driver对象找到组合键并点击ctrl+c。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------- | -| key0 | number | 是 | 指定的第一个key值。 | -| key1 | number | 是 | 指定的第二个key值。 | -| key2 | number | 否 | 指定的第三个key值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------- | +| key0 | number | 是 | 指定的第一个key值。 | +| key1 | number | 是 | 指定的第二个key值。 | +| key2 | number | 否 | 指定的第三个key值。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.triggerCombineKeys(2072, 2047, 2035) } ``` -### click +### click9+ click(x: number, y: number): Promise\ -UiDriver对象采取如下操作:在目标坐标点单击。 +Driver对象采取如下操作:在目标坐标点单击。 **系统能力**:SystemCapability.Test.UiTest @@ -1324,20 +1547,28 @@ UiDriver对象采取如下操作:在目标坐标点单击。 | x | number | 是 | 以number的形式传入目标点的横坐标信息。 | | y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.click(100,100) } ``` -### doubleClick +### doubleClick9+ doubleClick(x: number, y: number): Promise\ -UiDriver对象采取如下操作:在目标坐标点双击。 +Driver对象采取如下操作:在目标坐标点双击。 **系统能力**:SystemCapability.Test.UiTest @@ -1348,20 +1579,28 @@ UiDriver对象采取如下操作:在目标坐标点双击。 | x | number | 是 | 以number的形式传入目标点的横坐标信息。 | | y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.doubleClick(100,100) } ``` -### longClick +### longClick9+ longClick(x: number, y: number): Promise\ -UiDriver对象采取如下操作:在目标坐标点长按下鼠标左键。 +Driver对象采取如下操作:在目标坐标点长按下。 **系统能力**:SystemCapability.Test.UiTest @@ -1372,11 +1611,19 @@ UiDriver对象采取如下操作:在目标坐标点长按下鼠标左键。 | x | number | 是 | 以number的形式传入目标点的横坐标信息。 | | y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.longClick(100,100) } ``` @@ -1385,7 +1632,7 @@ async function demo() { swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\ -UiDriver对象采取如下操作:从给出的起始坐标点滑向给出的目的坐标点。 +Driver对象采取如下操作:从给出的起始坐标点滑向给出的目的坐标点。 **系统能力**:SystemCapability.Test.UiTest @@ -1397,13 +1644,21 @@ UiDriver对象采取如下操作:从给出的起始坐标点滑向给出的目 | starty | number | 是 | 以number的形式传入起始点的纵坐标信息。 | | endx | number | 是 | 以number的形式传入目的点的横坐标信息。 | | endy | number | 是 | 以number的形式传入目的点的纵坐标信息。 | -| speed | number | 否 | 滑动速率,范围:200-3000,不在范围内设为默认值为600,单位:像素点/秒。 | +| speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.swipe(100,100,200,200,600) } ``` @@ -1412,7 +1667,7 @@ async function demo() { drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\ -UiDriver对象采取如下操作:从给出的起始坐标点拖拽至给出的目的坐标点。 +Driver对象采取如下操作:从给出的起始坐标点拖拽至给出的目的坐标点。 **系统能力**:SystemCapability.Test.UiTest @@ -1424,22 +1679,30 @@ UiDriver对象采取如下操作:从给出的起始坐标点拖拽至给出的 | starty | number | 是 | 以number的形式传入起始点的纵坐标信息。 | | endx | number | 是 | 以number的形式传入目的点的横坐标信息。 | | endy | number | 是 | 以number的形式传入目的点的纵坐标信息。 | -| speed | number | 否 | 滑动速率,范围:200-3000,不在范围内设为默认值为600,单位:像素点/秒。 | +| speed | number | 否 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.drag(100,100,200,200,600) } ``` -### screenCap +### screenCap9+ screenCap(savePath: string): Promise\ -UiDriver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的图片至给出的保存路径中。 +Driver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的图片至给出的保存路径中。 **系统能力**:SystemCapability.Test.UiTest @@ -1451,15 +1714,23 @@ UiDriver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的 **返回值:** -| 类型 | 说明 | -| -------------- | -------------------------------------- | +| 类型 | 说明 | +| ----------------- | -------------------------------------- | | Promise\ | 截图操作是否成功完成。成功完成为true。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.screenCap('/local/tmp/') } ``` @@ -1478,11 +1749,19 @@ setDisplayRotation(rotation: DisplayRotation): Promise\ | -------- | ------------------------------------ | ---- | ---------------- | | rotation | [DisplayRotation](#displayrotation9) | 是 | 设备的显示方向。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.setDisplayRotation(DisplayRotation.ROTATION_180) } ``` @@ -1501,11 +1780,19 @@ getDisplayRotation(): Promise\ | ---------------------------------------------- | --------------------------------------- | | Promise\<[DisplayRotation](#displayrotation9)> | 以Promise的形式返回当前设备的显示方向。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let rotation = await driver.getDisplayRotation() } ``` @@ -1520,15 +1807,23 @@ setDisplayRotationEnabled(enabled: boolean): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ---- | ---- | -------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | ------------------------------------------------------- | | enabled | boolean | 是 | 能否旋转屏幕的标识,true:可以旋转,false:不可以旋转。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.setDisplayRotationEnabled(false) } ``` @@ -1547,11 +1842,19 @@ getDisplaySize(): Promise\ | -------------------------- | --------------------------------------- | | Promise\<[Point](#point9)> | 以Promise的形式返回当前设备的屏幕大小。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let size = await driver.getDisplaySize() } ``` @@ -1570,11 +1873,19 @@ getDisplayDensity(): Promise\ | -------------------------- | ------------------------------------------- | | Promise\<[Point](#point9)> | 以Promise的形式返回当前设备的屏幕的分辨率。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let density = await driver.getDisplayDensity() } ``` @@ -1587,11 +1898,19 @@ wakeUpDisplay(): Promise\ **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.wakeUpDisplay() } ``` @@ -1604,11 +1923,19 @@ pressHome(): Promise\ **系统能力**:SystemCapability.Test.UiTest +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.pressHome() } ``` @@ -1630,15 +1957,23 @@ waitForIdle(idleTime: number, timeout: number): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------------------------------- | +| 类型 | 说明 | +| ----------------- | --------------------------------------------------- | | Promise\ | 以Promise的形式返回当前界面的所有控件是否已经空闲。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let idled = await driver.waitForIdle(4000,5000) } ``` @@ -1656,15 +1991,23 @@ fling(from: Point, to: Point, stepLen: number, speed: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------- | ---- | ------------------------------------------------------------ | | from | [Point](#point9) | 是 | 手指接触屏幕的起始点坐标。 | -| to | [Point](#point9) | 是 | 手指离开屏幕时的坐标点。 | +| to | [Point](#point9) | 是 | 手指离开屏幕时的坐标点。 | | stepLen | number | 是 | 间隔距离,单位:像素点。 | -| speed | number | 是 | 滑动速率,范围:200-3000,不在范围内设为默认值为600,单位:像素点/秒。 | +| speed | number | 是 | 滑动速率,范围:200-15000,不在范围内设为默认值为600,单位:像素点/秒。 | + +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() await driver.fling({X: 500, Y: 480},{X: 450, Y: 480},5,600) } ``` @@ -1682,14 +2025,22 @@ injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise\ | 以Promise的形式返回植入操作是否成功完成。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | + **示例:** ```js @@ -1705,23 +2056,73 @@ async function demo() { } ``` -## UiWindow9+ +## PointerMatrix9+ -UiTest中,UiWindow类代表了UI界面上的一个窗口,提供窗口属性获取,窗口拖动、调整窗口大小等API。 -该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 +表示存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。 + +### create9+ -### WindowFilter9+ +static create(fingers: number, steps: number): PointerMatrix -窗口的标志属性信息。 +静态方法,构造一个PointerMatrix对象,并返回该对象。 **系统能力**:SystemCapability.Test.UiTest -| 名称 | 参数类型 | 必填 | 可读 | 可写 | 描述 | -| ---------- | -------- | ---- | ---- | ---- | -------------------------- | -| bundleName | string | 否 | 是 | 否 | 窗口对应的包名。 | -| title | string | 否 | 是 | 否 | 窗口的标题。 | -| focused | boolean | 否 | 是 | 否 | 窗口是否获焦。 | -| actived | boolean | 否 | 是 | 否 | 窗口是否正与用户进行交互。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------ | +| fingers | number | 是 | 多指操作中注入的手指数,取值范围:[1,10]。 | +| steps | number | 是 | 每根手指操作的步骤数,取值范围:[1,1000]。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ----------------------------- | +| [PointerMatrix](#pointermatrix9) | 返回构造的PointerMatrix对象。 | + +**示例:** + +```js +async function demo() { + let pointerMatrix = PointerMatrix.create(2,3) +} +``` + +### setPoint9+ + +setPoint(finger: number, step: number, point: Point): void + +设置PointerMatrix对象中指定手指和步骤对应动作的坐标点。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------- | ---- | ---------------- | +| finger | number | 是 | 手指的序号。 | +| step | number | 是 | 步骤的序号。 | +| point | [Point](#point9) | 是 | 该行为的坐标点。 | + +**示例:** + +```js +async function demo() { + let pointers = PointerMatrix.create(2,3) + pointers.setPoint(0,0,{X:230,Y:480}) + pointers.setPoint(0,1,{X:250,Y:380}) + pointers.setPoint(0,2,{X:270,Y:280}) + pointers.setPoint(1,0,{X:230,Y:680}) + pointers.setPoint(1,1,{X:240,Y:580}) + pointers.setPoint(1,2,{X:250,Y:480}) +} +``` + +## UiWindow9+ + +UiTest中,UiWindow类代表了UI界面上的一个窗口,提供窗口属性获取,窗口拖动、调整窗口大小等API。 +该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 ### getBundleName9+ @@ -1737,11 +2138,20 @@ getBundleName(): Promise\ | ---------------- | --------------------------------- | | Promise\ | 以Promise形式返回窗口的包名信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let name = await window.getBundleName() } @@ -1761,11 +2171,20 @@ getBounds(): Promise\ | ------------------------ | --------------------------------- | | Promise\<[Rect](#rect9)> | 以Promise形式返回窗口的边框信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let rect = await window.getBounds() } @@ -1785,11 +2204,20 @@ getTitle(): Promise\ | ---------------- | --------------------------------- | | Promise\ | 以Promise形式返回窗口的标题信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let rect = await window.getTitle() } @@ -1805,15 +2233,24 @@ getWindowMode(): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------------------------------------ | ------------------------------------- | +| 类型 | 说明 | +| ------------------------------------ | ------------------------------------- | | Promise\<[WindowMode](#windowmode9)> | 以Promise形式返回窗口的窗口模式信息。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let mode = await window.getWindowMode() } @@ -1829,15 +2266,24 @@ isFocused(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回窗口对象是否获焦,true:获焦,false:未获焦。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let focused = await window.isFocused() } @@ -1853,15 +2299,24 @@ isActived(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------------------------- | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | | Promise\ | 以Promise形式返回窗口对象是否为用户交互窗口,true:交互窗口,false:非交互窗口。 | +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | + **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) let focused = await window.isActived() } @@ -1869,23 +2324,26 @@ async function demo() { ### focus9+ -focus(): Promise\ +focus(): Promise\ 让窗口获焦。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.focus() } @@ -1893,7 +2351,7 @@ async function demo() { ### moveTo9+ -moveTo(x: number, y: number): Promise\ +moveTo(x: number, y: number): Promise\ 将窗口移动到目标点。适用于支持移动的窗口。 @@ -1906,17 +2364,21 @@ moveTo(x: number, y: number): Promise\ | x | number | 是 | 以number的形式传入目标点的横坐标信息。 | | y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | -**返回值:** +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.moveTo(100, 100) } @@ -1924,7 +2386,7 @@ async function demo() { ### resize9+ -resize(wide: number, height: number, direction: ResizeDirection): Promise\ +resize(wide: number, height: number, direction: ResizeDirection): Promise\ 根据传入的宽、高和调整方向来调整窗口的大小。适用于支持大小调整的窗口。 @@ -1932,23 +2394,27 @@ resize(wide: number, height: number, direction: ResizeDirection): Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.resize(100, 100, ResizeDirection.LEFT) } @@ -1956,23 +2422,27 @@ async function demo() { ### split9+ -split(): Promise\ +split(): Promise\ 将窗口模式切换成分屏模式。适用于支持切屏操作的窗口。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +| 类型 | 说明 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.split() } @@ -1980,23 +2450,27 @@ async function demo() { ### maximize9+ -maximize(): Promise\ +maximize(): Promise\ 将窗口最大化。适用于支持窗口最大化操作的窗口。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.maximize() } @@ -2004,23 +2478,27 @@ async function demo() { ### minimize9+ -minimize(): Promise\ +minimize(): Promise\ 将窗口最小化。适用于支持窗口最小化操作的窗口。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.minimize() } @@ -2028,23 +2506,27 @@ async function demo() { ### resume9+ -resume(): Promise\ +resume(): Promise\ 将窗口恢复到之前的窗口模式。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 + +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.resume() } @@ -2052,93 +2534,32 @@ async function demo() { ### close9+ -close(): Promise\ +close(): Promise\ 将窗口关闭。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成,true:操作已完成,false:操作未完成。 | +| 错误码ID | 错误码信息 | +| -------- | ---------------------------------------- | +| 17000002 | API does not allow calling concurrently. | +| 17000004 | Component lost/UiWindow lost. | +| 17000005 | This operation is not supported. | **示例:** ```js async function demo() { - let driver = UiDriver.create() + let driver = Driver.create() let window = await driver.findWindow({actived: true}) await window.close() } ``` -## PointerMatrix9+ - -表示存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。 - -### create9+ - -static create(fingers: number, steps: number): PointerMatrix - -静态方法,构造一个PointerMatrix对象,并返回该对象。 - -**系统能力**:SystemCapability.Test.UiTest - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------ | -| fingers | number | 是 | 多指操作中注入的手指数,取值范围:[1,10]。 | -| steps | number | 是 | 每根手指操作的步骤数,取值范围:[1,1000]。 | - -**返回值:** - -| 类型 | 说明 | -| -------------------------------- | ----------------------------- | -| [PointerMatrix](#pointermatrix9) | 返回构造的PointerMatrix对象。 | - -**示例:** - -```js -async function demo() { - let pointerMatrix = PointerMatrix.create(2,3) -} -``` - -### setPoint9+ - -setPoint(finger: number, step: number, point: Point): void - -设置PointerMatrix对象中指定手指和步骤对应动作的坐标点。 - -**系统能力**:SystemCapability.Test.UiTest - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------- | ---- | ---------------- | -| finger | number | 是 | 手指的序号。 | -| step | number | 是 | 步骤的序号。 | -| point | [Point](#point9) | 是 | 该行为的坐标点。 | - -**示例:** - -```js -async function demo() { - let pointers = PointerMatrix.create(2,3) - pointers.setPoint(0,0,{X:230,Y:480}) - pointers.setPoint(0,1,{X:250,Y:380}) - pointers.setPoint(0,2,{X:270,Y:280}) - pointers.setPoint(1,0,{X:230,Y:680}) - pointers.setPoint(1,1,{X:240,Y:580}) - pointers.setPoint(1,2,{X:250,Y:480}) -} -``` - -### - ## MatchPattern 控件属性支持的匹配模式。 @@ -2169,6 +2590,30 @@ async function demo() { | RIGHT_UP | 右上方。 | | RIGHT_DOWN | 右下方。 | +## Point9+ + +坐标点信息。 + +**系统能力**:SystemCapability.Test.UiTest + +| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| ---- | -------- | ---- | ---- | ---------------- | +| X | number | 是 | 否 | 坐标点的横坐标。 | +| Y | number | 是 | 否 | 坐标点的纵坐标。 | + +## Rect9+ + +控件的边框信息。 + +**系统能力**:SystemCapability.Test.UiTest + +| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| ------- | -------- | ---- | ---- | ------------------------- | +| leftX | number | 是 | 否 | 控件边框的左上角的X坐标。 | +| topY | number | 是 | 否 | 控件边框的左上角的Y坐标。 | +| rightX | number | 是 | 否 | 控件边框的右下角的X坐标。 | +| bottomY | number | 是 | 否 | 控件边框的右下角的Y坐标。 | + ## WindowMode9+ **系统能力**:SystemCapability.Test.UiTest @@ -2194,3 +2639,1052 @@ async function demo() { | ROTATION_90 | 设备显示器顺时针旋转90°,水平显示。 | | ROTATION_180 | 设备显示器顺时针旋转180°,逆向垂直显示。 | | ROTATION_270 | 设备显示器顺时针旋转270°,逆向水平显示。 | + +## WindowFilter9+ + +窗口的标志属性信息。 + +**系统能力**:SystemCapability.Test.UiTest + +| 名称 | 参数类型 | 必填 | 可读 | 可写 | 描述 | +| ---------- | -------- | ---- | ---- | ---- | -------------------------- | +| bundleName | string | 否 | 是 | 否 | 窗口对应的包名。 | +| title | string | 否 | 是 | 否 | 窗口的标题。 | +| focused | boolean | 否 | 是 | 否 | 窗口是否获焦。 | +| actived | boolean | 否 | 是 | 否 | 窗口是否正与用户进行交互。 | + +## By(deprecated) + +UiTest框架通过By类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。
+By提供的API能力具有以下几个特点:
1、支持单属性匹配和多属性组合匹配,例如同时指定目标控件text和id。
2、控件属性支持多种匹配模式。
3、支持控件绝对定位,相对定位,可通过[By.isBefore](#isbefore)和[By.isAfter](#isafter)等API限定邻近控件特征进行辅助定位。
By类提供的所有API均为同步接口,建议使用者通过静态构造器BY来链式创建By对象。 + +从API version9开始不再维护,建议使用[On9+](#on9)。 + +```js +BY.text('123').type('button') +``` + +### text(deprecated) + +text(txt: string, pattern?: MatchPattern): By + +指定目标控件文本属性,支持多种匹配模式,返回By对象自身。 + +从API version9开始不再维护,建议使用[text9+](#text9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------- | ---- | --------------------------------------------------- | +| txt | string | 是 | 指定控件文本,用于匹配目标控件文本。 | +| pattern | [MatchPattern](#matchpattern) | 否 | 指定的文本匹配模式,默认为[EQUALS](#matchpattern)。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------- | +| [By](#by) | 返回指定目标控件文本属性的By对象。 | + +**示例:** + +```js +let by = BY.text('123') //使用静态构造器BY创建by对象,指定目标控件的text属性。 +``` + + +### key(deprecated) + +key(key: string): By + +指定目标控件key值属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[id9+](#id9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------------- | +| key | string | 是 | 指定控件的Key值。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ----------------------------------- | +| [By](#by) | 返回指定目标控件key值属性的By对象。 | + +**示例:** + +```js +let by = BY.key('123') //使用静态构造器BY创建by对象,指定目标控件的key值属性。 +``` + + +### id(deprecated) + +id(id: number): By + +指定目标控件id属性,返回By对象自身。 + +从API version9开始不再维护,被废弃。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------- | +| id | number | 是 | 指定控件的id值。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | -------------------------------- | +| [By](#by) | 返回指定目标控件id属性的By对象。 | + +**示例:** + +```js +let by = BY.id(123) //使用静态构造器BY创建by对象,指定目标控件的id属性。 +``` + + +### type(deprecated) + +type(tp: string): By + +指定目标控件的控件类型属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[type9+](#type9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| tp | string | 是 | 指定控件类型。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------------- | +| [By](#by) | 返回指定目标控件的控件类型属性的By对象。 | + +**示例:** + +```js +let by = BY.type('button') //使用静态构造器BY创建by对象,指定目标控件的控件类型属性。 +``` + + +### clickable(deprecated) + +clickable(b?: boolean): By + +指定目标控件的可点击状态属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[clickable9+](#clickable9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件可点击状态,true:可点击,false:不可点击。默认为true。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ------------------------------------------ | +| [By](#by) | 返回指定目标控件的可点击状态属性的By对象。 | + +**示例:** + +```js +let by = BY.clickable(true) //使用静态构造器BY创建by对象,指定目标控件的可点击状态属性。 +``` + + +### scrollable(deprecated) + +scrollable(b?: boolean): By + +指定目标控件的可滑动状态属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[scrollable9+](#scrollable9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------------- | +| b | boolean | 否 | 控件可滑动状态,true:可滑动,false:不可滑动。默认为true。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ------------------------------------------ | +| [By](#by) | 返回指定目标控件的可滑动状态属性的By对象。 | + +**示例:** + +```js +let by = BY.scrollable(true) //使用静态构造器BY创建by对象,指定目标控件的可滑动状态属性。 +``` + +### enabled(deprecated) + +enabled(b?: boolean): By + +指定目标控件的使能状态属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[enabled9+](#enabled9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | --------------------------------------------------------- | +| b | boolean | 否 | 指定控件使能状态,true:使能,false:未使能。默认为true。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------------- | +| [By](#by) | 返回指定目标控件的使能状态属性的By对象。 | + +**示例:** + +```js +let by = BY.enabled(true) //使用静态构造器BY创建by对象,指定目标控件的使能状态属性。 +``` + +### focused(deprecated) + +focused(b?: boolean): By + +指定目标控件的获焦状态属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[focused9+](#focused9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------- | +| b | boolean | 否 | 控件获焦状态,true:获焦,false:未获焦。默认为true。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------------- | +| [By](#by) | 返回指定目标控件的获焦状态属性的By对象。 | + +**示例:** + +```js +let by = BY.focused(true) //使用静态构造器BY创建by对象,指定目标控件的获焦状态属性。 +``` + +### selected(deprecated) + +selected(b?: boolean): By + +指定目标控件的被选中状态属性,返回By对象自身。 + +从API version9开始不再维护,建议使用[selected9+](#selected9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件被选中状态,true:被选中,false:未被选中。默认为true。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ------------------------------------------ | +| [By](#by) | 返回指定目标控件的被选中状态属性的By对象。 | + +**示例:** + +```js +let by = BY.selected(true) //使用静态构造器BY创建by对象,指定目标控件的被选中状态属性。 +``` + +### isBefore(deprecated) + +isBefore(by: By): By + +指定目标控件位于给出的特征属性控件之前,返回By对象自身。 + +从API version9开始不再维护,建议使用[isBefore9+](#isbefore9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | ---------------- | +| by | [By](#by) | 是 | 特征控件的属性。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------------------------- | +| [By](#by) | 返回指定目标控件位于给出的特征属性控件之前的By对象。 | + +**示例:** + +```js +let by = BY.isBefore(BY.text('123')) //使用静态构造器BY创建by对象,指定目标控件位于给出的特征属性控件之前。 +``` + +### isAfter(deprecated) + +isAfter(by: By): By + +指定目标控件位于给出的特征属性控件之后,返回By对象自身。 + +从API version9开始不再维护,建议使用[isAfter9+](#isafter9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | ---------------- | +| by | [By](#by) | 是 | 特征控件的属性。 | + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------------------------- | +| [By](#by) | 返回指定目标控件位于给出的特征属性控件之后的By对象。 | + +**示例:** + +```js +let by = BY.isAfter(BY.text('123')) //使用静态构造器BY创建by对象,指定目标控件位于给出的特征属性控件之后。 +``` + +## UiComponent(deprecated) + +UiTest中,UiComponent类代表了UI界面上的一个控件,提供控件属性获取,控件点击,滑动查找,文本注入等API。 +该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 + +从API version9开始不再维护,建议使用[Component9+](#component9)。 + +### click(deprecated) + +click(): Promise\ + +控件对象进行点击操作。 + +从API version9开始不再维护,建议使用[click9+](#click9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + await button.click() +} +``` + +### doubleClick(deprecated) + +doubleClick(): Promise\ + +控件对象进行双击操作。 + +从API version9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + await button.doubleClick() +} +``` + +### longClick(deprecated) + +longClick(): Promise\ + +控件对象进行长按操作。 + +从API version9开始不再维护,建议使用[longClick9+](#longclick9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + await button.longClick() +} +``` + +### getId(deprecated) + +getId(): Promise\ + +获取控件对象的id值。 + +从API version9开始不再维护,建议使用[getId9+](#getid9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------- | +| Promise\ | 以Promise形式返回的控件的id值。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + let num = await button.getId() +} +``` + +### getKey(deprecated) + +getKey(): Promise\ + +获取控件对象的key值。 + +从API version9开始不再维护,被废弃。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------ | +| Promise\ | 以Promise形式返回控件的key值。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + let str_key = await button.getKey() +} +``` + +### getText(deprecated) + +getText(): Promise\ + +获取控件对象的文本信息。 + +从API version9开始不再维护,建议使用[getText9+](#gettext9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ---------------- | --------------------------------- | +| Promise\ | 以Promise形式返回控件的文本信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + let text = await button.getText() +} +``` + +### getType(deprecated) + +getType(): Promise\ + +获取控件对象的控件类型。 + +从API version9开始不再维护,建议使用[getType9+](#gettype9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ----------------------------- | +| Promise\ | 以Promise形式返回控件的类型。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + let type = await button.getType() +} +``` + +### isClickable(deprecated) + +isClickable(): Promise\ + +获取控件对象可点击状态。 + +从API version9开始不再维护,建议使用[isClickable9+](#isclickable9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回控件对象可点击状态,true:可点击,false:不可点击。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + if(await button.isClickable()) { + console.info('This button can be Clicked') + } + else{ + console.info('This button can not be Clicked') + } +} +``` + +### isScrollable(deprecated) + +isScrollable(): Promise\ + +获取控件对象可滑动状态。 + +从API version9开始不再维护,建议使用[isScrollable9+](#isscrollable9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回控件对象可滑动状态,true:可滑动,false:不可滑动。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let scrollBar = await driver.findComponent(BY.scrollable(true)) + if(await scrollBar.isScrollable()) { + console.info('This scrollBar can be operated') + } + else{ + console.info('This scrollBar can not be operated') + } +} +``` + + +### isEnabled(deprecated) + +isEnabled(): Promise\ + +获取控件使能状态。 + +从API version9开始不再维护,建议使用[isEnabled9+](#isenabled9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ---------------------------------------------------------- | +| Promise\ | 以Promise形式返回控件使能状态,true:使能,false:未使能。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + if(await button.isEnabled()) { + console.info('This button can be operated') + } + else{ + console.info('This button can not be operated') + } +} + +``` + +### isFocused(deprecated) + +isFocused(): Promise\ + +判断控件对象是否获焦。 + +从API version9开始不再维护,建议使用[isFocused9+](#isfocused9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回控件对象是否获焦,true:获焦,false:未获焦。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + if(await button.isFocused()) { + console.info('This button is focused') + } + else{ + console.info('This button is not focused') + } +} +``` + +### isSelected(deprecated) + +isSelected(): Promise\ + +获取控件对象被选中状态。 + +从API version9开始不再维护,建议使用[isSelected9+](#isselected9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ----------------------------------------------------- | +| Promise\ | 控件对象被选中的状态,true:被选中,false:未被选中。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.type('button')) + if(await button.isSelected()) { + console.info('This button is selected') + } + else{ + console.info('This button is not selected') + } +} +``` + +### inputText(deprecated) + +inputText(text: string): Promise\ + +向控件中输入文本(适用于文本框控件)。 + +从API version9开始不再维护,建议使用[inputText9+](#inputtext9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------- | +| text | string | 是 | 输入的文本信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let text = await driver.findComponent(BY.text('hello world')) + await text.inputText('123') +} +``` + +### scrollSearch(deprecated) + +scrollSearch(by: By): Promise\ + +在控件上滑动查找目标控件(适用于List等支持滑动的控件)。 + +从API version9开始不再维护,建议使用[scrollSearch9+](#scrollsearch9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| by | [By](#by) | 是 | 目标控件的属性要求。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------- | +| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的目标控件对象。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let scrollBar = await driver.findComponent(BY.type('Scroll')) + let button = await scrollBar.scrollSearch(BY.text('next page')) +} +``` + +## UiDriver(deprecated) + +UiDriver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等API。 +该类提供的方法除UiDriver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await调用。 + +从API version9开始不再维护,建议使用[Driver9+](#driver9)。 + +### create(deprecated) + +static create(): UiDriver + +静态方法,构造一个UiDriver对象,并返回该对象。 + +从API version9开始不再维护,建议使用[create9+](#create9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**返回值:** + +| 类型 | 说明 | +| -------- | ------------------------ | +| UiDriver | 返回构造的UiDriver对象。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() +} +``` + +### delayMs(deprecated) + +delayMs(duration: number): Promise\ + +UiDriver对象在给定的时间内延时。 + +从API version9开始不再维护,建议使用[delayMs9+](#delayms9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------ | +| duration | number | 是 | 给定的时间。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.delayMs(1000) +} +``` + +### findComponent(deprecated) + +findComponent(by: By): Promise\ + +在UiDriver对象中,根据给出的目标控件属性要求查找目标控件。 + +从API version9开始不再维护,建议使用[findComponent9+](#findcomponent9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| by | [By](#by) | 是 | 目标控件的属性要求。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------- | --------------------------------- | +| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let button = await driver.findComponent(BY.text('next page')) +} +``` + +### findComponents(deprecated) + +findComponents(by: By): Promise\> + +在UiDriver对象中,根据给出的目标控件属性要求查找出所有匹配控件,以列表保存。 + +从API version9开始不再维护,建议使用[findComponents9+](#findcomponents9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| by | [By](#by) | 是 | 目标控件的属性要求。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------- | --------------------------------------- | +| Promise\> | 以Promise形式返回找到的控件对象的列表。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + let buttonList = await driver.findComponents(BY.text('next page')) +} +``` + +### assertComponentExist(deprecated) + +assertComponentExist(by: By): Promise\ + +断言API,用于断言当前界面存在满足给出的目标控件属性的控件; 如果控件不存在,该API将抛出JS异常,使当前测试用例失败。 + +从API version9开始不再维护,建议使用[assertComponentExist9+](#assertcomponentexist9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| by | [By](#by) | 是 | 目标控件的属性要求。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.assertComponentExist(BY.text('next page')) +} +``` + +### pressBack(deprecated) + +pressBack(): Promise\ + +UiDriver对象进行点击BACK键的操作。 + +从API version9开始不再维护,建议使用[pressBack9+](#pressback9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.pressBack() +} +``` + +### triggerKey(deprecated) + +triggerKey(keyCode: number): Promise\ + +UiDriver对象采取如下操作:通过key值找到对应键并点击。 + +从API version9开始不再维护,建议使用[triggerKey9+](#triggerkey9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------- | +| keyCode | number | 是 | 指定的key值。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.triggerKey(123) +} +``` + + +### click(deprecated) + +click(x: number, y: number): Promise\ + +UiDriver对象采取如下操作:在目标坐标点单击。 + +从API version9开始不再维护,建议使用[click9+](#click9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| x | number | 是 | 以number的形式传入目标点的横坐标信息。 | +| y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.click(100,100) +} +``` + +### doubleClick(deprecated) + +doubleClick(x: number, y: number): Promise\ + +UiDriver对象采取如下操作:在目标坐标点双击。 + +从API version9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| x | number | 是 | 以number的形式传入目标点的横坐标信息。 | +| y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.doubleClick(100,100) +} +``` + +### longClick(deprecated) + +longClick(x: number, y: number): Promise\ + +UiDriver对象采取如下操作:在目标坐标点长按下鼠标左键。 + +从API version9开始不再维护,建议使用[longClick9+](#longclick9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| x | number | 是 | 以number的形式传入目标点的横坐标信息。 | +| y | number | 是 | 以number的形式传入目标点的纵坐标信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.longClick(100,100) +} +``` + +### swipe(deprecated) + +swipe(startx: number, starty: number, endx: number, endy: number): Promise\ + +UiDriver对象采取如下操作:从给出的起始坐标点滑向给出的目的坐标点。 + +从API version9开始不再维护,建议使用[swipe9+](#swipe9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| startx | number | 是 | 以number的形式传入起始点的横坐标信息。 | +| starty | number | 是 | 以number的形式传入起始点的纵坐标信息。 | +| endx | number | 是 | 以number的形式传入目的点的横坐标信息。 | +| endy | number | 是 | 以number的形式传入目的点的纵坐标信息。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.swipe(100,100,200,200) +} +``` + +### screenCap(deprecated) + +screenCap(savePath: string): Promise\ + +UiDriver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的图片至给出的保存路径中。 + +从API version9开始不再维护,建议使用[screenCap9+](#screencap9)。 + +**系统能力**:SystemCapability.Test.UiTest + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | -------------- | +| savePath | string | 是 | 文件保存路径。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------------- | +| Promise\ | 截图操作是否成功完成。成功完成为true。 | + +**示例:** + +```js +async function demo() { + let driver = UiDriver.create() + await driver.screenCap('/local/tmp/') +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md index 4c8e64ae8b409e691f0893ad254728d3217a8ede..5f4b865d34a2b425b4764373d9ba8b00002fd874 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md @@ -31,6 +31,14 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: Asy | attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | | callback | AsyncCallback<void> | 是 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.vibrator错误码](../errorcodes/errorcode-vibrator.md) + +| 错误码ID | 错误信息 | +| -------- | ------------------------- | +| 14600101 | Device operation failed。 | + 示例: ```js @@ -76,6 +84,14 @@ startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise<v | ------------------- | -------------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下错误码的详细介绍请参见 [ohos.vibrator错误码](../errorcodes/errorcode-vibrator.md) + +| 错误码ID | 错误信息 | +| -------- | ------------------------- | +| 14600101 | Device operation failed。 | + **示例:** ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 618db8db2c38c6d2b9a1140f817b647c3c0685d9..0d28afc2ae1bc5b80f25077a4b9fa2837df5ec9f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -44,6 +44,22 @@ import window from '@ohos.window'; | TYPE_DIALOG9+ | 16 | 表示模态窗口。
**模型约束:** 此接口仅可在Stage模型下使用。
**系统接口:** 此接口为系统接口。 | | TYPE_SCREENSHOT9+ | 17 | 表示截屏窗口。
**模型约束:** 此接口仅可在Stage模型下使用。
**系统接口:** 此接口为系统接口。 | +## Configuration9+ + +创建子窗口时的参数。 + +当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口时,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| 名称 | 参数类型 | 必填 | 说明 | +| ---------- | -------------------------- | -- | ----------------------------------- | +| name | string | 是 | 子窗口名字。 | +| windowType | [WindowType](#windowtype7) | 是 | 子窗口类型。 | +| ctx | BaseContext | 否 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。不设置,则默认为空。 | +| displayId | number | 否 | 当前物理屏幕id。不设置,则默认为-1。 | +| parentId | number | 否 | 父窗口id。不设置,则默认为-1。 | + ## AvoidAreaType7+ 窗口内容需要规避区域的类型枚举。 @@ -95,10 +111,10 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | | statusBarColor | string | 否 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 | +| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。 | | statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 | | navigationBarColor | string | 否 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| isNavigationBarLightIcon7+ | boolean | 否 | 是 | 导航栏图标是否为高亮状态。 | +| isNavigationBarLightIcon7+ | boolean | 否 | 是 | 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。 | | navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 | ## Orientation9+ @@ -147,8 +163,8 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| type | [WindowType](#windowtype) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | -| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。 | +| type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | +| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。true表示显示;false表示不显示。 | | region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 | | backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | | contentColor | string | 是 | 否 | 系统栏文字颜色。 | @@ -187,7 +203,7 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ---------- | ------------- | ---- | ---- | ------------------ | -| visible9+ | boolean | 是 | 是 | 规避区域是否可见。 | +| visible9+ | boolean | 是 | 是 | 规避区域是否可见。true表示可见;false表示不可见。 | | leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | | topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | | rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | @@ -213,17 +229,17 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | -| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。 | -| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | -| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | -| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | -| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。 | +| type7+ | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 | +| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。true表示全屏;false表示非全屏。 | +| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 | +| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。true表示可聚焦;false表示不可聚焦。 | +| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。true表示可触摸;false表示不可触摸。 | | brightness | number | 是 | 是 | 屏幕亮度, 取值范围为0~1,1表示最大亮度值。 | -| dimBehindValue(deprecated) | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持 | -| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。 | -| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。 | -| isRoundCorner(deprecated) | boolean | 是 | 是 | 窗口是否为圆角。默认为false。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持 | -| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。 | +| dimBehindValue(deprecated) | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持。 | +| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。true表示常亮;false表示不常亮。 | +| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。true表示模式开启;false表示模式关闭。 | +| isRoundCorner(deprecated) | boolean | 是 | 是 | 窗口是否为圆角。默认为false。true表示圆角;false表示非圆角。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持。 | +| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。true表示透明;false表示不透明。 | | id9+ | number | 是 | 否 | 窗口ID,默认值为0.0。 | ## ColorSpace8+ @@ -282,179 +298,102 @@ import window from '@ohos.window'; | y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 | | z | number | 否 | 是 | Z轴的平移参数,默认值为0.0。 | -## window.create7+ +## window.createWindow9+ -create(id: string, type: WindowType, callback: AsyncCallback<Window>): void +createWindow(config: Configuration, callback: AsyncCallback<Window>): void 创建子窗口,使用callback异步回调。 -**模型约束:** 此接口仅可在FA模型下使用。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------ | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | - -**示例:** - -```js -let windowClass = null; -window.create('first', window.WindowType.TYPE_APP,(err,data) => { - if(err.code){ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); -}); -``` - -## window.create7+ - -create(id: string, type: WindowType): Promise<Window> - -创建子窗口,使用Promise异步回调。 - -**模型约束:** 此接口仅可在FA模型下使用。 - **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ---------- | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | - -**返回值:** - -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | - -**示例:** - -```js -let windowClass = null; -let promise = window.create('first', window.WindowType.TYPE_APP); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); -}); -``` - -## window.create8+ - -create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void - -创建子窗口,使用callback异步回调,其中Context详见[Context](js-apis-Context.md)。 - -从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | -- | --------------------------------- | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**参数:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300001 | This is repeat operation. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; - window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - if (err.code) { - console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); -}); +let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context}; +try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); + }); +} catch (exception) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.create8+ - -create(ctx: Context, id: string, type: WindowType): Promise<Window> +## window.createWindow9+ -创建子窗口,使用Promise异步回调,其中Context详见[Context](js-apis-Context.md)。 +createWindow(config: Configuration): Promise<Window> -从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。 +创建子窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------- | -- | ------------------ | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| -------------------------------- | ------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | -**示例:** - -```js -let windowClass = null; -let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); -}); -``` - -## window.find7+ - -find(id: string, callback: AsyncCallback<Window>): void - -查找id所对应的窗口,使用callback异步回调。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**参数:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------ | -| id | string | 是 | 窗口id。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前查找到的窗口对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300001 | This is repeat operation. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; - window.find('alertWindow', (err, data) => { - if (err.code) { - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); -}); +let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: this.context}; +try { + let promise = window.createWindow(config); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.find7+ +## window.findWindow9+ -find(id: string): Promise<Window> +findWindow(name: string): Window -查找id所对应的窗口,使用Promise异步回调。 +查找id所对应的窗口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -462,118 +401,69 @@ find(id: string): Promise<Window> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------- | -| id | string | 是 | 窗口id。 | +| name | string | 是 | 窗口id。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | ------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前查找的窗口对象。 | +| 类型 | 说明 | +| ----------------- | ------------------- | +| [Window](#window) | 当前查找的窗口对象。 | **示例:** ```js -let windowClass = null; -let promise = window.find('alertWindow'); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); -}); +try { + let windowClass = window.findWindow('alertWindow'); +} catch (exception) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.getTopWindow +## window.getLastWindow9+ -getTopWindow(callback: AsyncCallback<Window>): void +getLastWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void 获取当前应用内最后显示的窗口,使用callback异步回调。 -**模型约束:** 此接口仅可在FA模型下使用。 - **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | -------------------------------------------- | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | - -**示例:** - -```js -let windowClass = null; -window.getTopWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}); -``` - -## window.getTopWindow - -getTopWindow(): Promise<Window> - -获取当前应用内最后显示的窗口,使用Promise异步回调。 - -**模型约束:** 此接口仅可在FA模型下使用。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**返回值:** - -| 类型 | 说明 | -| -------------------------------- | ----------------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | - -**示例:** - -```js -let windowClass = null; -let promise = window.getTopWindow(); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); -}) -``` - -## window.getTopWindow8+ - -getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void - -获取当前应用内最后显示的窗口,使用callback异步回调。 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | -- | ---------------------------------------- | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**参数:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; -window.getTopWindow(this.context, (err, data) => { - if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}); +try { + window.getLastWindow(this.context, (err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.getTopWindow8+ +## window.getLastWindow9+ -getTopWindow(ctx: Context): Promise<Window> +getLastWindow(ctx: BaseContext): Promise<Window> 获取当前应用内最后显示的窗口,使用Promise异步回调。 @@ -581,27 +471,40 @@ getTopWindow(ctx: Context): Promise<Window> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------- | ---- | ------------------------------------------------------------ | -| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | ----------------------------------------------- | +| 类型 | 说明 | +| -------------------------------- | ------------------------------------------- | | Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300006 | This window context is abnormal. | + **示例:** ```js let windowClass = null; -let promise = window.getTopWindow(this.context); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); -}) +try { + let promise = window.getLastWindow(this.context); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); +}; ``` ## window.minimizeAll9+ @@ -617,29 +520,41 @@ minimizeAll(id: number, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------- | -| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号 | +| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号。 | | callback | AsyncCallback<void> | 是 | 回调信息。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js import display from '@ohos.display' import window from '@ohos.window' -let displayClass = null; -display.getDefaultDisplay((err, data) => { - if(err.code) { - return; - } - displayClass = data; - window.minimizeAll(displayClass.id, (err, data) => { +try { + displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); + return; +}; + +try { + window.minimizeAll(displayClass.id, (err) => { if(err.code) { console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); return; } console.info('Succeeded in minimizing all windows.'); }); -}); +} catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); +}; ``` ## window.minimizeAll9+ @@ -655,7 +570,7 @@ minimizeAll(id: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------- | -| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号 | +| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号。 | **返回值:** @@ -663,26 +578,38 @@ minimizeAll(id: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js import display from '@ohos.display' import window from '@ohos.window' -let displayClass = null; -display.getDefaultDisplay((err, data) => { - if(err.code) { - return; - } - displayClass = data; +try { + displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); + return; +}; + +try { let promise = window.minimizeAll(displayClass.id); - promise.then((data)=> { + promise.then(()=> { console.info('Succeeded in minimizing all windows.'); }).catch((err)=>{ console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); - }) -}); -``` + }); +} catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); +}; +``` ## window.toggleShownStateForAllAppWindows9+ toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void @@ -699,10 +626,18 @@ toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void | -------- | ------------------------- | ---- | -------------- | | callback | AsyncCallback<void> | 是 | 回调信息。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -window.toggleShownStateForAllAppWindows((err, data) => { +window.toggleShownStateForAllAppWindows((err) => { if (err.code) { console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); return; @@ -726,12 +661,20 @@ toggleShownStateForAllAppWindows(): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js let promise = window.toggleShownStateForAllAppWindows(); -promise.then((data)=> { - console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data)); +promise.then(()=> { + console.info('Succeeded in toggling shown state for all app windows.'); }).catch((err)=>{ console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); }) @@ -750,15 +693,31 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>) | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------- | -| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式 | +| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式。 | | callback | AsyncCallback<void> | 是 | 回调信息。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => { - console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); -}); +try { + window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err) => { + if(err.code) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window layout mode.'); + }); +} catch (exception) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); +}; ``` ## window.setWindowLayoutMode9+ @@ -774,7 +733,7 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------- | -| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式 | +| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式。 | **返回值:** @@ -782,18 +741,30 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); -promise.then((data)=> { - console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); -}) +try { + let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); + promise.then(()=> { + console.info('Succeeded in setting window layout mode.'); + }).catch((err)=>{ + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); +}; ``` -## on('systemBarTintChange')8+ +## window.on('systemBarTintChange')8+ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void @@ -813,12 +784,16 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v **示例:** ```js -window.on('systemBarTintChange', (data) => { - console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); -}); +try { + window.on('systemBarTintChange', (data) => { + console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); +}; ``` -## off('systemBarTintChange')8+ +## window.off('systemBarTintChange')8+ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void @@ -838,325 +813,426 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) **示例:** ```js -window.off('systemBarTintChange'); +try { + window.off('systemBarTintChange'); +} catch (exception) { + console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); +}; ``` -## Window - -当前窗口实例,窗口管理器管理的基本单元。 - -下列API示例中都需先使用[getTopWindow()](#windowgettopwindow)、[create()](#windowcreate7)、[find()](#windowfind7)中的任一方法获取到Window实例,再通过此实例调用对应方法。 +## window.create(deprecated) -### hide7+ +create(id: string, type: WindowType, callback: AsyncCallback<Window>): void -hide (callback: AsyncCallback<void>): void +创建子窗口,使用callback异步回调。 -隐藏当前窗口,使用callback异步回调。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 -**系统接口:** 此接口为系统接口。 +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** ```js -windowClass.hide((err, data) => { - if (err.code) { - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); +let windowClass = null; +window.create('first', window.WindowType.TYPE_APP,(err,data) => { + if(err.code){ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); -}) + windowClass = data; + console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); +}); ``` -### hide7+ +## window.create(deprecated) -hide(): Promise<void> +create(id: string, type: WindowType): Promise<Window> -隐藏当前窗口,使用Promise异步回调。 +创建子窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 + +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ---------- | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | --------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | **示例:** ```js -let promise = windowClass.hide(); +let windowClass = null; +let promise = window.create('first', window.WindowType.TYPE_APP); promise.then((data)=> { - console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); -}) + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); +}); ``` -### hideWithAnimation9+ +## window.create(deprecated) -hideWithAnimation(callback: AsyncCallback<void>): void +create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback<Window>): void -隐藏当前窗口,过程中播放动画,使用callback异步回调。 +创建子窗口,使用callback异步回调,其中Context详见[Context](js-apis-Context.md)。 -**系统接口:** 此接口为系统接口。 +从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。 | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** ```js -windowClass.hideWithAnimation((err, data) => { +let windowClass = null; + window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { if (err.code) { - console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data)); -}) + windowClass = data; + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); +}); ``` -### hideWithAnimation9+ +## window.create(deprecated) -hideWithAnimation(): Promise<void> +create(ctx: BaseContext, id: string, type: WindowType): Promise<Window> -隐藏当前窗口,过程中播放动画,使用Promise异步回调。 +创建子窗口,使用Promise异步回调,其中Context详见[Context](js-apis-Context.md)。 -**系统接口:** 此接口为系统接口。 +从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。 | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | --------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | **示例:** ```js -let promise = windowClass.hideWithAnimation(); +let windowClass = null; +let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { - console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); -}) + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); +}); ``` -### show7+ +## window.find(deprecated) -show(callback: AsyncCallback<void>): void +find(id: string, callback: AsyncCallback<Window>): void -显示当前窗口,使用callback异步回调。 +查找id所对应的窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | 是 | 窗口id。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前查找到的窗口对象。 | **示例:** ```js -windowClass.show((err, data) => { - if (err.code) { - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); -}) +let windowClass = null; + window.find('alertWindow', (err, data) => { + if (err.code) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); +}); ``` -### show7+ +## window.find(deprecated) -show(): Promise<void> +find(id: string): Promise<Window> -显示当前窗口,使用Promise异步回调。 +查找id所对应的窗口,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| id | string | 是 | 窗口id。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | ------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前查找的窗口对象。 | **示例:** ```js -let promise = windowClass.show(); +let windowClass = null; +let promise = window.find('alertWindow'); promise.then((data)=> { - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); -}) + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); +}); ``` -### showWithAnimation9+ +## window.getTopWindow(deprecated) -showWithAnimation(callback: AsyncCallback<void>): void +getTopWindow(callback: AsyncCallback<Window>): void -显示当前窗口,过程中播放动画,使用callback异步回调。 +获取当前应用内最后显示的窗口,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 + +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | -------------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -windowClass.showWithAnimation((err, data) => { +let windowClass = null; +window.getTopWindow((err, data) => { if (err.code) { - console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); -}) + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); ``` -### showWithAnimation9+ +## window.getTopWindow(deprecated) -showWithAnimation(): Promise<void> +getTopWindow(): Promise<Window> -显示当前窗口,过程中播放动画,使用Promise异步回调。 +获取当前应用内最后显示的窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 + +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -let promise = windowClass.showWithAnimation(); +let windowClass = null; +let promise = window.getTopWindow(); promise.then((data)=> { - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }) ``` -### destroy7+ +## window.getTopWindow(deprecated) -destroy(callback: AsyncCallback<void>): void +getTopWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void -销毁当前窗口,使用callback异步回调。 +获取当前应用内最后显示的窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -windowClass.destroy((err, data) => { +let windowClass = null; +window.getTopWindow(this.context, (err, data) => { if (err.code) { - console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); -}) + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); ``` -### destroy7+ +## window.getTopWindow(deprecated) -destroy(): Promise<void> +getTopWindow(ctx: BaseContext): Promise<Window> -销毁当前窗口,使用Promise异步回调。 +获取当前应用内最后显示的窗口,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -let promise = windowClass.destroy(); +let windowClass = null; +let promise = window.getTopWindow(this.context); promise.then((data)=> { - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }) ``` -### moveTo7+ +## Window -moveTo(x: number, y: number, callback: AsyncCallback<void>): void +当前窗口实例,窗口管理器管理的基本单元。 -移动窗口位置,使用callback异步回调。 +下列API示例中都需先使用[getLastWindow()](#windowgetlastwindow9)、[createWindow()](#windowcreatewindow9)、[findWindow()](#windowfindwindow9)中的任一方法获取到Window实例,再通过此实例调用对应方法。 + +### hide7+ + +hide (callback: AsyncCallback<void>): void + +隐藏当前窗口,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -windowClass.moveTo(300, 300, (err, data)=>{ +windowClass.hide((err) => { if (err.code) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); - -}); + console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); +}) ``` -### moveTo7+ - -moveTo(x: number, y: number): Promise<void> +### hide7+ -移动窗口位置,使用Promise异步回调。 +hide(): Promise<void> -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +隐藏当前窗口,使用Promise异步回调。 -**参数:** +**系统接口:** 此接口为系统接口。 -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1164,59 +1240,72 @@ moveTo(x: number, y: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -let promise = windowClass.moveTo(300, 300); -promise.then((data)=> { - console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); +let promise = windowClass.hide(); +promise.then(()=> { + console.info('Succeeded in hiding the window.'); }).catch((err)=>{ - console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); }) ``` -### resetSize7+ +### hideWithAnimation9+ -resetSize(width: number, height: number, callback: AsyncCallback<void>): void +hideWithAnimation(callback: AsyncCallback<void>): void -改变当前窗口大小,使用callback异步回调。 +隐藏当前窗口,过程中播放动画,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------------------- | -| width | number | 是 | 目标窗口的宽度,单位为px。 | -| height | number | 是 | 目标窗口的高度,单位为px。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | **示例:** ```js -windowClass.resetSize(500, 1000, (err, data) => { +windowClass.hideWithAnimation((err) => { if (err.code) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); -}); + console.info('Succeeded in hiding the window with animation.'); +}) ``` -### resetSize7+ - -resetSize(width: number, height: number): Promise<void> +### hideWithAnimation9+ -改变当前窗口大小,使用Promise异步回调。 +hideWithAnimation(): Promise<void> -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +隐藏当前窗口,过程中播放动画,使用Promise异步回调。 -**参数:** +**系统接口:** 此接口为系统接口。 -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------------- | -| width | number | 是 | 目标窗口的宽度,单位为px。 | -| height | number | 是 | 目标窗口的高度,单位为px。 | +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1224,584 +1313,1024 @@ resetSize(width: number, height: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | + **示例:** ```js -let promise = windowClass.resetSize(500, 1000); -promise.then((data)=> { - console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); +let promise = windowClass.hideWithAnimation(); +promise.then(()=> { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); -}); + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); +}) ``` -### setWindowType(deprecated) - -setWindowType(type: WindowType, callback: AsyncCallback<void>): void - -设置窗口类型,使用callback异步回调。 +### showWindow9+ -**系统接口:** 此接口为系统接口。 +showWindow(callback: AsyncCallback<void>): void -> **说明:** 从API version 9开始废弃。 -> -> 从 API version 7开始支持。 +显示当前窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let type = window.WindowType.TYPE_APP; -windowClass.setWindowType(type, (err, data) => { - if (err.code) { - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); +windowClass.showWindow((err) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window.'); }); ``` -### setWindowType(deprecated) - -setWindowType(type: WindowType): Promise<void> - -设置窗口类型,使用Promise异步回调。 +### showWindow9+ -**系统接口:** 此接口为系统接口。 +showWindow(): Promise<void> -> **说明:** 从API version 9开始废弃。 -> -> 从 API version 7开始支持。 +显示当前窗口,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | - **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ----------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -let type = window.WindowType.TYPE_APP; -let promise = windowClass.setWindowType(type); -promise.then((data)=> { - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); +let promise = windowClass.showWindow(); +promise.then(()=> { + console.info('Succeeded in showing the window.'); }).catch((err)=>{ - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); }); ``` -### getProperties +### showWithAnimation9+ -getProperties(callback: AsyncCallback<WindowProperties>): void +showWithAnimation(callback: AsyncCallback<void>): void -获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 +显示当前窗口,过程中播放动画,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调函数。返回当前窗口属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | **示例:** ```js -windowClass.getProperties((err, data) => { +windowClass.showWithAnimation((err) => { if (err.code) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); -}); + console.info('Succeeded in showing the window with animation.'); +}) ``` -### getProperties +### showWithAnimation9+ -getProperties(): Promise<WindowProperties> +showWithAnimation(): Promise<void> -获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 +显示当前窗口,过程中播放动画,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ---------------------------------------------------- | ------------------------------- | -| Promise<[WindowProperties](#windowproperties)> | Promise对象。返回当前窗口属性。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | **示例:** ```js -let promise = windowClass.getProperties(); -promise.then((data)=> { - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); +let promise = windowClass.showWithAnimation(); +promise.then(()=> { + console.info('Succeeded in showing the window with animation.'); }).catch((err)=>{ - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); -}); + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); +}) ``` -### getAvoidArea7+ +### destroyWindow9+ -getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void +destroyWindow(callback: AsyncCallback<void>): void -获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。 +销毁当前窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | -| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回窗口内容规避区域。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let type = window.AvoidAreaType.TYPE_SYSTEM; -windowClass.getAvoidArea(type, (err, data) => { +windowClass.destroyWindow((err) => { if (err.code) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); -}); + console.info('Succeeded in destroying the window.'); +}) ``` -### getAvoidArea7+ +### destroyWindow9+ -getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)> +destroyWindow(): Promise<void> -获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。 +销毁当前窗口,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ |----------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -|-----------------------------------------| ----------------------------------- | -| Promise<[AvoidArea](#avoidarea7)> | Promise对象。返回窗口内容规避区域。 | +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let type = window.AvoidAreaType.TYPE_SYSTEM; -let promise = windowClass.getAvoidArea(type); -promise.then((data)=> { - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +let promise = windowClass.destroyWindow(); +promise.then(()=> { + console.info('Succeeded in destroying the window.'); }).catch((err)=>{ - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); -}); + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); +}) ``` -### setFullScreen +### moveWindowTo9+ -setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void +moveWindowTo(x: number, y: number, callback: AsyncCallback<void>): void -设置是否为全屏状态,使用callback异步回调。 +移动窗口位置,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------- | ---- | ---------------------------------------------- | -| isFullScreen | boolean | 是 | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let isFullScreen = true; -windowClass.setFullScreen(isFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.moveWindowTo(300, 300, (err)=>{ + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window.'); + }); +} catch (exception) { + console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); +}; ``` -### setFullScreen +### moveWindowTo9+ -setFullScreen(isFullScreen: boolean): Promise<void> +moveWindowTo(x: number, y: number): Promise<void> -设置是否为全屏状态,使用Promise异步回调。 +移动窗口位置,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------- | ---- | ---------------------------------------------- | -| isFullScreen | boolean | 是 | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 | +| 参数名 | 类型 | 必填 | 说明 | +| -- | ----- | -- | --------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -let isFullScreen = true; -let promise = windowClass.setFullScreen(isFullScreen); -promise.then((data)=> { - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); -}); +try { + let promise = windowClass.moveWindowTo(300, 300); + promise.then(()=> { + console.info('Succeeded in moving the window.'); + }).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); +}; ``` -### setLayoutFullScreen7+ +### resize9+ -setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void +resize(width: number, height: number, callback: AsyncCallback<void>): void -设置窗口的布局是否为全屏显示状态,使用callback异步回调。 +改变当前窗口大小,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | ------------------------ | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let isLayoutFullScreen= true; -windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.resize(500, 1000, (err) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size.'); + }); +} catch (exception) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); +}; ``` -### setLayoutFullScreen7+ +### resize9+ -setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> +resize(width: number, height: number): Promise<void> -设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 +改变当前窗口大小,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------- | ---- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | -- | ------------------------ | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -let isLayoutFullScreen = true; -let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); -promise.then((data)=> { - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); -}); +try { + let promise = windowClass.resize(500, 1000); + promise.then(()=> { + console.info('Succeeded in changing the window size.'); + }).catch((err)=>{ + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception)); +}; ``` -### setSystemBarEnable7+ +### setWindowMode9+ -setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void +setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void -设置导航栏、状态栏的可见模式,使用callback异步回调。 +设置窗口模式,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | -- | --------- | +| mode | [WindowMode](#windowmode7) | 是 | 窗口模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -// 此处以不显示导航栏、状态栏为例 -let names = []; -windowClass.setSystemBarEnable(names, (err, data) => { +let mode = window.WindowMode.FULLSCREEN; +try { + windowClass.setWindowMode(mode, (err) => { if (err.code) { - console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); -}); + console.info('Succeeded in setting the window mode.'); + }); +} catch (exception) { + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); +}; ``` -### setSystemBarEnable7+ +### setWindowMode9+ -setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> +setWindowMode(mode: WindowMode): Promise<void> -设置导航栏、状态栏的可见模式,使用Promise异步回调。 +设置窗口类型,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----- | ---- | ------------------------------------------------------------ | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | -- | --------- | +| mode | [WindowMode](#windowmode7) | 是 | 窗口模式。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ----------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -// 此处以不显示导航栏、状态栏为例 -let names = []; -let promise = windowClass.setSystemBarEnable(names); -promise.then((data)=> { - console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); -}); +let mode = window.WindowMode.FULLSCREEN; +try { + let promise = windowClass.setWindowMode(type); + promise.then(()=> { + console.info('Succeeded in setting the window mode.'); + }).catch((err)=>{ + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); +}; ``` -### setSystemBarProperties +### getWindowProperties9+ -setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void +getWindowProperties(): WindowProperties -设置窗口内导航栏、状态栏的属性,使用callback异步回调。 +获取当前窗口的属性,返回WindowProperties。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 类型 | 说明 | +| ------------------------------------- | ------------- | +| [WindowProperties](#windowproperties) | 当前窗口属性。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version7开始支持 - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' +try { + let properties = windowClass.getWindowProperties(); +} catch (exception) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); }; -windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { - if (err.code) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); -}); ``` -### setSystemBarProperties +### getWindowAvoidArea9+ -setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> +getWindowAvoidArea(type: AvoidAreaType): AvoidArea -设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- |----------------------------------| -- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +|--------------------------| ----------------- | +| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version7开始支持 - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' +let type = window.AvoidAreaType.TYPE_SYSTEM; +try { + let avoidArea = windowClass.getWindowAvoidArea(type); +} catch (exception) { + console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); }; -let promise = windowClass.setSystemBarProperties(SystemBarProperties); -promise.then((data)=> { - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); -}); ``` -### setPreferredOrientation9+ +### setWindowLayoutFullScreen9+ -setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void +setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -设置窗口的显示方向属性,使用callback异步回调。 +设置窗口的布局是否为全屏显示状态,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | -- | --------- | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏显示;false表示非全屏显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let orientation = window.Orientation.AUTO_ROTATION; -windowClass.setPreferredOrientation(orientation, (err, data) => { - if (err.code) { - console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data)); -}); +let isLayoutFullScreen= true; +try { + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode.'); + }); +} catch (exception) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); +}; ``` -### setPreferredOrientation9+ +### setWindowLayoutFullScreen9+ -setPreferredOrientation(orientation: Orientation): Promise<void> +setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -设置窗口的显示方向属性,使用Promise异步回调。 +设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏显示;false表示非全屏显示。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -let orientation = window.Orientation.AUTO_ROTATION; -let promise = windowClass.setPreferredOrientation(orientation); -promise.then((data)=> { - console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err)); -}); +let isLayoutFullScreen = true; +try { + let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + promise.then(()=> { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }).catch((err)=>{ + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); +}; ``` -### loadContent7+ +### setWindowSystemBarEnable9+ -loadContent(path: string, callback: AsyncCallback<void>): void +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void -为当前窗口加载具体页面内容,使用callback异步回调。 +设置导航栏、状态栏的可见模式,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------------- | -| path | string | 是 | 设置加载页面的路径。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -windowClass.loadContent('pages/page2/page2', (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); -}); +// 此处以不显示导航栏、状态栏为例 +let names = []; +try { + windowClass.setWindowSystemBarEnable(names, (err) => { + if (err.code) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be invisible.'); + }); +} catch (exception) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); +}; ``` -### loadContent7+ +### setWindowSystemBarEnable9+ -loadContent(path: string): Promise<void> +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> -为当前窗口加载具体页面内容,使用Promise异步回调。 +设置导航栏、状态栏的可见模式,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------- | -| path | string | 是 | 设置加载页面的路径。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | +| 类型 | 说明 | +| ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | -**示例:** +**错误码:** -```js -let promise = windowClass.loadContent('pages/page2/page2'); -promise.then((data)=> { - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); -}); -``` -### loadContent9+ +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | -为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。 +**示例:** -**模型约束:** 此接口仅可在Stage模型下使用。 +```js +// 此处以不显示导航栏、状态栏为例 +let names = []; +try { + let promise = windowClass.setWindowSystemBarEnable(names); + promise.then(()=> { + console.info('Succeeded in setting the system bar to be invisible.'); + }).catch((err)=>{ + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowSystemBarProperties9+ + +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +try { + windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties.'); + }); +} catch (exception) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowSystemBarProperties9+ + +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> + +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +try { + let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties); + promise.then(()=> { + console.info('Succeeded in setting the system bar properties.'); + }).catch((err)=>{ + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setPreferredOrientation9+ + +setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void + +设置窗口的显示方向属性,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let orientation = window.Orientation.AUTO_ROTATION; +try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window orientation.'); + }); +} catch (exception) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setPreferredOrientation9+ + +setPreferredOrientation(orientation: Orientation): Promise<void> + +设置窗口的显示方向属性,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let orientation = window.Orientation.AUTO_ROTATION; +try { + let promise = windowClass.setPreferredOrientation(orientation); + promise.then(()=> { + console.info('Succeeded in setting the window orientation.'); + }).catch((err)=>{ + console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setUIContent9+ + +setUIContent(path: string, callback: AsyncCallback<void>): void + +为当前窗口加载具体页面内容,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +try { + windowClass.setUIContent('pages/page2/page2', (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); +} catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); +}; +``` + +### setUIContent9+ + +setUIContent(path: string): Promise<void> + +为当前窗口加载具体页面内容,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | -- | ------------------ | +| path | string | 是 | 设置加载页面的路径。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +try { + let promise = windowClass.setUIContent('pages/page2/page2'); + promise.then(()=> { + console.info('Succeeded in loading the content.'); + }).catch((err)=>{ + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); +}; +``` + +### loadContent9+ + +loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void + +为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。 + +**模型约束:** 此接口仅可在Stage模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1813,6 +2342,15 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void | storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```ts @@ -1822,13 +2360,17 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent('pages/page2',this.storage,(err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.loadContent('pages/page2',this.storage,(err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -1856,6 +2398,15 @@ loadContent(path: string, storage: LocalStorage): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```ts @@ -1866,65 +2417,52 @@ class myAbility extends Ability { this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); let windowClass = null; - let promise = windowStage.loadContent('pages/page2',this.storage); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - }) + try { + let promise = windowStage.loadContent('pages/page2',this.storage); + promise.then(()=> { + windowClass = data; + console.info('Succeeded in loading the content.'); + }).catch((err)=>{ + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` -### isShowing7+ - -isShowing(callback: AsyncCallback<boolean>): void - -判断当前窗口是否已显示,使用callback异步回调。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | +### isWindowShowing9+ -**示例:** +isWindowShowing(): boolean -```js -windowClass.isShowing((err, data) => { - if (err.code) { - console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); -}); -``` +判断当前窗口是否已显示。 -### isShowing7+ +**系统能力:** SystemCapability.WindowManager.WindowManager.Core -isShowing(): Promise<boolean> +**返回值:** -判断当前窗口是否已显示,使用Promise异步回调。 +| 类型 | 说明 | +| ------- | ------------------------------------------------------------------ | +| boolean | 当前窗口是否已显示。true表示当前窗口已显示,false则表示当前窗口未显示。 | -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**返回值:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let promise = windowClass.isShowing(); -promise.then((data)=> { +try { + let data = windowClass.isWindowShowing(); console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); -}); +} catch (exception) { + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('windowSizeChange')7+ @@ -1945,14 +2483,18 @@ on(type: 'windowSizeChange', callback: Callback<Size>): void **示例:** ```js -windowClass.on('windowSizeChange', (data) => { - console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('windowSizeChange')7+ -off(type: 'windowSizeChange', callback?: Callback<Size >): void +off(type: 'windowSizeChange', callback?: Callback<Size>): void 关闭窗口尺寸变化的监听。 @@ -1968,490 +2510,2192 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void **示例:** ```js -windowClass.off('windowSizeChange'); +try { + windowClass.off('windowSizeChange'); +} catch (exception) { + console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); +}; ``` -### on('systemAvoidAreaChange')(deprecated) +### on('avoidAreaChange')9+ -on(type: 'systemAvoidAreaChange', callback: Callback<[AvoidArea](#avoidarea7)>): void +on(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void 开启系统规避区变化的监听。 -> **说明:** 从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。 -> -> 从 API version 7开始支持。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------| ---- | ------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回当前规避区。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------------------------------| ---- |--------------------------------------| +| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 是 | 回调函数。返回当前规避区以及规避区类型。| + +**示例:** + +```js +try { + windowClass.on('avoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. type:' + + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); + }); +} catch (exception) { + console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('avoidAreaChange')9+ + +off(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void + +关闭系统规避区变化的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- |-----------------------------------------------------------------------------|-----|------------------------------------| +| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 否 | 回调函数。返回当前规避区以及规避区类型。| + +**示例:** + +```js +try { + windowClass.off('avoidAreaChange'); +} catch (exception) { + console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); +}; +``` + +### on('keyboardHeightChange')7+ + +on(type: 'keyboardHeightChange', callback: Callback<number>): void + +开启键盘高度变化的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | +| callback | Callback<number> | 是 | 回调函数。返回当前的键盘高度。 | + +**示例:** + +```js +try { + windowClass.on('keyboardHeightChange', (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('keyboardHeightChange')7+ + +off(type: 'keyboardHeightChange', callback?: Callback<number>): void + +关闭键盘高度变化的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | +| callback | Callback<number> | 否 | 回调函数。返回当前的键盘高度。 | + +**示例:** + +```js +try { + windowClass.off('keyboardHeightChange'); +} catch (exception) { + console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); +}; +``` + +### on('touchOutside')9+ + +on(type: 'touchOutside', callback: Callback<void>): void + +开启本窗口区域范围外的点击事件的监听。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | +| callback | Callback<void> | 是 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | + +**示例:** + +```js +try { + windowClass.on('touchOutside', () => { + console.info('touch outside'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('touchOutside')9+ + +off(type: 'touchOutside', callback?: Callback<void>): void + +关闭本窗口区域范围外的点击事件的监听。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | +| callback | Callback<number> | 否 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | + +**示例:** + +```js +try { + windowClass.off('touchOutside'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### on('screenshot')9+ + +on(type: 'screenshot', callback: Callback<void>): void + +开启截屏事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | +| callback | Callback<void> | 是 | 回调函数。发生截屏事件时的回调。 | + +**示例:** + +```js +try { + windowClass.on('screenshot', () => { + console.info('screenshot happened'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('screenshot')9+ + +off(type: 'screenshot', callback?: Callback<void>): void + +关闭截屏事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | +| callback | Callback<void> | 否 | 回调函数。发生截屏事件时的回调。 | + +**示例:** + +```js +let callback = ()=>{ + console.info('screenshot happened'); +} +try { + windowClass.on('screenshot', callback); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +try { + windowClass.off('screenshot', callback); + // 如果通过on开启多个callback进行监听,同时关闭所有监听: + windowClass.off('screenshot'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### on('dialogTargetTouch')9+ + +on(type: 'dialogTargetTouch', callback: Callback<void>): void + +开启模态窗口目标窗口的点击事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | +| callback | Callback<void>| 是 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | + +**示例:** + +```js +try { + windowClass.on('dialogTargetTouch', () => { + console.info('touch dialog target'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('dialogTargetTouch')9+ + +off(type: 'dialogTargetTouch', callback?: Callback<void>): void + +关闭模态窗口目标窗口的点击事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | +| callback | Callback<void> | 否 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | + +**示例:** + +```js +try { + windowClass.off('dialogTargetTouch'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### bindDialogTarget9+ + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void + +绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | +| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +class MyDeathRecipient { + onRemoteDied() { + console.log('server died'); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject('testObject'); +try { + windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }, (err) => { + if (err.code) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in binding dialog target.'); + }); +} catch (exception) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); +}; +``` + +### bindDialogTarget9+ + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> + +绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | +| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +class MyDeathRecipient { + onRemoteDied() { + console.log('server died'); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject('testObject'); +try { + let promise = windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }); + promise.then(()=> { + console.info('Succeeded in binding dialog target.'); + }).catch((err)=>{ + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); +}; +``` + +### isWindowSupportWideGamut9+ + +isWindowSupportWideGamut(callback: AsyncCallback<boolean>): void + +判断当前窗口是否支持广色域模式,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +windowClass.isWindowSupportWideGamut((err, data) => { + if (err.code) { + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); +}); +``` + +### isWindowSupportWideGamut9+ + +isWindowSupportWideGamut(): Promise<boolean> + +判断当前窗口是否支持广色域模式,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let promise = windowClass.isWindowSupportWideGamut(); +promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); +}); +``` + +### setWindowColorSpace9+ + +setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void + +设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ----------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +try { + windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { + if (err.code) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window colorspace.'); + }); +} catch (exception) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowColorSpace9+ + +setWindowColorSpace(colorSpace:ColorSpace): Promise<void> + +设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ------------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +try { + let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT); + promise.then(()=> { + console.info('Succeeded in setting window colorspace.'); + }).catch((err)=>{ + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); +}; +``` + +### getWindowColorSpace9+ + +getWindowColorSpace(): ColorSpace + +获取当前窗口色域模式。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------- | +| [ColorSpace](#colorspace) | 当前色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let colorSpace = windowClass.getWindowColorSpace(); +``` + +### setWindowBackgroundColor9+ + +setWindowBackgroundColor(color: string): void + +设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | -- | ----------------------------------------------------------------------- | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let color = '#00ff33'; +try { + windowClass.setWindowBackgroundColor(color); +} catch (exception) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowBrightness9+ + +setWindowBrightness(brightness: number, callback: AsyncCallback<void>): void + +设置屏幕亮度值,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let brightness = 1; +try { + windowClass.setWindowBrightness(brightness, (err) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness.'); + }); +} catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowBrightness9+ + +setWindowBrightness(brightness: number): Promise<void> + +设置屏幕亮度值,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let brightness = 1; +try { + let promise = windowClass.setWindowBrightness(brightness); + promise.then(()=> { + console.info('Succeeded in setting the brightness.'); + }).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowFocusable9+ + +setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void + +设置点击时是否支持切换焦点窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | ------------------------------------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isFocusable= true; +try { + windowClass.setWindowFocusable(isFocusable, (err) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable.'); + }); +} catch (exception) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowFocusable9+ + +setWindowFocusable(isFocusable: boolean): Promise<void> + +设置点击时是否支持切换焦点窗口,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | -- | -------------------------------------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isFocusable= true; +try { + let promise = windowClass.setWindowFocusable(isFocusable); + promise.then(()=> { + console.info('Succeeded in setting the window to be focusable.'); + }).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowKeepScreenOn9+ + +setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void + +设置屏幕是否为常亮状态,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | -- | ---------------------------------------------------- | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isKeepScreenOn = true; +try { + windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err) => { + if (err.code) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the screen to be always on.'); + }); +} catch (exception) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowKeepScreenOn9+ + +setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise<void> + +设置屏幕是否为常亮状态,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------- | -- | --------------------------------------------------- | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isKeepScreenOn = true; +try { + let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn); + promise.then(() => { + console.info('Succeeded in setting the screen to be always on.'); + }).catch((err)=>{ + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWakeUpScreen()9+ + +setWakeUpScreen(wakeUp: boolean): void + +窗口唤醒屏幕。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ------- | ---- | ---------------------------- | +| wakeUp | boolean | 是 | 是否设置唤醒屏幕。true表示唤醒;false表示不唤醒。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let wakeUp = true; +try { + windowClass.setWakeUpScreen(wakeUp); +} catch (exception) { + console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowPrivacyMode9+ + +setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**需要权限:** ohos.permission.PRIVACE_WINDOW + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------------------------- | -- | ------------------------------------------------------ | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let isPrivacyMode = true; +try { + windowClass.setWindowPrivacyMode(isPrivacyMode, (err) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode.'); + }); +} catch (exception) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowPrivacyMode9+ + +setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void> + +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**需要权限:** ohos.permission.PRIVACE_WINDOW + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | -- | ----------------------------------------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let isPrivacyMode = true; +try { + let promise = windowClass.setWindowPrivacyMode(isPrivacyMode); + promise.then(()=> { + console.info('Succeeded in setting the window to privacy mode.'); + }).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### setSnapshotSkip9+ +setSnapshotSkip(isSkip: boolean): void + +截屏录屏是否忽略当前窗口。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +```js +let isSkip = true; +try { + windowClass.setSnapshotSkip(isSkip); +} catch (exception) { + console.error('Failed to Skip. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowTouchable9+ + +setWindowTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为可触状态,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | ----------------------------------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isTouchable = true; +try { + windowClass.setWindowTouchable(isTouchable, (err) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable.'); + }); +} catch (exception) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowTouchable9+ + +setWindowTouchable(isTouchable: boolean): Promise<void> + +设置窗口是否为可触状态,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | -- | ----------------------------------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isTouchable = true; +try { + let promise = windowClass.setWindowTouchable(isTouchable); + promise.then(()=> { + console.info('Succeeded in setting the window to be touchable.'); + }).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setForbidSplitMove9+ + +setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void + +设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isForbidSplitMove = true; +try { + windowClass.setForbidSplitMove(isForbidSplitMove, (err) => { + if (err.code) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in forbidding window moving in split screen mode.'); + }); +} catch (exception) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### setForbidSplitMove9+ + +setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> + +设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +let isForbidSplitMove = true; +try { + let promise = windowClass.setForbidSplitMove(isForbidSplitMove); + promise.then(()=> { + console.info('Succeeded in forbidding window moving in split screen mode.'); + }).catch((err)=>{ + console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### snapshot9+ + +snapshot(callback: AsyncCallback<image.PixelMap>): void + +获取窗口截图,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +windowClass.snapshot((err, data) => { + if (err.code) { + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + data.release(); // PixelMap使用完后及时释放内存 +}); +``` + +### snapshot9+ + +snapshot(): Promise<image.PixelMap> + +获取窗口截图,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```js +let promise = windowClass.snapshot(); +promise.then((pixelMap)=> { + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 +}).catch((err)=>{ + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); +}); +``` + +### opacity9+ + +opacity(opacity: number): void + +设置窗口透明度。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | --------------------- | +| opacity | number | 是 | 透明度,范围0.0~1.0。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.opacity(0.5); +} catch (exception) { + console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); +}; +``` + +### scale9+ + +scale(scaleOptions: ScaleOptions): void + +设置窗口缩放参数。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------------ | ---- | ---------- | +| scaleOptions | [ScaleOptions](#scaleoptions9) | 是 | 缩放参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let obj : window.ScaleOptions = { + x : 2.0, + y : 1.0, + pivotX = 0.5; + pivotY = 0.5; +} +try { + windowClass.scale(obj); +} catch (exception) { + console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); +}; +``` + +### rotate9+ + +rotate(rotateOptions: RotateOptions): void + +设置窗口旋转参数。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | -------------------------------- | ---- | ---------- | +| rotateOptions | [RotateOptions](#rotateoptions9) | 是 | 旋转参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let obj : window.RotateOptions = { + x : 1.0, + y : 1.0, + z : 45.0, + pivotX = 0.5; + pivotY = 0.5; +} +try { + windowClass.rotate(obj); +} catch (exception) { + console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); +}; +``` + +### translate9+ + +translate(translateOptions: TranslateOptions): void + +设置窗口平移参数。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | -------------------------------------- | ---- | ---------- | +| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let obj : window.TranslateOptions = { + x : 100.0, + y : 0.0, + z : 0.0 +} +try { + windowClass.translate(obj); +} catch (exception) { + console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); +}; +``` + +### getTransitionController9+ + + getTransitionController(): TransitionController + +获取窗口属性转换控制器。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------- | ---------------- | +| [TransitionController](#transitioncontroller9) | 属性转换控制器。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let controller = windowClass.getTransitionController(); // 获取属性转换控制器 +controller.animationForHidden = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // 动画时长 + tempo: 0.5, // 播放速率 + curve: Curve.EaseInOut, // 动画曲线 + delay: 0, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: ()=> { + context.completeTransition(true) + } + }, () => { + let obj : window.TranslateOptions = { + x : 100.0, + y : 0.0, + z : 0.0 + } + toWindow.translate(obj); // 设置动画过程中的属性转换 + console.info('toWindow translate end'); + } + ) + console.info('complete transition end'); +} +windowClass.hideWithAnimation((err, data) => { + if (err.code) { + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); +}) +``` + +### setBlur9+ + +setBlur(radius: number): void + +设置窗口模糊。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.setBlur(4.0); +} catch (exception) { + console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setBackdropBlur9+ + +setBackdropBlur(radius: number): void + +设置窗口背景模糊。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.setBackdropBlur(4.0); +} catch (exception) { + console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setBackdropBlurStyle9+ + +setBackdropBlurStyle(blurStyle: BlurStyle): void + +设置窗口背景模糊类型。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------- | ---- | ---------------------- | +| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.setBackdropBlurStyle(window.BlurType.THIN); +} catch (exception) { + console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setShadow9+ + +setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void + +设置窗口边缘阴影。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | +| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | +| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```js -windowClass.on('systemAvoidAreaChange', (data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +} catch (exception) { + console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); +}; ``` -### off('systemAvoidAreaChange')(deprecated) +### setCornerRadius9+ -off(type: 'systemAvoidAreaChange', callback?: Callback<[AvoidArea](#avoidarea7)>): void +setCornerRadius(cornerRadius: number): void -关闭系统规避区变化的监听。 -> **说明:** 从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。 -> -> 从 API version 7开始支持。 +设置窗口圆角半径。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------| ---- | ------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<[AvoidArea](#avoidarea7)> | 否 | 回调函数。返回当前规避区。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```js -windowClass.off('systemAvoidAreaChange'); +try { + windowClass.setCornerRadius(4.0); +} catch (exception) { + console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); +}; ``` +### show(deprecated) -### on('avoidAreaChange')9+ +show(callback: AsyncCallback<void>): void -on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void +显示当前窗口,使用callback异步回调。 -开启系统规避区变化的监听。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------------------------------| ---- |--------------------------------------| -| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 是 | 回调函数。返回当前规避区以及规避区类型。| +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.on('avoidAreaChange', (data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); -}); +windowClass.show((err) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window.'); +}) ``` -### off('avoidAreaChange')9+ +### show(deprecated) + +show(): Promise<void> -off(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void +显示当前窗口,使用Promise异步回调。 -关闭系统规避区变化的监听。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |-----------------------------------------------------------------------------|-----|------------------------------------| -| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 否 | 回调函数。返回当前规避区以及规避区类型。| +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.off('avoidAreaChange'); +let promise = windowClass.show(); +promise.then(()=> { + console.info('Succeeded in showing the window.'); +}).catch((err)=>{ + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); +}) ``` -### on('keyboardHeightChange')7+ +### destroy(deprecated) -on(type: 'keyboardHeightChange', callback: Callback<number>): void +destroy(callback: AsyncCallback<void>): void -开启键盘高度变化的监听。 +销毁当前窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | -| callback | Callback { - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); -}); +windowClass.destroy((err) => { + if (err.code) { + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window.'); +}) ``` -### off('keyboardHeightChange')7+ +### destroy(deprecated) -off(type: 'keyboardHeightChange', callback?: Callback<number>): void +destroy(): Promise<void> -关闭键盘高度变化的监听。 +销毁当前窗口,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | -| callback | Callback<number> | 否 | 回调函数。返回当前的键盘高度。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.off('keyboardHeightChange'); +let promise = windowClass.destroy(); +promise.then(()=> { + console.info('Succeeded in destroying the window.'); +}).catch((err)=>{ + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); +}) ``` -### on('touchOutside')9+ +### moveTo(deprecated) -on(type: 'touchOutside', callback: Callback<void>): void +moveTo(x: number, y: number, callback: AsyncCallback<void>): void -开启本窗口区域范围外的点击事件的监听。 +移动窗口位置,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | -| callback | Callback { - console.info('touch outside'); +windowClass.moveTo(300, 300, (err)=>{ + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window.'); + }); ``` -### off('touchOutside')9+ +### moveTo(deprecated) -off(type: 'touchOutside', callback?: Callback<void>): void +moveTo(x: number, y: number): Promise<void> -关闭本窗口区域范围外的点击事件的监听。 +移动窗口位置,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | -| callback | Callback<number> | 否 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.off('touchOutside'); +let promise = windowClass.moveTo(300, 300); +promise.then(()=> { + console.info('Succeeded in moving the window.'); +}).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); +}) ``` -### on('screenshot')9+ +### resetSize(deprecated) -on(type: 'screenshot', callback: Callback<void>): void +resetSize(width: number, height: number, callback: AsyncCallback<void>): void -开启截屏事件的监听。 +改变当前窗口大小,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | -| callback | Callback<void> | 是 | 回调函数。发生截屏事件时的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.on('screenshot', () => { - console.info('screenshot happened'); +windowClass.resetSize(500, 1000, (err) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size.'); }); ``` -### off('screenshot')9+ +### resetSize(deprecated) -off(type: 'screenshot', callback?: Callback<void>): void +resetSize(width: number, height: number): Promise<void> -关闭截屏事件的监听。 +改变当前窗口大小,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | -| callback | Callback<void> | 否 | 回调函数。发生截屏事件时的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let callback = ()=>{ - console.info('screenshot happened'); -} -windowClass.on('screenshot', callback) -windowClass.off('screenshot', callback) - -// 如果通过on开启多个callback进行监听,同时关闭所有监听: -windowClass.off('screenshot'); +let promise = windowClass.resetSize(500, 1000); +promise.then(()=> { + console.info('Succeeded in changing the window size.'); +}).catch((err)=>{ + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); +}); ``` -### on('dialogTargetTouch')9+ +### setWindowType(deprecated) -on(type: 'dialogTargetTouch', callback: Callback<void>): void +setWindowType(type: WindowType, callback: AsyncCallback<void>): void -开启模态窗口目标窗口的点击事件的监听。 +设置窗口类型,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | -| callback | Callback<void>| 是 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.on('dialogTargetTouch', () => { - console.info('touch dialog target'); +let type = window.WindowType.TYPE_APP; +windowClass.setWindowType(type, (err) => { + if (err.code) { + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window type.'); }); ``` -### off('dialogTargetTouch')9+ +### setWindowType(deprecated) -off(type: 'dialogTargetTouch', callback?: Callback<void>): void +setWindowType(type: WindowType): Promise<void> -关闭模态窗口目标窗口的点击事件的监听。 +设置窗口类型,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | -| callback | Callback<void> | 否 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.off('dialogTargetTouch'); +let type = window.WindowType.TYPE_APP; +let promise = windowClass.setWindowType(type); +promise.then(()=> { + console.info('Succeeded in setting the window type.'); +}).catch((err)=>{ + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); +}); ``` -### bindDialogTarget9+ +### getProperties(deprecated) -bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void +getProperties(callback: AsyncCallback<WindowProperties>): void -绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。 +获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | -| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调函数。返回当前窗口属性。 | **示例:** ```js -class MyDeathRecipient { - onRemoteDied() { - console.log('server died'); - } -} -class TestRemoteObject extends rpc.RemoteObject { - constructor(descriptor) { - super(descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - isObjectDead(): boolean { - return false; - } -} -let token = new TestRemoteObject('testObject'); -windowClass.bindDialogTarget(token, () => { - console.info('Dialog Window Need Destroy.'); -}, (err, data) => { +windowClass.getProperties((err, data) => { if (err.code) { - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); }); ``` -### bindDialogTarget9+ +### getProperties(deprecated) -bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> +getProperties(): Promise<WindowProperties> -绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。 +获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | -| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | - **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------------------------------------- | ------------------------------- | +| Promise<[WindowProperties](#windowproperties)> | Promise对象。返回当前窗口属性。 | **示例:** ```js -class MyDeathRecipient { - onRemoteDied() { - console.log('server died'); - } -} -class TestRemoteObject extends rpc.RemoteObject { - constructor(descriptor) { - super(descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - isObjectDead(): boolean { - return false; - } -} -let token = new TestRemoteObject('testObject'); -let promise = windowClass.bindDialogTarget(token, () => { - console.info('Dialog Window Need Destroy.'); -}); +let promise = windowClass.getProperties(); promise.then((data)=> { - console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); }); ``` -### isSupportWideGamut8+ +### getAvoidArea(deprecated) -isSupportWideGamut(callback: AsyncCallback<boolean>): void +getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void -判断当前窗口是否支持广色域模式,使用callback异步回调。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | +| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回窗口内容规避区域。 | **示例:** ```js -windowClass.isSupportWideGamut((err, data) => { +let type = window.AvoidAreaType.TYPE_SYSTEM; +windowClass.getAvoidArea(type, (err, data) => { if (err.code) { - console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); -}) + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +}); ``` -### isSupportWideGamut8+ +### getAvoidArea(deprecated) -isSupportWideGamut(): Promise<boolean> +getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)> -判断当前窗口是否支持广色域模式,使用Promise异步回调。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ |----------------------------------| ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | + **返回值:** -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 类型 | 说明 | +|-----------------------------------------| ----------------------------------- | +| Promise<[AvoidArea](#avoidarea7)> | Promise对象。返回窗口内容规避区域。 | **示例:** ```js -let promise = windowClass.isSupportWideGamut(); +let type = window.AvoidAreaType.TYPE_SYSTEM; +let promise = windowClass.getAvoidArea(type); promise.then((data)=> { - console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); }); ``` -### setColorSpace8+ +### setFullScreen(deprecated) -setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void +setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void -设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 +设置是否为全屏状态,使用callback异步回调。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | ------------ | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | 是 | 是否设为全屏状态(该全屏状态隐藏状态栏导航栏)。true表示全屏;false表示非全屏。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { +let isFullScreen = true; +windowClass.setFullScreen(isFullScreen, (err) => { if (err.code) { - console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); -}) + console.info('Succeeded in enabling the full-screen mode.'); +}); ``` -### setColorSpace8+ +### setFullScreen(deprecated) -setColorSpace(colorSpace:ColorSpace): Promise<void> +setFullScreen(isFullScreen: boolean): Promise<void> -设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 +设置是否为全屏状态,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | -------------- | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | 是 | 是否设为全屏状态(该全屏状态隐藏状态栏导航栏)。true表示全屏;false表示非全屏。 | **返回值:** @@ -2462,70 +4706,92 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> **示例:** ```js -let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT); -promise.then((data)=> { - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); +let isFullScreen = true; +let promise = windowClass.setFullScreen(isFullScreen); +promise.then(()=> { + console.info('Succeeded in enabling the full-screen mode.'); }).catch((err)=>{ - console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); }); ``` -### getColorSpace8+ +### setLayoutFullScreen(deprecated) -getColorSpace(callback: AsyncCallback<ColorSpace>): void +setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -获取当前窗口色域模式,使用callback异步回调。 +设置窗口的布局是否为全屏显示状态,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | -| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数。当获取成功,err为undefined,data为当前色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏;false表示非全屏。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.getColorSpace((err, data) => { +let isLayoutFullScreen= true; +windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => { if (err.code) { - console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); -}) + console.info('Succeeded in setting the window layout to full-screen mode.'); +}); ``` -### getColorSpace8+ +### setLayoutFullScreen(deprecated) -getColorSpace(): Promise<ColorSpace> +setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -获取当前窗口色域模式,使用Promise异步回调。 +设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏;false表示非全屏。 | + **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------------------------------- | -| Promise<[ColorSpace](#colorspace)> | Promise对象。返回当前色域模式。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let promise = windowClass.getColorSpace(); -promise.then((data)=> { - console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); +let isLayoutFullScreen = true; +let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); +promise.then(()=> { + console.info('Succeeded in setting the window layout to full-screen mode.'); }).catch((err)=>{ - console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); }); ``` -### setBackgroundColor +### setSystemBarEnable(deprecated) -setBackgroundColor(color: string, callback: AsyncCallback<void>): void +setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void -设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +设置导航栏、状态栏的可见模式,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2533,35 +4799,40 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let color = '#00ff33'; -windowClass.setBackgroundColor(color, (err, data) => { +// 此处以不显示导航栏、状态栏为例 +let names = []; +windowClass.setSystemBarEnable(names, (err) => { if (err.code) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the system bar to be invisible.'); }); ``` -### setBackgroundColor +### setSystemBarEnable(deprecated) -setBackgroundColor(color: string): Promise<void> +setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> -设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +设置导航栏、状态栏的可见模式,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----- | ---- | ------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** @@ -2572,79 +4843,150 @@ setBackgroundColor(color: string): Promise<void> **示例:** ```js -let color = '#00ff33'; -let promise = windowClass.setBackgroundColor(color); -promise.then((data)=> { - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); +// 此处以不显示导航栏、状态栏为例 +let names = []; +let promise = windowClass.setSystemBarEnable(names); +promise.then(()=> { + console.info('Succeeded in setting the system bar to be invisible.'); }).catch((err)=>{ - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); +}); +``` + +### setSystemBarProperties(deprecated) + +setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +windowClass.setSystemBarProperties(SystemBarProperties, (err) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties.'); }); ``` -### setWakeUpScreen()9+ +### setSystemBarProperties(deprecated) -setWakeUpScreen(wakeUp: boolean): void; +setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> -窗口唤醒屏幕。 +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ------- | ---- | ---------------------------- | -| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let wakeUp = true; -windowClass.setWakeUpScreen(wakeUp); +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +let promise = windowClass.setSystemBarProperties(SystemBarProperties); +promise.then(()=> { + console.info('Succeeded in setting the system bar properties.'); +}).catch((err)=>{ + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); +}); ``` -### setBrightness +### loadContent(deprecated) -setBrightness(brightness: number, callback: AsyncCallback<void>): void +loadContent(path: string, callback: AsyncCallback<void>): void -设置屏幕亮度值,使用callback异步回调。 +为当前窗口加载具体页面内容,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | ------------------------------------ | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let brightness = 1; -windowClass.setBrightness(brightness, (err, data) => { - if (err.code) { - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); +windowClass.loadContent('pages/page2/page2', (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); }); ``` -### setBrightness +### loadContent(deprecated) -setBrightness(brightness: number): Promise<void> +loadContent(path: string): Promise<void> -设置屏幕亮度值,使用Promise异步回调。 +为当前窗口加载具体页面内容,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ------------------------------------ | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | **返回值:** @@ -2655,249 +4997,232 @@ setBrightness(brightness: number): Promise<void> **示例:** ```js -let brightness = 1; -let promise = windowClass.setBrightness(brightness); -promise.then((data)=> { - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); +let promise = windowClass.loadContent('pages/page2/page2'); +promise.then(()=> { + console.info('Succeeded in loading the content.'); }).catch((err)=>{ - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); }); ``` -### setDimBehind(deprecated) +### isShowing(deprecated) -setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void +isShowing(callback: AsyncCallback<boolean>): void -窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。 +判断当前窗口是否已显示,使用callback异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ---- | -------------------------------------------------- | -| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 | **示例:** ```js -windowClass.setDimBehind(0.5, (err, data) => { +windowClass.isShowing((err, data) => { if (err.code) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); }); ``` -### setDimBehind(deprecated) +### isShowing(deprecated) -setDimBehind(dimBehindValue: number): Promise<void> +isShowing(): Promise<boolean> -窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。 +判断当前窗口是否已显示,使用Promise异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------ | ---- | -------------------------------------------------- | -| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | - **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 | **示例:** ```js -let promise = windowClass.setDimBehind(0.5); +let promise = windowClass.isShowing(); promise.then((data)=> { - console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)); + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); }); ``` -### setFocusable7+ +### on('systemAvoidAreaChange')(deprecated) -setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void +on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void -设置点击时是否支持切换焦点窗口,使用callback异步回调。 +开启系统规避区变化的监听。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | ---------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回当前规避区。 | **示例:** ```js -let isFocusable= true; -windowClass.setFocusable(isFocusable, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); +windowClass.on('systemAvoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); }); ``` -### setFocusable7+ +### off('systemAvoidAreaChange')(deprecated) -setFocusable(isFocusable: boolean): Promise<void> +off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void -设置点击时是否支持切换焦点窗口,使用Promise异步回调。 +关闭系统规避区变化的监听。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | ---------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<[AvoidArea](#avoidarea7)> | 否 | 回调函数。返回当前规避区。 | **示例:** ```js -let isFocusable= true; -let promise = windowClass.setFocusable(isFocusable); -promise.then((data)=> { - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); -}); +windowClass.off('systemAvoidAreaChange'); ``` -### setKeepScreenOn +### isSupportWideGamut(deprecated) -setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void +isSupportWideGamut(callback: AsyncCallback<boolean>): void -设置屏幕是否为常亮状态,使用callback异步回调。 +判断当前窗口是否支持广色域模式,使用callback异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | **示例:** ```js -let isKeepScreenOn = true; -windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { +windowClass.isSupportWideGamut((err, data) => { if (err.code) { - console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); -}); + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); +}) ``` -### setKeepScreenOn - -setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> +### isSupportWideGamut(deprecated) -设置屏幕是否为常亮状态,使用Promise异步回调。 +isSupportWideGamut(): Promise<boolean> -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +判断当前窗口是否支持广色域模式,使用Promise异步回调。 -**参数:** +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | **示例:** ```js -let isKeepScreenOn = true; -let promise = windowClass.setKeepScreenOn(isKeepScreenOn); -promise.then((data) => { - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); +let promise = windowClass.isSupportWideGamut(); +promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); }); ``` -### setOutsideTouchable(deprecated) +### setColorSpace(deprecated) -setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void +setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void -设置是否允许可点击子窗口之外的区域,使用callback异步回调。 +设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------------------------- | ---- | ---------------- | -| touchable | boolean | 是 | 设置是否可点击。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setOutsideTouchable(true, (err, data) => { +windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { if (err.code) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting window colorspace.'); }) ``` -### setOutsideTouchable(deprecated) +### setColorSpace(deprecated) -setOutsideTouchable(touchable: boolean): Promise<void> +setColorSpace(colorSpace:ColorSpace): Promise<void> -设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。 +设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从 API version 7开始支持。 +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------- | ---- | ---------------- | -| touchable | boolean | 是 | 设置是否可点击。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | **返回值:** @@ -2908,136 +5233,122 @@ setOutsideTouchable(touchable: boolean): Promise<void> **示例:** ```js -let promise = windowClass.setOutsideTouchable(true); -promise.then((data)=> { - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); +let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT); +promise.then(()=> { + console.info('Succeeded in setting window colorspace.'); }).catch((err)=>{ - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); }); ``` -### setPrivacyMode7+ +### getColorSpace(deprecated) -setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void +getColorSpace(callback: AsyncCallback<ColorSpace>): void -设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +获取当前窗口色域模式,使用callback异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------------------------- | ---- | -------------------- | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | +| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数。当获取成功,err为undefined,data为当前色域模式。 | **示例:** ```js -let isPrivacyMode = true; -windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { +windowClass.getColorSpace((err, data) => { if (err.code) { - console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); - -}); + console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); +}) ``` -### setPrivacyMode7+ - -setPrivacyMode(isPrivacyMode: boolean): Promise<void> +### getColorSpace(deprecated) -设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +getColorSpace(): Promise<ColorSpace> -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +获取当前窗口色域模式,使用Promise异步回调。 -**参数:** +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | ---- | -------------------- | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------------------------- | ------------------------------- | +| Promise<[ColorSpace](#colorspace)> | Promise对象。返回当前色域模式。 | **示例:** ```js -let isPrivacyMode = true; -let promise = windowClass.setPrivacyMode(isPrivacyMode); +let promise = windowClass.getColorSpace(); promise.then((data)=> { - console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)); + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); }); ``` -### setSnapshotSkip9+ -setSnapshotSkip(isSkip: boolean): void - -截屏录屏是否忽略当前窗口。 - -**系统接口:** 此接口为系统接口。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | ---- | -------------------- | -| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| -```js -let isSkip = true; -windowClass.setSnapshotSkip(isSkip); -``` +### setBackgroundColor(deprecated) -### setTouchable7+ +setBackgroundColor(color: string, callback: AsyncCallback<void>): void -setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void +设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)或[setUIContent()](#setuicontent9)之后使用。 -设置窗口是否为可触状态,使用callback异步回调。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let isTouchable = true; -windowClass.setTouchable(isTouchable, (err, data) => { +let color = '#00ff33'; +windowClass.setBackgroundColor(color, (err) => { if (err.code) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); - + console.info('Succeeded in setting the background color.'); }); ``` -### setTouchable7+ +### setBackgroundColor(deprecated) -setTouchable(isTouchable: boolean): Promise<void> +setBackgroundColor(color: string): Promise<void> -设置窗口是否为可触状态,使用Promise异步回调。 +设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)或[setUIContent()](#setuicontent9)之后使用。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | **返回值:** @@ -3048,61 +5359,64 @@ setTouchable(isTouchable: boolean): Promise<void> **示例:** ```js -let isTouchable = true; -let promise = windowClass.setTouchable(isTouchable); -promise.then((data)=> { - console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); +let color = '#00ff33'; +let promise = windowClass.setBackgroundColor(color); +promise.then(()=> { + console.info('Succeeded in setting the background color.'); }).catch((err)=>{ - console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); }); ``` -### setForbidSplitMove9+ +### setBrightness(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void +setBrightness(brightness: number, callback: AsyncCallback<void>): void -设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 +设置屏幕亮度值,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------ | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let isForbidSplitMove = true; -windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => { +let brightness = 1; +windowClass.setBrightness(brightness, (err) => { if (err.code) { - console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data)); - + console.info('Succeeded in setting the brightness.'); }); ``` -### setForbidSplitMove9+ +### setBrightness(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> +setBrightness(brightness: number): Promise<void> -设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 +设置屏幕亮度值,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------ | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | **返回值:** @@ -3113,338 +5427,419 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> **示例:** ```js -let isForbidSplitMove = true; -let promise = windowClass.setForbidSplitMove(isForbidSplitMove); -promise.then((data)=> { - console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); +let brightness = 1; +let promise = windowClass.setBrightness(brightness); +promise.then(()=> { + console.info('Succeeded in setting the brightness.'); }).catch((err)=>{ - console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); }); ``` -### snapshot9+ +### setDimBehind(deprecated) -snapshot(callback: AsyncCallback<image.PixelMap>): void +setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void -获取窗口截图,使用callback异步回调。 +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。 + +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | -------------------------------------------------- | +| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.snapshot((err, data) => { +windowClass.setDimBehind(0.5, (err) => { if (err.code) { - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - data.release(); // PixelMap使用完后及时释放内存 + console.info('Succeeded in setting the dimness.'); }); ``` -### snapshot9+ +### setDimBehind(deprecated) -snapshot(): Promise<image.PixelMap> +setDimBehind(dimBehindValue: number): Promise<void> -获取窗口截图,使用Promise异步回调。 +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。 + +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------------------------------------- | +| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + **返回值:** | 类型 | 说明 | | ------------------- | ------------------------- | -| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let promise = windowClass.snapshot(); -promise.then((pixelMap)=> { - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 +let promise = windowClass.setDimBehind(0.5); +promise.then(()=> { + console.info('Succeeded in setting the dimness.'); }).catch((err)=>{ - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); }); ``` -### setBlur9+ +### setFocusable(deprecated) -setBlur(radius: number): void +setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void -设置窗口模糊。 +设置点击时是否支持切换焦点窗口,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | ---------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setBlur(4.0); +let isFocusable= true; +windowClass.setFocusable(isFocusable, (err) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable.'); +}); ``` -### setBackdropBlur9+ +### setFocusable(deprecated) -setBackdropBlur(radius: number): void +setFocusable(isFocusable: boolean): Promise<void> -设置窗口背景模糊。 +设置点击时是否支持切换焦点窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | ---------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.setBackdropBlur(4.0); +let isFocusable= true; +let promise = windowClass.setFocusable(isFocusable); +promise.then(()=> { + console.info('Succeeded in setting the window to be focusable.'); +}).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); +}); ``` -### setBackdropBlurStyle9+ +### setKeepScreenOn(deprecated) -setBackdropBlurStyle(blurStyle: BlurStyle): void +setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void -设置窗口背景模糊类型。 +设置屏幕是否为常亮状态,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | --------- | ---- | ---------------------- | -| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setBackdropBlurStyle(window.BlurType.THIN); +let isKeepScreenOn = true; +windowClass.setKeepScreenOn(isKeepScreenOn, (err) => { + if (err.code) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the screen to be always on.'); +}); ``` -### setShadow9+ +### setKeepScreenOn(deprecated) -setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void +setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> -设置窗口边缘阴影。 +设置屏幕是否为常亮状态,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | -| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | -| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +let isKeepScreenOn = true; +let promise = windowClass.setKeepScreenOn(isKeepScreenOn); +promise.then(() => { + console.info('Succeeded in setting the screen to be always on.'); +}).catch((err)=>{ + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); +}); ``` -### setCornerRadius9+ +### setOutsideTouchable(deprecated) -setCornerRadius(cornerRadius: number): void +setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void -设置窗口圆角半径。 +设置是否允许可点击子窗口之外的区域,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------- | +| touchable | boolean | 是 | 设置是否可点击。true表示可点击;false表示不可点击。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setCornerRadius(4.0); +windowClass.setOutsideTouchable(true, (err) => { + if (err.code) { + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the area to be touchable.'); +}) ``` -### opacity9+ +### setOutsideTouchable(deprecated) -opacity(opacity: number): void +setOutsideTouchable(touchable: boolean): Promise<void> -设置窗口透明度。 +设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | --------------------- | -| opacity | number | 是 | 透明度,范围0.0~1.0。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------- | ---- | ---------------- | +| touchable | boolean | 是 | 设置是否可点击。true表示可点击;false表示不可点击。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.opacity(0.5); +let promise = windowClass.setOutsideTouchable(true); +promise.then(()=> { + console.info('Succeeded in setting the area to be touchable.'); +}).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); +}); ``` -### scale9+ +### setPrivacyMode(deprecated) -scale(scaleOptions: ScaleOptions): void +setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -设置窗口缩放参数。 +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------------ | ---- | ---------- | -| scaleOptions | [ScaleOptions](#scaleoptions9) | 是 | 缩放参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------------------------- | ---- | -------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let obj : window.ScaleOptions = { - x : 2.0, - y : 1.0, - pivotX = 0.5; - pivotY = 0.5; -} -windowClass.scale(obj); +let isPrivacyMode = true; +windowClass.setPrivacyMode(isPrivacyMode, (err) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode.'); + +}); ``` -### rotate9+ +### setPrivacyMode(deprecated) -rotate(rotateOptions: RotateOptions): void +setPrivacyMode(isPrivacyMode: boolean): Promise<void> -设置窗口旋转参数。 +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | -------------------------------- | ---- | ---------- | -| rotateOptions | [RotateOptions](#rotateoptions9) | 是 | 旋转参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let obj : window.RotateOptions = { - x : 1.0, - y : 1.0, - z : 45.0, - pivotX = 0.5; - pivotY = 0.5; -} -windowClass.rotate(obj); +let isPrivacyMode = true; +let promise = windowClass.setPrivacyMode(isPrivacyMode); +promise.then(()=> { + console.info('Succeeded in setting the window to privacy mode.'); +}).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); +}); ``` -### translate9+ +### setTouchable(deprecated) -translate(translateOptions: TranslateOptions): void +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void -设置窗口平移参数。 +设置窗口是否为可触状态,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | -------------------------------------- | ---- | ---------- | -| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let obj : window.TranslateOptions = { - x : 100.0, - y : 0.0, - z : 0.0 -} -windowClass.translate(obj); +let isTouchable = true; +windowClass.setTouchable(isTouchable, (err) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable.'); + +}); ``` -### getTransitionController9+ +### setTouchable(deprecated) - getTransitionController(): TransitionController +setTouchable(isTouchable: boolean): Promise<void> -获取窗口属性转换控制器。 +设置窗口是否为可触状态,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | + **返回值:** -| 类型 | 说明 | -| ---------------------------------------------- | ---------------- | -| [TransitionController](#transitioncontroller9) | 属性转换控制器。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let controller = windowClass.getTransitionController(); // 获取属性转换控制器 -controller.animationForHidden = (context : window.TransitionContext) => { - let toWindow = context.toWindow - animateTo({ - duration: 1000, // 动画时长 - tempo: 0.5, // 播放速率 - curve: Curve.EaseInOut, // 动画曲线 - delay: 0, // 动画延迟 - iterations: 1, // 播放次数 - playMode: PlayMode.Normal, // 动画模式 - onFinish: ()=> { - context.completeTransition(true) - } - }, () => { - let obj : window.TranslateOptions = { - x : 100.0, - y : 0.0, - z : 0.0 - } - toWindow.translate(obj); // 设置动画过程中的属性转换 - console.info('toWindow translate end'); - } - ) - console.info('complete transition end'); -} -windowClass.hideWithAnimation((err, data) => { - if (err.code) { - console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); -}) +let isTouchable = true; +let promise = windowClass.setTouchable(isTouchable); +promise.then(()=> { + console.info('Succeeded in setting the window to be touchable.'); +}).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); +}); ``` ## WindowStageEventType9+ @@ -3484,6 +5879,15 @@ getMainWindow(callback: AsyncCallback<Window>): void | -------- | -------------------------------------- | ---- | --------------------------------------------- | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的主窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3503,6 +5907,7 @@ class myAbility extends Ability { } } ``` + ### getMainWindow9+ getMainWindow(): Promise<Window> @@ -3519,6 +5924,15 @@ getMainWindow(): Promise<Window> | -------------------------------- | ------------------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的主窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3537,6 +5951,48 @@ class myAbility extends Ability { } } ``` + +### getMainWindowSync9+ + +getMainWindowSync(): Window + +获取该WindowStage实例下的主窗口。 + +**模型约束:** 此接口仅可在Stage模型下使用。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------- | +| [Window](#window) | 返回当前WindowStage下的主窗口对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + +**示例:** + +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + try { + let windowClass = windowStage.getMainWindowSync(); + } catch (exception) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); + }; + } +} +``` + ### createSubWindow9+ createSubWindow(name: string, callback: AsyncCallback<Window>): void @@ -3554,6 +6010,15 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void | name | String | 是 | 子窗口的名字。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3562,15 +6027,19 @@ class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; - windowStage.createSubWindow('mySubWindow', (err, data) => { - if (err.code) { - console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); - }); + try { + windowStage.createSubWindow('mySubWindow', (err, data) => { + if (err.code) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); + }); + } catch (exception) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); + }; } } ``` @@ -3596,6 +6065,15 @@ createSubWindow(name: string): Promise<Window> | -------------------------------- | ------------------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3604,16 +6082,21 @@ class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; - let promise = windowStage.createSubWindow('mySubWindow'); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); - }) + try { + let promise = windowStage.createSubWindow('mySubWindow'); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); + }; } } ``` + ### getSubWindow9+ getSubWindow(callback: AsyncCallback<Array<Window>>): void @@ -3630,6 +6113,14 @@ getSubWindow(callback: AsyncCallback<Array<Window>>): void | -------- | --------------------------------------------------- | ---- | ------------------------------------------------- | | callback | AsyncCallback<Array<[Window](#window)>> | 是 | 回调函数。返回当前WindowStage下的所有子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3665,6 +6156,14 @@ getSubWindow(): Promise<Array<Window>> | --------------------------------------------- | ---------------------------------------------------- | | Promise<Array<[Window](#window)>> | Promise对象。返回当前WindowStage下的所有子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3701,6 +6200,15 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void | storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3711,13 +6219,17 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent('pages/page2',this.storage,(err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.loadContent('pages/page2',this.storage,(err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3745,6 +6257,15 @@ loadContent(path: string, storage?: LocalStorage): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3755,14 +6276,16 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - let windowClass = null; - let promise = windowStage.loadContent('pages/page2',this.storage); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - }) + try { + let promise = windowStage.loadContent('pages/page2',this.storage); + promise.then(()=> { + console.info('Succeeded in loading the content.'); + }).catch((err)=>{ + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3784,6 +6307,15 @@ loadContent(path: string, callback: AsyncCallback<void>): void | path | string | 是 | 设置加载页面的路径。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3791,13 +6323,17 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.loadContent('pages/page2', (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.loadContent('pages/page2', (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3819,6 +6355,15 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType> | type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 | | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 是 | 回调函数。返回当前的WindowStage生命周期状态。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3826,9 +6371,15 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.on('windowStageEvent', (data) => { - console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.on('windowStageEvent', (data) => { + console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + + JSON.stringify(data)); + }); + } catch (exception) { + console.error('Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; } } ``` @@ -3850,6 +6401,15 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g | type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 | | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 否 | 回调函数。返回当前的WindowStage生命周期状态。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3857,7 +6417,12 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.off('windowStageEvent'); + try { + windowStage.off('windowStageEvent'); + } catch (exception) { + console.error('Failed to disable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; } } ``` @@ -3874,6 +6439,15 @@ disableWindowDecor(): void **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -3902,7 +6476,16 @@ setShowOnLockScreen(showOnLockScreen: boolean): void | 参数名 | 类型 | 必填 | 说明 | | ---------------- | ------- | ---- | ---------------------------- | -| showOnLockScreen | boolean | 是 | 是否设置应用显示在锁屏之上。 | +| showOnLockScreen | boolean | 是 | 是否设置应用显示在锁屏之上。true表示显示在锁屏之上;false表示不显示在锁屏之上。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | **示例:** @@ -3911,7 +6494,11 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.setShowOnLockScreen(true); + try { + windowStage.setShowOnLockScreen(true); + } catch (exception) { + console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3943,7 +6530,7 @@ completeTransition(isCompleted: boolean): void | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------- | ---- | ------------------------------------------------------------ | -| isCompleted | boolean | 是 | 窗口属性转换是否完成。true:完成本次转换;false:撤销本次转换。 | +| isCompleted | boolean | 是 | 窗口属性转换是否完成。true表示完成本次转换;false表示撤销本次转换。 | **示例:** @@ -3968,9 +6555,13 @@ controller.animationForShown = (context : window.TransitionContext) => { console.info('toWindow translate end'); } ) - context.completeTransition(true) + try { + context.completeTransition(true) + } catch (exception) { + console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception)); + } console.info('complete transition end'); -} +}; ``` ## TransitionController9+ @@ -4067,4 +6658,4 @@ controller.animationForHidden = (context : window.TransitionContext) => { ) console.info('complete transition end'); } -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md index 4e86e1d8a387ab4e8d4d22d2a8b29d5daf019899..8138283e12eac6f85872a718f035bf00670afb64 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-zlib.md +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -1,23 +1,24 @@ # Zip模块(JS端SDK接口) +本模块提供压缩解压缩文件的能力 + > **说明:** > > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -## 使用限制 - -无。 ## 导入模块 ```javascript import zlib from '@ohos.zlib'; ``` -## zlib.zipFile -zipFile(inFile:string, outFile:string, options: Options): Promise<void> +## zlib.zipFile(deprecated) + zipFile(inFile:string, outFile:string, options: Options): Promise<void> 压缩接口(Promise形式)。 +> 从api9开始不再维护,建议使用[zlib.compressFile](#zlibcompressfile9) + **系统能力:** SystemCapability.BundleManager.Zlib **参数:** @@ -76,12 +77,14 @@ zlib.zipFile(inFile , outFile, options).then((data) => { }); ``` -## zlib.unzipFile +## zlib.unzipFile(deprecated) unzipFile(inFile:string, outFile:string, options: Options): Promise<void> 解压文件,解压完成返回执行结果(Promise形式)。 +> 从api9开始不再看护,建议使用[zlib.decompressFile](#zlibdecompressfile9) + **系统能力:** SystemCapability.BundleManager.Zlib **参数:** @@ -119,6 +122,193 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { ``` +## zlib.compressFile9+ + +**function** compressFile(inFile: **string**, outFile: **string**, options: Options, callback: AsyncCallback<**void**>): **void**; + +压缩文件,压缩的结果通过callback返回。成功时返回null,失败时返回错误码。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | +| outFile | string | 是 | 指定的解压文件路径 | +| options | [Options](#options) | 是 | 压缩的配置参数 | +| AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数 | + +**相关错误码** + +| 错误码 | 错误信息 | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +**示例** + +```javascript +// 【压缩例子1】 +// 代码中使用的路径需为应用的沙箱路径,如/data/storage/el2/base/haps,也可以通过context获取 +import zlib from '@ohos.zlib' +var inFile = "/xxx/filename.xxx"; +var outFile = "/xxx/xxx.zip"; +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.compressFile(inFile, outFile, options, (errData) => { + if (erData != null) { + console.log("errData is " + errData.errCode + " " + errData.message) + } + }) +} catch(errData => { + console.log("catch err " + errData.errCode + " " + errData.message) +}) +``` + +**function** compressFile(inFile:**string**, outFile:**string**, options: Options): Promise<**void**>; + +压缩文件,压缩的结果通过promise返回,成功时返回null,失败时返回错误码。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | +| outFile | string | 是 | 指定的解压文件路径 | +| options | [Options](#options) | 是 | 压缩的配置参数 | +| AsyncCallback<**void**> | callback | 否 | 压缩时的回调函数 | + +**相关错误码** + +| 错误码 | 错误信息 | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +```javascript +// 【压缩例子2】 +// 代码中使用的路径需为应用的沙箱路径,如/data/storage/el2/base/haps,也可以通过context获取 +import zlib from '@ohos.zlib' +var inFile = "/xxx/filename.xxx"; +var outFile = "/xxx/xxx.zip"; +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.compressFile(inFile, outFile, options).then(data => { + console.info("compressFile success") + }).catch(errData => { + console.info("catch err " + errData.errCode + " " + errData.message) + }) +} catch(errData => { + console.log("catch err " + errData.errCode + " " + errData.message) +}) +``` + + + +## zlib.decompressFile9+ + +**function** decompressFile(inFile: **string**, outFile: **string**, options: Options, callback: AsyncCallback<**void**>): **void**; + +解压文件,解压的结果通过callback返回,成功时返回null,失败时返回错误码。 + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | +| outFile | string | 是 | 指定的解压后的目录路径 | +| options | [Options](#options) | 是 | 解压的配置参数 | +| AsyncCallback<**void**> | callback | 否 | 解压是的回调函数 | + +**相关错误码** + +| 错误码 | 错误信息 | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +**示例** + +```javascript +// 【解压缩例子1】 +// 代码中使用的路径需为应用的沙箱路径,如/data/storage/el2/base/haps,也可以通过context获取 +import zlib from '@ohos.zlib' +var inFile = "/xx/xxx.zip"; +var outFile = "/xxx"; +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; +try { + zlib.decompressFile(inFile, outFile, options, (errData) => { + if (erData != null) { + console.log("errData is " + errData.errCode + " " + errData.message) + } + }) +} catch(errData => { + console.log("catch err " + errData.errCode + " " + errData.message) +}) +``` + +**function** decompressFile(inFile: **string**, outFile: **string**, options: Options): Promise<**void**>; + +解压文件,解压的结果通过promise返回,成功时返回null,失败时返回错误码。 + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | +| outFile | string | 是 | 指定的解压后的目录路径 | +| options | [Options](#options) | 是 | 解压时的配置参数 | + +**相关错误码** + +| 错误码 | 错误信息 | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +```javascript +// 【解压缩例子2】 +// 代码中使用的路径需为应用的沙箱路径,如/data/storage/el2/base/haps,也可以通过context获取 +import zlib from '@ohos.zlib' +var inFile = "/xx/xxx.zip"; +var outFile = "/xxx"; +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; +try { + zlib.compressFile(inFile, outFile, options).then(data => { + console.info("compressFile success") + }).catch(errData => { + console.info("catch err " + errData.errCode + " " + errData.message) + }) +} catch(errData => { + console.log("catch err " + errData.errCode + " " + errData.message) +}) +``` + ## Options **系统能力:** SystemCapability.BundleManager.Zlib diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md index cbf543e21600743e9f5a522b8c74f8355c894d18..0d5f9a9f15f924edce8872ac7d34e5413a30297b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md @@ -29,19 +29,20 @@ ```js // xxx.js export default { - onShow(){ - const el =this.$refs.canvas; - var ctx =el.getContext('2d'); - var img = new Image(); - img.src = 'common/images/example.jpg'; - img.onload = function() { - console.log('Image load success'); - ctx.drawImage(img, 0, 0, 360, 250); - }; - img.onerror = function() { - console.log('Image load fail'); - }; - } + onShow() { + const el = this.$refs.canvas; + var ctx = el.getContext('2d'); + var img = new Image(); + // 图片路径建议放在common目录下 + img.src = 'common/images/example.jpg'; + img.onload = function () { + console.log('Image load success'); + ctx.drawImage(img, 0, 0, 360, 250); + }; + img.onerror = function () { + console.log('Image load fail'); + }; + } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/relativecontainer.png b/zh-cn/application-dev/reference/arkui-ts/figures/relativecontainer.png index ebe9c3c7f6ba5ba6756b61f757894cc3f69014bf..574fcaa48023d14a579eaa843ebc59f1b961a29f 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/relativecontainer.png and b/zh-cn/application-dev/reference/arkui-ts/figures/relativecontainer.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md index cc8d763c17ca1ba2368d6f3570b348272f2ef1f8..bcabffd14afc2f668cb5e6c15571fe572eb05ac3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md @@ -22,7 +22,7 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------- | -------- | ----- | -------- | -| values | number[] | 是 | 数据值列表,最大支持9个数据。 | +| values | number[] | 是 | 数据值列表,最多包含9个数据,大于9个数据则取前9个数据。若数据值小于0则置为0。 | | max | number | 否 | - max大于0,表示数据的最大值。
- max小于等于0,max等于value数组各项的和,按比例显示。
默认值:100 | | type8+ | [DataPanelType](#datapaneltype枚举说明) | 否 | 数据面板的类型。
默认值:DataPanelType.Circle | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md index 52bfcd5ba688f84db5e9dc57264545caa4453b89..a6031d9440bc49619853cc154bd01b5d5e13852f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -43,7 +43,7 @@ Gauge(options:{value: number, min?: number, max?: number}) | 名称 | 类型定义 | 描述 | | --------- | -------------------- | ------------------------------------------------------------ | -| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | 描述渐进色颜色断点类型,第一个参数为颜色值,第二个参数为0~1之间的比例值。 | +| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | 描述渐进色颜色断点类型,第一个参数为颜色值,若设置为非颜色类型,则置为黑色。第二个参数为颜色所占比重,若设置为负数或是非数值类型,则将比重置为0,该颜色不显示。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index e9155e11faaea76c751d01fbe8bffb0a5cee9c8b..d13a14c6835699a69d9f5e88211b0ef8d0e8bf11 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -1,6 +1,6 @@ # TextArea -可以输入多行文本并支持响应部分输入事件的组件。 +多行文本输入框组件,当输入的文本内容超过组件宽度时会自动换行显示。 > **说明:** > @@ -20,7 +20,7 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------------- | ---------------------------------------- | ---- | -------------- | -| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 无输入时的提示文本。 | +| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。 | | text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。 | | controller8+ | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 | @@ -33,10 +33,10 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | ------------------------ | ---------------------------------------- | ---------------------------------------- | | placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。 | | placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本水平对齐式。
默认值:TextAlign.Start | +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在输入框中的水平对齐式。
默认值:TextAlign.Start | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。 | -| inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | 通过正则表达式设置输入过滤器。满足表达式的输入允许显示,不满足的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,不支持过滤8到10位的强密码。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置文本是否可复制。 | +| inputFilter8+ | {
value: [ResourceStr](ts-types.md#resourcestr),
error?: (value: string) => void
} | 通过正则表达式设置输入过滤器。匹配表达式的输入允许显示,不匹配的输入将被过滤。仅支持单个字符匹配,不支持字符串匹配。
- value:设置正则表达式。
- error:正则匹配失败时,返回被过滤的内容。 | +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。 | ## 事件 @@ -45,14 +45,14 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | 名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| onChange(callback: (value: string) => void) | 输入发生变化时,触发回调。 | -| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
- value:复制的文本内容。 | -| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
- value:剪切的文本内容。 | -| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
- value:粘贴的文本内容。 | +| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发该回调。
- value:当前输入的文本内容。 | +| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发该回调。
- value:复制的文本内容。 | +| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发该回调。
- value:剪切的文本内容。 | +| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发该回调。
- value:粘贴的文本内容。 | ## TextAreaController8+ -TextArea组件的控制器,通过它操作TextArea组件。 +TextArea组件的控制器,目前可通过它设置TextArea组件的光标位置。 ### 导入对象 @@ -75,63 +75,32 @@ caretPosition(value: number): void ## 示例 - -### 多行文本输入 - ```ts // xxx.ets @Entry @Component -struct TextAreaExample1 { - controller: TextAreaController = new TextAreaController() +struct TextAreaExample { @State text: string = '' + controller: TextAreaController = new TextAreaController() + build() { Column() { - TextArea({ placeholder: 'input your word', controller: this.controller}) - .placeholderColor("rgb(0,0,225)") - .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) - .textAlign(TextAlign.Center) - .caretColor(Color.Blue) - .height(50) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .fontFamily("sans-serif") - .fontStyle(FontStyle.Normal) - .fontColor(Color.Red) - .inputFilter('^[\u4E00-\u9FA5A-Za-z0-9_]+$',(value: string) => { - console.info("hyb"+value) - }) + TextArea({ placeholder: 'input your word', controller: this.controller }) + .placeholderFont({ size: 14, weight: 400 }) + .width(400) + .margin(20) + .fontSize(14) .onChange((value: string) => { this.text = value - this.controller.caretPosition(-1) }) - Text(this.text).width('90%') - } + Text(this.text) + Button('Set caretPosition 1') + .margin(15) + .onClick(() => { + // 设置光标位置到第一个字符后 + this.controller.caretPosition(1) + }) + }.width('100%') } } ``` - -![zh-cn_image_0000001251087311](figures/zh-cn_image_0000001251087311.gif) - - -### 设置光标 - -```ts -// xxx.ets -@Entry -@Component -struct TextAreaExample2 { - controller: TextAreaController = new TextAreaController() - build() { - Column() { - TextArea({ placeholder: 'input your word',controller:this.controller }) - Button('caretPosition') - .onClick(() => { - this.controller.caretPosition(4) - }) - } - } -} -``` - -![zh-cn_image_0000001252653499](figures/zh-cn_image_0000001252653499.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-relativecontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-relativecontainer.md index 3d46fe5c2ead4d6359b428220f6f75928aa1fe8d..96d969831d568a1c6314379297d7b1f2c4c98a0d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-relativecontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-relativecontainer.md @@ -10,18 +10,16 @@ ## 规则说明 * 容器内子组件区分水平方向,垂直方向: - * 水平方向为left, middle, right,对应容器的HorizontalAlign.Start, HorizontalAlign.Center, HorizontalAlign.End。 + * 水平方向为left, middle, right,对应容器的HorizontalAlign.Start, HorizontalAlign.Center, HorizontalAlign.End。 * 垂直方向为top, center, bottom,对应容器的VerticalAlign.Top, VerticalAlign.Center, VerticalAlign.Bottom。 * 子组件可以将容器或者其他子组件设为锚点: - * 参与相对布局的容器内组件必须设置id,容器RelativeContainer的id固定为'__container__'。 - * 无id的子组件位置设置默认为容器左上方。 - * 此子组件某一方向上的三个位置可以将容器或其他子组件的同方向三个位置为锚点,同方向上两个以上位置设置锚点以后会跳过第三个。 - * 同方向上两个以上位置设置锚点时此子组件额外设置width,height不生效。 - * 对齐后需要额外偏移可设置offset。 + * 参与相对布局的容器内组件必须设置id,容器id固定为__container__。 + * 此子组件某一方向上的三个位置可以将容器或其他子组件的同方向三个位置为锚点,同方向上两个以上位置设置锚点以后会跳过第三个。 + * 前端页面设置的子组件尺寸大小不会受到相对布局规则的影响。 + * 对齐后需要额外偏移可设置offset。 * 特殊情况 - * 互相依赖,环形依赖时容器内子组件全部不绘制。 - * 同方向上两个以上位置设置锚点但锚点位置逆序时此子组件大小为0,即不绘制。 - + * 互相依赖,环形依赖时容器内子组件全部不绘制。 + * 同方向上两个以上位置设置锚点但锚点位置逆序时此子组件大小为0,即不绘制。 ## 子组件 @@ -42,64 +40,59 @@ struct Index { Row() { Button("Extra button").width(100).height(50) - // 外层容器的id默认为为'__container__' RelativeContainer() { Button("Button 1") .width(120) .height(30) .alignRules({ - middle: { anchor: "__container__", align: HorizontalAlign.Center }, // 水平方向上,组件中部与容器中间对齐,即组件在容器中水平居中 + middle: { anchor: "__container__", align: HorizontalAlign.Center }, }) - .id("bt1") // id设置为bt1 + .id("bt1") .borderWidth(1) .borderColor(Color.Black) Text("This is text 2") .fontSize(20) .padding(10) - .borderWidth(1) - .borderColor(Color.Black) - .height(30) - .id("tx2") // id设置为tx2 .alignRules({ - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, // 组件下边与容器下边对齐 - top: { anchor: "bt1", align: VerticalAlign.Bottom }, // 组件上边与button1底部对齐 - right: { anchor: "bt1", align: HorizontalAlign.Center } // 组件右侧与button1中间点对齐 + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, + top: { anchor: "bt1", align: VerticalAlign.Bottom }, + right: { anchor: "bt1", align: HorizontalAlign.Center } }) - - LoadingProgress() - .color(Color.Blue) + .id("tx2") .borderWidth(1) .borderColor(Color.Black) .height(30) - .width(30) - .id("lp3") // id设置为lp3 + + Button("Button 3") + .width(100) + .height(100) .alignRules({ - left: { anchor: "bt1", align: HorizontalAlign.End }, // 组件左边对齐容器bt1的右边 - top: { anchor: "tx2", align: VerticalAlign.Center }, // 组件上边对齐容器tx2的中间 - bottom: { anchor: "__container__", align: VerticalAlign.Bottom } // 组件下边对齐最外层容器的底边 + left: { anchor: "bt1", align: HorizontalAlign.End }, + top: { anchor: "tx2", align: VerticalAlign.Center }, + bottom: { anchor: "__container__", align: VerticalAlign.Bottom } }) + .id("bt3") + .borderWidth(1) + .borderColor(Color.Black) - Gauge({ value: 50, min: 0, max: 100 }) - .startAngle(210) - .endAngle(150) - .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) - .strokeWidth(20) - .width(50) - .height(50) + Text("This is text 4") + .fontSize(20) + .padding(10) .alignRules({ - left: { anchor: "tx2", align: HorizontalAlign.End }, // 组件左边对齐容器tx2的右边 - right: { anchor: "__container__", align: HorizontalAlign.End }, // 组件右边对齐最外层容器的右边 - top: { anchor: "__container__", align: VerticalAlign.Top }, // 组件上边对齐最外层容器的上边 - bottom: { anchor: "lp3", align: VerticalAlign.Top } // 组件下边对齐容器lp3的上边 + left: { anchor: "tx2", align: HorizontalAlign.End }, + right: { anchor: "__container__", align: HorizontalAlign.End }, + top: { anchor: "__container__", align: VerticalAlign.Top }, + bottom: { anchor: "bt3", align: VerticalAlign.Top } }) - .id("g4") + .id("tx4") .borderWidth(1) .borderColor(Color.Black) } .width(200).height(200) .backgroundColor(Color.Orange) - }.height('100%') + } + .height('100%') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 3ef11f73e3e90adfc0eccd69fa76bbf51027be4d..1e6a02dd7a8cbd08fb7d8ce6a942123103e9bdfd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -59,13 +59,6 @@ SideBarContainer( type?: SideBarContainerType ) | Start | 侧边栏位于容器左侧。 | | End | 侧边栏位于容器右侧。 | -## SideBarPosition9+枚举说明 - -| 名称 | 描述 | -| -------- | -------- | -| Start | 侧边栏位于容器左侧。 | -| End | 侧边栏位于容器右侧。 | - ## 事件 | 名称 | 功能描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index 7b442f93de876c69c909970fee623809819adfb1..7330ab11ee2cca5e1c9ba87f81952b0fd4cae3f3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -1,15 +1,12 @@ # 日期滑动选择器弹窗 -根据指定范围的Date创建可以选择日期的滑动选择器,展示在弹窗上。 +根据指定的日期范围创建日期滑动选择器,展示在弹窗上。 > **说明:** +> > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - ## DatePickerDialog.show show(options?: DatePickerDialogOptions) @@ -17,83 +14,70 @@ show(options?: DatePickerDialogOptions) 定义日期滑动选择器弹窗并弹出。 - DatePickerDialogOptions参数说明 + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | - | start | Date | 否 | Date('1970-1-1') | 指定选择器的起始日期。 | - | end | Date | 否 | Date('2100-12-31') | 指定选择器的结束日期。 | - | selected | Date | 否 | 当前系统日期 | 设置选中项的日期。 | - | lunar | boolean | 否 | false | 日期是否显示农历。 | - | onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 点击弹窗中确定按钮时触发。 | - | onCancel | () => void | 否 | - | 点击弹窗中取消按钮时触发。 | - | onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 滑动选择器,当前选择项改变时触发。 | + | start | Date | 否 | Date('1970-1-1') | 设置选择器的起始日期。 | + | end | Date | 否 | Date('2100-12-31') | 设置选择器的结束日期。 | + | selected | Date | 否 | 当前系统日期 | 设置当前选中的日期。 | + | lunar | boolean | 否 | false | 日期是否显示为农历。 |确定 + | onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 点击弹窗中的“确定”按钮时触发该回调。 | + | onCancel | () => void | 否 | - | 点击弹窗中的“取消”按钮时触发该回调。 | + | onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。 | ## 示例 -### 日期滑动选择器(显示农历)示例 ```ts // xxx.ets @Entry @Component -struct DatePickerDialogExample01 { - @State isLunar: boolean = true - selectedDate: Date = new Date("2000-1-1") +struct DatePickerDialogExample { + selectedDate: Date = new Date("2010-1-1") build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center }) { - Button("DatePickerDialog").onClick(() => { - DatePickerDialog.show({ - start: new Date("2000-1-1"), - end: new Date("2005-1-1"), - selected: this.selectedDate, - lunar: this.isLunar, - onAccept: (value: DatePickerResult) => { - this.selectedDate.setFullYear(value.year, value.month, value.day) - console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) - }, - onCancel: () => { - console.info("DatePickerDialog:onCancel()") - }, - onChange: (value: DatePickerResult) => { - console.info("DatePickerDialog:onChange()" + JSON.stringify(value)) - } + Column() { + Button("DatePickerDialog") + .margin(20) + .onClick(() => { + DatePickerDialog.show({ + start: new Date("2000-1-1"), + end: new Date("2100-12-31"), + selected: this.selectedDate, + onAccept: (value: DatePickerResult) => { + // 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期 + this.selectedDate.setFullYear(value.year, value.month, value.day) + console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) + }, + onCancel: () => { + console.info("DatePickerDialog:onCancel()") + }, + onChange: (value: DatePickerResult) => { + console.info("DatePickerDialog:onChange()" + JSON.stringify(value)) + } + }) }) - }) - } - } -} -``` -### 日期滑动选择器(不显示农历)示例 -```ts -// xxx.ets -@Entry -@Component -struct DatePickerDialogExample02 { - @State isLunar: boolean = false - selectedDate: Date = new Date("2000-1-1") - build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center }) { - Button("DatePickerDialog").onClick(() => { - DatePickerDialog.show({ - start: new Date("2000-1-1"), - end: new Date("2005-1-1"), - selected: this.selectedDate, - lunar: this.isLunar, - onAccept: (value: DatePickerResult) => { - this.selectedDate.setFullYear(value.year, value.month, value.day) - console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) - }, - onCancel: () => { - console.info("DatePickerDialog:onCancel()") - }, - onChange: (value: DatePickerResult) => { - console.info("DatePickerDialog:onChange()" + JSON.stringify(value)) - } + Button("Lunar DatePickerDialog") + .margin(20) + .onClick(() => { + DatePickerDialog.show({ + start: new Date("2000-1-1"), + end: new Date("2100-12-31"), + selected: this.selectedDate, + lunar: true, + onAccept: (value: DatePickerResult) => { + this.selectedDate.setFullYear(value.year, value.month, value.day) + console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) + }, + onCancel: () => { + console.info("DatePickerDialog:onCancel()") + }, + onChange: (value: DatePickerResult) => { + console.info("DatePickerDialog:onChange()" + JSON.stringify(value)) + } + }) }) - }) - } + }.width('100%') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 95cf090c374104933239a351e082ee7bc421e568..25576aa891bb8f00d951d26a3cc62c67156458a6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -3,13 +3,10 @@ 根据指定的选择范围创建文本选择器,展示在弹窗上。 > **说明:** +> > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - ## TextPickerDialog.show show(options?: TextPickerDialogOptions) @@ -17,21 +14,23 @@ show(options?: TextPickerDialogOptions) 定义文本滑动选择器弹窗并弹出。 - TextPickerDialogOptions参数说明 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | range | string[] \| [Resource](../../ui/ts-types.md#resource类型) | 是 | - | 选择器的数据选择范围。 | - | selected | number | 否 | 0 | 选中项在数组中的index值。 | - | value | string | 否 | - | 选中项文本值。当设置了selected参数时,该值不生效。如果该值不在range范围内,则默认取range第一个元素。| - | defaultPickerItemHeight | number \| string | 否 | - | 默认Picker内容项元素高度。 | - | onAccept | (value: TextPickerResult) => void | 否 | - | 点击弹窗中确定按钮时触发。 | - | onCancel | () => void | 否 | - | 点击弹窗中取消按钮时触发。 | - | onChange | (value: TextPickerResult) => void | 否 | - | 滑动选择器,当前选择项改变时触发。 | + + | 参数名 | 参数类型 | 必填 | 参数描述 | + | -------- | -------- | -------- | -------- | + | range | string[] \| [Resource](../../ui/ts-types.md#resource类型) | 是 | 设置文本选择器的选择范围。 | + | selected | number | 否 | 设置选中项的索引值。
默认值:0 | + | value | string | 否 | 设置选中项的文本内容。当设置了selected参数时,该参数不生效。如果设置的value值不在range范围内,则默认取range第一个元素。| + | defaultPickerItemHeight | number \| string | 否 | 设置选择器中选项的高度。 | + | onAccept | (value: TextPickerResult) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | + | onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | + | onChange | (value: TextPickerResult) => void | 否 | 滑动弹窗中的选择器使当前选中项改变时触发该回调。 | - TextPickerResult对象说明 - | 名称 | 参数类型 | 描述 | + + | 名称 | 类型 | 描述 | | -------- | -------- | -------- | - | value | string | 选中项文本。 | - | index | number | 选中项在数组中的index值。 | + | value | string | 选中项的文本内容。 | + | index | number | 选中项在选择范围数组中的索引值。 | ## 示例 @@ -40,29 +39,31 @@ show(options?: TextPickerDialogOptions) @Entry @Component struct TextPickerDialogExample { - @State select: number = 1 - private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] + @State select: number = 2 + private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5'] build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center }) { - Button("TextPickerDialog").onClick(() => { - TextPickerDialog.show({ - range: this.fruits, - selected: this.select, - onAccept: (value: TextPickerResult) => { - console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) - this.select = value.index - }, - onCancel: () => { - console.info("TextPickerDialog:onCancel()") - }, - onChange: (value: TextPickerResult) => { - console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) - } + Column() { + Button("TextPickerDialog") + .margin(20) + .onClick(() => { + TextPickerDialog.show({ + range: this.fruits, + selected: this.select, + onAccept: (value: TextPickerResult) => { + // 设置select为按下确定按钮时候的选中项index,这样当弹窗再次弹出时显示选中的是上一次确定的选项 + this.select = value.index + console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) + }, + onCancel: () => { + console.info("TextPickerDialog:onCancel()") + }, + onChange: (value: TextPickerResult) => { + console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) + } + }) }) - }) - } + }.width('100%') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index 494aabc0122e49cb4a09f9b8e67b0143db07013e..76ea01dc98ffc8ac952cba14b5192b8bebcc26da 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -1,8 +1,9 @@ # 时间滑动选择器弹窗 -默认以00:00至23:59的时间区间创建滑动选择器,展示在弹窗上。 +以24小时的时间区间创建时间滑动选择器,展示在弹窗上。 > **说明:** +> > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## TimePickerDialog.show @@ -11,79 +12,64 @@ show(options?: TimePickerDialogOptions) 定义时间滑动选择器弹窗并弹出。 -- options参数 +- TimePickerDialogOptions参数 + | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | - | selected | Date | 否 | 设置选中项的时间。
默认值:当前系统时间 | - | useMilitaryTime | boolean | 否 | 展示时间是否为24小时制。
默认值:false | - | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中确定按钮时触发。 | - | onCancel | () => void | 否 | 点击弹窗中取消按钮时触发。 | - | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动选择器,当前选择项改变时触发。 | + | selected | Date | 否 | 设置当前选中的时间。
默认值:当前系统时间 | + | useMilitaryTime | boolean | 否 | 展示时间是否为24小时制,默认为12小时制。
默认值:false | + | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | + | onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | + | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动弹窗中的选择器使当前选中时间改变时触发该回调。 | ## 示例 -### 时间滑动选择器(24小时制)示例 ```ts // xxx.ets @Entry @Component -struct TimePickerDialogExample01 { - @State isUseMilitaryTime: boolean = true; - private selectTime: Date = new Date('7/22/2022 12:45:00'); +struct TimePickerDialogExample { + private selectTime: Date = new Date('2020-12-25T08:30:00') build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center }) { - Button("TimePickerDialog").onClick(() => { - TimePickerDialog.show({ - selected:this.selectTime, - useMilitaryTime: this.isUseMilitaryTime, - onAccept: (value: TimePickerResult) => { - console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)); - }, - onCancel: () => { - console.info("TimePickerDialog:onCancel()"); - }, - onChange: (value: TimePickerResult) => { - console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); - } + Column() { + Button("TimePickerDialog 12小时制") + .margin(20) + .onClick(() => { + TimePickerDialog.show({ + selected: this.selectTime, + onAccept: (value: TimePickerResult) => { + // 设置selectTime为按下确定按钮时的时间,这样当弹窗再次弹出时显示选中的为上一次确定的时间 + this.selectTime.setHours(value.hour, value.minute) + console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)); + }, + onCancel: () => { + console.info("TimePickerDialog:onCancel()"); + }, + onChange: (value: TimePickerResult) => { + console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); + } + }) }) - }) - } - } -} -``` - ![zh-cn_image_0000001118642010](figures/zh-cn_image_0000001118642010.gif) - -### 时间滑动选择器(12小时制)示例 - -```ts -// xxx.ets -@Entry -@Component -struct TimePickerDialogExample02 { - @State isUseMilitaryTime: boolean = false; - - build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, - justifyContent: FlexAlign.Center }) { - Button("TimePickerDialog").onClick(() => { - TimePickerDialog.show({ - useMilitaryTime: this.isUseMilitaryTime, - onAccept: (value: TimePickerResult) => { - console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) - }, - onCancel: () => { - console.info("TimePickerDialog:onCancel()"); - }, - onChange: (value: TimePickerResult) => { - console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); - } + Button("TimePickerDialog 24小时制") + .margin(20) + .onClick(() => { + TimePickerDialog.show({ + selected: this.selectTime, + useMilitaryTime: true, + onAccept: (value: TimePickerResult) => { + this.selectTime.setHours(value.hour, value.minute) + console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)); + }, + onCancel: () => { + console.info("TimePickerDialog:onCancel()"); + }, + onChange: (value: TimePickerResult) => { + console.info("TimePickerDialog:onChange()" + JSON.stringify(value)); + } + }) }) - }) - } + }.width('100%') } } -``` - - ![zh-cn_image_0000001118642020](figures/zh-cn_image_0000001118642020.gif) \ No newline at end of file +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md new file mode 100644 index 0000000000000000000000000000000000000000..183bf1b8c250b333bf0be5c475bdfb7a2542342d --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md @@ -0,0 +1,733 @@ +# 状态管理 + +状态管理模块提供了应用程序的数据存储能力、持久化数据管理能力、Ability数据存储能力和应用程序需要的环境状态,其中Ability数据存储从API version9开始支持。 + +> 说明:本模块首批接口从API version 7开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## AppStorage + +### Link + +Link(propName: string): any + +与localStorage双向数据绑定。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | :--------------------- | +| propName | string | 是 | 要双向绑定的属性名称。 | + +**返回值:** + +| 类型 | 描述 | +| ----- | ------------------------------------------------------------ | +| @Link | 在具有给定键的数据,则返回到此属性的双向数据绑定,该双向绑定意味着变量或者组件对数据的更改将同步到AppStorage,通过AppStorage对数据的修改将同步到变量或者组件。 | + +```ts +let simple = AppStorage.Link('simpleProp'); +``` + +### SetAndLink + +SetAndLink\(propName: string, defaultValue: T): SubscribedAbstractProperty\ + +与Link接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Link返回。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------------ | ------ | :--- | -------------------- | +| propName | string | 是 | 要进行创建的key值。 | +| defaultValue | T | 是 | 要进行设置的默认值。 | + +**返回值:** + +| 类型 | 描述 | +| ----- | ------------------------------------------------------------ | +| @Link | 与Link接口类似,如果当前的key保存于LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Link返回。 | + +```ts +let simple = AppStorage.SetAndLink('simpleProp',121); +``` + +### Prop + +Prop(propName: string): any + +单向属性绑定的一种。更新组件的状态。。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--: | ------------------- | +| propName | string | 是 | 要进行创建的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ----- | ------------------------------------------------------------ | +| @Prop | 如果存在具有给定键的属性,则返回此属性的单向数据绑定。该单向绑定意味着只能通过AppStorage将属性的更改同步到变量或者组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态属性,如果具有此键的属性不存在则返回undefined。 | + +```ts +let simple = AppStorage.Prop('simpleProp'); +``` + +### SetAndProp + +SetAndProp\(propName: string, defaultValue: S): SubscribedAbstractProperty\; + +与Prop接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Prop返回。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------------ | ------ | :--: | --------------------------- | +| propName | string | 是 | 要保存的的键值对中的key值。 | +| defaultValue | S | 是 | 创建的默认值。 | + +**返回值:** + +| 类型 | 描述 | +| ----- | ------------------------------------------------------------ | +| @Prop | 如果当前的key保存与LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Prop返回。 | + +```ts +let simple = AppStorage.SetAndProp('simpleProp',121); +``` + +### Has + +Has(propName: string): boolean + +判断对应键值的属性是否存在。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | -------------- | +| propName | string | 是 | 属性的属性值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | -------------------------- | +| boolean | 返回属性的属性值是否存在。 | + +```ts +let simple = AppStorage.Has('simpleProp'); +``` + +### Get + +Get\(propName: string): T | undefined + +通过此接口获取对应key值的value。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | ---- | ------------------- | +| propName | string | 是 | 要获取对应的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ------------------ | -------------------------- | +| boolean或undefined | 返回属性的属性值是否存在。 | + +```ts +let simple = AppStorage.Get('simpleProp'); +``` + +### Set + +Set(propName: string, newValue: T): boolean + +对已保存的key值,替换其value值。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ----------------- | +| propName | string | 是 | 要设置的key值。 | +| newValue | T | 是 | 要设置的value值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ----------------------------------------------------- | +| boolean | 如果存在key值,设置value值并返回true,否则返回false。 | + +```ts +let simple = AppStorage.Set('simpleProp'); +``` + +### SetOrCreate + +SetOrCreate(propName: string, newValue: T): void + +创建或更新setOrCreate内部的值。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ------------------------- | +| propName | string | 是 | 要更新或者创建的key值。 | +| newValue | T | 是 | 要更新或者创建的value值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 如果已存在与给定键名字相同的属性,更新其值且返回true。如果不存在具有给定名称的属性,在LocalStorage中创建具有给定默认值的新属性,默认值必须是T类型。不允许undefined 或 null 返回true。 | + +```ts +let simple = AppStorage.SetOrCreate('simpleProp',121); +``` + +### Delete + +Delete(propName: string): boolean + +删除key指定的键值对。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | --------------------- | +| propName | string | 是 | 要删除的属性的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 删除key指定的键值对,如果存在且删除成功返回true,不存在或删除失败返回false。 | + +```ts +let simple = AppStorage.Delete('simpleProp'); +``` + +### keys + +keys(): IterableIterator\ + +查找所有键。 + +**返回值:** + +| 类型 | 描述 | +| -------------- | ---------------------------- | +| array\ | 返回包含所有键的字符串数组。 | + +```ts +let simple = AppStorage.Keys(); +``` + +### staticClear + +staticClear(): boolean + +删除所有的属性。 + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 删除所有的属性,如果当前有状态变量依旧引用此属性,返回false。 | + +```ts +let simple = AppStorage.staticClear(); +``` + +### IsMutable + +IsMutable(propName: string): boolean + +查询属性及状态。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | --------------------- | +| propName | string | 是 | 要查询的属性的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------ | +| boolean | 返回此属性是否存在并且是否可以改变。 | + +```ts +let simple = AppStorage.IsMutable(); +``` + +### Size + +Size(): number + +存在的键值对的个数。 + +**返回值:** + +| 类型 | 描述 | +| ------ | ------------------ | +| number | 返回键值对的数量。 | + +```ts +let simple = AppStorage.Size(); +``` + +## LocalStorage9+ + +### constructor9+ + +constructor(initializingProperties?: Object) + +创建一个新的LocalStorage对象,并进行初始化。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ---------------------- | ------ | ---- | ------------------------------------------------------------ | +| initializingProperties | Object | 否 | object.keys(obj)返回的所有对象属性及其值都将添加到LocalStorage。 | + +```ts +this.storage = new LocalStorage(); +``` + +### GetShared9+ + +static GetShared(): LocalStorage + +获取当前的共享的LocalStorage对象。 + +此接口仅可在Stage模型下使用。 + +**返回值:** + +| 类型 | 描述 | +| ----------------------------- | ---------------------- | +| [LocalStorage](#localstorage) | 返回LocalStorage对象。 | + +```ts +let storage = LocalStorage.GetShared(); +``` + +### has9+ + +has(propName: string): boolean + +判断属性值是否存在。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | -------------- | +| propName | string | 是 | 属性的属性值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | -------------------------- | +| boolean | 返回属性的属性值是否存在。 | + +```ts +this.storage = new LocalStorage(); +this.storage.has("storageSimpleProp"); +``` + +### get9+ + +get\(propName: string): T + +获取对应key值的value。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ------------------- | +| propName | string | 是 | 要获取对应的key值。 | + +**返回值:** + +| 类型 | 描述 | +| -------------- | ------------------------------------------------------- | +| T \| undefined | 当keyvalue存在时,返回keyvalue值。不存在返回undefined。 | + +```ts +this.storage = new LocalStorage(); +let simpleValue = this.storage.get("storageSimpleProp"); +``` + +### set9+ + +set\(propName: string, newValue: T): boolean + +存储对象值。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ----------------- | +| propName | string | 是 | 要设置的key值。 | +| newValue | T | 是 | 要设置的value值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ----------------------------------------------------- | +| boolean | 如果存在key值,设置value值并返回true,否则返回false。 | + +```ts +this.storage = new LocalStorage(); +this.storage.set("storageSimpleProp",121); +``` + +### setOrCreate9+ + +setOrCreate\(propName: string, newValue: T): boolean + +创建或更新setOrCreate内部的值。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ----------------------- | +| propName | string | 是 | 要更新或创建的key值。 | +| newValue | T | 是 | 要更新或创建的value值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 如果已存在与给定键名字相同的属性,更新其值且返回true。如果不存在具有给定名称的属性,在LocalStorage中创建具有给定默认值的新属性,默认值必须是T类型。不允许undefined 或 null 返回true。 | + +```ts +this.storage = new LocalStorage(); +this.storage.setOrCreate("storageSimpleProp",121); +``` + +### link9+ + +link\(propName: string): T + +与localStorage双向数据绑定。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ---------------------- | +| propName | string | 是 | 要双向绑定的属性名称。 | + +**返回值:** + +| 类型 | 描述 | +| ---- | ------------------------------------------------------------ | +| T | 如果存在具有给定键的属性,返回到此属性的双向绑定,该双向绑定意味着变量或者组件对数据的更改将同步到LocalStorage,然后通过LocalStorage实例同步到任何变量或组件。如果不存在给定键的属性,返回undefined。 | + +```ts +this.storage = new LocalStorage(); +let localStorage = this.storage.link("storageSimpleProp"); +``` + +### setAndLink9+ + +setAndLink\(propName: string, defaultValue: T): T + +与link接口类似,双向数据绑定localStorage。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------------ | ------ | :--- | -------------------- | +| propName | string | 是 | 要进行创建的key值。 | +| defaultValue | T | 是 | 要进行设置的默认值。 | + +**返回值:** + +| 类型 | 描述 | +| ------------------------------------ | ------------------------------------------------------------ | +| @Link | 与Link接口类似,如果当前的key保存于LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Link返回。 | + +```ts +this.storage = new LocalStorage(); +let localStorage = this.storage.setAndLink("storageSimpleProp",121); +``` + +### prop9+ + +prop\(propName: string): T + +单向属性绑定的一种。更新组件的状态。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | ----------------------- | +| propName | string | 是 | 要单向数据绑定的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ------------------------------------ | ------------------------------------------------------------ | +| @Prop | 如果存在具有给定键的属性,返回此属性的单向数据绑定。该单向绑定意味着只能通过LocalStorage将属性的更改同步到变量或组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态变量。如果此键的属性不存在则返回undefined。 | + +```ts +this.storage = new LocalStorage(); +let localStorage = this.storage.prop("storageSimpleProp"); +``` + +### setAndProp9+ + +setAndProp\(propName: string, defaultValue: T): T + +与Prop接口类似,存在localStorage的单向数据绑定prop值。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------------ | ------ | :--- | ------------------------- | +| propName | string | 是 | 要保存的键值对中的key值。 | +| defaultValue | T | 是 | 创建的默认值。 | + +**返回值:** + +| 类型 | 描述 | +| ------------------------------------ | ------------------------------------------------------------ | +| @Prop | 如果当前的key保存与LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Prop返回。 | + +```ts +this.storage = new LocalStorage(); +let localStorage = this.storage.setAndProp("storageSimpleProp",121); +``` + +### delete9+ + +delete(propName: string): boolean + +删除key指定的键值对。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| -------- | ------ | :--- | --------------------- | +| propName | string | 是 | 要删除的属性的key值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 删除key指定的键值对,如果存在且删除成功返回true,不存在或删除失败返回false。 | + +```ts +this.storage = new LocalStorage(); +this.storage.delete("storageSimpleProp"); +``` + +### keys9+ + +keys(): IterableIterator\ + +查找所有键。 + +**返回值:** + +| 类型 | 描述 | +| -------------- | ---------------------------- | +| array\ | 返回包含所有键的字符串数组。 | + +```ts +this.storage = new LocalStorage(); +let simple = this.storage.keys(); +``` + +### size9+ + +size(): number + +存在的键值对的个数。 + +**返回值:** + +| 类型 | 描述 | +| ------ | ------------------ | +| number | 返回键值对的数量。 | + +```ts +this.storage = new LocalStorage(); +let simple = this.storage.size(); +``` + +### Clear9+ + +clear(): boolean + +删除所有的属性。 + +**返回值:** + +| 类型 | 描述 | +| ------- | ------------------------------------------------------------ | +| boolean | 删除所有的属性,如果当前有状态变量依旧引用此属性,返回false。 | + +```ts +this.storage = new LocalStorage(); +let simple = this.storage.clear(); +``` + +## persistentstorage + +### constructor + +constructor(appStorage: AppStorage, storage: Storage) + +创建一个新的persistentstorage对象。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ---------- | ---------- | :--- | -------------------------------- | +| appStorage | AppStorage | 是 | 保存所有属性及属性值的单例对象。 | +| storage | Storage | 是 | Storage实例对象。 | + +```ts +this.persistentstorage = new PersistentStorage(AppStorage,Storage); +``` + +### PersistProp + +PersistProp(key:string,defaultValue:T):void + +关联命名的属性再AppStorage变为持久化数据。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------------ | ------ | :--- | ----------------------- | +| key | string | 是 | 要关联的属性的key值。 | +| defaultValue | T | 是 | 要关联的属性的value值。 | + +```ts +PersistentStorage.PersistProp("highScore", "0"); +``` + +### DeleteProp + +DeleteProp(key: string): void + +取消双向数据绑定,该属性值将从持久存储中删除。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------ | ------ | :--- | --------------------- | +| key | string | 是 | 要取消的属性的key值。 | + +```ts +PersistentStorage.DeleteProp("highScore"); +``` + +### PersistProps + +PersistProps(properties: {key: string, defaultValue: any}[]): void; + +关联多个命名的属性绑定。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | +| ------ | ---------------------------------- | :--: | ------------------ | +| key | {key: string, defaultValue: any}[] | 是 | 要关联的属性数组。 | + +```ts +PersistentStorage.PersistProps([{"highScore", "0"},{"wightScore","1"}]); +``` + +### Keys + +Keys(): Array + +返回所有持久化属性的标记。 + +**返回值:** + +| 类型 | 描述 | +| ------------- | -------------------------- | +| Array | 返回所有持久化属性的标记。 | + +```ts +let simple = PersistentStorage.keys(); +``` + +> **说明:** +> +> - PersistProp接口使用时,需要保证输入对应的key应当在AppStorage存在。 +> +> - DeleteProp接口使用时,只能对本次启动已经link过的数据生效。 + +## Environment + +### constructor + +创建一个environment对象。 + +```ts +let simple = new Environment(); +``` + +### EnvProp + +EnvProp\(key: string, value: S): boolean + +关联此系统项到AppStorage中,建议在app启动时使用此接口。如果该属性在AppStorage已存在,返回false。请勿使用AppStorage中的变量,在调用此方法关联环境变量。 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | 参数描述 | +| ------ | ------ | :--- | --------------- | ----------------- | +| key | string | 是 | 要关联的key值 | 要关联的key值。 | +| value | S | 是 | 要关联的value值 | 要关联的value值。 | + +**返回值:** + +| 类型 | 描述 | +| ------- | ---------------------------------- | +| boolean | 返回该属性再AppStorage中是否存在。 | + +```ts +Environment.EnvProp("accessibilityEnabled", "default"); +``` + +### EnvProps + +EnvProps(props: {key: string;defaultValue: any}[]): void + +关联此系统项数组到AppStorage中 + +**参数:** + +| 参数名 | 类型 | 必填 | 参数描述 | 参数描述 | +| ------ | ---------------------------------- | :--- | ------------------ | ------------------ | +| key | {key: string, defaultValue: any}[] | 是 | 要关联的属性数组。 | 要关联的属性数组。 | + +```ts +Environment.EnvProps([{"accessibilityEnabled", "default"},{"accessibilityUnEnabled","undefault"}]); +``` + +### Keys + +Keys(): Array + +返回关联的系统项。 + +**返回值:** + +| 类型 | 描述 | +| ------------- | ---------------------- | +| Array | 返回关联的系统项数组。 | + +```ts +let simple = Environment.keys(); +``` + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 7213e77d845a93e31e123014b397b814d6b897e5..ea49954ac5e7a1771a4976597f318d2bcdcc12a4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -13,7 +13,7 @@ | backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 设置组件的背景色。 | | backgroundImage | src: [ResourceStr](ts-types.md#resourcestr),
repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat:设置背景图片的重复样式,默认不重复。 | | backgroundImageSize | {
width?: [Length](ts-types.md#length),
height?: [Length](ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
默认值:ImageSize.Auto | -| backgroundImagePosition | [Position](ts-types.md#position8) \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。
默认值:
{
x: 0,
y: 0
} | +| backgroundImagePosition | [Position](ts-types.md#position8) \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。
默认值:
{
x: 0,
y: 0
}
使用百分比设置x和y值时,偏移量是相对于容器的。 | ## 示例 diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-Account.md b/zh-cn/application-dev/reference/errorcodes/errcode-Account.md index a5a1abe953816488972326325ca9253051991477..e176a23a6f7d23a11f5a3afd3990649183c10d98 100644 --- a/zh-cn/application-dev/reference/errorcodes/errcode-Account.md +++ b/zh-cn/application-dev/reference/errorcodes/errcode-Account.md @@ -1,52 +1,19 @@ -# 账号子系统通用错误码 +# Account错误码 -## 201 权限校验失败 - -### 错误信息 -Permission denied. - -### 可能原因 -该错误码表示权限校验失败,可能原因如下: -1. 调用目标接口时,未申请权限。 -2. 非会话请求方和响应方查询会话信息。 - -### 处理步骤 -1. 请申请相应接口要求的权限。 -2. 请取消非法查询,使用会话请求方和响应方查询会话信息。 - -## 401 参数检查失败 - -### 错误信息 -Parameter check failed. - -### 可能原因 -该错误码表示参数检查失败,可能原因如下: -1. 必选参数没有传入,参数类型错误。 - -### 处理步骤 -1. 请按照参数类型、位置,传入合法的参数。 - -## 801 API不支持 - -### 错误信息 -Capability not supported. - -### 可能原因 -暂无 - -### 处理步骤 -1. 取消调用和调用替代接口。 +以下错误码包括系统帐号和分布式帐号错误码。 ## 12300001 系统服务异常 -### 错误信息 +**错误信息** + System service works abnormally. -### 可能原因 +**可能原因** + 该错误码表示系统服务异常,可能原因如下: -1. 账号管理服务无法正常启动。 -2. 账号管理的IPC对象无法获取。 -3. 账号管理依赖的其他服务无法正常启动或者IPC对象无法获取。 +1. 帐号管理服务无法正常启动。 +2. 帐号管理的IPC对象无法获取。 +3. 帐号管理依赖的其他服务无法正常启动或者IPC对象无法获取。 4. 服务未初始化。 5. 磁盘空间不足。 6. 读写文件异常。 @@ -54,375 +21,328 @@ System service works abnormally. 8. 创建删除文件异常。 9. 读写数据库异常。 -### 处理步骤 -1. 请稍后重试,或重启设备。 +**处理步骤** + +请稍后重试,或重启设备。 ## 12300002 无效参数 -### 错误信息 + +**错误信息** + Invalid parameter. -### 可能原因 +**可能原因** + 该错误码表示传入无效的参数,可能原因如下: 1. 用户名为空。 -2. 系统账号用户名长度大于1024。 -3. 分布式账号用户名长度大于256。 -4. 系统账号id小于0、小于100或大于1000。 -5. 分布式账号id长度大于512。 -6. 分布式账号传入不支持的事件类型。 +2. 系统帐号用户名长度大于1024。 +3. 分布式帐号用户名长度大于256。 +4. 系统帐号id小于0、小于100或大于1000。 +5. 分布式帐号id长度大于512。 +6. 分布式帐号传入不支持的事件类型。 7. 域名为空。 8. 域名长度大于128。 -9. 域账号为空。 -10. 域账号长度大于512。 +9. 域帐号为空。 +10. 域帐号长度大于512。 11. 约束为空。 12. 约束长度大于128。 13. 传入无效的认证和查询参数。 -14. 提供的系统账号头像编码字符串长度超过4KB。 -15. 提供的分布式账号头像编码字符串长度超过2MB。 +14. 提供的系统帐号头像编码字符串长度超过4KB。 +15. 提供的分布式帐号头像编码字符串长度超过2MB。 16. 提供非jpg和png的图片。 -17. 应用账号名长度超过512。 +17. 应用帐号名长度超过512。 18. 鉴权类型长度超过1024。 19. 令牌长度超过1024。 20. 键名长度超过1024。 21. 自定义数据值长度超过1024。 -### 处理步骤 -1. 请传入正确的参数。 +**处理步骤** + +请传入正确的参数。 + +## 12300003 帐号不存在 -## 12300003 账号不存在 +**错误信息** -### 错误信息 -The account does not exist. +The account does not exist. -### 可能原因 -该错误码表示操作的账号不存在,可能原因如下: -1. 查询/激活/删除未创建的账号。 -2. 查询/激活/删除已删除的账号。 -3. 为已删除的账号设置约束/用户名/头像。 -4. 更新未创建的账号。 -5. 为不存在的账号设置/取消账号信息访问授权。 -6. 为不存在的账号设置/删除/查询密码。 -7. 为不存在的账号设置/删除令牌。 -8. 为不存在的账号设置额外信息。 -9. 为不存在的账号设置/删除凭据。 -10. 为不存在的账号设置自定义数据。 -11. 为不存在的账号使能分布式同步功能。 +**可能原因** -### 处理步骤 -1. 请检查账号是否存在。 +该错误码表示操作的帐号不存在,可能原因如下: +1. 查询/激活/删除未创建的帐号。 +2. 查询/激活/删除已删除的帐号。 +3. 为已删除的帐号设置约束/用户名/头像。 +4. 更新未创建的帐号。 +5. 为不存在的帐号设置/取消帐号信息访问授权。 +6. 为不存在的帐号设置/删除/查询密码。 +7. 为不存在的帐号设置/删除令牌。 +8. 为不存在的帐号设置额外信息。 +9. 为不存在的帐号设置/删除凭据。 +10. 为不存在的帐号设置自定义数据。 +11. 为不存在的帐号使能分布式同步功能。 -## 12300004 操作受限账号 +**处理步骤** + +请检查帐号是否存在。 + +## 12300004 操作受限帐号 + +**错误信息** -### 错误信息 The specified account is restricted. -### 可能原因 -该错误码表示操作的是受限账号,可能原因如下: +**可能原因** + +该错误码表示操作的是受限帐号,可能原因如下: 1. 删除系统保留用户。 2. 查询系统保留用户的约束源类型。 -3. 创建id为0-100的账号。 +3. 创建id为0-100的帐号。 + +**处理步骤** -### 处理步骤 -1. 指定id为系统保留用户,无法操作。 +指定id为系统保留用户,无法操作。 ## 12300005 监听器已注册 -### 错误信息 +**错误信息** + The listener has been registered. -### 可能原因 +**可能原因** + 该错误码表示监听器已注册,可能原因如下: -1. 当前应用向系统注册一个已经注册过的监听器,无法重复注册。 +当前应用向系统注册一个已经注册过的监听器,无法重复注册。 + +**处理步骤** -### 处理步骤 -1. 请取消注册,或使用未注册过的监听器重新注册。 +请取消注册,或使用未注册过的监听器重新注册。 ## 12300006 监听器未注册 -### 错误信息 +**错误信息** + The Listener is not registered. -### 可能原因 +**可能原因** + 该错误码表示监听器未注册,可能原因如下: -1. 解注册一个未注册过的监听器。 +解注册一个未注册过的监听器。 -### 处理步骤 -1. 请使用注册的监听器执行解注册操作 +**处理步骤** + +请使用注册的监听器执行解注册操作 ## 12300007 PIN码输入器已注册 -### 错误信息 -The PIN inputer already exists. +**错误信息** + +The PIN inputer already exists. + +**可能原因** -### 可能原因 该错误码表示PIN码输入器已注册,可能原因如下: -1. PIN码输入器已注册,解注册之前无法重复注册。 +PIN码输入器已注册,解注册之前无法重复注册。 + +**处理步骤** + +PIN码输入器已存在,请勿重复操作。 + +## 12300008 帐号已存在 + +**错误信息** + +The account already exists. + +**可能原因** -### 处理步骤 -1. PIN码输入器已存在,请勿重复操作。 +该错误码表示帐号已存在,可能原因如下: +创建已存在的帐号。 -## 12300008 账号已存在 +**处理步骤** -### 错误信息 -The account already exists. +请取消创建,或使用其他账户号名重试。 -### 可能原因 -该错误码表示账号已存在,可能原因如下: -1. 创建已存在的账号。 +## 12300009 帐号已激活 -### 处理步骤 -1. 请取消创建,或使用其他账户号名重试。 +**错误信息** -## 12300009 账号已激活 +The account has been activated. -### 错误信息 -The account has been activated. +**可能原因** -### 可能原因 -该错误码表示账号已激活,可能原因如下: -1. 激活已激活的账号。 +该错误码表示帐号已激活,可能原因如下: +激活已激活的帐号。 -### 处理步骤 -1. 当前账号已激活,请勿重复操作。 +**处理步骤** -## 12300010 账号服务忙 +当前帐号已激活,请勿重复操作。 -### 错误信息 -The account service is busy. +## 12300010 帐号服务忙 -### 可能原因 -该错误码表示账号服务忙,可能原因如下: +**错误信息** + +The account service is busy. + +**可能原因** + +该错误码表示帐号服务忙,可能原因如下: 1. 短时间提交重复请求,如重复激活、重复设置等。 -2. 应用账号的认证会话数量超过256,无法处理新的认证请求。 +2. 应用帐号的认证会话数量超过256,无法处理新的认证请求。 -### 处理步骤 -1. 请等待一段时间后重试,并降低调用频率。 +**处理步骤** -## 12300011 账号数量已达上限 +请等待一段时间后重试,并降低调用频率。 + +## 12300011 帐号数量已达上限 + +**错误信息** -### 错误信息 The account number has reached the upper limit. -### 可能原因 -该错误码表示账号数量已达上限,可能原因如下: -1. 创建系统账号/应用账号时,已存在1000个账号。 +**可能原因** + +该错误码表示帐号数量已达上限,可能原因如下: +创建系统帐号/应用帐号时,已存在1000个帐号。 -### 处理步骤 -1. 请删除其他账号后再创建。 +**处理步骤** + +请删除其他帐号后再创建。 ## 12300012 不支持多用户 -### 错误信息 +**错误信息** + Multi-user is not supported. -### 可能原因 +**可能原因** + 该错误码表示不支持多用户,可能原因如下: -1. 当前设备不支持多用户,无法创建账号 +当前设备不支持多用户,无法创建帐号 -### 处理步骤 -1. 无法创建其他账号,请取消创建 +**处理步骤** -## 12300013 不支持的账号类型 +无法创建其他帐号,请取消创建 + +## 12300013 不支持的帐号类型 + +**错误信息** -### 错误信息 The account type is not supported. -### 可能原因 -该错误码表示提供了不支持的账号类型,可能原因如下: -1. 当前设备不支持创建管理员账号 +**可能原因** + +该错误码表示提供了不支持的帐号类型,可能原因如下: +当前设备不支持创建管理员帐号 -### 处理步骤 -1. 请创建非管理员账号 +**处理步骤** + +请创建非管理员帐号 ## 12300014 可信等级不支持 -### 错误信息 +**错误信息** + The trust level is not supported. -### 可能原因 +**可能原因** + 该错误码表示提供了可信等级不支持,可能原因如下: -1. 传入系统不支持的可信等级。 +传入系统不支持的可信等级。 + +**处理步骤** -### 处理步骤 -1. 请输入正确的可信等级。 +请输入正确的可信等级。 ## 12300015 认证类型不支持 -### 错误信息 +**错误信息** + The auth type is not supported. -### 可能原因 +**可能原因** + 该错误码表示提供了认证类型不支持,可能原因如下: -1. 传入系统不支持的认证类型。 +传入系统不支持的认证类型。 + +**处理步骤** -### 处理步骤 -1. 请提供系统支持的认证类型。 +请提供系统支持的认证类型。 ## 12300016 认证超时 -### 错误信息 +**错误信息** + The auth service is timeout. -### 可能原因 +**可能原因** + 该错误码表示认证超时,可能原因如下: 1. 认证录入超过三分钟。 2. 认证服务因网络原因无法及时响应而超时。 -### 处理步骤 +**处理步骤** + 1. 认证录入超时,请重试。 2. 请确认网络环境无问题后重试。 ## 12300017 认证服务忙 -### 错误信息 +**错误信息** + The auth service is busy. -### 可能原因 +**可能原因** + 该错误码表示认证服务忙,可能原因如下: -1. 认证总数超过5个。 +认证总数超过5个。 + +**处理步骤** -### 处理步骤 -1. 当前认证服务忙,请稍后重试。 +当前认证服务忙,请稍后重试。 ## 12300018 认证服务锁定 -### 错误信息 +**错误信息** + The auth service is locked. -### 可能原因 +**可能原因** + 该错误码表示认证服务锁定,可能原因如下: -1. 认证类型错误次数超过上限。 +认证类型错误次数超过上限。 + +**处理步骤** -### 处理步骤 -1. 认证错误次数超过上限,请在freezingTime之后重试。 +认证错误次数超过上限,请在freezingTime之后重试。 ## 12300019 凭据不存在 -### 错误信息 +**错误信息** + The credential does not exist. -### 可能原因 +**可能原因** + 该错误码表示凭据不存在,可能原因如下: 1. 认证未录入的凭据类型。 2. 查询未录入的凭据类型。 3. 删除未录入的凭据类型。 -### 处理步骤 -1. 请确认凭据类型是否存在。 - -## 12300020 无效的contextId - -### 错误信息 -The contextId is invalid. - -### 可能原因 -该错误码表示contextId无效,可能原因如下: -1. 传入取消的contexId未发起认证录入或已经完成。 - -### 处理步骤 -1. 请输入正确的contextId。 +**处理步骤** -# 应用账号错误码 +请确认凭据类型是否存在。 -## 12400001 应用不存在 - -### 错误信息 -The application does not exist. - -### 可能原因 -该错误码表示应用不存在,可能原因如下: -1. 设置访问权限时,目标应用不存在。 -2. 设置开放授权时,目标应用不存在。 - -### 处理步骤 -1. 请取消设置,或使用已安装的应用包名重试。 - -## 12400002 账号认证器服务不存在 - -### 错误信息 -The account authenticator service does not exist. -### 可能原因 -该错误码表示账号认证器服务不存在,可能原因如下: -1. 请求鉴权时,账号所属应用不支持认证器服务。 -2. 隐式添加账号时,账号所属应用不支持认证器服务。 -3. 验证指定账号的凭据时,该账号所属应用不支持认证器服务。 -4. 设置应用的认证器属性时,指定的应用不支持认证器服务。 - -### 处理步骤 -1. 请取消操作,或使用支持认证器服务的应用的包名重试。 - -## 12400003 账号认证器服务异常 - -### 错误信息 -The account authenticator service works abnormally. -### 可能原因 -该错误码表示账号认证器服务异常,可能原因如下: -1. 三方应用的鉴权服务接连失败。 - -### 处理步骤 -1. 请重试或重启系统。 - -## 12400004 鉴权类型不存在 - -### 错误信息 -The auth type does not exist. -### 可能原因 -该错误码表示鉴权类型不存在,可能原因如下: -1. 查询/删除令牌时,指定的鉴权类型不存在。 - -### 处理步骤 -1. 请使用存在的鉴权类型查询/删除。 - -## 12400005 会话不存在 - -### 错误信息 -The session does not exist. -### 可能原因 -该错误码表示会话不存在,可能原因如下: -1. 查询不存在的会话回调。 - -### 处理步骤 -1. 请使用已成功打开的会话标识查询会话回调。 - -## 12400006 授权列表已达上限 - -### 错误信息 -The size of authorization list reaches upper limit. -### 可能原因 -该错误码表示授权列表已达上限,可能原因如下: -1. 设置访问/开放授权时,授权列表的大小超过1024。 - -### 处理步骤 -1. 请取消设置操作,或者撤销已存在的访问/开放授权后再设置。 - -## 12400007 令牌数量已达上限 - -### 错误信息 -The number of token reaches upper limit. -### 可能原因 -该错误码表示令牌数量已达上限,可能原因如下: -1. 添加令牌时,目标账号的令牌数量已达1024。 - -### 处理步骤 -1. 请取消添加操作,或者删除已存在的令牌后再添加。 +## 12300020 无效的contextId -## 12400008 自定义数据的数量已达上限 +**错误信息** -### 错误信息 -The number of custom data reaches upper limit. -### 可能原因 -该错误码表示自定义数据的数量已达上限,可能原因如下: -1. 设置自定义数据时,目标账号的自定义数据数量已达512。 +The contextId is invalid. -### 处理步骤 -1. 请取消设置操作,或者删除已存在的自定义数据。 +**可能原因** -## 12400009 自定义数据不存在 +该错误码表示contextId无效,可能原因如下: +传入取消的contexId未发起认证录入或已经完成。 -### 错误信息 -The custom data does not exist. -### 可能原因 -该错误码表示自定义数据不存在,可能原因如下: -1. 查询账号的自定义数据时,输入的键名不存在。 +**处理步骤** -### 处理步骤 -1. 请使用存在的自定义数据的键名查询。 \ No newline at end of file +请输入正确的contextId。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-AccessToken.md b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md similarity index 62% rename from zh-cn/application-dev/reference/errorcodes/errorcode-AccessToken.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md index a4672eeb695ba0371e8ee31d5bdca10b57ee80e9..03e236d1efa66912b05626dc691b0e945b3211ed 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-AccessToken.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md @@ -1,140 +1,134 @@ -# AccessToken错误码 - -## 401 参数错误 - -### 错误信息 -Parameter error.${messageInfo}. - -### 可能原因 -该错误码表示js参数解析出现错误,可能原因如下。 -1. 入参数量不足。 -2. 参数类型错误。 - -### 处理步骤 -1. 检查入参,补充足够的入参数量。 -2. 检查入参,修正参数类型错误。 - - -## 201 权限校验失败 - -### 错误信息 -Permission denied.${messageInfo}. - -### 可能原因 -该错误码表示调用接口的应用进程未授权该接口所需目标权限,可能原因如下。 -1. 调用接口的应用进程未申请目标权限。 -2. 在该目标权限为用户授权类型的权限情况下,调用接口的应用进程未被用户授予该目标权限。 - -### 处理步骤 -1. 检查调用接口的应用进程是否申请了该权限。 -2. 在该目标权限为用户授权类型的权限情况下,检查调用接口的应用进程是否已被授予该权限。 - - -## 12100001 入参错误 - -### 错误信息 -Parameter invalid, message is ${messageInfo}. - -### 可能原因 -该错误码表示参数校验出现错误,可能原因如下。 -1. tokenId值为0。 -2. 指定的权限名为空或者权限名长度大于256。 -3. 请求授权/撤销权限的flag取值非法。 -4. 注册监听的参数检查错误。 - -### 处理步骤 -1. 检查入参,修正参数值为合法值。 - - -## 12100002 tokenId不存在 - -### 错误信息 -TokenId does not exist. - -### 可能原因 -1. 指定的tokenid不存在。 -2. 指定的tokenId对应的进程非应用进程。 - -### 处理步骤 -检查入参,修正参数值为有效值。 - - -## 12100003 权限名不存在 - -### 错误信息 -Permission does not exist. - -### 可能原因 -1. 指定的permissionName不存在。 -2. 请求授权/撤销权限场景下,指定的应用tokenid未申请过指定的permissionName。 -3. 权限使用记录场景下,指定的permissionName非用户授权的敏感权限。 - -### 处理步骤 -检查入参,修正参数值为有效值。[权限列表](../../security/permission-list.md)。 - - -## 12100004 接口未配套使用 - -### 错误信息 -The listener interface is not used together. - -### 可能原因 -该错误码表示监听器接口未配套使用,可能原因如下。 -1. 当前接口再未配套使用的情况下,重复调用。 -2. 当前接口再未配套使用的情况下,单独调用。 - -### 处理步骤 -1. 检查当前接口是否有配套使用,如调用启动记录的接口后,在未调用停止记录的接口前,不可再次使用相同的入参调用启动记录接口。 -2. 检查当前接口是否有配套使用,如停止记录的接口需要在启动记录的接口调用之后方可调用,注销监听接口需要在注册监听接口调用之后方可调用。 - - -## 12100005 监听器数量超过限制 - -### 错误信息 -The number of listeners exceeds the limit. - -### 可能原因 -该错误码表示当前监听器数量超过限制200. - -### 处理步骤 -及时释放已注册的无用的监听器。 - - -## 12100006 指定的应用不支持被授予或被取消授予指定的权限 - -### 错误信息 -The specified application does not support the permissions granted or ungranted as specified. - -### 可能原因 -1. 输入的tokenid是远端设备的身份标识,尚未支持分布式授权和取消授权。 -2. 入参指定的tokenid为沙箱应用,被禁止申请指定的权限。 - -### 处理步骤 -1. 请确认tokenid的获取方式是否正确。 -2. 确认待授权的沙箱应用是否为特殊的受限沙箱应用进程,部分模式下的沙箱应用被禁止授予大部分权限。 - - -## 12100007 系统服务工作异常 - -### 错误信息 -Service is abnormal. - -### 可能原因 -该错误码表示系统服务工作异常。 -1. 权限管理服务无法正常启动。 -2. IPC数据读取写入失败。 - -### 处理步骤 -系统服务内部工作异常,请稍后重试,或者重启设备。 - - -## 12100008 内存申请失败 - -### 错误信息 -Out of memory. - -### 可能原因 -系统内存不足。 - -### 处理步骤 -系统内存不足,请稍后重试,或者重启设备。 \ No newline at end of file +# AccessToken错误码 + +## 12100001 入参错误 + +**错误信息** + +Parameter invalid, message is ${messageInfo}. + +**可能原因** + +该错误码表示参数校验出现错误,可能原因如下。 +1. tokenId值为0。 +2. 指定的权限名为空或者权限名长度大于256。 +3. 请求授权/撤销权限的flag取值非法。 +4. 注册监听的参数检查错误。 + +**处理步骤** + +检查入参,修正参数值为合法值。 + + +## 12100002 tokenId不存在 + +**错误信息** + +TokenId does not exist. + +**可能原因** + +1. 指定的tokenid不存在。 +2. 指定的tokenId对应的进程非应用进程。 + +**处理步骤** + +检查入参,修正参数值为有效值。 + + +## 12100003 权限名不存在 + +**错误信息** + +Permission does not exist. + +**可能原因** + +1. 指定的permissionName不存在。 +2. 请求授权/撤销权限场景下,指定的应用tokenid未申请过指定的permissionName。 +3. 权限使用记录场景下,指定的permissionName非用户授权的敏感权限。 + +**处理步骤** + +检查入参,修正参数值为有效值。[权限列表](../../security/permission-list.md)。 + + +## 12100004 接口未配套使用 + +**错误信息** + +The listener interface is not used together. + +**可能原因** + +该错误码表示监听器接口未配套使用,可能原因如下。 +1. 当前接口再未配套使用的情况下,重复调用。 +2. 当前接口再未配套使用的情况下,单独调用。 + +**处理步骤** + +1. 检查当前接口是否有配套使用,如调用启动记录的接口后,在未调用停止记录的接口前,不可再次使用相同的入参调用启动记录接口。 +2. 检查当前接口是否有配套使用,如停止记录的接口需要在启动记录的接口调用之后方可调用,注销监听接口需要在注册监听接口调用之后方可调用。 + + +## 12100005 监听器数量超过限制 + +**错误信息** + +The number of listeners exceeds the limit. + +**可能原因** + +该错误码表示当前监听器数量超过限制200. + +**处理步骤** + +及时释放已注册的无用的监听器。 + + +## 12100006 指定的应用不支持被授予或被取消授予指定的权限 + +**错误信息** + +The specified application does not support the permissions granted or ungranted as specified. + +**可能原因** + +1. 输入的tokenid是远端设备的身份标识,尚未支持分布式授权和取消授权。 +2. 入参指定的tokenid为沙箱应用,被禁止申请指定的权限。 + +**处理步骤** + +1. 请确认tokenid的获取方式是否正确。 +2. 确认待授权的沙箱应用是否为特殊的受限沙箱应用进程,部分模式下的沙箱应用被禁止授予大部分权限。 + + +## 12100007 系统服务工作异常 + +**错误信息** + +Service is abnormal. + +**可能原因** + +该错误码表示系统服务工作异常。 +1. 权限管理服务无法正常启动。 +2. IPC数据读取写入失败。 + +**处理步骤** + +系统服务内部工作异常,请稍后重试,或者重启设备。 + + +## 12100008 内存申请失败 + +**错误信息** + +Out of memory. + +**可能原因** + +系统内存不足。 + +**处理步骤** + +系统内存不足,请稍后重试,或者重启设备。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md b/zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md new file mode 100644 index 0000000000000000000000000000000000000000..e9d1820c857b5bf10b2424e3aca47f9e96460033 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md @@ -0,0 +1,134 @@ +# 应用帐号错误码 + +## 12400001 应用不存在 + +**错误信息** + +The application does not exist. + +**可能原因** + +该错误码表示应用不存在,可能原因如下: +1. 设置访问权限时,目标应用不存在。 +2. 设置开放授权时,目标应用不存在。 + +**处理步骤** + +请取消设置,或使用已安装的应用包名重试。 + +## 12400002 帐号认证器服务不存在 + +**错误信息** + +The account authenticator service does not exist. +**可能原因** + +该错误码表示帐号认证器服务不存在,可能原因如下: +1. 请求鉴权时,帐号所属应用不支持认证器服务。 +2. 隐式添加帐号时,帐号所属应用不支持认证器服务。 +3. 验证指定帐号的凭据时,该帐号所属应用不支持认证器服务。 +4. 设置应用的认证器属性时,指定的应用不支持认证器服务。 + +**处理步骤** + +请取消操作,或使用支持认证器服务的应用的包名重试。 + +## 12400003 帐号认证器服务异常 + +**错误信息** + +The account authenticator service works abnormally. +**可能原因** + +该错误码表示帐号认证器服务异常,可能原因如下: +三方应用的鉴权服务接连失败。 + +**处理步骤** + +请重试或重启系统。 + +## 12400004 鉴权类型不存在 + +**错误信息** + +The auth type does not exist. +**可能原因** + +该错误码表示鉴权类型不存在,可能原因如下: +查询/删除令牌时,指定的鉴权类型不存在。 + +**处理步骤** + +请使用存在的鉴权类型查询/删除。 + +## 12400005 会话不存在 + +**错误信息** + +The session does not exist. + +**可能原因** + +该错误码表示会话不存在,可能原因如下: + +查询不存在的会话回调。 + +**处理步骤** + +请使用已成功打开的会话标识查询会话回调。 + +## 12400006 授权列表已达上限 + +**错误信息** + +The size of authorization list reaches upper limit. +**可能原因** + +该错误码表示授权列表已达上限,可能原因如下: +设置访问/开放授权时,授权列表的大小超过1024。 + +**处理步骤** +1. 请取消设置操作,或者撤销已存在的访问/开放授权后再设置。 + +## 12400007 令牌数量已达上限 + +**错误信息** + +The number of token reaches upper limit. +**可能原因** + +该错误码表示令牌数量已达上限,可能原因如下: +添加令牌时,目标帐号的令牌数量已达1024。 + +**处理步骤** + +请取消添加操作,或者删除已存在的令牌后再添加。 + +## 12400008 自定义数据的数量已达上限 + +**错误信息** + +The number of custom data reaches upper limit. +**可能原因** + +该错误码表示自定义数据的数量已达上限,可能原因如下: +设置自定义数据时,目标帐号的自定义数据数量已达512。 + +**处理步骤** + +请取消设置操作,或者删除已存在的自定义数据。 + +## 12400009 自定义数据不存在 + +**错误信息** + +The custom data does not exist. + +**可能原因** + +该错误码表示自定义数据不存在,可能原因如下: +查询帐号的自定义数据时,输入的键名不存在。 + +**处理步骤** + +请使用存在的自定义数据的键名查询。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-display.md b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md new file mode 100755 index 0000000000000000000000000000000000000000..2d19ab659374a9e87095fcb53c883148a3af0ec0 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md @@ -0,0 +1,34 @@ +# 屏幕错误码 + +## 1400001 无效虚拟屏 +### 错误信息 +This is invalid screen. +### 错误描述 +当操作无效的虚拟屏时,会报此错误码。 +### 可能原因 +1. 虚拟屏未创建。 +2. 虚拟屏已销毁。 +### 处理步骤 +1. 在操作虚拟屏前,检查该虚拟屏是否已经存在,确保已创建该虚拟屏。 +2. 在操作虚拟屏前,检查虚拟屏是否已被销毁,确保其未被销毁,再进行相关操作。 + +## 1400002 无权限操作 +### 错误信息 +This operation is not access. +### 错误描述 +当对无操作权限的对象进行操作时,会报此错误码。 +### 可能原因 +操作了其它进程的虚拟屏对象。 +### 处理步骤 +请检查是否非法操作了别的进程的对象,删除相关非法操作。 + +## 1400003 系统服务工作异常 +### 错误信息 +This window manager service work abnormally. +### 错误描述 +当系统服务工作异常时,会报此错误码。 +### 可能原因 +1. 窗口内部服务没有正常启动。 +2. 底层图形图像合成渲染异常。 +### 处理步骤 +系统服务内部工作异常,请稍候重试,或者重启设备尝试。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md new file mode 100644 index 0000000000000000000000000000000000000000..0baec0448e812c078b0f89b2f7d983960460ffdd --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @@ -0,0 +1,223 @@ +# huks错误码 + +## 12000001 该子功能不支持(特性) + +**错误信息** + +``${messageInfo}`` mode is not support in current device. + +**可能原因** +支持API,但是不支持API内部某些子特性(功能),如算法参数。 + +**处理步骤** + +调整API参数,使用可替代可支持的参数。 + +## 12000002 缺少密钥算法参数 +**错误信息** + +Check get ``${messageInfo}`` failed. User should add ``${messageInfo}`` in param set. + +**可能原因** + +使用密钥时缺少相关参数。 + +**处理步骤** + +1. 查看errorMessage确认缺少的密钥参数。 +2. 添加对应的正确的密钥参数。 + +## 12000003 无效的密钥算法参数 + +**错误信息** + +``${messageInfo}`` argument is invalid. User should make sure using the correct value. + +**可能原因** + +使用密钥时无效相关参数。 + +**处理步骤** + +1. 查看errorMessage确认无效的的密钥参数名。 +2. 修改对应的密钥参数。 + +## 12000004 文件错误 + +**错误信息** + +Read file failed. or Write file failed. + +**可能原因** + +文件操作错误。 + +**处理步骤** + +1. 查看是否磁盘空间已经写满、文件系统是否有其他异常。 +2. 清理磁盘。 + +## 12000005 进程通信错误 + +**错误信息** + +IPC communication timeout. or Receive message from IPC failed. + +**可能原因** + +进程通信错误。 + +**处理步骤** + +查看错误信息,排查是否进程IPC通信问题。 + +## 12000006 算法库操作失败 + +**错误信息** + +Error occured in crypto engine. + +**可能原因** + +该错误码表示算法库操作失败,可能原因如下。 + +1. 算法库加解密错误,可能是密文数据不对。 +2. 密钥参数不正确。 + +**处理步骤** + +1. 排查密文数据是否正确。 +2. 排查加解密参数是否正确。 + +## 12000007 密钥访问失败 - 密钥已失效 + +**错误信息** + +This credential is already invalidated permanently. + +**可能原因** + +该错误码表示密钥访问失败 - 密钥已失效,可能原因如下。 + +1. 该密钥设置了清除密码失效的用户认证访问控制属性,清除过设备密钥导致密钥失效。 +2. 该密钥设置了新录入生物特征失效的用户认证访问控制属性,由于录入过新的指纹或人脸导致该密钥失败。 + +**处理步骤** + +1. 确认日志是哪种方式导致的认证不通过。 +2. 如果使用了正确参数,但是失效控制导致认证不通过,则该密钥已经无法使用。 + +## 12000008 密钥访问失败 - 密钥认证失败 + +**错误信息** + +Verify authtoken failed. + +**可能原因** + +该密钥设置了用户认证访问控制属性,由于challenge参数不正确导致无法通过认证。 + +**处理步骤** + +1. 检查userIAM认证的challenge参数组装是否正确。 +2. 如果是challenge参数不正确导致,则修改正确的组装方式,使用huks生成challenge组装,并传入userIAM重新认证。 + +## 12000009 密钥访问失败 - 密钥访问超时 + +**错误信息** + +This authtoken is already timeout. + +**可能原因** + +该密钥设置了用户认证访问控制属性,由于使用时间窗timeout导致无法通过认证。 + +**处理步骤** + +如果是timeout导致不正确,则重新触发密钥init并重新认证,使得认证时间和密钥init时间小于设置的timeout时间。 + +## 12000010 密钥操作会话数已达上限 + +**错误信息** + +The number of session has reached limit. + +**可能原因** + +同时使用huks进行密钥会话操作的调用方(同应用或者跨应用)过多,已经达到上限(15个)。 + +**处理步骤** + +1. 检查同应用内部是否同时存在多个密钥会话操作(init),存在则修改避免同时调用。 +2. 如不存在上述情形,则可能是其它应用同时调用多个会话,通过等待其它应用释放会话后再使用。 + +## 12000011 目标对象不存在 + +**错误信息** + +Queried entity does not exist. + +**可能原因** + +该别名对应的密钥不存在。 + +**处理步骤** + +1. 检查密钥别名是否拼写错误。 +2. 检查改密钥别名对应的密钥是否生成成功。 + +## 12000012 外部错误 + +**错误信息** + +External error ``${messageInfo}``. + +**可能原因** + +外部的硬件出错,文件错误等。 + +**处理步骤** + +拿错误码与日志在社区反馈。 + +## 12000013 密钥设置生物访问控制时,待绑定的凭据不存在 + +**错误信息** + +Queried credential does not exist. + +**可能原因** + +密钥绑定PIN、指纹、人脸时,未录入相关凭据。 + +**处理步骤** + +录入相关凭据,或更改绑定凭据类型。 + +## 12000014 内存不足 + +**错误信息** + +Memory is insufficient. + +**可能原因** + +系统内存不足。 + +**处理步骤** + +开发者释放部分内存或重启。 + +## 12000015 调用其他系统服务失败 + +**错误信息** + +Call ``${messageInfo}`` service to do ``${messageInfo}`` failed. + +**可能原因** + +其他系统服务未启动。 + +**处理步骤** + +开发者等待一段时间后尝试再次触发调用。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md b/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md new file mode 100644 index 0000000000000000000000000000000000000000..45da702e55b3f3af0eef50de7593968aedd3adc0 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @@ -0,0 +1,76 @@ +# 剪贴板错误码 + +## 12900001 索引超过范围 + +### 错误信息 + +The index is out of range. + +### 错误描述 + +当调用getRecord等涉及索引的接口时,索引超过范围时,系统会报此错误码。 + +### 可能原因 + +接口的参数索引值超出当前PasteData中的记录数,比如,getRecord传入index值过大。 + +### 处理步骤 + +检查参数索引值是否在正确范围,使用恰当的索引值重新进行开发。 + +## 12900002 Record数量超过最大限制 + +### 错误信息 + +The number of record exceeds the maximum limit. + +### 错误描述 + +当添加Record时,若当前PasteData记录数已达到最大值,系统会报此错误码。 + +### 可能原因 + +当前PasteData记录数已达到最大值,未进行相关Record的删除或数目检查,直接继续添加Record导致。 + +### 处理步骤 + +1. 检查判断当前PasteData记录数是否已达最大值。 +2. 若当前PasteData记录数已达最大值,删除相关Record后,再重新添加Record进行开发。 + +## 12900003 另外一个复制或粘贴正在进行 + +### 错误信息 + +Another copy or paste is in progress. + +### 错误描述 + +上次的复制/粘贴动作还未结束时,再次调用相关接口,系统会报此错误码。 + +### 可能原因 + +复制粘贴均为异步接口,当复制/粘贴的数据内容较大,需要时间较长时,在此期间再次执行复制/粘贴则会出错。 + +### 处理步骤 + +1. 再次进行复制/粘贴时,首先判断上次复制/粘贴的状态。 +2. 当上次复制/粘贴动作完成后,再进行后续操作。 + +## 12900004 禁止复制 + +### 错误信息 + +Replication is prohibited. + +### 错误描述 + +当对不支持复制的数据内容进行复制操作时,系统会报此错误码。 + +### 可能原因 + +数据内容不支持复制,比如只读类型的数据内容。 + +### 处理步骤 + +1. 在对相关数据内容进行复制时,首先判断其数据类型是否支持复制。 +2. 若数据内容不支持复制,不对此类数据内容进行复制操作。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md new file mode 100644 index 0000000000000000000000000000000000000000..e733f2814fb3f7b90ad431d88461abbffe268b72 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @@ -0,0 +1,89 @@ +# 资源管理错误码 + +## 9001001 无效的资源id + +### 错误信息 +The resId invalid. + +### 错误描述 +当传入的资源id符合类型校验,但却是一个不存在的资源id时,会报出此错误。 + +### 可能原因 +传入的是一个不存在的id值。 + +### 处理步骤 +检查传入参数的资源id是否已有。 + +## 9001002 根据当前资源id,找不到匹配的资源 + +### 错误信息 +The resource not found by resId. + +### 错误描述 +当传入的资源id符合类型校验,但是根据此资源id匹配不到资源时,会报出此错误。 + +### 可能原因 +1、传入的是资源id有误。 + +2、资源解析有误。 + +### 处理步骤 +检查传入的资源id是否符合预期。 + +## 9001003 无效的资源名称 + +### 错误信息 +The resName invalid. + +### 错误描述 +当传入的资源名称符合类型校验,但却是一个不存在的资源名称时,会报出此错误。 + +### 可能原因 +传入的是一个不存在的资源名称。 + +### 处理步骤 +检查传入的资源名称是否符合预期。 + +## 9001004 根据当前资源名称,找不到匹配的资源 + +### 错误信息 +The resource not found by resName. + +### 错误描述 +当传入的资源名称符合类型校验,但是根据此资源名称,匹配不到资源。 + +### 可能原因 +1、传入的是资源名称有误。 + +2、资源解析有误。 + +### 处理步骤 +可先检查传入的资源名称是否符合预期。 + +## 9001005 无效的相对路径 + +### 错误信息 +The resource not found by path. + +### 错误描述 +根据参数相对路径, 找不到对应的资源。 + +### 可能原因 +传入的相对路径有误。 + +### 处理步骤 +可检查传入的相对路径是否符合预期。 + +## 9001006 循环引用 + +### 错误信息 +the resource re-ref too much. + +### 错误描述 +解析引用次数过高。 + +### 可能原因 +出现资源循环引用的情况。 + +### 处理步骤 +查看资源$引用的地方,去除循环引用的情况。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md b/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md new file mode 100644 index 0000000000000000000000000000000000000000..2c5743f21c4b269dfef62d679d60948adadd767f --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @@ -0,0 +1,264 @@ +# RPC错误码 + + 从API version 9起,IPC支持异常返回功能。错误码对应数值及含义如下。 + + +## 1900001 系统调用mmap失败 + +### 错误信息 + +Call mmap function failed. + +### 错误描述 + +执行系统调用mmap失败。 + +### 可能原因 + +1. 映射区域过大。 +2. 系统内存压力大,没有足够内存可以用来进行映射。 + +### 处理步骤 + +1. 请检查调用Ashmem::create()时是否指定了超大内存; +2. 请检查执行映射时系统是否有足够的内存可用。 + + +## 1900002 系统调用ioctl失败 + +### 错误信息 + +Call os ioctl function failed. + +### 错误描述 + +在共享内存文件描述符上执行系统调用ioctl失败。 + +### 可能原因 + +1. 设置的参数为内核非法参数; +2. 设置的类型超过了共享内存映射时指定的类型。 + +### 处理步骤 + +1. 请检查调用指定的参数是否来自Ashmem类的PROT_EXEC、PROT_READ和PROT_WRITE; +2. 请检查指定的参数是否为映射共享内存时所指类型的子集。 + + +## 1900003 共享内存写数据失败 + +### 错误信息 + +Write to ashmem failed. + +### 错误描述 + +向共享内存写数据失败。 + +### 可能原因 + +1. 单次写或者连续写的总内容超过了映射的共享内存大小; +2. 没有对共享内存设置PROT_WRITE模式。 + +### 处理步骤 + +1. 请检查当前向共享内存所写内容是否已经超过了映射的总大小; +2. 请检查是否设置了PROT_WRITE保护权限。 + + +## 1900004 共享内存读数据失败 + +### 错误信息 + +Read from ashmem failed. + +### 错误描述 + +从共享内存读数据失败。 + +### 可能原因 + +1. 单次写或者连续写的总内容超过了映射的共享内存大小; +2. 没有对共享内存设置PROT_READ模式。 + +### 处理步骤 + +1. 请检查当前向共享内存所写内容是否已经超过了映射的总大小; +2. 请检查是否设置了PROT_READ保护权限。 + + +## 1900005 ipc对象权限错误 + +### 错误信息 + +Only proxy object permitted. + +### 错误描述 + +只有proxy对象允许该操作。 + +### 可能原因 + +在RemoteObject对象上调用了只有RemoteProxy对象支持的方法。 + +### 处理步骤 + +请检查是否在RemoteObject对象上调用了只有RemoteProxy对象支持的方法。 + + +## 1900006 ipc对象权限错误 + +### 错误信息 + +Only remote object permitted. + +### 错误描述 + +只有remote对象允许该操作。 + +### 可能原因 + +在RemoteProxy对象上调用了只有RemoteObject对象支持的方法。 + +### 处理步骤 + +请检查是否在RemoteProxy对象上调用了只有RemoteObject对象支持的方法。 + + +## 1900007 远端对象通信失败 + +### 错误信息 + +Communication failed. + +### 错误描述 + +和远端对象进行进程间通信失败。 + +### 可能原因 + +1. 远端对象已经销毁; +2. 远端对象发生了销毁然后重新创建,本端持有的代理对象已经过期。 + +### 处理步骤 + +1. 请检查远端对象是否已经销毁; +2. 请检查是否注册了死亡监听,并且远端对象发生析构又重新创建。 + + +## 1900008 非法的ipc对象 + +### 错误信息 + +Proxy or remote object is invalid. + +### 错误描述 + +非法的代理对象或者远端对象。 + +### 可能原因 + +1. 代理对象已经失效; +2. 远端对象已经销毁。 + +### 处理步骤 + +1. 请检查proxy对象获取过程是否有异常; +2. 请检查远端对象是否已经析构。 + + +## 1900009 向MessageSequence写入数据失败 + +### 错误信息 + +Write data to message sequence failed. + +### 错误描述 + +向MessageSequence写数据失败。 + +### 可能原因 + +sequence默认空间已满。 + +### 处理步骤 + +请使用MessageSequence提供的获取缓冲区空间相关方法确认是否还有剩余空间。 + + +## 1900010 读取MessageSequence数据失败 + +### 错误信息 + +Read data from message sequence failed. + +### 错误描述 + +读取MessageSequence数据失败。 + +### 可能原因 + +读取和写入顺序不一致。 + +### 处理步骤 + +请检查读取的顺序和写入的顺序保持严格一致。 + + +## 1900011 内存分配失败 + +### 错误信息 + +Sequence memory alloc failed. + +### 错误描述 + +序列化过程中内存分配失败。 + +### 可能原因 + +写入的数据过大。 + +### 处理步骤 + +请检查写入的数据或者设置的参数是否过大。 + + +## 1900012 JS方法失败 + +### 错误信息 + +Call JS callback function failed. + +### 错误描述 + +执行JS回调方法失败。 + +### 可能原因 + +业务的JS方法返回失败。 + +### 处理步骤 + +请检查业务JS方法是否执行成功。 + + +## 1900013 系统调用dup失败 + +### 错误信息 + +Call os dup function failed. + +### 错误描述 + +执行系统调用dup失败。 + +### 可能原因 + +1. 进程的文件句柄资源已经耗尽; +2. 入参fd已经被关闭。 + +### 处理步骤 + +1. 请检查入参fd是否依然有效; +2. 请排查进程是否已经耗尽了fd资源。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md b/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md new file mode 100644 index 0000000000000000000000000000000000000000..dda3aabebadab92b9937e8f86039344e87329343 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md @@ -0,0 +1,87 @@ +# uitest错误码 + +## 17000001 初始化失败 + +**错误信息** + +Initialize failed. + +**错误描述** + +框架初始化失败。 + +**可能原因** + +无法连接到无障碍服务。 + +**处理步骤** + +执行param set persist.ace.testmode.enabled 1,并重启设备。 + +## 17000002 当前无法调用 +**错误信息** + +API does not allow calling concurrently. + +**错误描述** + +当前无法调用API。 + +**可能原因** + +API没有使用await进行异步调用,造成堵塞。 + +**处理步骤** + +检查测试用例,确保异步接口使用await调用。 + +## 17000003 断言失败 +**错误信息** + +Component existence assertion failed. + +**错误描述** + +用户断言失败。 + +**可能原因** + +用户断言存在的控件实际不存在。 + +**处理步骤** + +检查用户断言存在的控件实际是否存在。 + +## 17000004 目标控件/窗口丢失 +**错误信息** + +Component lost/UiWindow lost. + +**错误描述** + +目标控件/窗口丢失,无法进行操作。 + +**可能原因** + +获取到目标控件/窗口后,页面发生变化导致目标丢失。 + +**处理步骤** + +检查获取到目标控件/窗口后,页面是否发生变化导致目标丢失。 + +## 17000005 操作不支持 +**错误信息** + +This operation is not supported. + +**错误描述** + +UI对象不支持该操作。 + +**可能原因** + +当前界面控件/窗口属性不支持该操作。 + +**处理步骤** + +检查当前界面控件/窗口属性是否该操作。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-window.md b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md new file mode 100755 index 0000000000000000000000000000000000000000..f55c63a902daf8e263d1f9fd410fb70791b8bfef --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md @@ -0,0 +1,61 @@ +# 窗口错误码 + +## 1300001 重复操作 +### 错误信息 +This is repeat operation. +### 错误描述 +当进行某些重复操作时,系统会报此错误码。 +### 可能原因 +创建的窗口已经存在时,再次创建该窗口会报错。 +### 处理步骤 +在创建窗口前,检查该窗口是否已经存在,确保为首次创建该窗口。 + +## 1300002 窗口状态异常 +### 错误信息 +This window state is abnormal. +### 错误描述 +当窗口状态异常,如已被销毁时,操作该窗口,会报此错误码。 +### 可能原因 +操作窗口时,该窗口已被销毁。 +### 处理步骤 +在对窗口进行操作前,检查该窗口是否存在,确保其未被销毁,再进行相关操作。 + +## 1300003 系统服务工作异常 +### 错误信息 +This window manager service work abnormally. +### 错误描述 +当系统服务工作异常时,会报此错误码。 +### 可能原因 +窗口内部服务没有正常启动。 +### 处理步骤 +系统服务内部工作异常,请稍候重试,或者重启设备尝试。 + +## 1300004 无权限操作 +### 错误信息 +This operation is not access. +### 错误描述 +当对无操作权限的对象进行操作时,会报此错误码。 +### 可能原因 +操作了其它进程的窗口对象。 +### 处理步骤 +请检查是否非法操作了别的进程的对象,删除相关操作。 + +## 1300005 WindowStage异常 +### 错误信息 +This window stage is abnormal. +### 错误描述 +当WindowStage异常,如已被销毁时,操作该WindowStage,会报此错误码。 +### 可能原因 +操作WindowStage时,该WindowStage已被销毁。 +### 处理步骤 +在对WindowStage进行操作前,检查该WindowStage是否存在,若已被销毁,请释放该WindowStage下的窗口。 + +## 1300006 窗口上下文异常 +### 错误信息 +This window context is abnormal. +### 错误描述 +当窗口上下文异常,如已被销毁时,操作该窗口上下文,会报此错误码。 +### 可能原因 +操作窗口上下文时,该窗口上下文已被销毁。 +### 处理步骤 +在对窗口上下文进行操作前,检查该窗口上下文是否存在,确保其未被销毁,再进行相关操作。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcodes-zlib.md b/zh-cn/application-dev/reference/errorcodes/errorcodes-zlib.md new file mode 100755 index 0000000000000000000000000000000000000000..559f2ba4a7e76e966212fc53bb96e88270e1c09a --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcodes-zlib.md @@ -0,0 +1,39 @@ +# zlib子系统错误码 + +## 900001 传入的源文件错误 + +**错误信息** + +The input source file is invalid. + +**错误描述** + +当调用compress或decompress接口时,传入源文件无效。 + +**可能原因** + +当调用compress接口时,传入的待压缩的文件不存在;当调用decompress接口时,传入的待解压缩的文件不存在。 + +**处理步骤** + +检查源文件是否存在。 + +## 900002 传入的目标文件错误 + +**错误信息** + +The input destination file is invalid. + +**错误描述** + +当调用compress或decompress接口时,传入目标文件无效。 + +**可能原因** + +1. 当调用compress接口时,传入的目标文件路径无效,如不存在的沙箱路径。 +2. 当调用decompress接口时,传入的目标目录不存在。 + +**处理步骤** + +1. 检查目标文件路径是否正确,不正确填写正确的沙箱路径。 +2. 检查目标文件目录是否存在,不存在新建这个路径。 \ No newline at end of file diff --git a/zh-cn/application-dev/security/cryptoFramework-guidelines.md b/zh-cn/application-dev/security/cryptoFramework-guidelines.md index 25ec2c1d5f90c205e85feb869efd7356b70bc7b1..368108ba13572fde86046d1e30febc4dae2551ed 100644 --- a/zh-cn/application-dev/security/cryptoFramework-guidelines.md +++ b/zh-cn/application-dev/security/cryptoFramework-guidelines.md @@ -1,8 +1,211 @@ # 加解密算法库框架开发指导 + +> **说明** +> +> 本开发指导基于API version 9,OH SDK版本3.2.7.3,适用于JS语言开发 + +## 使用密钥对象生成与转换操作 + +**场景说明** + +使用密钥生成操作中,典型的场景有: + +1. 随机生成算法库密钥对象。该对象可用于后续的加解密等操作。 +2. 根据指定数据生成算法库密钥对象(也就是将外部或存储的二进制数据转换为算法库的密钥对象)。该对象可用于后续的加解密等操作。 +3. 获取算法库密钥对象的二进制数据,用于存储或传输。 +> **说明**:密钥对象Key包括对称密钥SymKey和非对称密钥(公钥PubKey和私钥PriKey),其中公钥和私钥组成密钥对KeyPair。密钥之间的具体关系可参考[接口声明](../reference/apis/js-apis-cryptoFramework.md)。 + + +**接口及参数说明** + +详细接口说明可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 + +以上场景涉及的常用接口如下表所示: + +|实例名|接口名|描述| +|---|---|---| +|cryptoFramework|createAsyKeyGenerator(algName : string) : AsyKeyGenerator|根据algName设置的非对称密钥规格,创建非对称密钥生成器对象| +|cryptoFramework|createSymKeyGenerator(algName : string) : SymKeyGenerator|根据algName设置的对称密钥规格,创建对称密钥生成器对象| +|AsyKeyGenerator|generateKeyPair(callback : AsyncCallback\) : void|使用callback方式,随机生成非对称密钥对象KeyPair| +|AsyKeyGenerator|generateKeyPair() : Promise\|使用Promise方式,随机生成非对称密钥对象KeyPair| +|SymKeyGenerator|generateSymKey(callback : AsyncCallback\) : void|使用callback方式,随机生成对称密钥对象SymKey| +|SymKeyGenerator|generateSymKey() : Promise\|使用Promise方式,随机生成对称密钥对象SymKey| +| AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\) : void | 使用callback方式,根据指定的公钥和私钥二进制数据生成KeyPair对象
(允许公钥/私钥为null,即只传入单一公钥或私钥,生成只携带公钥或私钥的KeyPair对象) | +| AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\ | 使用Promise方式,根据指定的公钥和私钥二进制数据生成KeyPair对象
(允许公钥/私钥为null,即只传入单一公钥或私钥,生成只携带公钥或私钥的KeyPair对象) | +| SymKeyGenerator | convertKey(key : DataBlob, callback : AsyncCallback\) : void| 使用callback方式,根据指定的二进制数据,生成对称密钥对象SymKey | +| SymKeyGenerator |convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\| 使用Promise方式,根据指定的二进制数据,生成对称密钥对象SymKey | +| Key | getEncoded() : DataBlob; | 获取Key密钥对象的二进制数据(Key的子类实例包括对称密钥SymKey、公钥PubKey、私钥PriKey) | + +**开发步骤** + +示例1:随机生成非对称密钥KeyPair,并获得二进制数据(场景1、3) + +1. 创建非对称密钥生成器; +2. 通过非对称密钥生成器随机生成非对称密钥; +3. 获取密钥对象的二进制数据; + +以使用Promise方式随机生成RSA密钥(1024位,素数个数为2)为例: + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function generateAsyKey() { + // 创建非对称密钥生成器 + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + // 通过非对称密钥生成器,随机生成非对称密钥 + let keyGenPromise = rsaGenerator.generateKeyPair(); + keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + let pubKey = globalKeyPair.pubKey; + let priKey = globalKeyPair.priKey; + // 获取非对称密钥的二进制数据 + pkBlob = pubKey.getEncoded(); + skBlob = priKey.getEncoded(); + AlertDialog.show({ message : "pk bin data" + pkBlob.data} ); + AlertDialog.show({ message : "sk bin data" + skBlob.data} ); + }) +} +``` + +示例2:随机生成对称密钥SymKey,并获得二进制数据(场景1、3) + +1. 创建对称密钥生成器; +2. 通过对称密钥生成器随机生成对称密钥; +3. 获取算法库密钥对象的二进制数据; + +以使用Promise方式随机生成AES密钥(256位)为例: + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 字节流以16进制输出 +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +function testGenerateAesKey() { + // 创建对称密钥生成器 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + // 通过密钥生成器随机生成对称密钥 + let promiseSymKey = symKeyGenerator.generateSymKey(); + promiseSymKey.then( key => { + // 获取对称密钥的二进制数据,输出长度为256bit的字节流 + let encodedKey = key.getEncoded(); + console.info('key hex:' + uint8ArrayToShowStr(encodedKey.data)); + }) +} +``` + +示例3:根据指定的RSA非对称密钥二进制数据,生成KeyPair对象(场景2) + +1. 获取RSA二进制密钥数据封装成DataBlob对象,按keysize(32位) 、nsize(keysize/8)、 esize(e实际长度)、dsize(keysize/8)、nval(大数n的二进制数据)、eval(大数e的二进制数据)和dval(大数d的二进制数据)拼接形成。 +2. 调用convertKey方法,传入公钥二进制和私钥二进制(二者非必选项,可只传入其中一个),转换为KeyPair对象。 + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function convertAsyKey() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024"); + // 公钥二进制数据 + let pkval = new Uint8Array([0,4,0,0,128,0,0,0,3,0,0,0,0,0,0,0,182,22,137,81,111,129,17,47,33,97,67,85,251,53,127,42,130,150,93,144,129,104,14,73,110,189,138,82,53,74,114,86,24,186,143,65,87,110,237,69,206,207,5,81,24,32,41,160,209,125,162,92,0,148,49,241,235,0,71,198,1,28,136,106,152,22,25,249,77,241,57,149,154,44,200,6,0,83,246,63,162,106,242,131,80,227,143,162,210,28,127,136,123,172,26,247,2,194,16,1,100,122,180,251,57,22,69,133,232,145,107,66,80,201,151,46,114,175,116,57,45,170,188,77,86,230,111,45,1,0,1]); + // 封装成DataBlob对象 + let pkBlob = {data : pkval}; + // 调用密钥转换函数 + let convertKeyPromise = rsaGenerator.convertKey(pkBlob, null); + convertKeyPromise.then( keyPair => { + if (keyPair == null) { + AlertDialog.show({message : "Convert keypair fail"}); + } + AlertDialog.show({message : "Convert KeyPair success"}); + }) +} +``` + +**说明** + +1. nsize和dsize为密钥位数/8,esize为具体的实际长度。 +2. 私钥材料需要包含keysize,nsize,esize,dsize,nval,eval,dval的全部数据,公钥材料中dsize设置为为0,缺省dval的数据。 +3. 公钥和私钥二进制数据为可选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。 +4. keysize、nsize、esize和dsize为32位二进制数据,数据的大小端格式请按设备CPU默认格式,密钥材料(nval、eval、dval)统一为大端格式。 + +示例4:根据指定的ECC非对称密钥二进制数据,生成KeyPair对象(场景2、3) + +1. 获取ECC二进制密钥数据,封装成DataBlob对象。 +2. 调用convertKey方法,传入公钥二进制和私钥二进制(二者非必选项,可只传入其中一个),转换为KeyPair对象。 + +```javascript +function convertEccAsyKey() { + let pubKeyArray = new Uint8Array([4,196,55,233,100,227,224,38,38,5,128,81,53,112,129,7,59,189,116,105,182,87,190,85,31,248,172,116,213,7,206,85,190,65,169,193,138,173,232,187,74,54,78,251,29,131,192,223,251,227,170,138,80,7,98,193,216,168,235,114,255,188,70,134,104]); + let priKeyArray = new Uint8Array([255,70,89,220,189,19,41,157,175,173,83,60,74,216,195,96,24,181,231,23,112,247,150,126,15,155,24,79,33,97,31,225]); + let pubKeyBlob = { data: pubKeyArray }; + let priKeyBlob = { data: priKeyArray }; + let generator = cryptoFrameWork.createAsyKeyGenerator("ECC256"); + generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { + if (error) { + AlertDialog.show({message : "Convert keypair fail"}); + } + AlertDialog.show({message : "Convert KeyPair success"}); + }) +} +``` + +示例5:根据指定的对称密钥二进制数据,生成SymKey对象(场景2、3) + +1. 创建对称密钥生成器; +2. 通过对称密钥生成器,根据指定的对称密钥二进制数据,生成SymKey对象; +3. 获取算法库密钥对象的二进制数据; + +以使用callback方式生成3DES密钥(3DES密钥只能为192位)为例: + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 字节流以16进制输出 +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + +function testConvertAesKey() { + // 生成对称密钥生成器 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + // 根据用户指定的数据,生成对称密钥 + let keyMaterialBlob = genKeyMaterialBlob(); + try { + symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { + if (error) { // 业务逻辑执行错误通过callback的第一个参数返回错误信息 + console.error(`convertKey error, ${error.code}, ${error.message}`); + return; + } + console.info(`key algName: ${key.algName}`); + console.info(`key format: ${key.format}`); + let encodedKey = key.getEncoded(); // 获取对称密钥的二进制数据,输出长度为192bit的字节流 + console.info('key getEncoded hex: ' + uint8ArrayToShowStr(encodedKey.data)); + }) + } catch (error) { // 参数检查的错误以同步的方式立即抛出异常 + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } +} +``` + ## 使用加解密操作 + **场景说明** -使用加解密操作中,典型的场景有: +在数据存储或传输场景中,可以使用加解密操作用于保证数据的机密性,防止敏感数据泄露。使用加解密操作中,典型的场景有: 1. 使用对称密钥的加解密操作 2. 使用非对称密钥的加解密操作 @@ -26,9 +229,9 @@ 示例1:使用对称密钥的加解密操作 -1. 生成对称密钥生成器。 +1. 创建对称密钥生成器。 2. 通过密钥生成器生成对称密钥。 -3. 生成加解密生成器。 +3. 创建加解密生成器。 4. 通过加解密生成器加密或解密数据。 以AES GCM以Promise方式加解密为例: @@ -345,7 +548,8 @@ function encryptMessageCallback() { ## 使用签名验签操作 **场景说明** -使用签名验签操作中,典型的场景有: + +当需要判断接收的数据是否被篡改且是否为指定对象发送的数据时,可以使用签名验签操作。使用签名验签操作中,典型的场景有: 1. 使用RSA签名验签操作 2. 使用ECC签名验签操作 @@ -375,9 +579,9 @@ function encryptMessageCallback() { 示例1:使用RSA签名验签操作 1. 生成RSA密钥。通过createAsyKeyGenerator接口创建AsyKeyGenerator对象,并生成RSA非对称密钥。 2. 生成Sign对象。通过createSign接口创建Sign对象,执行初始化操作并设置签名私钥。 -3. 执行签名操作。通过Sign类提供的update接口,添加签名数据,并调用doFinal接口生成数据的签名。 +3. 执行签名操作。通过Sign类提供的update接口,添加签名数据,并调用sign接口生成数据的签名。 4. 生成Verify对象。通过createVerify接口创建Verify对象,执行初始化操作并设置验签公钥。 -5. 执行验签操作。通过Verify类提供的update接口,添加签名数据,并调用doFinal接口传入签名进行验签。 +5. 执行验签操作。通过Verify类提供的update接口,添加签名数据,并调用verify接口传入签名进行验签。 ```javascript import cryptoFramework from "@ohos.security.cryptoFramework" @@ -545,6 +749,8 @@ function verifyMessageCallback() { **场景说明** +用户指定摘要算法(如SHA256)生成Md实例,并输入单段或多段需要摘要的信息,进行摘要计算更新,并返回消息摘要计算结果,在指定算法后可获取当前算法名与摘要计算长度(字节) + 使用摘要操作的主要场景为: 用户指定摘要算法(如SHA256)生成Md实例,并输入单段或多段需要摘要的信息,进行摘要计算更新,并返回消息摘要计算结果,在指定算法后可获取当前算法名与摘要计算长度(字节) @@ -647,9 +853,9 @@ function doMdByCallback(algName) { **场景说明** -使用签名验签操作中,典型的场景有: +使用密钥协商操作中,典型的场景有: -使用ECDH操作。 +通信双方可以在一个公开的信道上通过相互传送一些消息,共同建立一个安全的共享秘密密钥。 **接口及参数说明** @@ -714,7 +920,9 @@ function ecdhCallback() { **场景说明** -使用消息认证码操作的主要场景为: +消息认证码操作主要应用于身份认证的场景: + +Mac(message authentication code)可以对消息进行完整性校验,通过使用双方共享的密钥,识别出信息伪装篡改等行为 用户指定摘要算法(如SHA256)生成消息认证码Mac实例,输入对称密钥初始化Mac,并传入单段或多段需要摘要的信息,进行消息认证码计算,并获取消息认证码计算结果,在指定算法后可获取当前算法名与消息认证码计算长度(字节)。 @@ -915,3 +1123,497 @@ function doRandByCallback(len) { }); } ``` + +## 使用证书操作 + +**场景说明** + +使用证书操作中,典型的场景有: + +1. 解析X509证书数据生成证书对象。 +2. 获取证书信息,比如:证书版本、证书序列号等。 +3. 获取证书对象的序列化数据。 +4. 获取证书公钥。 +5. 证书验签。 +6. 校验证书有效期。 + +**接口及参数说明** + +详细接口说明可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 + +以上场景涉及的常用接口如下表所示: + +| 实例名 | 接口名 | 描述 | +| --------------- | ------------------------------------------------------------ | -------------------------------------------- | +| cryptoFramework | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback) : void | 使用callback方式解析X509证书数据生成证书对象 | +| cryptoFramework | createX509Cert(inStream : EncodingBlob) : Promise | 使用promise方式解析X509证书数据生成证书对象 | +| X509Cert | verify(key : PubKey, callback : AsyncCallback) : void | 使用callback方式进行证书验签 | +| X509Cert | verify(key : PubKey) : Promise | 使用promise方式进行证书验签 | +| X509Cert | getEncoded(callback : AsyncCallback) : void | 使用callback方式获取证书序列化数据 | +| X509Cert | getEncoded() : Promise | 使用promise方式获取证书序列化数据 | +| X509Cert | getPublicKey(callback : AsyncCallback) : void | 使用callback方式获取证书公钥 | +| X509Cert | getPublicKey() : Promise | 使用Promise方式获取证书公钥 | +| X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback) : void | 使用callback方式校验证书有效期 | +| X509Cert | checkValidityWithDate(date: string) : Promise | 使用Promise方式校验证书有效期 | +| X509Cert | getVersion() : number | 获取证书版本 | +| X509Cert | getSerialNumber() : number | 获取证书序列号 | +| X509Cert | getIssuerName() : DataBlob | 获取证书颁发者名称 | +| X509Cert | getSubjectName() : DataBlob | 获取证书主体名称 | +| X509Cert | getNotBeforeTime() : string | 获取证书有效期起始时间 | +| X509Cert | getNotAfterTime() : string | 获取证书有效期截至时间 | +| X509Cert | getSignature() : DataBlob | 获取证书签名 | +| X509Cert | getSignatureAlgName() : string | 获取证书签名算法名称 | +| X509Cert | getSignatureAlgOid() : string | 获取证书签名算法OID | +| X509Cert | getSignatureAlgParams() : DataBlob | 获取证书签名算法参数 | +| X509Cert | getKeyUsage() : DataBlob | 获取证书秘钥用途 | +| X509Cert | getExtKeyUsage() : DataArray | 获取证书扩展秘钥用途 | +| X509Cert | getBasicConstraints() : number | 获取证书基本约束 | +| X509Cert | getSubjectAltNames() : DataArray | 获取证书主体可选名称 | +| X509Cert | getIssuerAltNames() : DataArray | 获取证书颁发者可选名称 | + +**开发步骤** + +示例:解析X509证书数据生成证书对象,并调用对象方法(包含场景1-6) + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 证书数据,此处仅示例,业务需根据场景自行设置 +let certData = "-----BEGIN CERTIFICATE-----\n" ++ "IBzTCCAXCgAwIBAgIGAXKnMKNyMAwGCCqBHM9VAYN1BQAwSTELMAkGA1UEBhMC\n" ++ "04xDjAMBgNVBAoTBUdNU1NMMRAwDgYDVQQLEwdQS0kvU00yMRgwFgYDVQQDEw9S\n" ++ "290Q0EgZm9yIFRlc3QwIhgPMjAxNTEyMzExNjAwMDBaGA8yMDM1MTIzMDE2MDAw\n" ++ "FowSTELMAkGA1UEBhMCQ04xDjAMBgNVBAoTBUdNU1NMMRAwDgYDVQQLEwdQS0kv\n" ++ "00yMRgwFgYDVQQDEw9Sb290Q0EgZm9yIFRlc3QwWTATBgcqhkjOPQIBBggqgRzP\n" ++ "QGCLQNCAATj+apYlL+ddWXZ7+mFZXZJGbcJFXUN+Fszz6humeyWZP4qEEr2N0+a\n" ++ "dwo/21ft232yo0jPLzdscKB261zSQXSoz4wPDAZBgNVHQ4EEgQQnGnsD7oaOcWv\n" ++ "CTrspwSBDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIAxjAMBggqgRzP\n" ++ "QGDdQUAA0kAMEYCIQCEnW5BlQh0vmsOLxSoXYc/7zs++wWyFc1tnBHENR4ElwIh\n" ++ "I1Lwu6in1ruflZhzseWulXwcITf3bm/Y5X1g1XFWQUH\n" ++ "-----END CERTIFICATE-----\n"; + +// string转Uint8Array +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// 证书示例 +function certSample() { + let encodingBlob = { + // 将string类型证书数据转为Uint8Array + data: stringToUint8Array(certData), + // 证书格式:支持PEM和DER,此例中对应PEM + encodingFormat: cryptoFramework.EncodingFormat.FORMAT_PEM + }; + + // 创建证书对象 + cryptoFramework.createX509Cert(encodingBlob, function (err, x509Cert) { + if (err != null) { + // 创建证书对象失败 + Console.log("createX509Cert failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // 创建证书对象成功 + Console.log("createX509Cert success"); + + // 获取证书版本 + let version = x509Cert.getVersion(); + + // 获取证书对象的序列化数据 + x509Cert.getEncoded(function (err, data) { + if (err != null) { + // 获取序列化数据失败 + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取序列化数据成功 + Console.log("getEncoded success"); + } + }); + + // 获取证书公钥对象 + x509Cert.getPublicKey(function (err, pubKey) { + if (err != null) { + // 获取证书公钥失败 + Console.log("getPublicKey failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取证书公钥成功 + Console.log("getPublicKey success"); + } + }); + + // 业务需通过上级证书对象或本证书对象(自签名)的getPublicKey接口获取公钥对象,此处省略 + let pubKey = null; + + // 证书验签 + x509Cert.verify(pubKey, function (err, data) { + if (err == null) { + // 验签成功 + Console.log("verify success"); + } else { + // 验签失败 + Console.log("verify failed, errCode: " + err.code + ", errMsg: " + err.message); + } + }); + + // 时间字符串 + let date = "150527000001Z"; + + // 校验证书有效期 + x509Cert.checkValidityWithDate(date, function (err, data) { + if (err != null) { + // 证书有效期校验失败 + Console.log("checkValidityWithDate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 证书有效期校验成功 + Console.log("checkValidityWithDate success"); + } + }); + }); +} +``` + +## 使用证书吊销列表操作 + +**场景说明** + +使用证书吊销列表操作中,典型的场景有: + +1. 解析X509证书吊销列表数据生成吊销列表对象。 +2. 获取证书吊销列表信息,比如:证书吊销列表版本、证书吊销列表类型等。 +3. 获取证书吊销列表对象的序列化数据。 +4. 检查证书是否被吊销。 +5. 证书吊销列表验签。 +6. 获取被吊销证书。 + +**接口及参数说明** + +详细接口说明可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 + +以上场景涉及的常用接口如下表所示: + +| 实例名 | 接口名 | 描述 | +| --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| cryptoFramework | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback) : void | 使用callback方式解析X509证书吊销列表数据生成证书吊销列表对象 | +| cryptoFramework | createX509Crl(inStream : EncodingBlob) : Promise | 使用promise方式解析X509证书吊销列表数据生成证书吊销列表对象 | +| X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback) : void | 使用callback方式检查证书是否被吊销 | +| X509Crl | isRevoked(cert : X509Cert) : Promise | 使用promise方式检查证书是否被吊销 | +| X509Crl | getType() : string | 获取证书吊销列表类型 | +| X509Crl | getEncoded(callback : AsyncCallback) : void | 使用callback方式获取证书吊销列表序列化数据 | +| X509Crl | getEncoded() : Promise | 使用promise方式获取证书吊销列表序列化数据 | +| X509Crl | verify(key : PubKey, callback : AsyncCallback) : void | 使用callback方式进行证书吊销列表验签 | +| X509Crl | verify(key : PubKey) : Promise | 使用Promise方式进行证书吊销列表验签 | +| X509Crl | getVersion() : number | 获取证书吊销列表版本 | +| X509Crl | getIssuerName() : DataBlob | 获取证书吊销列表颁发者名称 | +| X509Crl | getLastUpdate() : string | 获取证书吊销列表lastUpdate日期 | +| X509Crl | getNextUpdate() : string | 获取证书吊销列表nextUpdate日期 | +| X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback) : void | 使用callback方式通过序列号获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCert(serialNumber : number) : Promise | 使用Promise方式通过序列号获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback) : void | 使用callback方式通过X509证书获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCertWithCert(cert : X509Cert) : Promise | 使用Promise方式通过X509证书获取证书吊销列表中的被吊销证书 | +| X509Crl | getRevokedCerts(callback : AsyncCallback>) : void | 使用callback方式获取证书吊销列表的所有被吊销证书 | +| X509Crl | getRevokedCerts() : Promise> | 使用Promise方式获取证书吊销列表的所有被吊销证书 | +| X509Crl | getTbsInfo(callback : AsyncCallback) : void | 使用callback方式获取证书吊销列表的tbsCertList | +| X509Crl | getTbsInfo() : Promise | 使用Promise方式获取证书吊销列表的tbsCertList | +| X509Crl | getSignature() : DataBlob | 获取证书吊销列表的签名 | +| X509Crl | getSignatureAlgName() : string | 获取证书吊销列表的签名算法名称 | +| X509Crl | getSignatureAlgOid() : string | 获取证书吊销列表的签名算法OID | +| X509Crl | getSignatureAlgParams() : DataBlob | 获取证书吊销列表的签名算法参数 | + +**开发步骤** + +示例:解析X509证书吊销列表数据生成证书吊销列表对象,并调用对象方法(包含场景1-6) + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 证书吊销列表数据,此处仅示例,业务需根据场景自行设置 +let crlData = "-----BEGIN X509 CRL-----\n" ++ "MIIBijB0AgEBMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCHJvb3QtY2ExFw0y\n" ++ "MDA2MTkxNjE1NDhaFw0yMDA3MTkxNjE1NDhaMBwwGgIJAMsozRATnap1Fw0yMDA2\n" ++ "MTkxNjEyMDdaoA8wDTALBgNVHRQEBAICEAIwDQYJKoZIhvcNAQELBQADggEBACPs\n" ++ "9gQB+djaXPHHRmAItebZpD3iJ/e36Dxr6aMVkn9FkI8OVpUI4RNcCrywyCZHQJte\n" ++ "995bbPjP7f1sZstOTZS0fDPgJ5SPAxkKOQB+SQnBFrlZSsxoUNU60gRqd2imR0Rn\n" ++ "1r09rP69F6E4yPc9biEld+llLGgoImP3zPOVDD6fbfcvVkjStY3bssVEQ/vjp4a3\n" ++ "/I12U7ZnSe3jaKqaQBoVJppkTFOIOq7IOxf5/IkMPmvRHDeC2IzDMzcUxym0dkny\n" ++ "EowHrjzo0bZVqpHMA2YgKZuwTpVLHk9GeBEK2hVkIoPVISkmiU4HFg0S6z68C5yd\n" ++ "DrAA7hErVgXhtURLbAI=\n" ++ "-----END X509 CRL-----\n"; + +// string转Uint8Array +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// 证书吊销列表示例 +function crlSample() { + let encodingBlob = { + // 将string类型证书吊销列表数据转为Uint8Array + data: stringToUint8Array(crlData), + // 证书吊销列表格式:支持PEM和DER,此例中对应PEM + encodingFormat: cryptoFramework.EncodingFormat.FORMAT_PEM + }; + + // 创建证书吊销列表对象 + cryptoFramework.createX509Crl(encodingBlob, function (err, x509Crl) { + if (err != null) { + // 创建证书吊销列表对象失败 + Console.log("createX509Crl failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // 创建证书吊销列表对象成功 + Console.log("createX509Crl success"); + + // 获取证书吊销列表版本 + let version = x509Crl.getVersion(); + + // 获取证书吊销列表对象的序列化数据 + x509Crl.getEncoded(function (err, data) { + if (err != null) { + // 获取序列化数据失败 + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取序列化数据成功 + Console.log("getEncoded success"); + } + }); + + // 业务需通过cryptoFramework的createX509Cert生成X509Cert证书对象,此处省略 + let x509Cert = null; + + // 检查证书是否被吊销 + x509Crl.isRevoked(x509Cert, function (err, isRevoked) { + if (err != null) { + // 检查证书是否被吊销失败 + Console.log("isRevoked failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 检查证书是否被吊销成功 + Console.log("isRevoked success, isRevoked? " + isRevoked); + } + }); + + // 业务需通过AsyKeyGenerator的generateKeyPair或convertKey接口获取PubKey对象,此处省略 + let pubKey = null; + + // 证书吊销列表验签 + x509Crl.verify(pubKey, function (err, data) { + if (err == null) { + // 验签成功 + Console.log("verify success"); + } else { + // 验签失败 + Console.log("verify failed, errCode: " + err.code + ", errMsg: " + err.message); + } + }); + + // 证书序列号,业务需自行设置 + let serialNumber = 1000; + + // 获取被吊销证书对象 + x509Crl.getRevokedCert(serialNumber, function (err, entry) { + if (err != null) { + // 获取被吊销证书对象失败 + Console.log("getRevokedCert failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取被吊销证书对象成功 + Console.log("getRevokedCert success"); + } + }); + }); +} +``` + +## 使用证书链校验器操作 + +**场景说明** + +使用证书链校验器操作中,典型的场景有: + +1. 证书链校验。 + +**接口及参数说明** + +详细接口说明可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 + +以上场景涉及的常用接口如下表所示: + +| 实例名 | 接口名 | 描述 | +| ------------------ | ------------------------------------------------------------ | -------------------------------- | +| cryptoFramework | createCertChainValidator(algorithm :string) : CertChainValidator | 使用指定算法生成证书链校验器对象 | +| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback) : void | 使用callback方式校验证书链 | +| CertChainValidator | validate(certChain : CertChainData) : Promise | 使用promise方式校验证书链 | +| CertChainValidator | algorithm : string | 证书链校验器算法名称 | + +**开发步骤** + +示例:创建证书链校验器对象,并对证书链数据进行校验(场景1) + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 一级证书数据,此处仅示例,业务需自行设置真实数据 +let caCertData = "-----BEGIN CERTIFICATE-----\n" ++ "...\n" ++ "...\n" ++ "...\n" ++ "-----END CERTIFICATE-----\n"; + +// 二级证书数据,此处仅示例,业务需自行设置真实数据 +let secondCaCertData = "-----BEGIN CERTIFICATE-----\n" ++ "...\n" ++ "...\n" ++ "...\n" ++ "-----END CERTIFICATE-----\n"; + +// string转Uint8Array +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// 证书链校验器示例:此示例中以校验二级证书链为例,业务需根据场景自行修改 +function certChainValidatorSample() { + // 证书链校验器算法,当前仅支持PKIX + let algorithm = "PKIX"; + + // 创建证书链校验器对象 + let validator = cryptoFramework.createCertChainValidator(algorithm); + + // 一级证书数据 + let uint8ArrayOfCaCertData = stringToUint8Array(caCertData); + + // 一级证书数据长度 + let uint8ArrayOfCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOfCaCertData.byteLength]).buffer); + + // 二级证书数据 + let uint8ArrayOf2ndCaCertData = stringToUint8Array(secondCaCertData); + + // 二级证书数据长度 + let uint8ArrayOf2ndCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOf2ndCaCertData.byteLength]).buffer); + + // 证书链二进制数据:二级证书数据长度+二级证书数据+一级证书数据长度+一级证书数据(L-V格式) + let encodingData = new Uint8Array(uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + uint8ArrayOfCaCertData.length); + for (var i = 0; i < uint8ArrayOf2ndCaCertDataLen.length; i++) { + encodingData[i] = uint8ArrayOf2ndCaCertDataLen[i]; + } + for (var i = 0; i < uint8ArrayOf2ndCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + i] = uint8ArrayOf2ndCaCertData[i]; + } + for (var i = 0; i < uint8ArrayOfCaCertDataLen.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + i] = uint8ArrayOfCaCertDataLen[i]; + } + for (var i = 0; i < uint8ArrayOfCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + i] = uint8ArrayOfCaCertData[i]; + } + + let certChainData = { + // Uint8Array类型:L-V格式(证书数据长度-证书数据) + data: encodingData, + // 证书数量,此示例中为2 + count: 2, + // 证书格式:支持PEM和DER,此例中对应PEM + encodingFormat: cryptoFramework.EncodingFormat.FORMAT_PEM + }; + + // 校验证书链 + validator.validate(certChainData, function (err, data) { + if (err != null) { + // 证书链校验失败 + Console.log("validate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 证书链校验成功 + Console.log("validate success"); + } + }); +} +``` + +## 使用被吊销证书操作 + +**场景说明** + +使用被吊销证书操作中,典型的场景有: + +1. 获取被吊销证书对象。 +2. 获取被吊销证书信息,比如:序列号、证书颁发者、证书吊销日期。 +3. 获取被吊销证书对象的序列化数据。 + +**接口及参数说明** + +详细接口说明可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 + +以上场景涉及的常用接口如下表所示: + +| 实例名 | 接口名 | 描述 | +| ------------ | ----------------------------------------------------------- | ------------------------------------------ | +| X509CrlEntry | getEncoded(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书的序列化数据 | +| X509CrlEntry | getEncoded() : Promise; | 使用promise方式获取被吊销证书的序列化数据 | +| X509CrlEntry | getSerialNumber() : number; | 获取被吊销证书的序列号 | +| X509CrlEntry | getCertIssuer(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书颁发者 | +| X509CrlEntry | getCertIssuer() : Promise; | 使用promise方式获取被吊销证书颁发者 | +| X509CrlEntry | getRevocationDate(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书的吊销日期 | +| X509CrlEntry | getRevocationDate() : Promise; | 使用promise方式获取被吊销证书的吊销日期 | + +**开发步骤** + +示例:获取被吊销证书对象,并调用对象方法(包含场景1-3) + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// 被吊销证书示例 +function crlEntrySample() { + // 业务需自行通过cryptoFramework的createX509Crl接口创建X509Crl对象,此处省略 + let x509Crl = null; + + // 获取被吊销证书对象,业务需根据场景调用X509Crl的接口获取,此示例使用getRevokedCert获取 + let serialNumber = 1000; + x509Crl.getRevokedCert(serialNumber, function (err, crlEntry) { + if (err != null) { + // 获取被吊销证书对象失败 + Console.log("getRevokedCert failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // 获取被吊销证书对象成功 + Console.log("getRevokedCert success"); + + // 获取被吊销证书的序列号 + let serialNumber = crlEntry.getSerialNumber(); + + // 获取被吊销证书的吊销日期 + crlEntry.getRevocationDate(function (err, date) { + if (err != null) { + // 获取吊销日期失败 + Console.log("getRevocationDate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取吊销日期成功 + Console.log("getRevocationDate success, date is: " + date); + } + }); + + // 获取被吊销证书对象的序列化数据 + crlEntry.getEncoded(function (err, data) { + if (err != null) { + // 获取序列化数据失败 + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // 获取序列化数据成功 + Console.log("getEncoded success"); + } + }); + }); +} +``` + diff --git a/zh-cn/application-dev/task-management/Readme-CN.md b/zh-cn/application-dev/task-management/Readme-CN.md index 159ee194cc514d7907eec755118216397a609958..366d781608794fb232246ee0db5413cdf89e39fa 100644 --- a/zh-cn/application-dev/task-management/Readme-CN.md +++ b/zh-cn/application-dev/task-management/Readme-CN.md @@ -4,5 +4,9 @@ - [后台任务概述](background-task-overview.md) - [短时任务开发指导](transient-task-dev-guide.md) - [长时任务开发指导](continuous-task-dev-guide.md) - - [延时任务开发指导](work-scheduler-dev-guide.md) - - [能效资源申请开发指导](efficiency-resources-apply-dev-guide.md) \ No newline at end of file + - [延迟任务开发指导](work-scheduler-dev-guide.md) + - [能效资源申请开发指导](efficiency-resources-apply-dev-guide.md) + +- 后台代理提醒 + - [后台代理提醒开发概述](background-agent-scheduled-reminder-overview.md) + - [后台代理提醒开发指导](background-agent-scheduled-reminder-guide.md) diff --git a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/task-management/background-agent-scheduled-reminder-guide.md similarity index 100% rename from zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md rename to zh-cn/application-dev/task-management/background-agent-scheduled-reminder-guide.md diff --git a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-overview.md b/zh-cn/application-dev/task-management/background-agent-scheduled-reminder-overview.md similarity index 100% rename from zh-cn/application-dev/notification/background-agent-scheduled-reminder-overview.md rename to zh-cn/application-dev/task-management/background-agent-scheduled-reminder-overview.md diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index de85a882c0692bc2d2962070638d6f9187210192..43a36d9c018f9e9b7679c5a6a64117f38e91d9b1 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -1,6 +1,7 @@ # UI开发 - [方舟开发框架(ArkUI)概述](arkui-overview.md) + - UI开发(基于eTS的声明式开发范式) - [概述](ui-ts-overview.md) - 框架说明 @@ -11,49 +12,11 @@ - [资源文件的分类](ui-ts-basic-resource-file-categories.md) - [资源访问](ts-resource-access.md) - [像素单位](ts-pixel-units.md) - - 声明式语法 - - [描述规范使用说明](ts-syntax-intro.md) - - 通用UI描述规范 - - [基本概念](ts-general-ui-concepts.md) - - 声明式UI描述规范 - - [无构造参数配置](ts-parameterless-configuration.md) - - [必选参数构造配置](ts-configuration-with-mandatory-parameters.md) - - [属性配置](ts-attribution-configuration.md) - - [事件配置](ts-event-configuration.md) - - [子组件配置](ts-child-component-configuration.md) - - 组件化 - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - [@Styles](ts-component-based-styles.md) - - UI状态管理 - - [基本概念](ts-ui-state-mgmt-concepts.md) - - 管理组件拥有的状态 - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - 管理应用程序的状态 - - [应用程序的数据存储](ts-application-states-appstorage.md) - - [Ability数据存储](ui-ts-local-storage.md) - - [持久化数据管理](ts-application-states-apis-persistentstorage.md) - - [环境变量](ts-application-states-apis-environment.md) - - 其他类目的状态管理 - - [Observed和ObjectLink数据管理](ts-other-states-observed-objectlink.md) - - [@Consume和@Provide数据管理](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - 渲染控制语法 - - [条件渲染](ts-rending-control-syntax-if-else.md) - - [循环渲染](ts-rending-control-syntax-foreach.md) - - [数据懒加载](ts-rending-control-syntax-lazyforeach.md) + - 深入理解组件化 - - [build函数](ts-function-build.md) - [自定义组件初始化](ts-custom-component-initialization.md) - [自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md) - [组件创建和重新初始化示例](ts-component-creation-re-initialization.md) - - [语法糖](ts-syntactic-sugar.md) - 常见组件开发指导 - [Button开发指导](ui-ts-basic-components-button.md) - [Web开发指导](ui-ts-components-web.md) diff --git a/zh-cn/application-dev/ui/arkui-overview.md b/zh-cn/application-dev/ui/arkui-overview.md index 3d809b82f2c6fbc107a710376dc63b3fd2800b60..fa6a13c44764b405d9233895a71216803086f671 100644 --- a/zh-cn/application-dev/ui/arkui-overview.md +++ b/zh-cn/application-dev/ui/arkui-overview.md @@ -1,42 +1,60 @@ # 方舟开发框架概述 -## 框架介绍 - -方舟开发框架(简称:ArkUI),是一套UI开发框架,提供开发者进行应用UI开发时所必需的能力。 - +方舟开发框架(简称:ArkUI),是一套构建OpenHarmony应用界面的UI开发框架,它提供了极简的UI语法与包括UI组件、动画机制、事件交互等在内的UI开发基础设施,以满足应用开发者的可视化界面开发需求。 ## 基本概念 -- 组件:组件是界面搭建与显示的最小单位。开发者通过多种组件的组合,构建出满足自身应用诉求的完整界面。 - -- 页面:page页面是方舟开发框架最小的调度分割单位。开发者可以将应用设计为多个功能页面,每个页面进行单独的文件管理,并通过路由API实现页面的调度管理,以实现应用内功能的解耦。 +- **组件:** 组件是界面搭建与显示的最小单位。开发者通过多种组件的组合,构建出满足自身应用诉求的完整界面。 +- **页面:** page页面是方舟开发框架最小的调度分割单位。开发者可以将应用设计为多个功能页面,每个页面进行单独的文件管理,并通过[页面路由](../reference/apis/js-apis-router.md)API完成页面间的调度管理,以实现应用内功能的解耦。 ## 主要特征 -- UI组件:方舟开发框架不仅提供了多种基础组件, 例如文本、图片、按钮等 ,也提供了支持视频播放能力的媒体组件。并且针对不同类型设备进行了组件设计,提供了组件在不同平台上的样式适配能力,此种组件称为“多态组件”。 +- **UI组件:** 方舟开发框架内置了丰富的多态组件,包括文本、图片、按钮等基础组件,可包含一个或多个子组件的容器组件,满足开发者自定义绘图需求的绘制组件,以及提供视频播放能力的媒体组件等。其中“多态”是指组件针对不同类型设备进行了设计,提供了在不同平台上的样式适配能力。 -- 布局:UI界面设计离不开布局的参与。方舟开发框架提供了多种布局方式,不仅保留了经典的弹性布局能力,也提供了列表、宫格、栅格布局和适应多分辨率场景开发的原子布局能力。 +- **布局:** UI界面设计离不开布局的参与。方舟开发框架提供了多种布局方式,除了基础的线性布局、弹性布局外,也提供了相对复杂的列表、宫格、栅格布局,以及自适应多分辨率场景开发的原子布局能力。 -- 动画:方舟开发框架对于UI界面的美化,除了组件内置动画效果外,也提供了属性动画、转场动画和自定义动画能力。 +- **动画:** 动画是UI界面的重要元素之一,优秀的动画设计能够极大地提升用户体验,方舟开发框架提供了丰富的动画能力,除了组件内置动画效果外,还包括属性动画、自定义转场动画以及动画API等。 -- 绘制:方舟开发框架提供了多种绘制能力,以满足开发者绘制自定义形状的需求,支持图形绘制、颜色填充、文本绘制、图片绘制等。 +- **绘制:** 方舟开发框架提供了多种绘制能力,以满足开发者的自定义绘图需求,支持绘制形状、颜色填充、绘制文本、变形与裁剪、嵌入图片等。 -- 交互事件:方舟开发框架提供了多种交互能力,满足应用在不同平台通过不同输入设备均可正常进行UI交互响应,默认适配了触摸手势、遥控器、鼠标等输入操作,同时也提供事件通知能力。 +- **交互事件:** 方舟开发框架提供了多种交互能力,以满足应用在不同平台通过不同输入设备进行UI交互响应的需求,默认适配了触摸手势、遥控器按键输入、键鼠输入,同时提供了相应的事件回调以便开发者添加交互逻辑。 -- 平台API通道:方舟开发框架提供了API扩展机制,平台能力通过此种机制进行封装,提供风格统一的JS接口。 +- **平台API通道:** 方舟开发框架提供了API扩展机制,可通过该机制对平台能力进行封装,提供风格统一的JS接口。 -- 两种开发范式:方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于eTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。 +- **两种开发范式:** 方舟开发框架针对不同的应用场景以及不同技术背景的开发者提供了两种开发范式,分别是[基于ArkTS的声明式开发范式](./ui-ts-overview.md)(简称“声明式开发范式”)和[兼容JS的类Web开发范式](./ui-js-overview.md)(简称“类Web开发范式”)。 | 开发范式名称 | 简介 | 适用场景 | 适用人群 | | -------- | ---------------------------------------- | ---------------- | ------------------- | - | 声明式开发范式 | 采用TS语言并进行声明式UI语法扩展,从组件、动效和状态管理三个维度提供了UI绘制能力。UI开发更接近自然语义的编程方式,让开发者直观地描述UI界面,不必关心框架如何实现UI绘制和渲染,实现极简高效开发。同时,选用有类型标注的TS语言,引入编译期的类型校验。 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 | - | 类Web开发范式 | 采用经典的HML、CSS、JavaScript三段式开发方式。使用HML标签文件进行布局搭建,使用CSS文件进行样式描述,使用JavaScript文件进行逻辑处理。UI组件与数据之间通过单向数据绑定的方式建立关联,当数据发生变化时,UI界面自动触发更新。此种开发方式,更接近Web前端开发者的使用习惯,快速将已有的Web应用改造成方舟开发框架应用。 | 界面较为简单的中小型应用和卡片 | Web前端开发人员 | + | 声明式开发范式 | 采用基于TypeScript进行声明式UI语法扩展而来的[ArkTS语言](../quick-start/ets-get-started.md),从组件、动画和状态管理三个维度提供了UI绘制能力。声明式开发范式更接近自然语义的编程方式,让开发者直观地描述UI界面,不必关心框架如何实现UI绘制和渲染,实现极简高效开发。 | 复杂度较大、团队合作度较高的应用 | 移动系统应用开发人员、系统应用开发人员 | + | 类Web开发范式 | 采用经典的HML、CSS、JavaScript三段式开发方式,使用HML标签文件进行布局搭建,使用CSS文件进行样式描述,使用JavaScript文件进行逻辑处理。UI组件与数据之间通过单向数据绑定的方式建立关联,当数据发生变化时,UI界面自动触发刷新。该开发方式更接近Web前端开发者的使用习惯,便于快速将已有的Web应用改造成方舟开发框架应用。 | 界面较简单的中小型应用和卡片 | Web前端开发人员 | +## 框架结构 +![zh-cn_image_0000001183709904](figures/zh-cn_image_0000001183709904.png) -### 框架结构 +从上图可以看出,类Web开发范式与声明式开发范式的UI后端引擎和语言运行时是共用的,其中,UI后端引擎实现了方舟开发框架的六种基本能力。声明式开发范式无需JS Framework进行页面DOM管理,渲染更新链路更为精简,占用内存更少,因此更推荐开发者选用声明式开发范式来搭建应用UI界面。 + +## UI与Ability框架的关系 + +Ability也是OpenHarmony应用的重要组成部分,[Ability框架](../ability/ability-brief.md)包括FA模型与Stage模型两种模型。下表给出了Ability框架的两种模型分别与方舟开发框架的两种开发范式的关系。 + + **FA模型:** + + | 类型 | UI开发范式 | 说明 | + | -------- | --------------------------- | --------------------------- | + | 应用 | 类web开发范式 | UI开发语言:使用hml/css/js
业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability)
业务逻辑语言:js/ts | + | | 声明式开发范式 | UI开发语言:ArkTS
业务入口:使用固定文件名app.ets(Page类型Ability)/service.ts(Service类型Ability)/data.ts(Data类型Ability)
业务逻辑语言:js/ts | + | 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action)
业务入口:form.ts
卡片业务逻辑语言:js/ts | + | | 声明式开发范式 | 当前不支持 | + + **Stage模型:** + + | 类型 | UI开发范式 | 说明 | + | -------- | --------------------------- | --------------------------- | + | 应用 | 类web开发范式 | 当前不支持 | + | | 声明式开发范式 | UI开发语言:ArkTS
业务入口:应用模型基于ohos.application.Ability/ExtensionAbility等派生
业务逻辑语言:ts | + | 服务卡片 | 类web开发范式 | UI开发语言:卡片显示使用hml+css+json(action)
业务入口:从FormExtensionAbility派生
业务逻辑语言:ts | + | | 声明式开发范式 | 当前不支持 | -![zh-cn_image_0000001183709904](figures/zh-cn_image_0000001183709904.png) -从上图可以看出,类Web开发范式与声明式开发范式的UI后端引擎和语言运行时是共用的,其中,UI后端引擎实现了方舟开发框架的六种基本能力。声明式开发范式无需JS Framework进行页面DOM管理,渲染更新链路更为精简,占用内存更少,因此更推荐开发者选用声明式开发范式来搭建应用UI界面。 \ No newline at end of file diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png deleted file mode 100644 index 451c2869775b6b9a68171eca6f3b2ba53f7aff4b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png deleted file mode 100644 index 8dfe0814355dcbe52ceb2126ce32ceac8a725804..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md b/zh-cn/application-dev/ui/ts-application-states-apis-environment.md deleted file mode 100644 index 54c3703e6bf98ac25926741fe4fdc18bf25c3bbe..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md +++ /dev/null @@ -1,32 +0,0 @@ -# 环境变量 - -Environment是框架在应用程序启动时创建的单例对象,它为AppStorage提供了一系列应用程序需要的环境状态属性,这些属性描述了应用程序运行的设备环境。Environment及其属性是不可变的,所有属性值类型均为简单类型。如下示例展示了从Environment获取语音环境: - - -```ts -Environment.EnvProp("accessibilityEnabled", "default"); -var enable = AppStorage.Get("accessibilityEnabled"); -``` - -accessibilityEnabled是Environment提供默认系统变量识别符。首先需要将对应系统属性绑定到AppStorage中,再通过AppStorage中的方法或者装饰器访问对应系统的属性数据。 - - -## Environment接口 - -| key | 参数 | 返回值 | 说明 | -| -------- | ---------------------------------------- | ------- | ---------------------------------------- | -| EnvProp | key: string,
defaultValue: any | boolean | 关联此系统项到AppStorage中,建议在app启动时使用此接口。如果该属性在AppStorage已存在,返回false。请勿使用AppStorage中的变量,在调用此方法关联环境变量。 | -| EnvProps | keys: {
key: string,
defaultValue: any
}[] | void | 关联此系统项数组到AppStorage中。 | -| Keys | Array<string> | number | 返回关联的系统项。 | - - -## Environment内置的环境变量 - -| key | 类型 | 说明 | -| -------------------- | --------------- | ---------------------------------------- | -| accessibilityEnabled | boolean | 无障碍屏幕朗读是否启用。 | -| colorMode | ColorMode | 深浅色模式,可选值为:
- ColorMode.LIGHT:浅色模式;
- ColorMode.DARK:深色模式。 | -| fontScale | number | 字体大小比例,取值范围为[0.85, 1.45]。 | -| fontWeightScale | number | 字体权重比例,取值范围为[0.6, 1.6]。 | -| layoutDirection | LayoutDirection | 布局方向类型,可选值为:
- LayoutDirection.LTR:从左到右;
- LayoutDirection.RTL:从右到左。 | -| languageCode | string | 设置当前系统的语言,小写字母,例如zh。 | diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md b/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md deleted file mode 100644 index 6c8c29d7ca078f56ae8fccbd14aaf61fb75931d9..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md +++ /dev/null @@ -1,46 +0,0 @@ -# 持久化数据管理 - -方舟开发框架通过PersistentStorage类提供了一些静态方法用来管理应用持久化数据,可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据,或者通过@StorageLink装饰器来访问对应key的变量。 - - -| 方法 | 参数说明 | 返回值 | 定义 | -| ------------ | ---------------------------------------- | ------------------- | ---------------------------------------- | -| PersistProp | key : string
defaultValue: T | void | 关联命名的属性在AppStorage变为持久化数据,赋值覆盖顺序如下:
- 首先,如果该属性存在于AppStorage,将Persistent中的数据复写为AppStorage中的属性值。
- 其次,Persistent中有此命名的属性,使用Persistent中的属性值。
- 最后,以上条件均不满足,则使用defaultValue,不支持null和undefined。 | -| DeleteProp | key: string | void | 取消双向数据绑定,该属性值将从持久存储中删除。 | -| PersistProps | keys: {
key: string,
defaultValue: any
}[] | void | 关联多个命名的属性绑定。 | -| Keys | void | Array<string> | 返回所有持久化属性的标记。 | - - -> **说明:** -> - PersistProp接口使用时,需要保证输入对应的key应当在AppStorage存在。 -> -> - DeleteProp接口使用时,只能对本次启动已经link过的数据生效。 - - -```ts -// xxx.ets -PersistentStorage.PersistProp("highScore", "0"); - -@Entry -@Component -struct PersistentComponent { - @StorageLink('highScore') highScore: string = '0' - @State currentScore: number = 0 - build() { - Column() { - if (this.currentScore === Number(this.highScore)) { - Text(`new highScore : ${this.highScore}`) - } - Button() { - Text(`goal!, currentScore : ${this.currentScore}`) - .fontSize(10) - }.onClick(() => { - this.currentScore++ - if (this.currentScore > Number(this.highScore)) { - this.highScore = this.currentScore.toString() - } - }) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-application-states-appstorage.md b/zh-cn/application-dev/ui/ts-application-states-appstorage.md deleted file mode 100644 index 503d3a225b777cfb00cfb55245f69d4be5f92d45..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-application-states-appstorage.md +++ /dev/null @@ -1,101 +0,0 @@ -# 应用程序的数据存储 - -AppStorage是应用程序中的单例对象,由UI框架在应用程序启动时创建,在应用程序退出时销毁,为应用程序范围内的可变状态属性提供中央存储。AppStorage包含整个应用程序中需要访问的所有状态属性,只要应用程序保持运行,AppStorage就会保存所有属性及属性值,属性值可以通过唯一的键值进行访问。 - - -UI组件可以通过装饰器将应用程序状态数据与AppStorage进行同步,应用业务逻辑的实现也可以通过接口访问AppStorage。 - - -AppStorage的选择状态属性可以与不同的数据源或数据接收器同步,这些数据源和接收器可以是设备上的本地或远程,并具有不同的功能,如数据持久性。这样的数据源和接收器可以独立于UI在业务逻辑中实现。 - - -默认情况下,AppStorage中的属性是可变的,AppStorage还可使用不可变(只读)属性。 - - -## AppStorage接口 - -| 方法 | 参数说明 | 返回值 | 定义 | -| ----------- | ---------------------------------------- | ------------------- | ---------------------------------------- | -| SetAndLink | key: string,
defaultValue: T | @Link | 与Link接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Link返回。 | -| Set | key: string,
newValue: T | void | 对已保存的key值,替换其value值。 | -| Link | key: string | @Link | 如果存在具有给定键的数据,则返回到此属性的双向数据绑定,该双向绑定意味着变量或者组件对数据的更改将同步到AppStorage,通过AppStorage对数据的修改将同步到变量或者组件。如果具有此键的属性不存在或属性为只读,则返回undefined。 | -| SetAndProp | propName: string,
defaultValue: S | @Prop | 与Prop接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Prop返回。 | -| Prop | key: string | @Prop | 如果存在具有给定键的属性,则返回此属性的单向数据绑定。该单向绑定意味着只能通过AppStorage将属性的更改同步到变量或者组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态属性,如果具有此键的属性不存在则返回undefined。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> prop方法对应的属性值类型为简单类型。 | -| SetOrCreate | key: string,
newValue: T | boolean | 如果已存在与给定键名字相同的属性,如果此属性可以被更改则替换其value值且返回true,否则不替换且返回false。
如果不存在存在与给定键名字相同的属性, 则创建一个键为key, 值为newValue的属性,属性值不支持null和undefined。 | -| Get | key: string | T或undefined | 通过此接口获取对应key值的value。 | -| Has | propName: string | boolean | 判断对应键值的属性是否存在。 | -| Keys | void | array<string> | 返回包含所有键的字符串数组。 | -| Delete | key: string | boolean | 删除key指定的键值对,如果存在且删除成功返回true,不存在或删除失败返回false。 | -| Clear | void | boolean | 删除所有的属性,如果当前有状态变量依旧引用此属性,则返回false。 | -| IsMutable | key: string | boolean | 返回此属性是否存在并且是否可以改变。 | - - -## AppStorage与组件同步 - -在[管理组件拥有的状态](ts-component-states-state.md)中,已经定义了如何将组件的状态变量与父组件或祖先组件中的@State装饰的状态变量同步,主要包括@Prop、@Link、@Consume。 - -本章节定义如何将组件变量与AppStorage同步,主要提供@StorageLink和@StorageProp装饰器。 - - -### @StorageLink装饰器 - -组件通过使用@StorageLink(key)装饰的状态变量,与AppStorage建立双向数据绑定,key为AppStorage中的属性键值。当创建包含@StorageLink的状态变量的组件时,该状态变量的值将使用AppStorage中的值进行初始化。在UI组件中对@StorageLink的状态变量所做的更改将同步到AppStorage,并从AppStorage同步到任何其他绑定实例中,如PersistentStorage或其他绑定的UI组件。 - - -### @StorageProp装饰器 - -组件通过使用@StorageProp(key)装饰的状态变量,将与AppStorage建立单向数据绑定,key标识AppStorage中的属性键值。当创建包含@StoageProp的状态变量的组件时,该状态变量的值将使用AppStorage中的值进行初始化。AppStorage中的属性值的更改会导致绑定的UI组件进行状态更新。 - - -## 示例 - -```ts -// xxx.ets - -@Entry -@Component -struct ComponentA { - @StorageLink('varA') varA: number = 2 - @StorageProp('languageCode') lang: string = 'en' - private label: string = 'count' - - aboutToAppear() { - this.label = (this.lang === 'zh') ? '数' : 'Count' - } - - build() { - Column(){ - Row({ space: 20 }) { - Button(`${this.label}: ${this.varA}`) - .onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1) - }) - Button(`lang: ${this.lang}`) - .onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en') - } else { - AppStorage.Set('languageCode', 'zh') - } - this.label = (this.lang === 'zh') ? '数' : 'Count' - }) - } - .margin({ bottom: 50 }) - Row(){ - Button(`更改@StorageLink修饰的变量:${this.varA}`).fontSize(10) - .onClick(() => { - this.varA++ - }) - }.margin({ bottom: 50 }) - Row(){ - Button(`更改@StorageProp修饰的变量:${this.lang}`).fontSize(10) - .onClick(() => { - this.lang = 'test' - }) - } - } - } -} -``` - -每次用户单击Count按钮时,this.varA变量值都会增加,此变量与AppStorage中的varA同步。每次用户单击当前语言按钮时,修改AppStorage中的languageCode,此修改会同步给this.lang变量。 diff --git a/zh-cn/application-dev/ui/ts-attribution-configuration.md b/zh-cn/application-dev/ui/ts-attribution-configuration.md deleted file mode 100644 index 64834f2571e3819a8c3cb5084b42c150f6ff6a2d..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-attribution-configuration.md +++ /dev/null @@ -1,40 +0,0 @@ -# 属性配置 - - -使用属性方法配置组件的属性,属性方法紧随组件,并用“.”运算符连接。 - - -- 配置Text组件的字体大小属性: - ```ts - Text('123') - .fontSize(12) - ``` - - -- 使用“.”操作进行链式调用并同时配置组件的多个属性,如下所示: - ```ts - Image('a.jpg') - .alt('error.jpg') - .width(100) - .height(100) - ``` - - -- 除了直接传递常量参数外,还可以传递变量或表达式,如下所示: - ```ts - // Size, count, and offset are private variables defined in the component. - Text('hello') - .fontSize(this.size) - Image('a.jpg') - .width(this.count % 2 === 0 ? 100 : 200) - .height(this.offset + 100) - ``` - - -- 对于内置组件,框架还为其属性预定义了一些枚举类型,供开发人员调用,枚举值可以作为参数传递。枚举类型必须满足参数类型要求,有关特定属性的枚举类型定义的详细信息。可以按以下方式配置Text组件的颜色和字体属性: - ```ts - Text('hello') - .fontSize(20) - .fontColor(Color.Red) - .fontWeight(FontWeight.Bold) - ``` diff --git a/zh-cn/application-dev/ui/ts-child-component-configuration.md b/zh-cn/application-dev/ui/ts-child-component-configuration.md deleted file mode 100644 index 926d1d1c4f49a35598ef46597382285468fa50fb..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-child-component-configuration.md +++ /dev/null @@ -1,47 +0,0 @@ -# 子组件配置 - - -对于支持子组件配置的组件,例如容器组件,在“{ ... }”里为组件添加子组件的UI描述。Column、Row、Stack、Button、Grid和List组件都是容器组件。 - - -- 以下是简单的Column示例: - ```ts - Column() { - Text('Hello') - .fontSize(100) - Divider() - Text(this.myText) - .fontSize(100) - .fontColor(Color.Red) - } - ``` - - -- 可以嵌套多个子组件: - ```ts - Column() { - Column() { - Button() { - Text('+ 1') - }.type(ButtonType.Capsule) - .onClick(() => console.log ('+1 clicked!')) - Image('1.jpg') - } - Divider() - Column() { - Button() { - Text('+ 2') - }.type(ButtonType.Capsule) - .onClick(() => console.log ('+2 clicked!')) - Image('2.jpg') - } - Divider() - Column() { - Button() { - Text('+ 3') - }.type(ButtonType.Capsule) - .onClick(() => console.log('+3 clicked!')) - Image('3.jpg') - } - }.alignItems(HorizontalAlign.Center) // center align components inside Column - ``` diff --git a/zh-cn/application-dev/ui/ts-component-based-component.md b/zh-cn/application-dev/ui/ts-component-based-component.md deleted file mode 100644 index fd7a8f8cab8dbb989e077d5871ee55dc013dfc95..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-component.md +++ /dev/null @@ -1,121 +0,0 @@ -# @Component - -@Component装饰的struct表示该结构体具有组件化能力,能够成为一个独立的组件,这种类型的组件也称为自定义组件,在build方法里描述UI结构。自定义组件具有以下特点: - - -- 可组合:允许开发人员组合使用内置组件、其他组件、公共属性和方法; -- 链式调用9+:通过链式调用通用属性改变组件样式; -- 可重用:自定义组件可以被其他组件重用,并作为不同的实例在不同的父组件或容器中使用; -- 生命周期:生命周期的回调方法可以在组件中配置,用于业务逻辑处理; -- 数据驱动更新:由状态变量的数据驱动,实现UI自动更新。 - - -对组件化的深入描述,请参考[深入理解组件化](ts-custom-component-initialization.md)。 - - -> **说明:** -> -> - 自定义组件必须定义build方法。 ->- 自定义组件禁止自定义构造函数。 - - -如下代码定义了MyComponent组件: - - -```ts -@Component -struct MyComponent { - build() { - Column() { - Text('my component') - .fontColor(Color.Red) - }.alignItems(HorizontalAlign.Center) // center align Text inside Column - } -} -``` - - -MyComponent的build方法会在初始渲染时执行,此外,当组件中的状态发生变化时,build方法将再次执行。 - - -以下代码使用了MyComponent组件: - - -```ts -@Component -struct ParentComponent { - build() { - Column() { - MyComponent() - Text('we use component') - .fontSize(20) - } - } -} -``` - - -可以多次使用MyComponent,并在不同的组件中进行重用: - - -```ts -@Component -struct ParentComponent { - build() { - Row() { - Column() { - MyComponent() - Text('first column') - .fontSize(20) - } - Column() { - MyComponent() - Text('second column') - .fontSize(20) - } - } - } - - aboutToAppear() { - console.log('ParentComponent: Just created, about to become rendered first time.') - } - - aboutToDisappear() { - console.log('ParentComponent: About to be removed from the UI.') - } -} -``` - -可链式调用通用属性,使组件样式多样化: - -> **说明:** 从API version 9开始支持。 -> -> 自定义组件链式调用暂不支持尾随闭包写法(在初始化自定义组件时,组件名称紧跟一个大括号“{}”形成尾随闭包场景`(Inedx(){})`。开发者可把尾随闭包看做一个容器,向其填充内容,如在闭包内增加组件`{Column(){Text("content")}` )。 - -```ts -@Entry -@Component -struct Index { - @State bannerValue: string = 'Hello,world'; - build() { - Column() { - Chind({ ChindBannerValue:$bannerValue }) - .height(60) - .width(250) - .border({ width:5, color:Color.Red, radius:10, style: BorderStyle.Dotted }) - } - } -} - -@Component -struct Chind { - @Link ChindBannerValue: string; - build() { - Column() { - Text(this.ChindBannerValue) - .fontSize(30) - } - } -} -``` - diff --git a/zh-cn/application-dev/ui/ts-component-based-customdialog.md b/zh-cn/application-dev/ui/ts-component-based-customdialog.md deleted file mode 100644 index f8b04e394c8a802479d0717b060142d8519ddb88..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-customdialog.md +++ /dev/null @@ -1,51 +0,0 @@ -# @CustomDialog - -@CustomDialog装饰器用于装饰自定义弹窗。 - - -```ts -// custom-dialog-demo.ets -@CustomDialog -struct DialogExample { - controller: CustomDialogController; - action: () => void; - - build() { - Row() { - Button ("Close CustomDialog") - .onClick(() => { - this.controller.close(); - this.action(); - }) - }.padding(20) - } -} - -@Entry -@Component -struct CustomDialogUser { - dialogController : CustomDialogController = new CustomDialogController({ - builder: DialogExample({action: this.onAccept}), - cancel: this.existApp, - autoCancel: true - }); - - onAccept() { - console.log("onAccept"); - } - existApp() { - console.log("Cancel dialog!"); - } - - build() { - Column() { - Button("Click to open Dialog") - .onClick(() => { - this.dialogController.open() - }) - } - } -} -``` - -![custom-dialog-demo](figures/custom-dialog-demo.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-component-based-entry.md b/zh-cn/application-dev/ui/ts-component-based-entry.md deleted file mode 100644 index 74e81fe05e1681b687a5b6827d6c41bbd903bac4..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-entry.md +++ /dev/null @@ -1,35 +0,0 @@ -# @Entry - -用@Entry装饰的自定义组件用作页面的默认入口组件,加载页面时,将首先创建并呈现@Entry装饰的自定义组件。 - - -> **说明:** -> 在单个源文件中,最多可以使用@Entry装饰一个自定义组件。 - - -@Entry的用法如下: - - -```ts -// Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed. -@Entry -@Component -struct MyComponent { - build() { - Column() { - Text('hello world') - .fontColor(Color.Red) - } - } -} - -@Component -struct HideComponent { - build() { - Column() { - Text('goodbye') - .fontColor(Color.Blue) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-component-based-extend.md b/zh-cn/application-dev/ui/ts-component-based-extend.md deleted file mode 100644 index ff4074ff372110eba74767474c1b51cc2734a030..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-extend.md +++ /dev/null @@ -1,32 +0,0 @@ -# @Extend - -@Extend装饰器将新的属性函数添加到内置组件上,如Text、Column、Button等。通过@Extend装饰器可以快速定义并复用组件的自定义样式。 - - -```ts -// xxx.ets -@Extend(Text) function fancy(fontSize: number) { - .fontColor(Color.Red) - .fontSize(fontSize) - .fontStyle(FontStyle.Italic) -} - -@Entry -@Component -struct FancyUse { - build() { - Row({ space: 10 }) { - Text("Fancy") - .fancy(16) - Text("Fancy") - .fancy(24) - } - } -} -``` - - -> **说明:** -> -> - @Extend装饰器不能用在自定义组件struct定义框内。 -> - @Extend装饰器内仅支持属性函数语句。 diff --git a/zh-cn/application-dev/ui/ts-component-based-preview.md b/zh-cn/application-dev/ui/ts-component-based-preview.md deleted file mode 100644 index 83c47e4916d73634511bebd5fb95dfabc284c21d..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ /dev/null @@ -1,61 +0,0 @@ -# @Preview - -用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行实时预览,不支持动态图和动态预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。 - - -> **说明:** -> 在单个源文件中,最多可以使用10个@Preview装饰自定义组件,更多说明请参考[查看eTS组件预览效果]( https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596#section146052489820 )。 - - -@Preview的用法如下: - - -```ts -// xxx.ets -@Entry -@Component -struct MyComponent { - build() { - Column() { - Row() { - Text('Hello World!') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - Row() { - Component1() - } - Row() { - Component2() - } - } - } -} - -@Preview -@Component -struct Component1 { - build() { - Column() { - Row() { - Text('Hello Component1') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - } - } -} - -@Component -struct Component2 { - build() { - Column() { - Row() { - Text('Hello Component2') - .fontSize("50lpx") - .fontWeight(FontWeight.Bold) - } - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-component-based-styles.md b/zh-cn/application-dev/ui/ts-component-based-styles.md deleted file mode 100644 index 288081d69ff3d0c4a7908c883319d5a4f430f7f0..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-styles.md +++ /dev/null @@ -1,74 +0,0 @@ -# @Styles - - - -@Styles装饰器将新的属性函数添加到基本组件上,如Text、Column、Button等。当前@Styles仅支持通用属性。通过@Styles装饰器可以快速定义并复用组件的自定义样式。 - -@Styles可以定义在组件内或组件外,在组件外定义时需在方法前添加function关键字,组件内定义时不需要添加function关键字。 - - -```ts -// xxx.ets -@Styles function globalFancy() { - .backgroundColor(Color.Red) -} - -@Entry -@Component -struct FancyUse { - @Styles componentFancy() { - .backgroundColor(Color.Blue) - } - build() { - Column({ space: 10 }) { - Text("Fancy") - .globalFancy() - .width(100) - .height(100) - .fontSize(30) - Text("Fancy") - .componentFancy() - .width(100) - .height(100) - .fontSize(30) - } - } -} -``` - -@Styles还可以在[StateStyles](../reference/arkui-ts/ts-universal-attributes-polymorphic-style.md)属性内部使用,在组件处于不同的状态时赋予相应的属性。 - -在StateStyles内可以直接调用组件外定义的Styles,但需要通过this关键字调用组件内定义的Styles。 - -```ts -// xxx.ets -@Styles function globalFancy() { - .width(100) - .height(100) -} - -@Entry -@Component -struct FancyUse { - @Styles componentFancy() { - .width(50) - .height(50) - } - build() { - Row({ space: 10 }) { - Button() { - Text("Fancy") - } - .stateStyles({ - normal: { - .width(80) - .height(80) - }, - disabled: this.componentFancy, - pressed: globalFancy - }) - } - } -} -``` - diff --git a/zh-cn/application-dev/ui/ts-component-states-link.md b/zh-cn/application-dev/ui/ts-component-states-link.md deleted file mode 100644 index e6aef9bf933352edd56b46dfc8050cc91259b377..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-states-link.md +++ /dev/null @@ -1,137 +0,0 @@ -# @Link - -@Link装饰的变量可以和父组件的@State变量建立双向数据绑定: - - -- 支持多种类型:@Link变量的值与@State变量的类型相同,即class、number、string、boolean或这些类型的数组; - -- 私有:仅在组件内访问; - -- 单个数据源:初始化@Link变量的父组件的变量必须是@State变量; - -- 双向通信:子组件对@Link变量的更改将同步修改父组件的@State变量; - -- 创建自定义组件时需要将变量的引用传递给@Link变量,在创建组件的新实例时,必须使用命名参数初始化所有@Link变量。@Link变量可以使用@State变量或@Link变量的引用进行初始化,@State变量可以通过`'$'`操作符创建引用。 - - -> 说明: -> @Link变量不能在组件内部进行初始化。 - - -## 简单类型示例 - -```ts -// xxx.ets -@Entry -@Component -struct Player { - @State isPlaying: boolean = false - build() { - Column() { - PlayButton({buttonPlaying: $isPlaying}) - Text(`Player is ${this.isPlaying? '':'not'} playing`) - } - } -} - -@Component -struct PlayButton { - @Link buttonPlaying: boolean - build() { - Column() { - Button() { - Image(this.buttonPlaying? 'play.png' : 'pause.png') - }.onClick(() => { - this.buttonPlaying = !this.buttonPlaying - }) - } - } -} -``` - -@Link语义是从`'$'`操作符引出,即`$isPlaying`是`this.isPlaying`内部状态的双向数据绑定。当单击PlayButton时,PlayButton的Image组件和Text组件将同时进行刷新。 - - -## 复杂类型示例 - -```ts -// xxx.ets -@Entry -@Component -struct Parent { - @State arr: number[] = [1, 2, 3] - build() { - Column() { - Child({items: $arr}) - ForEach(this.arr, - item => Text(`${item}`), - item => item.toString()) - } - } -} - -@Component -struct Child { - @Link items: number[] - build() { - Column() { - Button() { - Text('Button1: push') - }.onClick(() => { - this.items.push(100) - }) - Button() { - Text('Button2: replace whole item') - }.onClick(() => { - this.items = [100, 200, 300] - }) - } - } -} -``` - -在上面的示例中,点击Button1和Button2更改父组件中显示的文本项目列表。 - - -## @Link、@State和@Prop结合使用示例 - -```ts -// xxx.ets -@Entry -@Component -struct ParentView { - @State counter: number = 0 - build() { - Column() { - ChildA({counterVal: this.counter}) // pass by value - ChildB({counterRef: $counter}) // $ creates a Reference that can be bound to counterRef - } - } -} - -@Component -struct ChildA { - @Prop counterVal: number - build() { - Button() { - Text(`ChildA: (${this.counterVal}) + 1`) - }.onClick(() => {this.counterVal+= 1}) - } -} - -@Component -struct ChildB { - @Link counterRef: number - build() { - Button() { - Text(`ChildB: (${this.counterRef}) + 1`) - }.onClick(() => {this.counterRef+= 1}) - } -} -``` - -上述示例中,ParentView包含ChildA和ChildB两个子组件,ParentView的状态变量counter分别初始化ChildA和ChildB。 - -- ChildB使用@Link建立双向状态绑定。当ChildB修改counterRef状态变量值时,该更改将同步到ParentView和ChildA共享; - -- ChildA使用@Prop建立从ParentView到自身的单向状态绑定。当ChildA修改状态时,ChildA将重新渲染,但该更改不会传达给ParentView和ChildB。 diff --git a/zh-cn/application-dev/ui/ts-component-states-prop.md b/zh-cn/application-dev/ui/ts-component-states-prop.md deleted file mode 100644 index 997bf63e91803ccfef3f03fcad26021bc28968b8..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-states-prop.md +++ /dev/null @@ -1,70 +0,0 @@ -# @Prop - -@Prop与@State有相同的语义,但初始化方式不同。@Prop装饰的变量必须使用其父组件提供的@State变量进行初始化,允许组件内部修改@Prop变量,但更改不会通知给父组件,即@Prop属于单向数据绑定。 - -@Prop状态数据具有以下特征: - - -- 支持简单类型:仅支持number、string、boolean简单类型; - -- 私有:仅在组件内访问; - -- 支持多个实例:一个组件中可以定义多个标有@Prop的属性; - -- 创建自定义组件时将值传递给@Prop变量进行初始化:在创建组件的新实例时,必须初始化所有@Prop变量,不支持在组件内部进行初始化。 - - -## 示例 - -```ts -// xxx.ets -@Entry -@Component -struct ParentComponent { - @State countDownStartValue: number = 10 // 10 Nuggets default start value in a Game - build() { - Column() { - Text(`Grant ${this.countDownStartValue} nuggets to play.`) - Button() { - Text('+1 - Nuggets in New Game') - }.onClick(() => { - this.countDownStartValue += 1 - }) - Button() { - Text('-1 - Nuggets in New Game') - }.onClick(() => { - this.countDownStartValue -= 1 - }) - // 创建子组件时,必须在构造函数参数中提供其@Prop变量的初始值,同时初始化常规变量CostOfOneAttump(非Prop) - CountDownComponent({ count: this.countDownStartValue, costOfOneAttempt: 2}) - } - } -} - -@Component -struct CountDownComponent { - @Prop count: number - private costOfOneAttempt: number - - build() { - Column() { - if (this.count > 0) { - Text(`You have ${this.count} Nuggets left`) - } else { - Text('Game over!') - } - - Button() { - Text('Try again') - }.onClick(() => { - this.count -= this.costOfOneAttempt - }) - } - } -} -``` - -在上述示例中,当按“+1”或“-1”按钮时,父组件状态发生变化,重新执行build方法,此时将创建一个新的CountDownComponent组件。父组件的countDownStartValue状态属性被用于初始化子组件的@Prop变量,当按下子组件的“Try again”按钮时,其@Prop变量count将被更改,CountDownComponent重新渲染。但是count值的更改不会影响父组件的countDownStartValue值。 - -> **说明:** -> 创建新组件实例时,必须初始化其所有@Prop变量。 diff --git a/zh-cn/application-dev/ui/ts-component-states-state.md b/zh-cn/application-dev/ui/ts-component-states-state.md deleted file mode 100644 index 154c1a5c3a488026ad05ffab82ab9eebd9fd5bf8..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-states-state.md +++ /dev/null @@ -1,106 +0,0 @@ -# @State - -@State装饰的变量是组件内部的状态数据,当这些状态数据被修改时,将会调用所在组件的build方法进行UI刷新,只能监听第一层数据的改变,内层数据的改变@State监听不到,无法触发build生命周期。 - -@State状态数据具有以下特征: - - -- 支持多种类型:允许class、number、boolean、string强类型的按值和按引用类型。允许这些强类型构成的数组,即Array<class>、Array<string>、Array<boolean>、Array<number>。不允许object和any。 - -- 支持多实例:组件不同实例的内部状态数据独立。 - -- 内部私有:标记为@State的属性是私有变量,只能在组件内访问。 - -- 需要本地初始化:必须为所有@State变量分配初始值,将变量保持未初始化可能导致框架行为未定义。 - -- 创建自定义组件时支持通过状态变量名设置初始值:在创建组件实例时,可以通过变量名显式指定@State状态属性的初始值。 - - -## 简单类型的状态属性示例 - -```ts -// xxx.ets -@Entry -@Component -struct MyComponent { - @State count: number = 0 - // MyComponent provides a method for modifying the @State status data member. - private toggleClick() { - this.count += 1 - } - - build() { - Column() { - Button() { - Text(`click times: ${this.count}`) - .fontSize(10) - }.onClick(this.toggleClick.bind(this)) - } - } -} -``` - -![@state1](figures/@state1.gif) - -## 复杂类型的状态变量示例 - -```ts -// Customize the status data class. -// xxx.ets -class Model { - value: string - constructor(value: string) { - this.value = value - } -} - -@Entry -@Component -struct EntryComponent { - build() { - Column() { - MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document - MyComponent({title: {value: 'Hello, World 2'}, count: 7}) //MyComponent2 in this document - } - } -} - -@Component -struct MyComponent { - @State title: Model = {value: 'Hello World'} - @State count: number = 0 - private toggle: string = 'Hello World' - private increaseBy: number = 1 - - build() { - Column() { - Text(`${this.title.value}`).fontSize(30) - Button() { - Text(`Click to change title`).fontSize(20).fontColor(Color.White) - }.onClick(() => { - this.title.value = (this.toggle == this.title.value) ? 'Hello World' : 'Hello UI' - }) // Modify the internal state of MyComponent using the anonymous method. - - Button() { - Text(`Click to increase count=${this.count}`).fontSize(20).fontColor(Color.White) - }.onClick(() => { - this.count += this.increaseBy - }) // Modify the internal state of MyComponent using the anonymous method. - } - } -} -``` - -![@state1](figures/@state.png) - -在上述示例中: - - -- 用户定义的组件MyComponent定义了@State状态变量count和title。如果count或title的值发生变化,则执行MyComponent的build方法来重新渲染组件; - -- EntryComponent中有多个MyComponent组件实例,第一个MyComponent内部状态的更改不会影响第二个MyComponent; - -- 创建MyComponent实例时通过变量名给组件内的变量进行初始化,如: - ```ts - MyComponent({title: {value: 'Hello, World 2'}, count: 7}) - ``` diff --git a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md b/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md deleted file mode 100644 index 17c9aa3f3fa21e28cb37de06095141bde7ec7ddf..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md +++ /dev/null @@ -1,33 +0,0 @@ -# 必选参数构造配置 - - -如果组件的接口定义中包含必选构造参数,则在组件后面的“()”中必须配置参数,参数可以使用常量进行赋值。 - - -例如: - - -- Image组件的必选参数src: - ```ts - Image('http://xyz/a.jpg') - ``` - - -- Text组件的必选参数content: - ```ts - Text('123') - ``` - - -变量或表达式也可以用于参数赋值,其中表达式返回的结果类型必须满足参数类型要求。例如,传递变量或表达式来构造Image和Text组件的参数: - - -```ts -// imagePath, where imageUrl is a private data variable defined in the component. -Image(this.imagePath) -Image('http://' + this.imageUrl) -// count is a private data variable defined in the component. -// (``) and (${}) are the template character string features supported by the TS language and comply with the -// features of the corresponding language. This specification is not limited. -Text(`count: ${this.count}`) -``` diff --git a/zh-cn/application-dev/ui/ts-event-configuration.md b/zh-cn/application-dev/ui/ts-event-configuration.md deleted file mode 100644 index d9c2274dca564d045e687e391ce791e964dd8c00..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-event-configuration.md +++ /dev/null @@ -1,36 +0,0 @@ -# 事件配置 - -通过事件方法可以配置组件支持的事件。从API Version 9开始,可以在回调函数中获取当前component关联的Context,具体用法请参考[在eTS页面中访问Context](../ability/context-userguide.md)。 - - -- 使用lambda表达式配置组件的事件方法: - ```ts - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(() => { - this.counter += 2 - }) - ``` - - -- 使用匿名函数表达式配置组件的事件方法,要求使用bind,以确保函数体中的this引用包含的组件: - ```ts - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(function () { - this.counter += 2 - }.bind(this)) - ``` - - -- 使用组件的成员函数配置组件的事件方法: - ```ts - myClickHandler(): void { - // do something - } - - ... - - Button('add counter') - .onClick(this.myClickHandler) - ``` diff --git a/zh-cn/application-dev/ui/ts-function-build.md b/zh-cn/application-dev/ui/ts-function-build.md deleted file mode 100644 index 82d6b93c4f563e013c6d3c9b8930d4d4dca34334..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-function-build.md +++ /dev/null @@ -1,14 +0,0 @@ -# build函数 - -build函数满足Builder构造器接口定义,用于定义组件的声明式UI描述。必须遵循上述Builder接口约束,在build方法中以声明式方式进行组合自定义组件或系统内置组件,在组件创建和更新场景中都会调用build方法。 - - -```ts -interface Builder { - build: () => void -} -``` - - -> **说明:** -> build方法仅支持组合组件,使用渲染控制语法。 diff --git a/zh-cn/application-dev/ui/ts-general-ui-concepts.md b/zh-cn/application-dev/ui/ts-general-ui-concepts.md deleted file mode 100644 index 9735a4db91aff4684659e886f1b82a0effb1c4a5..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-general-ui-concepts.md +++ /dev/null @@ -1,50 +0,0 @@ -# 基本概念 - -基于eTS的声明式开发范式提供了一系列基础组件,这些组件以声明方式进行组合和扩展来描述应用程序的UI界面,并且还提供了基本的数据绑定和事件处理机制,帮助开发者实现应用交互逻辑。 - - -## HelloWorld基本示例 - -```ts -// An example of displaying Hello World. After you click the button, Hello UI is displayed. -// xxx.ets -@Entry -@Component -struct Hello { - @State myText: string = 'World' - build() { - Column() { - Text('Hello') - .fontSize(30) - Text(this.myText) - .fontSize(32) - Divider() - Button() { - Text('Click me') - .fontColor(Color.Red) - }.onClick(() => { - this.myText = 'UI' - }) - .width(500) - .height(200) - } - } -} -``` - - -## 基本概念描述 - -上述示例代码描述了简单页面的结构,并介绍了以下基本概念: - -- 装饰器:方舟开发框架定义了一些具有特殊含义的装饰器,用于装饰类、结构、方法和变量。例如,上例中的@Entry、@Component和@State都是装饰器。 - -- 自定义组件:可重用的UI单元,可以与其他组件组合,如@Component装饰的struct Hello。 - -- UI描述:声明性描述UI结构,例如build()方法中的代码块。 - -- 内置组件:框架中默认内置的基本组件和布局组件,开发者可以直接调用,如Column、Text、Divider、Button等。 - -- 属性方法:用于配置组件属性,如fontSize()、width()、height()、color()等。 - -- 事件方法:在事件方法的回调中添加组件响应逻辑。例如,为Button组件添加onClick方法,在onClick方法的回调中添加点击响应逻辑。 diff --git a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md b/zh-cn/application-dev/ui/ts-other-states-consume-provide.md deleted file mode 100644 index 91a13862b2db308743db5117cce79739fefd7861..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md +++ /dev/null @@ -1,73 +0,0 @@ -# @Consume和@Provide数据管理 - -Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。Consume在感知到Provide数据的更新后,会触发当前view的重新渲染。 - -表1 @Provide - -| 名称 | 说明 | -| ------- | ---------------------------------------- | -| 装饰器参数 | 是一个string类型的常量,用于给装饰的变量起别名。如果规定别名,则提供对应别名的数据更新。如果没有,则使用变量名作为别名。推荐使用@Provide("alias")这种形式。 | -| 同步机制 | @Provide的变量类似@state,可以修改对应变量进行页面重新渲染。也可以修改@Consume装饰的变量,反向修改@State变量。 | -| 初始值 | 必须制定初始值。 | -| 页面重渲染场景 | 触发页面渲染的修改:
- 基础类型(boolean,string,number)变量的改变;
- @Observed class类型变量及其属性的修改;
- 添加,删除,更新数组中的元素。 | - -表2 @Consume - -| 类型 | 说明 | -| ---- | -------- | -| 初始值 | 不可设置默认值。 | - - -> **说明:** -> 使用@Provide 和@Consume时避免循环引用导致死循环。 - - -其他属性说明与Provide一致。 - - -```ts -// xxx.ets -@Entry -@Component -struct CompA { - @Provide("reviewVote") reviewVotes : number = 0; - - build() { - Column() { - CompB() - Button() { - Text(`${this.reviewVotes}`) - .fontSize(30) - } - .onClick(() => { - this.reviewVotes += 1; - }) - } - } -} - -@Component -struct CompB { - build() { - Column() { - CompC() - } - } -} - -@Component -struct CompC { - @Consume("reviewVote") reviewVotes : number; - build() { - Column() { - Button() { - Text(`${this.reviewVotes}`) - .fontSize(30) - } - .onClick(() => { - this.reviewVotes += 1; - }) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md b/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md deleted file mode 100644 index 7a76f0d0c4fa4a308610b992697f2c8b71f4b368..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md +++ /dev/null @@ -1,183 +0,0 @@ -# Observed和ObjectLink数据管理 - -本章将引入两个新的装饰符@Observed和@ObjectLink: - - -- @Observed应用于类,表示该类中的数据变更被UI页面管理,例如:@Observed class ClassA {}。 - -- @ObjectLink应用于被@Observed所装饰类的对象,例如:@ObjectLink a: ClassA。 - - -## 引入动机 - -当开发者需要在子组件中针对父组件的一个变量(parent_a)设置双向同步时,开发者可以在父组件中使用\@State装饰变量(parent_a),并在子组件中使用@Link装饰相应的变量(child_a)。这样的话,不仅可以实现父组件与单个子组件之间的数据同步,也可以实现父组件与多个子组件之间的数据同步。如下图所示,可以看到,父子组件针对ClassA类型的变量设置了双向同步,那么当子组件1中变量的属性c的值变化时,会通知父组件同步变化,而当父组件中属性c的值变化时,会通知所有子组件同步变化。 - -![](figures/zh-cn_image_0000001251090821.png) - -然而,上述例子是针对某个数据对象进行的整体同步,而当开发者只想针对父组件中某个数据对象的部分信息进行同步时,使用@Link就不能满足要求。如果这些部分信息是一个类对象,就可以使用@ObjectLink配合@Observed来实现,如下图所示。 - -![](figures/zh-cn_image_0000001206450834.png) - - -## 设置要求 - -- @Observed 用于类,@ObjectLink 用于变量。 - -- @ObjectLink装饰的变量类型必须为类(class type)。 - - 类要被\@Observed装饰器所装饰。 - - 不支持简单类型参数,可以使用@Prop进行单向同步。 - -- @ObjectLink装饰的变量是不可变的(immutable)。 - - 属性的改动是被允许的,当改动发生时,如果同一个对象被多个@ObjectLink变量所引用,那么所有拥有这些变量的自定义组件都会被通知去重新渲染。 - -- @ObjectLink装饰的变量不可设置默认值。 - - 必须让父组件中有一个由@State、@Link、@StorageLink、@Provide或@Consume所装饰变量参与的TS表达式进行初始化。 - -- @ObjectLink装饰的变量是私有变量,只能在组件内访问。 - - -## 示例 - - -### 案例1 - -```ts -//父组件ViewB中的类对象ClassB,其包含的对象ClassA与子组件ViewA数据同步时,通过ObjectLink将数据c值的变化状态通知给父组件同步变化。 -@Observed -class ClassA { - public name : string; - public c: number; - constructor(c: number, name: string = 'OK') { - this.name = name; - this.c = c; - } -} - -class ClassB { - public a: ClassA; - constructor(a: ClassA) { - this.a = a; - } -} - -@Component -struct ViewA { - label : string = "ep1"; - @ObjectLink a : ClassA; - build() { - Column() { - Text(`ViewA [${this.label}]: a.c=${this.a.c}`) - .fontSize(20) - Button(`+1`) - .width(100) - .margin(2) - .onClick(() => { - this.a.c += 1; - }) - Button(`reset`) - .width(100) - .margin(2) - .onClick(() => { - this.a = new ClassA(0); // 错误:ObjectLink装饰的变量a是不可变的 - }) - } - } -} - -@Entry -@Component -struct ViewB { - @State b : ClassB = new ClassB(new ClassA(10)); - build() { - Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center}) { - ViewA({label: "ViewA #1", a: this.b.a}) - ViewA({label: "ViewA #2", a: this.b.a}) - - Button(`ViewB: this.b.a.c += 1` ) - .width(320) - .margin(4) - .onClick(() => { - this.b.a.c += 1; - }) - Button(`ViewB: this.b.a = new ClassA(0)`) - .width(240) - .margin(4) - .onClick(() => { - this.b.a = new ClassA(0); - }) - Button(`ViewB: this.b = new ClassB(ClassA(0))`) - .width(240) - .margin(4) - .onClick(() => { - this.b = new ClassB(new ClassA(0)); - }) - } - } -} -``` - - -### 案例2 - -```ts -// 父组件ViewB中的类对象ClassA与子组件ViewA保持数据同步时,可以使用@ObjectLink和@Observed,绑定该数据对象的父组件和其他子组件同步更新 -var nextID: number = 0; -@Observed -class ClassA { - public name : string; - public c: number; - public id : number; - constructor(c: number, name: string = 'OK') { - this.name = name; - this.c = c; - this.id = nextID++; - } -} - -@Component -struct ViewA { - label : string = "ViewA1"; - @ObjectLink a: ClassA; - build() { - Row() { - Button(`ViewA [${this.label}] this.a.c= ${this.a.c} +1`) - .onClick(() => { - this.a.c += 1; - }) - }.margin({ top: 10 }) - } -} - -@Entry -@Component -struct ViewB { - @State arrA : ClassA[] = [ new ClassA(0), new ClassA(0) ]; - build() { - Column() { - ForEach (this.arrA, (item) => { - ViewA({label: `#${item.id}`, a: item}) - }, - (item) => item.id.toString() - ) - ViewA({label: `ViewA this.arrA[first]`, a: this.arrA[0]}) - ViewA({label: `ViewA this.arrA[last]`, a: this.arrA[this.arrA.length-1]}) - - Button(`ViewB: reset array`) - .margin({ top: 10 }) - .onClick(() => { - this.arrA = [ new ClassA(0), new ClassA(0) ]; - }) - Button(`ViewB: push`) - .margin({ top: 10 }) - .onClick(() => { - this.arrA.push(new ClassA(0)) - }) - Button(`ViewB: shift`) - .margin({ top: 10 }) - .onClick(() => { - this.arrA.shift() - }) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-other-states-watch.md b/zh-cn/application-dev/ui/ts-other-states-watch.md deleted file mode 100644 index b1a6feb21e920d193d44e5a8b06f8fe79bd20e4a..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-other-states-watch.md +++ /dev/null @@ -1,46 +0,0 @@ -# @Watch - -@Watch用于监听状态变量的变化,语法结构为: - - -```ts -@State @Watch("onChanged") count : number = 0 -``` - - -如上给状态变量增加一个@Watch装饰器,通过@Watch注册一个回调方法onChanged, 当状态变量count被改变时, 触发onChanged回调。 - - -装饰器@State、@Prop、@Link、@ObjectLink、@Provide、@Consume、@StorageProp以及@StorageLink装饰的变量可以监听其变化。 - - -```ts -// xxx.ets -@Entry -@Component -struct CompA { - @State @Watch("onBasketUpdated") shopBasket : Array = [ 7, 12, 47, 3 ]; - @State totalPurchase : number = 0; - - updateTotal() : number { - let sum = 0; - this.shopBasket.forEach((i) => { sum += i; }); - // 计算新的购物篮总价值,如果超过100RMB,则适用折扣 - this.totalPurchase = (sum < 100) ? sum : 0.9 * sum; - return this.totalPurchase; - } - - // @Watch cb - onBasketUpdated(propName: string) : void { - this.updateTotal(); - } - - build() { - Column() { - Button("add to basket").onClick(() => { this.shopBasket.push(Math.round(100 * Math.random())) }) - Text(`${this.totalPurchase}`) - .fontSize(30) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-parameterless-configuration.md b/zh-cn/application-dev/ui/ts-parameterless-configuration.md deleted file mode 100644 index b328a96662d96cced6ec5d664aede1f3e2bdc355..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-parameterless-configuration.md +++ /dev/null @@ -1,13 +0,0 @@ -# 无参数构造配置 - - -组件的接口定义不包含必选构造参数,组件后面的“()”中不需要配置任何内容。例如,Divider组件不包含构造参数: - - -```ts -Column() { - Text('item 1') - Divider() // No parameter configuration of the divider component - Text('item 2') -} -``` diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md deleted file mode 100644 index 9ee7f145cefcf6e026edbeb881bd076f75e5aa0b..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md +++ /dev/null @@ -1,142 +0,0 @@ -# 循环渲染 - -开发框架提供循环渲染(ForEach组件)来迭代数组,并为每个数组项创建相应的组件。当循环渲染的元素较多时,会出现页面加载变慢的情况,出于性能考虑,建议使用[LazyForEach](ts-rending-control-syntax-lazyforeach.md)代替。ForEach定义如下: - - -```ts -ForEach( - arr: any[], // Array to be iterated - itemGenerator: (item: any, index?: number) => void, // child component generator - keyGenerator?: (item: any, index?: number) => string // (optional) Unique key generator, which is recommended. -) -``` - - -## ForEach - - -ForEach(arr: any[],itemGenerator: (item: any, index?: number) => void, keyGenerator?: (item: any, index?: number) => string):void - - -表1 参数说明 - -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | -| arr | any[] | 是 | - | 必须是数组,允许空数组,空数组场景下不会创建子组件。同时允许设置返回值为数组类型的函数,例如arr.slice(1, 3),设置的函数不得改变包括数组本身在内的任何状态变量,如Array.splice、Array.sort或Array.reverse这些改变原数组的函数。 | -| itemGenerator | (item: any, index?: number) => void | 是 | - | 生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。 | -| keyGenerator | (item: any, index?: number) => string | 否 | - | 匿名参数,用于给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则ForEach中的所有节点都将重建。 | - - -> **说明:** -> - 必须在容器组件内使用; -> -> - 生成的子组件允许在ForEach的父容器组件中,允许子组件生成器函数中包含if/else条件渲染,同时也允许ForEach包含在if/else条件渲染语句中; -> -> - 子项生成器函数的调用顺序不一定和数组中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: -> ```ts -> ForEach(anArray, item => {Text(`${++counter}. item.label`)}) -> ``` -> -> 正确的示例如下: -> -> ```ts -> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), -> item => Text(`${item.i}. item.data.label`), -> item => item.data.id.toString()) -> ``` - - -## 示例 - -简单类型数组示例: - -```ts -// xxx.ets -@Entry -@Component -struct MyComponent { - @State arr: number[] = [10, 20, 30] - build() { - Column() { - Button() { - Text('Reverse Array') - }.onClick(() => { - this.arr.reverse() - }) - - ForEach(this.arr, // Parameter 1: array to be iterated - (item: number) => { // Parameter 2: item generator - Text(`item value: ${item}`) - Divider() - }, - (item: number) => item.toString() // Parameter 3: unique key generator, which is optional but recommended. - ) - } - } -} -``` - -复杂类型数组示例: -```ts -// xxx.ets -class Month { - year: number - month: number - days: Array - - constructor(year, month, days) { - this.year = year; - this.month = month; - this.days = days; - } -} - -@Entry -@Component -struct Calendar1 { -// simulate with 6 months - @State calendar: Month[] = [ - new Month(2020, 1, [...Array(31).keys()]), - new Month(2020, 2, [...Array(28).keys()]), - new Month(2020, 3, [...Array(31).keys()]), - new Month(2020, 4, [...Array(30).keys()]), - new Month(2020, 5, [...Array(31).keys()]), - new Month(2020, 6, [...Array(30).keys()]), - ] - - build() { - Column() { - Button('next month') - .onClick(() => { - this.calendar.shift() - this.calendar.push({ - year: 2020, - month: 7, - days: [...Array(31) - .keys()] - }) - }) - ForEach(this.calendar, - (item: Month) => { - Text('month:' + item.month) - .fontSize(30) - .padding(20) - Grid() { - ForEach(item.days, - (day: number) => { - GridItem() { - Text((day + 1).toString()) - .fontSize(30) - } - }, - (day: number) => day.toString()) - } - .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr') - .rowsGap(20) - }, - // field is used together with year and month as the unique ID of the month. - (item: Month) => (item.year * 12 + item.month).toString()) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md deleted file mode 100644 index fc496c42b66c5d45e44490b5c8356123f14fafd6..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md +++ /dev/null @@ -1,44 +0,0 @@ -# 条件渲染 - -使用if/else进行条件渲染。 - - -> **说明:** -> - if条件语句可以使用状态变量。 -> -> - 使用if可以使子组件的渲染依赖条件语句。 -> -> - 必须在容器组件内使用。 -> -> - 某些容器组件限制子组件的类型或数量。将if放置在这些组件内时,这些限制将应用于if和else语句内创建的组件。例如,Grid组件的子组件仅支持GridItem组件,在Grid组件内使用if时,则if条件语句内仅允许使用GridItem组件。 - - -## 示例 - -使用if条件语句: - -```ts -Column() { - if (this.count > 0) { - Text('count is positive') - } -} -``` - - -使用if、else if、else条件语句: - - -```ts -Column() { - if (this.count < 0) { - Text('count is negative') - } else if (this.count % 2 === 0) { - Divider() - Text('even') - } else { - Divider() - Text('odd') - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md deleted file mode 100644 index 7c70032decd5629764a49e0998cc12bc6285147a..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md +++ /dev/null @@ -1,191 +0,0 @@ -# 数据懒加载 - -开发框架提供数据懒加载(LazyForEach组件)从提供的数据源中按需迭代数据,并在每次迭代过程中创建相应的组件。LazyForEach定义如下: - - -```ts -LazyForEach( - dataSource: IDataSource, // Data source to be iterated - itemGenerator: (item: any) => void, // child component generator - keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. -): void - -interface IDataSource { - totalCount(): number; // Get total count of data - getData(index: number): any; // Get single data by index - registerDataChangeListener(listener: DataChangeListener): void; // Register listener to listening data changes - unregisterDataChangeListener(listener: DataChangeListener): void; // Unregister listener -} - -interface DataChangeListener { - onDataReloaded(): void; // Called while data reloaded - onDataAdd(index: number): void; // Called while single data added - onDataMove(from: number, to: number): void; // Called while single data moved - onDataDelete(index: number): void; // Called while single data deleted - onDataChange(index: number): void; // Called while single data changed -} -``` - - -## 接口 - - -### LazyForEach - -LazyForEach(dataSource: IDataSource, itemGenerator: (item: any) => void, keyGenerator?: (item: any) => string):void - -表1 参数说明 - -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------------- | --------------------------------------- | ---- | ---- | ---------------------------------------- | -| dataSource | IDataSource | 是 | - | 实现IDataSource接口的对象,需要开发者实现相关接口。 | -| itemGenerator | (item: any) => void | 是 | - | 生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。 | -| keyGenerator | (item: any) => string | 否 | - | 匿名函数,用于键值生成,为给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则LazyForEach中的所有节点都将重建。 | - - -表2 IDataSource类型说明 - -| 名称 | 描述 | -| ---------------------------------------- | ----------- | -| totalCount(): number | 获取数据总数。 | -| getData(index: number): any | 获取索引对应的数据。 | -| registerDataChangeListener(listener:DataChangeListener): void | 注册改变数据的控制器。 | -| unregisterDataChangeListener(listener:DataChangeListener): void | 注销改变数据的控制器。 | - - -表3 DataChangeListener类型说明 - -| 名称 | 描述 | -| ---------------------------------------- | ---------------------- | -| onDataReloaded(): void | 重新加载所有数据。 | -| onDataAdded(index: number): void (deprecated) | 通知组件index的位置有数据添加。 | -| onDataMoved(from: number, to: number): void (deprecated) | 通知组件数据从from的位置移到to的位置。 | -| onDataDeleted(index: number): void (deprecated) | 通知组件index的位置有数据删除。 | -| onDataChanged(index: number): void (deprecated) | 通知组件index的位置有数据变化。 | -| onDataAdd(index: number): void 8+ | 通知组件index的位置有数据添加。 | -| onDataMove(from: number, to: number): void 8+ | 通知组件数据从from的位置移到to的位置。 | -| onDataDelete(index: number): void 8+ | 通知组件index的位置有数据删除。 | -| onDataChange(index: number): void 8+ | 通知组件index的位置有数据变化。 | - - -> **说明:** -> - 数据懒加载必须在容器组件内使用,且仅有List、Grid以及Swiper组件支持数据的懒加载(即只加载可视部分以及其前后少量数据用于缓冲),其他组件仍然是一次加载所有的数据; -> -> - LazyForEach在每次迭代中,必须且只允许创建一个子组件; -> -> - 生成的子组件必须允许在LazyForEach的父容器组件中; -> -> - 允许LazyForEach包含在if/else条件渲染语句中,不允许LazyForEach中出现if/else条件渲染语句; -> -> - 为了高性能渲染,通过DataChangeListener对象的onDataChange方法来更新UI时,仅itemGenerator中的UI描述的组件内使用了状态变量时,才会触发组件刷新; -> -> - 子项生成器函数的调用顺序不一定和数据源中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: -> ```ts -> LazyForEach(dataSource, item => {Text(`${++counter}. item.label`)}) -> ``` -> -> 正确的示例如下: -> -> ```ts -> LazyForEach(dataSource, -> item => Text(`${item.i}. item.data.label`)), -> item => item.data.id.toString()) -> ``` - - -## 示例 - -```ts -// Basic implementation of IDataSource to handle data listener -class BasicDataSource implements IDataSource { - private listeners: DataChangeListener[] = [] - - public totalCount(): number { - return 0 - } - public getData(index: number): any { - return undefined - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - console.info('add listener') - this.listeners.push(listener) - } - } - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - console.info('remove listener') - this.listeners.splice(pos, 1) - } - } - - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded() - }) - } - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdd(index) - }) - } - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChange(index) - }) - } - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index) - }) - } - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to) - }) - } -} - -class MyDataSource extends BasicDataSource { - private dataArray: string[] = ['/path/image0', '/path/image1', '/path/image2', '/path/image3'] - - public totalCount(): number { - return this.dataArray.length - } - public getData(index: number): any { - return this.dataArray[index] - } - - public addData(index: number, data: string): void { - this.dataArray.splice(index, 0, data) - this.notifyDataAdd(index) - } - public pushData(data: string): void { - this.dataArray.push(data) - this.notifyDataAdd(this.dataArray.length - 1) - } -} - -@Entry -@Component -struct MyComponent { - private data: MyDataSource = new MyDataSource() - build() { - List({space: 3}) { - LazyForEach(this.data, (item: string) => { - ListItem() { - Row() { - Image(item).width("30%").height(50) - Text(item).fontSize(20).margin({left:10}) - }.margin({left: 10, right: 10}) - } - .onClick(()=>{ - this.data.pushData('/path/image' + this.data.totalCount()) - }) - }, item => item) - } - } -} -``` diff --git a/zh-cn/application-dev/ui/ts-syntactic-sugar.md b/zh-cn/application-dev/ui/ts-syntactic-sugar.md deleted file mode 100644 index e7369cb4adc46939d4597cb8a62cd2fa60c5c442..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-syntactic-sugar.md +++ /dev/null @@ -1,197 +0,0 @@ -# 语法糖 - -## 装饰器 - - -装饰器@Decorator不仅可以装饰类或结构体,还可以装饰类的属性。多个装饰器可以叠加到目标元素,定义在同一行上或者在多行上,推荐定义在多行上。 - - -如下示例为@Component和@State的使用,被 @Component装饰的元素具备了组件化的含义,使用@State装饰的变量具备了状态数据的含义。 - - -```ts -@Component -struct MyComponent { - @State count: number = 0 -} -``` - - -装饰器定义在同一行上的描述如下: - - -```ts -@Entry @Component struct MyComponent { -} -``` - - -但更推荐定义在多行上: - - -```ts -@Entry -@Component -struct MyComponent { -} -``` - - -### 支持的装饰器列表 - -| 装饰器 | 装饰内容 | 说明 | -| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| @Component | struct | 结构体在装饰后具有基于组件的能力,需要实现build方法来更新UI。 | -| @Entry | struct | 组件被装饰后作为页面的入口,页面加载时将被渲染显示。 | -| @Preview | struct | 用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。 | -| @Builder | 方法 | 在@Builder装饰的方法里,通过声明式UI描述,可以在一个自定义组件内快速生成多个布局内容。 | -| @Extend | 方法 | @Extend装饰器将新的属性函数添加到内置组件上,通过@Extend装饰器可以快速定义并复用组件的自定义样式。 | -| @CustomDialog | struct | @CustomDialog装饰器用于装饰自定义弹窗。 | -| @State | 基本数据类型,类,数组 | 修饰的状态数据被修改时会触发组件的build方法进行UI界面更新。 | -| @Prop | 基本数据类型 | 修改后的状态数据用于在父组件和子组件之间建立单向数据依赖关系。修改父组件关联数据时,更新当前组件的UI。 | -| @Link | 基本数据类型,类,数组 | 父子组件之间的双向数据绑定,父组件的内部状态数据作为数据源,任何一方所做的修改都会反映给另一方。 | -| @Observed | 类 | @Observed应用于类,表示该类中的数据变更被UI页面管理。 | -| @ObjectLink | 被@Observed所装饰类的对象 | 装饰的状态数据被修改时,在父组件或者其他兄弟组件内与它关联的状态数据所在的组件都会更新UI。 | -| @Consume | 基本数据类型,类,数组 | @Consume装饰的变量在感知到@Provide装饰的变量更新后,会触发当前自定义组件的重新渲染。 | -| @Provide | 基本数据类型,类,数组 | @Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。 | -| @Watch | 被@State, @Prop, @Link, @ObjectLink, 
@Provide, @Consume, @StorageProp, @StorageLink中任意一个装饰的变量 | @Watch用于监听状态变量的变化,应用可以注册回调方法。 | - - -## 链式调用 - -允许开发者以“.”链式调用的方式配置UI结构及其属性、事件等。 - -```ts -Column() { - Image('1.jpg') - .alt('error.jpg') - .width(100) - .height(100) -}.padding(10) -``` - - -## struct对象 - -组件可以基于struct实现,组件不能有继承关系,struct可以比class更加快速的创建和销毁。 - -```ts -@Component -struct MyComponent { - @State data: string = '' - - build() { - } -} -``` - - -## 在实例化过程中省略"new" - -对于struct的实例化,可以省略new。 - -```ts -// 定义 -@Component -struct MyComponent { - build() { - } -} - -// 使用 -Column() { - MyComponent() -} - -// 等价于 -new Column() { - new MyComponent() -} -``` - - -## TS语言在生成器函数中的使用限制 - -TS语言的使用在生成器函数中存在一定的限制: - -- 表达式仅允许在字符串(${expression})、if条件、ForEach的参数和组件的参数中使用; - -- 这些表达式中的任何一个都不能导致任何应用程序状态变量(@State、@Link、@Prop)的改变,否则会导致未定义和潜在不稳定的框架行为; - -- 生成器函数内部不能有局部变量。 - -上述限制都不适用于事件处理函数(例如onClick)的匿名函数实现。 - -非法示例: - -```ts -build() { - let a: number = 1 // invalid: variable declaration not allowed - Column() { - Text(`Hello ${this.myName.toUpperCase()}`) // ok. - ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array variable in place - } - buildSpecial() // invalid: no function calls - Text(this.calcTextValue()) // this function call is ok. -} -``` - - -## 变量双向绑定 - -$$支持变量双向绑定,支持简单变量、@State、@Link、@Prop等类型。 - -当前$$仅支持[bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md)属性的show参数和@State变量之间的渲染,以及Radio组件的checked属性和Refresh组件的refreshing参数。 - - -```ts -// xxx.ets -@Entry -@Component -struct bindPopup { - @State customPopup: boolean = false - build() { - Column() { - Button(){ - Text('Popup') - } - .onClick(()=>{ - this.customPopup = !this.customPopup - }) - .bindPopup( - $$this.customPopup, { - message: "showPopup" - } - ) - } - } -} -``` - -## 状态变量多种数据类型声明使用限制 - -@State、@Provide、 @Link和@Consume四种状态变量的多种数据类型只能同时由简单数据类型或引用数据类型其中一种构成。 - -示例: - -```ts -@Entry -@Component -struct Index { - //错误写法: @State message: string | Resource = 'Hello World' - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(`${ this.message }`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } -} -``` - diff --git a/zh-cn/application-dev/ui/ts-syntax-intro.md b/zh-cn/application-dev/ui/ts-syntax-intro.md deleted file mode 100644 index 129f1d5459c04ed6d859ee5cf50088e564e84206..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-syntax-intro.md +++ /dev/null @@ -1,14 +0,0 @@ -# 描述规范使用说明 - -本节定义了基于TypeScript (TS)扩展的声明式开发范式的核心机制和功能,讲述了声明式UI描述、组件化机制、UI状态管理、渲染控制语法和语法糖。 - - -本节为应用开发人员开发UI提供了参考规范。有关组件的详细信息,请参考组件说明。 - - -> **说明:** -> - 本节所有示例都以TS语言为例,请遵循相应语言的语法要求。 -> -> - 示例中的Image、Button、Text、Divider、Row和Column等组件是UI框架中预置的组件控件,仅用于解释UI描述规范。 -> -> - 通用属性方法和事件方法通常支持所有组件,而组件内的属性方法和事件方法仅对当前组件有效。 diff --git a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md b/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md deleted file mode 100644 index 4ae1fd27f0dae8477177bcab5eac2acb0dfa1646..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md +++ /dev/null @@ -1,29 +0,0 @@ -# 基本概念 - -在声明式UI编程范式中,UI是应用程序状态的函数,开发人员通过修改当前应用程序状态来更新相应的UI界面。如下图所示,开发框架提供了多种应用程序状态管理的能力。 - - -![](figures/CoreSpec_figures_state-mgmt-overview.png) - - -## 状态变量装饰器 - -- @State:组件拥有的状态属性,当@State装饰的变量更改时,组件会重新渲染更新UI。 - -- @Link:组件依赖于其父组件拥有的某些状态属性,当任何一个组件中的数据更新时,另一个组件的状态都会更新,父子组件重新渲染。 - -- @Prop:原理类似@Link,但是子组件所做的更改不会同步到父组件上,属于单向传递。 -> **说明:** -> 状态变量名称不能使用id,如@Prop id:number 。 - - -## 应用程序状态数据 - -AppStorage是整个UI应用程序状态的中心“数据库”,UI框架会针对应用程序创建单例AppStorage对象,并提供相应的装饰器和接口供应用程序使用。 - -- @StorageLink:@StorageLink(name)的原理类似于@Consume(name),不同的是,该给定名称的链接对象是从AppStorage中获得的,在UI组件和AppStorage之间建立双向绑定同步数据。 - -- @StorageProp:@StorageProp(name)将UI组件属性与AppStorage进行单向同步,AppStorage中值的更改会更新组件中的属性,但UI组件无法更改AppStorage中的属性值。 - -- AppStorage还提供用于业务逻辑实现的API,用于添加、读取、修改和删除应用程序的状态属性,此API所做的更改会导致修改的状态数据同步到UI组件上进行UI更新。 - diff --git a/zh-cn/application-dev/ui/ui-ts-local-storage.md b/zh-cn/application-dev/ui/ui-ts-local-storage.md deleted file mode 100644 index 5330f574b0540c5613138558319e46fa155771d0..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ui-ts-local-storage.md +++ /dev/null @@ -1,359 +0,0 @@ -# Ability数据存储 - -> **说明:** 该组件从API version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - -LocalStorage是应用程序中的存储单元,生命周期跟随其关联的Ability。LocalStorage为应用程序范围内的可变状态属性和非可变状态属性提供存储,可变状态属性和非可变状态属性是构建应用程序UI的一部分,如一个Ability的UI。 - -应用层:一个应用程序可以创建多个LocalStorage实例,应用程序的每一个Ability对应一个LocalStorage实例。 - -Ability: 一个应用程序可以拥有多个Ability,一个Ability中的所有子组件最多可以分配一个LocalStorage实例。并且,Ability中的所有子组件都将继承对此LocalStorage实例存储对象的访问权。 - -一个组件最多可以访问一个LocalStorage实例,一个LocalStorage对象可以分配给多个组件。 - -## @LocalStorageLink装饰器 - -组件通过使用@LocalStorageLink(key)装饰的状态变量,key值为LocalStorage中的属性键值,与LocalStorage建立双向数据绑定。当创建包含@LocalStorageLink的状态变量的组件时,该状态变量的值将会使用LocalStorage中的值进行初始化。如果LocalStorage中未定义初始值,将使用@LocalStorageLink定义的初始值。在UI组件中对@LocalStorageLink的状态变量所做的更改将同步到LocalStorage中,并从LocalStorage同步到Ability下的组件中。 - -## @LocalStorageProp装饰器 - -组件通过使用LocalStorageProp(key)装饰的状态变量,key值为LocalStorage中的属性键值,与LocalStorage建立单向数据绑定。当创建包含@LocalStorageProp的状态变量的组件时,该状态变量的值将使用LocalStorage中的值进行初始化。LocalStorage中的属性值的更改会导致当前Ability下的所有UI组件进行状态更新。 - -> **说明:** 创建LocalStorage实例时如未定义初始值,可以使用组件内@LocalStorageLink和@LocalStorageProp的初始值。如果定义时给定了初始值,那么不会再使用@LocalStorageLink和@LocalStorageProp的初始值。 - -## LocalStorage - -### constructor - -constructor(initializingProperties?: Object) - -创建一个新的LocalStorage对象,并进行初始化。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| ---------------------- | ------ | :--: | ---- | ---------------------------------------- | -| initializingProperties | Object | 否 | - | object.keys(obj)返回的所有对象属性及其值都将添加到LocalStorage。 | - - - -### GetShared - -static GetShared(): LocalStorage - -获取当前的共享的LocalStorage对象。 - -此接口仅可在Stage模型下使用。 - -**返回值:** - -| 类型 | 描述 | -| ----------------------------- | ----------------- | -| [LocalStorage](#localstorage) | 返回LocalStorage对象。 | - - - -### has - -has(propName: string): boolean - -判断属性值是否存在。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ------- | -| propName | string | 是 | - | 属性的属性值。 | - -**返回值:** - -| 类型 | 描述 | -| ------- | ------------- | -| boolean | 返回属性的属性值是否存在。 | - - - -### get - -get\(propName: string): T - -获取对应key值的value。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ----------- | -| propName | string | 是 | - | 要获取对应的key值。 | - -**返回值:** - -| 类型 | 描述 | -| -------------- | ---------------------------------------- | -| T \| undefined | 当keyvalue存在时,返回keyvalue值。不存在返回undefined。 | - - - -### set - -set\(propName: string, newValue: T): boolean - -存储对象值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ----------- | -| propName | string | 是 | - | 要设置的key值。 | -| newValue | T | 是 | - | 要设置的value值。 | - -**返回值:** - -| 类型 | 描述 | -| ------- | ----------------------------------- | -| boolean | 如果存在key值,设置value值并返回true,否则返回false。 | - - - -### setOrCreate - -setOrCreate\(propName: string, newValue: T): boolean - -创建或更新setOrCreate内部的值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | -------------- | -| propName | string | 是 | - | 要更新或者创建的key值。 | -| newValue | T | 是 | - | 要更新或创建的value值。 | - -**返回值:** - -| 类型 | 描述 | -| ------- | ---------------------------------------- | -| boolean | 如果已存在与给定键名字相同的属性,更新其值且返回true。如果不存在具有给定名称的属性,在LocalStorage中创建具有给定默认值的新属性,默认值必须是T类型。不允许undefined 或 null 返回true。 | - - - -### link - -link\(propName: string): T - -与localStorage双向数据绑定。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ----------- | -| propName | string | 是 | - | 要双向绑定的属性名称。 | - -**返回值:** - -| 类型 | 描述 | -| ---- | ---------------------------------------- | -| T | 如果存在具有给定键的属性,返回到此属性的双向绑定,该双向绑定意味着变量或者组件对数据的更改将同步到LocalStorage,然后通过LocalStorage实例同步到任何变量或组件。如果不存在给定键的属性,返回undefined。 | - - - -### setAndLink - -setAndLink\(propName: string, defaultValue: T): T - -与link接口类似,双向数据绑定localStorage。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| ------------ | ------ | :--: | ---- | ----------- | -| propName | string | 是 | - | 要进行创建的key值。 | -| defaultValue | T | 是 | - | 要进行设置的默认值。 | - -**返回值:** - -| 类型 | 描述 | -| ------------------------------------ | ------------------------------------------------------------ | -| [@Link](ts-component-states-link.md) | 与Link接口类似,如果当前的key保存于LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Link返回。 | - - - -### prop - -prop\(propName: string): T - -单向属性绑定的一种。更新组件的状态。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ------------- | -| propName | string | 是 | - | 要单向数据绑定的key值。 | - -**返回值:** - -| 类型 | 描述 | -| ------------------------------------ | ---------------------------------------- | -| [@Prop](ts-component-states-prop.md) | 如果存在具有给定键的属性,返回此属性的单向数据绑定。该单向绑定意味着只能通过LocalStorage将属性的更改同步到变量或组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态变量。如果此键的属性不存在则返回undefined。 | - - - -### setAndProp - -setAndProp\(propName: string, defaultValue: T): T - -与Prop接口类似,存在localStorage的单向数据绑定prop值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| ------------ | ------ | :--: | ---- | --------------- | -| propName | string | 是 | - | 要保存的的键值对中的key值。 | -| defaultValue | T | 是 | - | 创建的默认值。 | - -**返回值:** - -| 类型 | 描述 | -| ------------------------------------ | ---------------------------------------- | -| [@Prop](ts-component-states-prop.md) | 如果当前的key保存与LocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValue的Prop返回。 | - - - -### delete - -delete(propName: string): boolean - -删除key指定的键值对。 - -**参数:** - -| 参数名 | 类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------ | :--: | ---- | ------------ | -| propName | string | 是 | - | 要删除的属性的key值。 | - -**返回值:** - -| 类型 | 描述 | -| ------- | ---------------------------------------- | -| boolean | 删除key指定的键值对,如果存在且删除成功返回true,不存在或删除失败返回false。 | - - - -### keys - -keys(): IterableIterator\ - -查找所有键。 - -**返回值:** - -| 类型 | 描述 | -| -------------- | -------------- | -| array\ | 返回包含所有键的字符串数组。 | - - - -### size - -size(): number - -存在的键值对的个数。 - -**返回值:** - -| 类型 | 描述 | -| ------ | --------- | -| number | 返回键值对的数量。 | - - - -### Clear - -clear(): boolean - -删除所有的属性。 - -**返回值:** - -| 类型 | 描述 | -| ------- | --------------------------------- | -| boolean | 删除所有的属性,如果当前有状态变量依旧引用此属性,返回false。 | - -### 示例1(在一个Ability创建的LocalStorage) - -LocalStorage通过loadContent接口加载,接口详见[loadContent](../reference/apis/js-apis-window.md#loadcontent9-1)。 - -```ts -import Ability from '@ohos.application.Ability' -export default class MainAbility extends Ability { - storage : LocalStorage - onCreate() { - this.storage = new LocalStorage(); - this.storage.setOrCreate("storageSimpleProp",121); - console.log("[Demo MainAbility onCreate]"); - } - onDestroy() { - console.log("[Demo MainAbility onDestroy]") - } - onWindowStageCreate(windowStage) { - // storage作为参数传递给loadContent接口。 - windowStage.loadContent("pages/index",this.storage) - } - onWindowStageDestroy() { - console.log("[Demo] MainAbility onWindoeStageDestroy") - } - onForeground() { - console.log("[Demo] MainAbility onForeground") - } - onBackground() { - console.log("[Demo] MainAbility onBackground") - } -} -``` - -@Component组件获取数据 - -```ts -let storage = LocalStorage.GetShared() -@Entry(storage) -@Component -struct LocalStorageComponent { - @LocalStorageLink("storageSimpleProp") simpleVarName: number = 0 - build() { - Column(){ - Text(this.simpleVarName.toString()) - .onClick(()=>{ - this.simpleVarName +=1; - }) - Text(JSON.stringify(this.simpleVarName)) - .fontSize(50) - } - .height(500) - } -} -``` - -### 示例2(在Entry页面定义LocalStorage) - -```ts -let storage = new LocalStorage({"PropA":47}); -@Entry(storage) -@Component -struct ComA { - @LocalStorageLink("PropA") storLink: number = 1; - build() { - Column() { - Text(`Parent from LocalStorage ${ this.storLink }`) - .onClick(()=>this.storLink+=1) - Child() - } - } -} - - -@Component -struct Child{ - @LocalStorageLink("PropA") storLink: number = 1; - build() { - Text(`Parent from LocalStorage ${ this.storLink }`) - .onClick(()=>this.storLink+=1) - } -} -``` \ No newline at end of file diff --git a/zh-cn/application-dev/windowmanager/application-window-stage.md b/zh-cn/application-dev/windowmanager/application-window-stage.md index 3fa18395aa66de772bcff1c225b16d2b4f4b6b29..661d379df7f0e29626aab080c37eeb092a68a67a 100644 --- a/zh-cn/application-dev/windowmanager/application-window-stage.md +++ b/zh-cn/application-dev/windowmanager/application-window-stage.md @@ -211,7 +211,7 @@ class MainAbility extends Ability { - 方式三:调用`setLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setSystemProperties`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 3. 加载显示沉浸式窗口的具体内容。 - 通过`loadContent`和`show`接口加载显示沉浸式窗口的具体内容。 + 通过`loadContent`接口加载沉浸式窗口的具体内容。 ```ts import Ability from '@ohos.application.Ability' @@ -280,14 +280,6 @@ class MainAbility extends Ability { return; } console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - // 3.显示沉浸式窗口。 - windowStage.show((err, data) => { - if (err.code) { - console.error('Failed to show the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); - }); }); } }; diff --git a/zh-cn/application-dev/windowmanager/system-window-stage.md b/zh-cn/application-dev/windowmanager/system-window-stage.md index 4cc4c98d56ad18cf9501124d401705031df4e558..a95c5e0335b969a4cf540ef8caea43d79bb6f734 100644 --- a/zh-cn/application-dev/windowmanager/system-window-stage.md +++ b/zh-cn/application-dev/windowmanager/system-window-stage.md @@ -2,7 +2,11 @@ ## 管理系统窗口概述 -在`Stage`模型下, 允许系统应用创建和管理系统窗口,包括音量条、壁纸、通知栏、状态栏、导航栏等。具体支持的系统窗口类型见[API参考-WindowType](../reference/apis/js-apis-window.md)。 +在`Stage`模型下, 允许系统应用创建和管理系统窗口,包括音量条、壁纸、通知栏、状态栏、导航栏等。具体支持的系统窗口类型见[API参考-WindowType](../reference/apis/js-apis-window.md#windowtype7)。 + +> **说明:** +> +> 本文档涉及系统接口的使用,请使用full-SDK进行开发。具体使用可见[full-SDK替换指南](../quick-start/full-sdk-switch-guide.md)。 ## 接口说明 diff --git a/zh-cn/contribute/OpenHarmony-security-test-guide.md b/zh-cn/contribute/OpenHarmony-security-test-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..2ef9bd4f8bbce5ab95a5100098077b68b16ef5c8 --- /dev/null +++ b/zh-cn/contribute/OpenHarmony-security-test-guide.md @@ -0,0 +1,27 @@ +# OpenHarmony安全测试规范 +本文档主要参考业界安全测试标准和最佳实践,提供OpenHarmony安全测试规范,用于指导开发人员/测试人员进行安全测试。 + + + +## 安全编码测试 + +1、各模块依据[OpenHarmony安全编码规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md),进行代码安全检视。 + +2、使用安全编码扫描工具扫描测试,扫描告警结果清零。OpenHarmony代码门禁已集成安全编码扫描工具。 + + +## 安全设计验证 + +1、各模块依据[OpenHarmony安全设计规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-security-design-guide.md),结合业务完成安全设计自检验证。 + + + +## 安全测试工具扫描 + +1、针对高风险模块,开发人员需要依据[Fuzz测试框架](https://gitee.com/openharmony/test_developertest/tree/master/libs/fuzzlib)开发灰白盒Fuzz测试套,并完成灰白盒Fuzz测试。 + +2、针对暴露用户态接口进行黑盒Fuzz,包括但不限于系统服务接口、内核驱动接口、socket网络接口。 + +3、依据[OpenHarmony编译规范](https://gitee.com/openharmony/community/blob/master/sig/sig-buildsystem/%E7%BC%96%E8%AF%91%E8%A7%84%E8%8C%83.md),使用编译选项扫描工具检查文件编译选项开启情况。 + +4、针对开源组件使用业界漏洞扫描工具扫描,开源组件漏洞均已按照社区漏洞管理流程修复。 \ No newline at end of file diff --git a/zh-cn/contribute/template/errorcodes-template.md b/zh-cn/contribute/template/errorcodes-template.md index 5672ec5ae132ad5ede2098ffe1392792c84b067a..cf89d10bf10bc03086d90de584d57ce1a6cc6353 100644 --- a/zh-cn/contribute/template/errorcodes-template.md +++ b/zh-cn/contribute/template/errorcodes-template.md @@ -17,11 +17,11 @@ ## 1300001 重复操作 *(错误码number+空格+错误简述)* -### 错误信息 +**错误信息** This is repeat operation. -### 错误描述 +**错误描述** > **说明:** > @@ -29,7 +29,7 @@ This is repeat operation. 当对同一窗口对象存在重复操作时,系统会产生此错误码。 -### 可能原因 +**可能原因** > **说明:** > @@ -45,7 +45,7 @@ This is repeat operation. 2. xxx。 -### 处理步骤 +**处理步骤** > **说明:** > @@ -81,19 +81,19 @@ This is repeat operation. ## 1300002 窗口状态异常 -### 错误信息 +**错误信息** xxx -### 错误描述 +**错误描述** xxx -### 可能原因 +**可能原因** 1. xxx -### 处理步骤 +**处理步骤** 1. 检查该窗口是否已创建。 diff --git a/zh-cn/contribute/template/tutorial-template.md b/zh-cn/contribute/template/tutorial-template.md index 39f673fc9e222b698964c1c22278929e007315f4..c877900fe31ef92d811bf560e2083e632412dbbd 100755 --- a/zh-cn/contribute/template/tutorial-template.md +++ b/zh-cn/contribute/template/tutorial-template.md @@ -24,7 +24,7 @@ _写作内容:介绍开发者学习本教程后将完成什么样的任务, 1. XXXX。 ``` - //代码示例 + // 代码示例 ``` 2. XXXX。 diff --git a/zh-cn/device-dev/device-test/developer_test.md b/zh-cn/device-dev/device-test/developer_test.md new file mode 100644 index 0000000000000000000000000000000000000000..05f860d7e9dc7420a75d0f9daa8fb378979fe9ee --- /dev/null +++ b/zh-cn/device-dev/device-test/developer_test.md @@ -0,0 +1,851 @@ +# 开发自测试执行框架使用指南 + + +## 概述 + +OpenHarmony为开发者提供了一套全面的开发自测试框架developer_test,作为OpenHarmony测试工具集的一部分,提供给开发者自测试使用。开发者可根据测试需求开发相关测试用例,开发阶段提前发现缺陷,大幅提高代码质量。 + +本文从基础环境构建,用例开发,编译以及执行等方面介绍OpenHarmony开发自测试执行框架如何运行和使用。 + + +### 简介 + +OpenHarmony系统开发人员在新增或修改代码之后,希望可以快速的验证修改代码的功能的正确性,而系统中已经存在了大量的已有功能的自动化测试用例,比如TDD用例或XTS用例等。开发者自测试执行框架目的就是为了提升开发者的自测试执行效率,方便开发人员可以快速便捷的执行指定的自动化测试用例,将测试活动左移到开发阶段。 + + +### 约束与限制 + +- 框架使用时必须提前连接OpenHarmony设备方可执行测试用例。 + + +## 环境准备 + +开发自测试框架依赖于python运行环境,python版本为3.8.X,在使用测试框架之前可参阅以下方式进行配置。 + + - [环境配置](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-testguide-test.md#%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE) + - [源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md) + + +## 编写测试用例 + +本测试框架支持多种类型测试,针对不同测试类型提供了不同的用例编写模板以供参考。_ + +**TDD测试(C++)** + +用例源文件命名规范 + +测试用例源文件名称和测试套内容保持一致,文件命名采用全小写+下划线方式命名,以test结尾,具体格式为:[功能]_[子功能]_test,子功能支持向下细分。 +示例: +``` +calculator_sub_test.cpp +``` + +用例示例 +``` +/* + * Copyright (c) 2021 XXXX Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "calculator.h" +#include + +using namespace testing::ext; + +class CalculatorSubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CalculatorSubTest::SetUpTestCase(void) +{ + // input testsuit setup step,setup invoked before all testcases +} + +void CalculatorSubTest::TearDownTestCase(void) +{ + // input testsuit teardown step,teardown invoked after all testcases +} + +void CalculatorSubTest::SetUp(void) +{ + // input testcase setup step,setup invoked before each testcases +} + +void CalculatorSubTest::TearDown(void) +{ + // input testcase teardown step,teardown invoked after each testcases +} + +/** + * @tc.name: integer_sub_001 + * @tc.desc: Verify the sub function. + * @tc.type: FUNC + * @tc.require: issueNumber + */ +HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1) +{ + // step 1:调用函数获取结果 + int actual = Sub(4,0); + + // Step 2:使用断言比较预期与实际结果 + EXPECT_EQ(4, actual); +} +``` +详细内容介绍: + +1.添加测试用例文件头注释信息 + +``` +/* + * Copyright (c) 2021 XXXX Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +``` + +2.引用测试框架头文件和命名空间 + +``` +#include + +using namespace testing::ext; +``` + +3.添加被测试类的头文件 + +``` +#include "calculator.h" +``` + +4.定义测试套(测试类) + +``` +class CalculatorSubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CalculatorSubTest::SetUpTestCase(void) +{ + // input testsuit setup step,setup invoked before all testcases +} + +void CalculatorSubTest::TearDownTestCase(void) +{ + // input testsuit teardown step,teardown invoked after all testcases +} + +void CalculatorSubTest::SetUp(void) +{ + // input testcase setup step,setup invoked before each testcases +} + +void CalculatorSubTest::TearDown(void) +{ + // input testcase teardown step,teardown invoked after each testcases +} +``` +> **注意:** 在定义测试套时,测试套名称应与编译目标保持一致,采用大驼峰风格。 + +5.测试用例实现,包含用例注释和逻辑实现 + +``` +/** + * @tc.name: integer_sub_001 + * @tc.desc: Verify the sub function. + * @tc.type: FUNC + * @tc.require: issueNumber + */ +HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1) +{ + //step 1:调用函数获取结果 + int actual = Sub(4,0); + + //Step 2:使用断言比较预期与实际结果 + EXPECT_EQ(4, actual); +} +``` +> **注意:** @tc.require: 格式必须以AR/SR或issue开头: 如:issueI56WJ7 + +在编写用例时,我们提供了三种用例模板供您选择。 + +| 类型 | 描述 | +| --------------- | ------------------------------------------------ | +| HWTEST(A,B,C) | 用例执行不依赖Setup&Teardown时,可选取 | +| HWTEST_F(A,B,C) | 用例执行(不含参数)依赖于Setup&Teardown时,可选取 | +| HWTEST_P(A,B,C) | 用例执行(含参数)依赖于Set&Teardown时,可选取 | + +其中,参数A,B,C的含义如下: + +- 参数A为测试套名。 + +- 参数B为测试用例名,其命名必须遵循[功能点]_[编号]的格式,编号为3位数字,从001开始。 + +- 参数C为测试用例等级,具体分为门禁level0 以及非门禁level1-level4共五个等级,其中非门禁level1-level4等级的具体选取规则为:测试用例功能越重要,level等级越低。 + + +**注意:** + +- 测试用例的预期结果必须有对应的断言。 + +- 测试用例必须填写用例等级。 + +- 测试体建议按照模板分步实现。 + +- 用例描述信息按照标准格式@tc.xxx value书写,注释信息必须包含用例名称,用例描述,用例类型,需求编号四项。其中用例测试类型@tc.type参数的选取,可参考下表。 + + +| 测试类型名称 | 类型编码 | +| ------------ | -------- | +| 功能测试 | FUNC | +| 性能测试 | PERF | +| 可靠性测试 | RELI | +| 安全测试 | SECU | +| 模糊测试 | FUZZ | + +**TDD测试(JS)** + +- 用例源文件命名规范 + + +测试用例原文件名称采用大驼峰风格,以TEST结尾,具体格式为:[功能][子功能]TEST,子功能支持向下细分。 +示例: +``` +AppInfoTest.js +``` + +- 用例示例 + +``` +/* + * Copyright (C) 2021 XXXX Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import app from '@system.app' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("AppInfoTest", function () { + beforeAll(function() { + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll caled') + }) + + afterAll(function() { + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll caled') + }) + + beforeEach(function() { + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach caled') + }) + + afterEach(function() { + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach caled') + }) + + /* + * @tc.name:appInfoTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: issueNumber + */ + it("appInfoTest001", 0, function () { + //step 1:调用函数获取结果 + var info = app.getInfo() + + //Step 2:使用断言比较预期与实际结果 + expect(info != null).assertEqual(true) + }) +}) +``` +详细内容介绍: +1. 添加测试用例文件头注释信息 + ``` + /* + * Copyright (C) 2021 XXXX Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + ``` +2. 导入被测api和jsunit测试库 + ``` + import app from '@system.app' + + import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + ``` +3. 定义测试套(测试类) + ``` + describe("AppInfoTest", function () { + beforeAll(function() { + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll caled') + }) + + afterAll(function() { + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll caled') + }) + + beforeEach(function() { + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach caled') + }) + + afterEach(function() { + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach caled') + }) + ``` +4. 测试用例实现 + ``` + /* + * @tc.name:appInfoTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: issueNumber + */ + it("appInfoTest001", 0, function () { + //step 1:调用函数获取结果 + var info = app.getInfo() + + //Step 2:使用断言比较预期与实际结果 + expect(info != null).assertEqual(true) + }) + ``` + > **注意:** @tc.require: 格式必须以AR/SR或issue开头: 如:issueI56WJ7 + +**Fuzz测试** + +[Fuzz用例编写规范](https://gitee.com/openharmony/test_developertest/blob/master/libs/fuzzlib/README_zh.md) + + +**Benchmark测试** + +[Benchmark用例编写规范](https://gitee.com/openharmony/test_developertest/blob/master/libs/benchmark/README_zh.md)_ + +## 编译测试用例 + +根据测试用例目录规划,当执行某一用例时,测试框架会根据编译文件逐层查找,最终找到所需用例进行编译。下面通过不同示例来讲解gn文件如何编写。 + +**TDD测试** + +针对不同语言,下面提供不同的编译模板以供参考。 + +- **C++用例编译配置示例** + +``` +# Copyright (c) 2021 XXXX Device Co., Ltd. + +import("//build/test.gni") + +module_output_path = "developertest/calculator" + +config("module_private_config") { + visibility = [ ":*" ] + + include_dirs = [ "../../../include" ] +} + +ohos_unittest("CalculatorSubTest") { + module_out_path = module_output_path + + sources = [ + "../../../include/calculator.h", + "../../../src/calculator.cpp", + ] + + sources += [ "calculator_sub_test.cpp" ] + + configs = [ ":module_private_config" ] + + deps = [ "//third_party/googletest:gtest_main" ] +} + +group("unittest") { + testonly = true + deps = [":CalculatorSubTest"] +} +``` +详细内容如下: + +1. 添加文件头注释信息 + ``` + # Copyright (c) 2021 XXXX Device Co., Ltd. + ``` +2. 导入编译模板文件 + ``` + import("//build/test.gni") + ``` +3. 指定文件输出路径 + ``` + module_output_path = "developertest/calculator" + ``` + > **说明:** 此处输出路径为部件/模块名。 + +4. 配置依赖包含目录 + + ``` + config("module_private_config") { + visibility = [ ":*" ] + + include_dirs = [ "../../../include" ] + } + ``` + > **说明:** 一般在此处对相关配置进行设置,在测试用例编译脚本中可直接引用。 + +5. 指定测试用例编译目标输出的文件名称 + + ``` + ohos_unittest("CalculatorSubTest") { + } + ``` +6. 编写具体的测试用例编译脚本(添加需要参与编译的源文件、配置和依赖) + ``` + ohos_unittest("CalculatorSubTest") { + module_out_path = module_output_path + sources = [ + "../../../include/calculator.h", + "../../../src/calculator.cpp", + "../../../test/calculator_sub_test.cpp" + ] + sources += [ "calculator_sub_test.cpp" ] + configs = [ ":module_private_config" ] + deps = [ "//third_party/googletest:gtest_main" ] + } + ``` + + > **说明:根据测试类型的不同,在具体编写过程中可选择不同的测试类型:** + > - ohos_unittest:单元测试 + > - ohos_moduletest:模块测试 + > - ohos_systemtest:系统测试 + > - ohos_performancetest:性能测试 + > - ohos_securitytest:安全测试 + > - ohos_reliabilitytest:可靠性测试 + > - ohos_distributedtest:分布式测试 + +7. 对目标测试用例文件进行条件分组 + + ``` + group("unittest") { + testonly = true + deps = [":CalculatorSubTest"] + } + ``` + > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 + +- **JavaScript用例编译配置示例** + +``` +# Copyright (C) 2021 XXXX Device Co., Ltd. + +import("//build/test.gni") + +module_output_path = "developertest/app_info" + +ohos_js_unittest("GetAppInfoJsTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "//test/developertest/signature/openharmony_sx.p7b" +} + +group("unittest") { + testonly = true + deps = [ ":GetAppInfoJsTest" ] +} +``` + +详细内容如下: + +1.添加文件头注释信息 + +``` +# Copyright (C) 2021 XXXX Device Co., Ltd. +``` + +2.导入编译模板文件 + +``` +import("//build/test.gni") +``` + +3.指定文件输出路径 + +``` +module_output_path = "developertest/app_info" +``` +> **说明:** 此处输出路径为部件/模块名。 + +4.指定测试用例编译目标输出的文件名称 + +``` +ohos_js_unittest("GetAppInfoJsTest") { +} +``` +> **说明:** +> - 使用模板ohos_js_unittest定义js测试套,注意与C++用例区分。 +> - js测试套编译输出文件为hap类型,hap名为此处定义的测试套名,测试套名称必须以JsTest结尾。 + +5.指定hap包配置文件config.json和签名文件,两个配置为必选项 + +``` +ohos_js_unittest("GetAppInfoJsTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "//test/developertest/signature/openharmony_sx.p7b" +} +``` + config.json为hap编译所需配置文件,需要开发者根据被测sdk版本配置“target”项,其余项可默认,具体如下所示: + +``` +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 // 根据被测sdk版本进行修改,此例为sdk5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } +``` + +6.对目标测试用例文件进行条件分组 + +``` +group("unittest") { + testonly = true + deps = [ ":GetAppInfoJsTest" ] +} +``` +> **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 + +**Fuzz测试** + +[Fuzz编译文件编写规范](https://gitee.com/openharmony/test_developertest/blob/master/libs/fuzzlib/README_zh.md) + +**Benchmark测试** + +[Benchmark编译文件编写规范](https://gitee.com/openharmony/test_developertest/blob/master/libs/benchmark/README_zh.md) + + +**编译入口配置文件ohos.build** + +当完成用例编译配置文件编写后,需要进一步编写部件编译配置文件,以关联到具体的测试用例。 +``` +"partA": { + "module_list": [ + + ], + "inner_list": [ + + ], + "system_kits": [ + + ], + "test_list": [ //配置模块calculator下的test + "//system/subsystem/partA/calculator/test:unittest", + "//system/subsystem/partA/calculator/test:fuzztest", + "//system/subsystem/partA/calculator/test:benchmarktest" + } +``` +> **说明:** test_list中配置的是对应模块的测试用例。 + +## 测试资源配置 + +试依赖资源主要包括测试用例在执行过程中需要的图片文件,视频文件、第三方库等对外的文件资源。 + +依赖资源文件配置步骤如下: + +1.在部件的test目录下创建resource目录,在resource目录下创建对应的模块,在模块目录中存放该模块所需要的资源文件 + +2.在resource目录下对应的模块目录中创建一个ohos_test.xml文件,文件内容格式如下: + +``` + + + + + + + +``` + +3.在测试用例的编译配置文件中定义resource_config_file进行指引,用来指定对应的资源文件ohos_test.xml + +``` +ohos_unittest("CalculatorSubTest") { + resource_config_file = "//system/subsystem/partA/test/resource/calculator/ohos_test.xml" +} +``` +>**说明:** +>- target_name: 测试套的名称,定义在测试目录的BUILD.gn中。preparer: 表示该测试套执行前执行的动作。 +>- src="res": 表示测试资源位于test目录下的resource目录下,src="out":表示位于out/release/$(部件)目录下。 + +## 执行测试用例 + +### 配置文件 + +在执行测试用例之前,针对用例使用设备的不同,需要对相应配置进行修改,修改完成即可执行测试用例。 + +#### user_config.xml配置 +``` + + + + false + + false + + true + + + + + + + + + + + + + + + + + cmd + 115200 + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + +``` +>**说明:** 在执行测试用例之前,若使用HDC连接设备,用例仅需配置设备IP和端口号即可,其余信息均默认不修改。 + +### 执行命令说明 + +1. 启动测试框架 + ``` + start.bat + ``` +2. 选择产品形态 + + 进入测试框架,系统会自动提示您选择产品形态,请根据实际的开发板进行选择。 + + 如需手动添加,请在config/framework_config.xml的\标签内增加产品项。 + +3. 执行测试用例 + + 当选择完产品形态,可参考如下指令执行测试用例。 + ``` + run -t UT -ts CalculatorSubTest -tc interger_sub_00l + ``` + 执行命令参数说明: + ``` + -t [TESTTYPE]: 指定测试用例类型,有UT,MST,ST,PERF,FUZZ,BENCHMARK等。(必选参数) + -tp [TESTPART]: 指定部件,可独立使用。 + -tm [TESTMODULE]: 指定模块,不可独立使用,需结合-tp指定上级部件使用。 + -ts [TESTSUITE]: 指定测试套,可独立使用。 + -tc [TESTCASE]: 指定测试用例,不可独立使用,需结合-ts指定上级测试套使用。 + -h : 帮助命令。 + +#### Windows环境执行 + +由于Windows环境下无法实现用例编译,因此执行用例前需要在Linux环境下进行用例编译,用例编译命令: +``` +./build.sh --product-name {product_name} --build-target make_test +``` + +>说明: +>- product-name:指定编译产品名称。 +>- build-target:指定所需编译用例,make_test表示指定全部用例,实际开发中可指定特定用例。 + +编译完成后,测试用例将自动保存在out/ohos-arm-release/packages/phone/tests目录下。 + +##### 搭建执行环境 +1. 在Windows环境创建测试框架目录Test,并在此目录下创建testcase目录 + +2. 从Linux环境拷贝测试框架developertest和xdevice到创建的Test目录下,拷贝编译好的测试用例到testcase目录下 + + >**说明:** 将测试框架及测试用例从Linux环境移植到Windows环境,以便后续执行。 + +3. 修改user_config.xml + ``` + + + false + + + + D:\Test\testcase\tests + + ``` + >**说明:** ``标签表示是否需要编译用例;``标签表示测试用例查找路径。 + +#### Linux环境执行 + +如是直接连接Linux机器,则可直接使用上面的执行命令执行命令 + +##### 远程端口映射 +为支持Linux远程服务器以及Linux虚拟机两种环境下执行测试用例,需要对端口进行远程映射,以实现与设备的数据通路连接。具体操作如下: +1. HDC Server指令: + ``` + hdc_std kill + hdc_std -m -s 0.0.0.0:8710 + ``` + >**说明:** IP和端口号为默认值。 + +2. HDC Client指令: + ``` + hdc_std -s xx.xx.xx.xx:8710 list targets + ``` + >**说明:** 此处IP填写设备侧IP地址。 + +## 查看测试结果 + +### 测试报告日志 + +当执行完测试指令,控制台会自动生成测试结果,若需要详细测试报告您可在相应的数据文档中进行查找。 + +### 测试结果 +测试结果输出根路径如下: +``` +test/developertest/reports/xxxx_xx_xx_xx_xx_xx +``` +>**说明:** 测试报告文件目录将自动生成。 + +该目录中包含以下几类结果: +| 类型 | 描述 | +| ------------------------------------ | ------------------ | +| result/ | 测试用例格式化结果 | +| log/plan_log_xxxx_xx_xx_xx_xx_xx.log | 测试用例日志 | +| summary_report.html | 测试报告汇总 | +| details_report.html | 测试报告详情 | + +### 测试框架日志 +``` +reports/platform_log_xxxx_xx_xx_xx_xx_xx.log +``` + +### 最新测试报告 +``` +reports/latest +``` diff --git a/zh-cn/device-dev/driver/driver-platform-mmc-develop.md b/zh-cn/device-dev/driver/driver-platform-mmc-develop.md index f1ecd21a8ba4317a2fe93646ea936ba702e05913..73e1f9bba87c5ad88940132eeb284e5c2fc0fe5a 100755 --- a/zh-cn/device-dev/driver/driver-platform-mmc-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-mmc-develop.md @@ -25,10 +25,10 @@ struct MmcCntlrOps { int32_t (*setSdioIrq)(struct MmcCntlr *cntlr, bool enable); int32_t (*hardwareReset)(struct MmcCntlr *cntlr); int32_t (*systemInit)(struct MmcCntlr *cntlr); - int32_t (*setEnhanceSrobe)(struct MmcCntlr *cntlr, bool enable); + int32_t (*setEnhanceStrobe)(struct MmcCntlr *cntlr, bool enable); int32_t (*switchVoltage)(struct MmcCntlr *cntlr, enum MmcVolt volt); bool (*devReadOnly)(struct MmcCntlr *cntlr); - bool (*devPluged)(struct MmcCntlr *cntlr); + bool (*devPlugged)(struct MmcCntlr *cntlr); bool (*devBusy)(struct MmcCntlr *cntlr); int32_t (*tune)(struct MmcCntlr *cntlr, uint32_t cmdCode); int32_t (*rescanSdioDev)(struct MmcCntlr *cntlr); @@ -47,10 +47,10 @@ struct MmcCntlrOps { | setSdioIrq | cntlr:核心层结构体指针,MMC控制器
enable:布尔值,控制中断 | HDF_STATUS相关状态 | 使能/去使能SDIO中断 | | hardwareReset | cntlr:核心层结构体指针,MMC控制器 | HDF_STATUS相关状态 | 复位硬件 | | systemInit | cntlr:核心层结构体指针,MMC控制器 | HDF_STATUS相关状态 | 系统初始化 | -| setEnhanceSrobe | cntlr:核心层结构体指针,MMC控制器
enable:布尔值,设置功能 | HDF_STATUS相关状态 | 设置增强选通 | +| setEnhanceStrobe | cntlr:核心层结构体指针,MMC控制器
enable:布尔值,设置功能 | HDF_STATUS相关状态 | 设置增强选通 | | switchVoltage | cntlr:核心层结构体指针,MMC控制器
volt:枚举值,电压值(3.3,1.8,1.2V) | HDF_STATUS相关状态 | 设置电压值 | | devReadOnly | cntlr:核心层结构体指针,MMC控制器 | 布尔值 | 检验设备是否只读 | -| cardPluged | cntlr:核心层结构体指针,MMC控制器 | 布尔值 | 检验设备是否拔出 | +| cardPlugged | cntlr:核心层结构体指针,MMC控制器 | 布尔值 | 检验设备是否拔出 | | devBusy | cntlr:核心层结构体指针,MMC控制器 | 布尔值 | 检验设备是否忙碌 | | tune | cntlr:核心层结构体指针,MMC控制器
cmdCode:uint32_t,命令代码 | HDF_STATUS相关状态 | 调谐 | | rescanSdioDev | cntlr:核心层结构体指针,MMC控制器 | HDF_STATUS相关状态 | 扫描并添加SDIO设备 | @@ -254,7 +254,7 @@ MMC模块适配的三个必选环节是实例化驱动入口,配置属性文 uint32_t maxBlkNum; uint32_t maxBlkSize; uint32_t maxReqSize; - bool devPluged; + bool devPlugged; bool detecting; void *priv; }; @@ -273,10 +273,10 @@ MMC模块适配的三个必选环节是实例化驱动入口,配置属性文 .setSdioIrq = HimciSetSdioIrq, .hardwareReset = HimciHardwareReset, .systemInit = HimciSystemInit, - .setEnhanceSrobe= HimciSetEnhanceSrobe, + .setEnhanceStrobe= HimciSetEnhanceStrobe, .switchVoltage = HimciSwitchVoltage, .devReadOnly = HimciDevReadOnly, - .devPluged = HimciCardPluged, + .devPlugged = HimciCardPlugged, .devBusy = HimciDevBusy, .tune = HimciTune, .rescanSdioDev = HimciRescanSdioDev, diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 10f14510e83b69dbad815992ca986139bb87df16..d243354b9c95f462dcddd8fcb6ef7acd396b62d9 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -65,6 +65,7 @@ - [虚拟文件系统](kernel-small-bundles-fs-virtual.md) - [支持的文件系统](kernel-small-bundles-fs-support.md) - [适配新的文件系统](kernel-small-bundles-fs-new.md) + - [Plimitsfs文件系统](kernel-small-plimits.md) - 调测与工具 - Shell - [Shell介绍](kernel-small-debug-shell-overview.md) diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000002324.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000002324.png new file mode 100644 index 0000000000000000000000000000000000000000..bb35a8ccde16464e275917644fb5066b2706bbdb Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000002324.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232425.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232425.png new file mode 100644 index 0000000000000000000000000000000000000000..8239b823f6d02fe6b9459b319c9f1260bbbfb789 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232425.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232426.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232426.png new file mode 100644 index 0000000000000000000000000000000000000000..fd8550c59b39a3c98a225060e93b2316e7c45b96 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232426.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232428.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232428.png new file mode 100644 index 0000000000000000000000000000000000000000..7c2ecfd6e8c1f0d84b9e9cb97efa29af98859d0b Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image_000000232428.png differ diff --git a/zh-cn/device-dev/kernel/kernel-small-plimits.md b/zh-cn/device-dev/kernel/kernel-small-plimits.md new file mode 100644 index 0000000000000000000000000000000000000000..7472c723e125f842df01088fddf2ff3a4b7f94d9 --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-small-plimits.md @@ -0,0 +1,331 @@ +# 容器配额(plimits) + +## 简介 + +面对进程越来越多,应用环境越来越复杂的状况,需要对容器做限制,若不做限制,会发生资源浪费、争夺等。容器配额plimits(Process Limits)是内核提供的一种可以限制单个进程或者多个进程所使用资源的机制,可以对cpu,内存等资源实现精细化控制。plimits的接口通过plimitsfs的伪文件系统提供。通过操作文件对进程及进程资源进行分组管理,通过配置plimits组内限制器Plimiter限制进程组的memory、sched等资源的使用。 + +## 基本概念 + +- plimits:内核的一个特性,用于限制、记录和隔离一组进程的资源使用。 +- plimitsfs:plimits文件系统,向用户提供操作接口,实现plimits的创建,删除。向用户展示plimits的层级等。 +- plimiter:资源限制器的总称,一个子系统代表一类资源限制器,包含memory限制器、pids限制器、sched限制器。 +- sched限制器:限制plimits组内的所有进程,在时间周期内占用的cpu时间。 +- memory限制器:限制plimits组内所有进程的内存使用总和。 +- pids限制器:限制plimits组内能挂载的最大进程数。 + +## 运行机制 + +plimitsfs文件系统,在系统初始化阶段,初始化plimits目录挂载至proc目录下: + +``` +├─proc +│ ├─plimits +│ │ ├─plimits.plimiter_add +│ │ ├─plimits.plimiter_delete +│ │ ├─plimits.procs +│ │ ├─plimits.limiters +│ │ ├─pids.max +│ │ ├─sched.period +│ │ ├─sched.quota +│ │ ├─sched.stat +│ │ ├─memory.failcnt +│ │ ├─memory.limit +│ │ ├─memory.peak +│ │ ├─memory.usage +│ │ ├─memory.oom_ctrl +│ │ └─memory.stat +``` + +1. plimits分组: + + **图1** plimits创建/删除 + + ![zh-cn_image_0000002324](figures/zh-cn_image_0000002324.png) + +2. sched限制器: + + **图2** sched限制器配置 + + ![zh-cn_image_000000252628](figures/zh-cn_image_000000232425.png) + +3. memory限制器: + + **图3** memory限制器配置 + + ![zh-cn_image_000000232426](figures/zh-cn_image_000000232426.png) + +4. pids限制器: + + **图4** Pids限制器配置 + + ![zh-cn_image_000000232428](figures/zh-cn_image_000000232428.png) + + +## 开发指导 + + +### 接口说明 + +LiteOS-A的plimits根目录在/proc/plimits下,其下的所有文件只有只读权限,不允许写操作。限制器文件设定值默认为最大值,通过读文件,可查看组内进程资源状态。 +通过mkdir创建plimitsA目录完成对进程资源分组,进而操作资源的分配限制。创建的plimitsA目录继承其父plimits目录。 + +1. plimitsA文件目录见下表: + + |
权限
| 大小 | 用户 | 用户组 | 文件名 | 文件描述 | + | --------- | ---- | ---- | ------ | ---------------------- | --------- | + |-r--r--r-- | 0 | u:0 | g:0 | sched.stat | 每个线程上周期内使用的时间片信息,方便测试验证使用 | + |-rw-r--r-- | 0 | u:0 | g:0 | sched.quota | 组内所有进程在周期内使用时间片总和,单位:ns | + |-rw-r--r-- | 0 | u:0 | g:0 | sched.period | 时间片统计周期,单位:ns | + |-r--r--r-- | 0 | u:0 | g:0 | memory.stat | 统计内存使用的信息,单位:字节 | + |-r--r--r-- | 0 | u:0 | g:0 | memory.usage | 已使用内存份额,单位:字节 | + |-r--r--r-- | 0 | u:0 | g:0 | memory.peak | 内存历史使用峰值,单位:字节 | + |-rw-r--r-- | 0 | u:0 | g:0 | memory.limit | 内存使用限额,单位:字节 | + |-r--r--r-- | 0 | u:0 | g:0 | memory.failcnt | 记录超过限额内存分配失败的次数,单位:次 | + |-rw-r--r-- | 0 | u:0 | g:0 | pids.max | 组内允许挂载进程的最大数,单位:个 | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.procs | 组内挂载的所有进程 | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.limiter_delete | 根据写入的限制器名称,删除限制器 | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.limiter_add | 根据写入的限制器名称,添加限制器 | + |-r--r--r-- | 0 | u:0 | g:0 | plimits.limiters | 查看组内限制器 | + + 在/proc/plimits/下创建的plimitsA目录下文件均可读部分可写,通过write对plimitsA子目录中写入内容,完成对进程资源分配与限制。 + - 对文件sched.quota写入时间,单位ns,可限制组内所有进程使用cpu的时间 + - 对文件sched.period写入时间,单位ns,可设置组内统计的时间周期 + - 对文件memory.limit写入内存,单位字节,可限制组内允许使用的内存制 + - 对文件pids.max写入十进制数字,可限制组内允许挂载的进程个数 + - 对文件plimits.procs写入Pid,可将进程挂到不同的plimits组 + - 通过read读不同的文件,可查看组内资源配置使用状况 + +2. 删除plimitsA组: + + 首先对/proc/plimits/plimitsA/plimits.limiter_delete文件依次写入字段“sched”、“memory”、“pids”删除限制器,才能使用rmdir删除plimitsA。 + + | 权限 | 大小 | 用户 | 用户组 | 文件名 | + | --------- | ------- | ------ | ------ | ----------------------- | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.procs | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.limiter_delete | + |-rw-r--r-- | 0 | u:0 | g:0 | plimits.limiter_add | + |-r--r--r-- | 0 | u:0 | g:0 | plimits.limiters | + +### 开发流程 + +plimits文件系统的主要开发流程包括创建新的plimitsA,将pid号写入/plimitsA/plimits.procs,对进程资源分组;按照字节大小写文件/plimitsA/memory.limit文件,限制plimitsA组内能使用的最大内存;对文件/plimitsA/pids.max写入十进制数字限制plimitsA组内所能挂载的进程数等;通过配置plimitsA组内限制器文件,对相应的资源进行分配和限制。亦可删除plimitsA,不限制资源的使用。 + +### 编程实例 + +编程示例主要是创建分组plimitsA,通过读写子目录内容,完成进程与进程资源的分组,对Plimits组内进程资源限制。 + +``` +#include +#include +#include +#include +#include +#include +#include + +#define LOS_OK 0 +#define LOS_NOK -1 + +int main () +{ + int ret; + ssize_t len; + int fd = -1; + //get main pid + int mainpid = getpid(); + char plimitsA[128] = "/proc/plimits/plimitsA"; + char plimitsAPids[128] = "/proc/plimits/plimitsA/pids.max"; + char plimitsAMemoryLimit[128] = "/proc/plimits/plimitsA/memory.limit"; + char plimitsAMemoryUsage[128] = "/proc/plimits/plimitsA/memory.usage"; + char plimitsAProcs[128] = "/proc/plimits/plimitsA/plimits.procs"; + char plimitsAAdd[128] = "/proc/plimits/plimitsA/plimits.limiter_add"; + char plimitsADelete[128] = "/proc/plimits/plimitsA/plimits.limiter_delete"; + char plimitsMem[128] = "/proc/plimits/memory.usage"; + char plimitsPid[128] = "/proc/plimits/plimits.procs"; + char *mem = NULL; + char writeBuf[128]; + char readBuf[128]; + + /* 查看根plimits组内进程 */ + memset(readBuf, 0, sizeof(readBuf)); + fd = open(plimitsPid, O_RDONLY); + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(readBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + close(fd); + printf("/proc/plimits组内进程:%s\n", readBuf); + + /* 查看根plimits组内内存使用 */ + memset(readBuf, 0, sizeof(readBuf)); + fd = open(plimitsMem, O_RDONLY); + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(readBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + close(fd); + printf("/proc/plimits组内已使用内存:%s\n", readBuf); + + + /* 创建plimitsA “/proc/plimits/plimitsA” */ + ret = mkdir(plimitsA, 0777); + if (ret != LOS_OK) { + printf("mkdir failed.\n"); + return LOS_NOK; + } + + /* 设置plimitsA组允许挂载进程个数 */ + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%d", 3); + fd = open(plimitsAPids, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + close(fd); + + /* 挂载进程至plimitsA组 */ + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%d", mainpid); + fd = open(plimitsAProcs, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + close(fd); + + /* 设置plimitsA组内分配内存限额 */ + memset(writeBuf, 0, sizeof(writeBuf)); + //limit memory + sprintf(writeBuf, "%d", (1024*1024*3)); + fd = open(plimitsAMemoryLimit, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + close(fd); + + /* 查看plimitsA组内允许使用的最大内存 */ + memset(readBuf, 0, sizeof(readBuf)); + fd = open(plimitsAMemoryLimit, O_RDONLY); + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(readBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + close(fd); + printf("/proc/plimits/plimitsA组允许使用的最大内存:%s\n", readBuf); + + /* 查看plimitsA组内挂载的进程 */ + memset(readBuf, 0, sizeof(readBuf)); + fd = open(plimitsAProcs, O_RDONLY); + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(readBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + close(fd); + printf("/proc/plimits/plimitsA组内挂载的进程:%s\n", readBuf); + + /* 查看plimitsA组内存的使用情况 */ + mem = (char*)malloc(1024*1024); + memset(mem, 0, 1024); + memset(readBuf, 0, sizeof(readBuf)); + fd = open(plimitsAMemoryUsage, O_RDONLY); + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(readBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + close(fd); + printf("/proc/plimits/plimitsA组已使用内存:%s\n", readBuf); + + /* 删除plimitsA组内memory限制器 */ + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%s", "memory"); + fd = open(plimitsADelete, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + close(fd); + + /* 增加plimitsA组内memory限制器 */ + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%s", "memory"); + fd = open(plimitsAAdd, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + close(fd); + + /* 删除plimitsA组,首先删除memory、pids、sched限制器 */ + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%s", "memory"); + fd = open(plimitsADelete, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%s", "pids"); + fd = open(plimitsADelete, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + + memset(writeBuf, 0, sizeof(writeBuf)); + sprintf(writeBuf, "%s", "sched"); + fd = open(plimitsADelete, O_WRONLY); + len = write(fd, writeBuf, strlen(writeBuf)); + close(fd); + ret = rmdir(plimitsA); + if (ret != LOS_OK) { + printf("rmdir failed.\n"); + return LOS_NOK; + } + + return 0; +} +``` + + +### 结果验证 + +编译运行得到的结果为: + + +``` +/proc/plimits组内进程: +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 + +/proc/plimits组内已使用内存:28016640 + +/proc/plimits/plimitsA组允许使用的最大内存:3145728 + +/proc/plimits/plimitsA组内挂载的进程: +15 + +/proc/plimits/plimitsA组已使用内存:4096 +``` diff --git a/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md b/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md index 98c7de011fef755a118ea6dc9e3f4ef10d1bae4c..eff04082dae1a611a07b61a2abadd589d061f604 100644 --- a/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md +++ b/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md @@ -1,22 +1,24 @@ -# HDI 接口参考 +# HDI 参数参考 - 模块 - [Audio](_audio.md) - [Battery](battery.md) - - [Camera](_camera.md) - - [Codec](_codec.md) + - [Camera](camera.md) + - [Codec](codec.md) - [Display](_display.md) - [HdfFaceAuth](_hdf_face_auth.md) - - [Input](_input.md) - - [Light](_light.md) - [HdfPinAuth](_hdf_pin_auth.md) + - [HdfUserAuth](_hdf_user_auth.md) + - [HdiActivityRecognition](activity_recognition.md) + - [Input](input.md) + - [Light](light.md) + - [Motion](motion.md) - [Power](power.md) - - [Sensor](_sensor.md) + - [Sensor](sensor.md) - [Thermal](thermal.md) - - [USB](_u_s_b.md) - - [HdfUserAuth](_hdf_user_auth.md) - - [Vibrator](_vibrator.md) - - [WLAN](_w_l_a_n.md) + - [USB](usb.md) + - [Vibrator](vibrator.md) + - [WLAN](wlan.md) - 头文件和结构体 - 头文件 - [audio_adapter.h](audio__adapter_8h.md) @@ -28,65 +30,74 @@ - [audio_scene.h](audio__scene_8h.md) - [audio_types.h](audio__types_8h.md) - [audio_volume.h](audio__volume_8h.md) - - [codec_callback_if.h](codec__callback__if_8h.md) - - [codec_common_type.h](codec__common__type_8h.md) - - [codec_component_if.h](codec__component__if_8h.md) - - [codec_component_manager.h](codec__component__manager_8h.md) - - [codec_component_type.h](codec__component__type_8h.md) + - [codec_callback_if.h](codec_callback_if_h.md) + - [codec_common_type.h](codec_common_type_h.md) + - [codec_component_if.h](codec_component_if_h.md) + - [codec_component_manager.h](codec__component__manager_h.md) + - [codec_component_type.h](codec__component__type_h.md) - [display_device.h](display__device_8h.md) - [display_gfx.h](display__gfx_8h.md) - [display_gralloc.h](display__gralloc_8h.md) - [display_layer.h](display__layer_8h.md) - [display_type.h](display__type_8h.md) - - [icamera_device_callback.h](icamera__device__callback_8h.md) - - [icamera_device.h](icamera__device_8h.md) - - [icamera_host_callback.h](icamera__host__callback_8h.md) - - [icamera_host.h](icamera__host_8h.md) + - [display_vgu.h](display__vgu_8h.md) - [input_controller.h](input__controller_8h.md) - [input_manager.h](input__manager_8h.md) - [input_reporter.h](input__reporter_8h.md) - [input_type.h](input__type_8h.md) - - [ioffline_stream_operator.h](ioffline__stream__operator_8h.md) - - [istream_operator_callback.h](istream__operator__callback_8h.md) - - [istream_operator.h](istream__operator_8h.md) - - [light_if.h](light__if_8h.md) - - [light_type.h](light_8typeh.md) - - [sensor_if.h](sensor__if_8h.md) - - [sensor_type.h](sensor__type_8h.md) - - [types.h](types_8h.md) - - [usb_info.h](usb__info_8h.md) - - [usbd_client.h](usbd__client_8h.md) - - [usbd_subscriber.h](usbd__subscriber_8h.md) - - [usbd_type.h](usbd__type_8h.md) - - [vibrator_if.h](vibrator__if_8h.md) - - [vibrator_type.h](vibrator__type_8h.md) - - [wifi_hal_ap_feature.h](wifi__hal__ap__feature_8h.md) - - [wifi_hal_base_feature.h](wifi__hal__base__feature_8h.md) - - [wifi_hal_sta_feature.h](wifi__hal__sta__feature_8h.md) - - [wifi_hal.h](wifi__hal_8h.md) + - [ActivityRecognitionTypes.idl](activity_recognition_types_idl.md) + - [Types.idl](battery_types_idl.md) - [IExecutor.idl](face__auth_2_i_executor_8idl.md) - [IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md) - [FaceAuthTypes.idl](_face_auth_types_8idl.md) - [PinAuthTypes.idl](_pin_auth_types_8idl.md) - - [IBatteryCallback.idl](_i_battery_callback_8idl.md) - - [IBatteryInterface.idl](_i_battery_interface_8idl.md) - [IExecutor.idl](pin__auth_2_i_executor_8idl.md) - [IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md) - [IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md) - [IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md) + - [IUserAuthInterface.idl](_i_user_auth_interface_8idl.md) + - [UserAuthTypes.idl](_user_auth_types_8idl.md) + - [IActivityChangedCallback.idl](_i_activity_changed_callback_8idl.md) + - [IActivityInterface.idl](_i_activity_interface_8idl.md) + - [IBatteryCallback.idl](_i_battery_callback_8idl.md) + - [IBatteryInterface.idl](_i_battery_interface_8idl.md) + - [ICameraDevice.idl](_i_camera_device_8idl.md) + - [ICameraDeviceCallback.idl](_i_camera_device_callback_8idl.md) + - [ICameraHostCallback.idl](_i_camera_host_callback_8idl.md) + - [ICameraHost.idl](_i_camera_host_8idl.md) + - [ILightInterface.idl](_i_light_interface_8idl.md) + - [IMotionCallback.idl](_i_motion_callback_8idl.md) + - [IMotionInterface.idl](_i_motion_interface_8idl.md) + - [IOfflineStreamOperator.idl](_i_offline_stream_operator_8idl.md) - [IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md) - [IPowerInterface.idl](_i_power_interface_8idl.md) - - [IThermalInterface.idl](_i_thermal_interface_8idl.md) + - [ISensorCallback.idl](_i_sensor_callback_8idl.md) + - [ISensorInterface.idl](_i_sensor_interface_8idl.md) + - [IStreamOperator.idl](_i_stream_operator_8idl.md) + - [IStreamOperatorCallback.idl](_i_stream_operator_callback_8idl.md) - [IThermalCallback.idl](_i_thermal_callback_8idl.md) - - [IUserAuthInterface.idl](_i_user_auth_interface_8idl.md) + - [IThermalInterface.idl](_i_thermal_interface_8idl.md) + - [IUsbdBulkCallback.idl](_i_usbd_bulk_callback_8idl.md) + - [IUsbInterface.idl](_i_usb_interface_8idl.md) + - [IUsbdSubscriber.idl](_i_usbd_subscriber_8idl.md) + - [IVibratorInterface.idl](_i_vibrator_interface_8idl.md) + - [IWlanCallback.idl](_i_wlan_callback_8idl.md) + - [IWlanInterface.idl](_i_wlan_interface_8idl.md) + - [LightTypes.idl](_light_types_8idl.md) + - [MotionTypes.idl](_motion_types_8idl.md) - [PowerTypes.idl](_power_types_8idl.md) + - [SensorTypes.idl](_sensor_types_8idl.md) - [ThermalTypes.idl](_thermal_types_8idl.md) - - [Types.idl](_types_8idl.md) - - [UserAuthTypes.idl](_user_auth_types_8idl.md) + - [Types.idl](camera_2v1__0_2_types_8idl.md) + - [UsbTypes.idl](_usb_types_8idl.md) + - [VibratorTypes.idl](_vibrator_types_8idl.md) + - [WlanTypes.idl](_wlan_types_8idl.md) - 结构体 - - [__attribute__](____attribute____.md) - - [Alignment](_alignment.md) + - [YUVDescInfo](_yun_desc_info_.md) + - [ExtDataHandle](_ext_data_handle.md) + - [ActRecognitionEvent](_act_recognition_event.md) - [AllocInfo](_alloc_info.md) + - [Alignment](_alignment.md) - [AudioAdapter](_audio_adapter.md) - [AudioAdapterDescriptor](_audio_adapter_descriptor.md) - [AudioAttribute](_audio_attribute.md) @@ -98,7 +109,7 @@ - [AudioMixExtInfo](_audio_mix_ext_info.md) - [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) - [AudioPort](_audio_port.md) - - [AudioPortCap](_audio_port_cap.md) + - [AudioPortCap](audio_portcap.md) - [AudioPortCapability](_audio_port_capability.md) - [AudioRender](_audio_render.md) - [AudioRoute](_audio_route.md) @@ -113,12 +124,16 @@ - [AudioVolume](_audio_volume.md) - [AuthResultInfo](_auth_result_info.md) - [AuthSolution](_auth_solution.md) - - [BatteryInfo](_battery_info.md) - [BufferData](_buffer_data.md) + - [BatteryInfo](_battery_info.md) + - [CaptureEndedInfo](_capture_ended_info.md) + - [CaptureErrorInfo](_capture_error_info.md) + - [CaptureInfo](_capture_info.md) - [CodecCallbackType](_codec_callback_type.md) - [CodecCompCapability](_codec_comp_capability.md) - [CodecComponentManager](_codec_component_manager.md) - [CodecComponentType](_codec_component_type.md) + - [ColorValue](union_color_value.md) - [CompVerInfo](_comp_ver_info.md) - [CredentialInfo](_credential_info.md) - [DeviceFuncs](_device_funcs.md) @@ -137,11 +152,33 @@ - [GfxFuncs](_gfx_funcs.md) - [GfxOpt](_gfx_opt.md) - [GrallocFuncs](_gralloc_funcs.md) + - [HdfFeatureInfo](_hdf_feature_info.md) + - [HdfLightColor](_hdf_light_color.md) + - [HdfLightEffect](_hdf_light_effect.md) + - [HdfLightFlashEffect](_hdf_light_flash_effect.md) + - [HdfLightInfo](_hdf_light_info.md) + - [HdfMotionEvent](_hdf_motion_event.md) + - [HdfNetDeviceInfo](_hdf_net_device_info.md) + - [HdfNetDeviceInfoResult](_hdf_net_device_info_result.md) + - [HdfSensorEvents](_hdf_sensor_events.md) + - [HdfSensorInformation](_hdf_sensor_information.md) + - [HdfStaInfo](_hdf_sta_info.md) - [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) + - [HdfVibratorInfo](_hdf_vibrator_info.md) + - [HdfWifiDriverScanSsid](_hdf_wifi_driver_scan_ssid.md) + - [HdfWifiInfo](_hdf_wifi_info.md) + - [HdfWifiScan](_hdf_wifi_scan.md) + - [HdfWifiScanResult](_hdf_wifi_scan_result.md) - [HDRCapability](_h_d_r_capability.md) - [HDRMetaData](_h_d_r_meta_data.md) + - [IActivityChangedCallback](interface_i_activity_changed_callback.md) + - [IActivityInterface](interface_i_activity_interface.md) - [IBatteryCallback](interface_i_battery_callback.md) - [IBatteryInterface](interface_i_battery_interface.md) + - [ICameraDevice](interface_i_camera_device.md) + - [ICameraDeviceCallback](interface_i_camera_device_callback.md) + - [ICameraHost](interface_i_camera_host.md) + - [ICameraHostCallback](interface_i_camera_host_callback.md) - [ICircle](_i_circle.md) - [IdentifyResultInfo](_identify_result_info.md) - [IExecutor](interface_i_executor.md) @@ -149,77 +186,91 @@ - [IExecutorCallback](interface_i_executor_callback.md) - [IExecutorCallback](interface_pin_i_executor_callback.md) - [IFaceAuthInterface](interface_i_face_auth_interface.md) - - [IInputInterface](_i_input_interface.md) - [ILine](_i_line.md) + - [IInputInterface](_i_input_interface.md) + - [ILightInterface](interface_i_light_interface.md) + - [IMotionCallback](interface_i_motion_callback.md) + - [IMotionInterface](interface_i_motion_interface.md) - [InputController](_input_controller.md) - [InputDevAbility](_input_dev_ability.md) - - [InputDevAttr](_input_dev_attr.md) + - [InputDevAttr](_input_dev_attr.md) - [InputDevDesc](_input_dev_desc.md) + - [InputDeviceInfo](_input_device_info.md) - [InputDevIdentify](_input_dev_identify.md) - - [InputDeviceInfo](_device_info.md) - - [InputDimensionInfo](_input_dimension_info.md) - - [InputEventCb](_input_report_event_cb.md) - - [InputEventPackage](_event_package.md) + - [InputDimensionInfo](_input_dimension_info.md) + - [InputEventCb](_input_event_cb.md) + - [InputEventPackage](_input_event_package.md) + - [IPowerHdiCallback](interface_i_power_hdi_callback.md) - [InputExtraCmd](_input_extra_cmd.md) - [InputHostCb](_input_host_cb.md) - - [InputHotPlugEvent](_input_hotplug_event.md) + - [InputHotPlugEvent](_input_hot_plug_event.md) - [InputManager](_input_manager.md) - [InputReporter](_input_reporter.md) + - [IOfflineStreamOperator](interface_i_offline_stream_operator.md) - [IPinAuthInterface](interface_i_pin_auth_interface.md) - - [IPowerHdiCallback](interface_i_power_hdi_callback.md) - [IPowerInterface](interface_i_power_interface.md) - [IRect](_i_rect.md) + - [ISensorCallback](interface_i_sensor_callback.md) + - [ISensorInterface](interface_i_sensor_interface.md) + - [IStreamOperator](interface_i_stream_operator.md) + - [IStreamOperatorCallback](interface_i_stream_operator_callback.md) - [ISurface](_i_surface.md) - [IThermalCallback](interface_i_thermal_callback.md) - [IThermalInterface](interface_i_thermal_interface.md) + - [IUsbdBulkCallback](interface_i_usbd_bulk_callback.md) + - [IUsbdSubscriber](interface_i_usbd_subscriber.md) + - [IUsbInterface](interface_i_usb_interface.md) - [IUserAuthInterface](interface_i_user_auth_interface.md) - - [IWiFi](_i_wi_fi.md) - - [IWiFiAp](_i_wi_fi_ap.md) - - [IWiFiBaseFeature](_i_wi_fi_base_feature.md) - - [IWiFiSta](_i_wi_fi_sta.md) + - [IVibratorInterface](interface_i_vibrator_interface.md) + - [IWlanCallback](interface_i_wlan_callback.md) + - [IWlanInterface](interface_i_wlan_interface.md) - [LayerAlpha](_layer_alpha.md) - [LayerBuffer](_layer_buffer.md) - [LayerFuncs](_layer_funcs.md) - [LayerInfo](_layer_info.md) - - [LightEffect](_light_effect.md) - - [LightFlashEffect](_light_flash_effect.md) - - [LightInfo](_light_info.md) - - [LightInterface](_light_interface.md) - - [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) - - [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) - - [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) - - [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) - - [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) - - [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) - - [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) - - [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) - - [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) - - [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) - - [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) - - [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) - - [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) - - [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) - - [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) - - [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) - - [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) - - [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) - - [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) + - [MeasChannelParam](_meas_channel_param.md) + - [MeasChannelResult](_meas_channel_result.md) - [OmxCodecBuffer](_omx_codec_buffer.md) - [PortCap](union_port_cap.md) + - [PortInfo](_port_info.md) - [PresentTimestamp](_present_timestamp.md) - [PropertyObject](_property_object.md) + - [ProjectionScreenCmdParam](_projection_screen_cmd_param.md) - [RangeValue](_range_value.md) - [Rect](_rect.md) - [Rectangle](_rectangle.md) + - [RGBColor](_r_g_b_color.md) - [ScheduleInfo](_schedule_info.md) - - [SensorEvents](_sensor_events.md) - - [SensorInformation](_sensor_information.md) - - [SensorInterface](_sensor_interface.md) - - [StaInfo](_sta_info.md) + - [StreamAttribute](_stream_attribute.md) + - [StreamInfo](_stream_info.md) - [SupportBufferType](_support_buffer_type.md) - [TemplateInfo](_template_info.md) - [ThermalZoneInfo](_thermal_zone_info.md) + - [UsbCtrlTransfer](_usb_ctrl_transfer.md) + - [UsbDev](_usb_dev.md) + - [USBDeviceInfo](_u_s_b_device_info.md) + - [UsbPipe](_usb_pipe.md) - [UseBufferType](_use_buffer_type.md) - [VerifyAllocInfo](_verify_alloc_info.md) - - [VibratorInterface](_vibrator_interface.md) + - [VGUBuffer](_v_g_u_buffer.md) + - [VGUColorStop](_v_g_u_color_stop.md) + - [VGUConic](_v_g_u_conic.md) + - [VGUFillAttr](_v_g_u_fill_attr.md) + - [VGUFuncs](_v_g_u_funcs.md) + - [VGUGradient](_v_g_u_gradient.md) + - [VGUImage](_v_g_u_image.md) + - [VGULinear](_v_g_u_linear.md) + - [VGUMaskLayer](_v_g_u_mask_layer.md) + - [VGUMatrix3](_v_g_u_matrix3.md) + - [VGUPaintStyle](_v_g_u_paint_style.md) + - [VGUPath](_v_g_u_path.md) + - [VGUPattern](_v_g_u_pattern.md) + - [VGUPoint](_v_g_u_point.md) + - [VGURadial](_v_g_u_radial.md) + - [VGURect](_v_g_u_rect.md) + - [VGUSolid](_v_g_u_solid.md) + - [VGUStrokeAttr](_v_g_u_stroke_attr.md) + - [VGUSurface](_v_g_u_surface.md) - [VideoPortCap](_video_port_cap.md) + - [WifiStationInfo](_wifi_station_info.md) + - [WRGBColor](_w_r_g_b_color.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/____attribute____.md b/zh-cn/device-dev/reference/hdi-apis/____attribute____.md deleted file mode 100644 index c271b05bee1f5f6ab32382c00e2c125470c6da91..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/____attribute____.md +++ /dev/null @@ -1,34 +0,0 @@ -# __attribute__ - - -## **概述** - -**所属模块:** - -[Display](_display.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [fd](_display.md#fd) | 句柄 fd, -1代表不支持。 | -| [reserveInts](_display.md#reserveints) | reserve数组的个数。 | -| [reserve](_display.md#reserve) [0] | reserve数组。 | -| [baseAddr](_display.md#baseaddr) | 内存的初始地址。 | -| [yOffset](_display.md#yoffset) | Y的偏移量。 | -| [uOffset](_display.md#uoffset) | U的偏移量。 | -| [vOffset](_display.md#voffset) | V的偏移量。 | -| [yStride](_display.md#ystride) | Y的stride信息。 | -| [uvStride](_display.md#uvstride) | UV的stride信息。 | -| [uvStep](_display.md#uvstep) | UV的step信息。 | - - -## **详细描述** - -扩展数据句柄结构体定义。 - -YUV描述信息结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_act_recognition_event.md b/zh-cn/device-dev/reference/hdi-apis/_act_recognition_event.md new file mode 100644 index 0000000000000000000000000000000000000000..be0a24cf5da6609d76c3ae7dc8d6bc8ebfeb0ae5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_act_recognition_event.md @@ -0,0 +1,82 @@ +# ActRecognitionEvent + + +## **概述** + +定义行为识别模块使用的数据类型。 + +**Since**: + +3.2 + +**Version**: + +1.0 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [activity](#activity) | 行为类型 | +| [eventType](#eventtype) | 事件类型 | +| [timestamp](#timestamp) | 时间戳 | +| [confidence](#confidence) | 置信度 | + + +## **类成员变量说明** + + +### activity + + +``` +int ActRecognitionEvent::activity +``` + +**描述:** + +行为类型,详见[ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype)。 + + +### confidence + + +``` +int ActRecognitionEvent::confidence +``` + +**描述:** + +置信度,100为最可信,0为最不可信,-1为该行为不支持置信度的计算。 + + +### eventType + + +``` +int ActRecognitionEvent::eventType +``` + +**描述:** + +事件类型,详见[ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype)。 + + +### timestamp + + +``` +long ActRecognitionEvent::timestamp +``` + +**描述:** + +时间戳。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_alignment.md b/zh-cn/device-dev/reference/hdi-apis/_alignment.md index fe001f65e7ca31fea14d7d5ae3bf63ba18b28d62..508dff7fee34820fe172e03b1cc4c60587153ce1 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_alignment.md +++ b/zh-cn/device-dev/reference/hdi-apis/_alignment.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +对齐结构定义,包含宽高的对齐值。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [widthAlignment](#widthalignment) | 宽的对齐值。 | | [heightAlignment](#heightalignment) | 高的对齐值。 | -## **详细描述** - -对齐结构定义,包含宽高的对齐值。 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md b/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md index 6873294ab8b4518a09450b67b7ff209e41102503..b75e855aa644a53d4a51f52124346e34c4368d9c 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义待分配的内存的信息。 + +**相关模块:** [Display](_display.md) @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](_display.md#width-67) | 申请内存宽度 | -| [height](_display.md#height-67) | 申请内存高度 | +| [width](_display.md#width-69) | 申请内存宽度 | +| [height](_display.md#height-68) | 申请内存高度 | | [usage](_display.md#usage-12) | 申请内存的使用场景 | | [format](_display.md#format-12) | 申请内存格式 | | [expectedSize](_display.md#expectedsize) | 申请内存大小 | - - -## **详细描述** - -定义关于要分配的内存的信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio.md b/zh-cn/device-dev/reference/hdi-apis/_audio.md index 554eb44177de3dd16d2f72091eb23972324c3a5c..4b9d2b89865f9c4dc73a96232a636a36a4d190de 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio.md @@ -1,12 +1,27 @@ # Audio +## **概述** + +Audio模块接口定义。 + +音频接口涉及自定义类型、驱动加载接口、驱动适配器接口、音频播放(Render)接口、音频录音(Capture)接口等。 + +**Since**: + +1.0 + +**Version**: + +1.0 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [audio_adapter.h](audio__adapter_8h.md) | Audio适配器的接口定义文件 | | [audio_attribute.h](audio__attribute_8h.md) | Audio属性的接口定义文件 | @@ -21,71 +36,71 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适配器接口 [更多...](_audio_adapter.md) | -| [AudioAttribute](_audio_attribute.md) | AudioAttribute音频属性接口 [更多...](_audio_attribute.md) | -| [AudioCapture](_audio_capture.md) | AudioCapture音频录音接口 [更多...](_audio_capture.md) | -| [AudioControl](_audio_control.md) | AudioControl音频控制接口 [更多...](_audio_control.md) | -| [AudioManager](_audio_manager.md) | AudioManager音频适配器管理接口 [更多...](_audio_manager.md) | -| [AudioRender](_audio_render.md) | AudioRender音频播放接口 [更多...](_audio_render.md) | -| [AudioScene](_audio_scene.md) | AudioScene音频场景接口 [更多...](_audio_scene.md) | -| [AudioPort](_audio_port.md) | 音频端口 [更多...](_audio_port.md) | -| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适配器描述符 [更多...](_audio_adapter_descriptor.md) | -| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备描述符 [更多...](_audio_device_descriptor.md) | -| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景描述符 [更多...](_audio_scene_descriptor.md) | -| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 [更多...](union_audio_scene_descriptor_1_1_scene_desc.md) | -| [AudioSampleAttributes](_audio_sample_attributes.md) | 音频采样属性 [更多...](_audio_sample_attributes.md) | -| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 [更多...](_audio_time_stamp.md) | -| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 [更多...](_audio_sub_port_capability.md) | -| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 [更多...](_audio_port_capability.md) | -| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 [更多...](_audio_mmap_buffer_descripter.md) | -| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息 [更多...](_audio_dev_ext_info.md) | -| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 [更多...](_audio_mix_ext_info.md) | -| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 [更多...](_audio_session_ext_info.md) | -| [AudioRouteNode](_audio_route_node.md) | 音频路由节点 [更多...](_audio_route_node.md) | -| [AudioRoute](_audio_route.md) | 音频路由信息 [更多...](_audio_route.md) | -| [AudioVolume](_audio_volume.md) | AudioVolume音频音量接口 [更多...](_audio_volume.md) | +| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适配器接口 | +| [AudioAttribute](_audio_attribute.md) | AudioAttribute音频属性接口 | +| [AudioCapture](_audio_capture.md) | AudioCapture音频录音接口 | +| [AudioControl](_audio_control.md) | AudioControl音频控制接口 | +| [AudioManager](_audio_manager.md) | AudioManager音频适配器管理接口 | +| [AudioRender](_audio_render.md) | AudioRender音频播放接口 | +| [AudioScene](_audio_scene.md) | AudioScene音频场景接口 | +| [AudioPort](_audio_port.md) | 音频端口 | +| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适配器描述符 | +| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备描述符 | +| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景描述符 | +| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 | +| [AudioSampleAttributes](_audio_sample_attributes.md) | 音频采样属性 | +| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 | +| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 | +| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 | +| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 | +| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息 | +| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 | +| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 | +| [AudioRouteNode](_audio_route_node.md) | 音频路由节点 | +| [AudioRoute](_audio_route.md) | 音频路由信息 | +| [AudioVolume](_audio_volume.md) | AudioVolume音频音量接口 | ### 类型定义 - | 类型定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | | AudioHandle | 音频句柄 | -| ([RenderCallback](#rendercallback)) (enum [AudioCallbackType](#audiocallbacktype), void \*reserved, void \*cookie) | 回调函数指针 [更多...](#rendercallback) | +| ([RenderCallback](#rendercallback)) (enum AudioCallbackType, void \*reserved, void \*cookie) | 回调函数指针 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioPortDirection](#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端口的类型 [更多...](#audioportdirection) | -| [AudioPortPin](#audioportpin) {   PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u,   PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u,   PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适配器端口的PIN脚 [更多...](#audioportpin) | -| [AudioCategory](#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) [更多...](#audiocategory) | -| [AudioFormat](#audioformat) {   AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u,   AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u,   AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u,   AUDIO_FORMAT_G726 = 0x2000003u } | 音频格式 [更多...](#audioformat) | -| [AudioChannelMask](#audiochannelmask) { AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通道掩码(mask) [更多...](#audiochannelmask) | -| [AudioSampleRatesMask](#audiosampleratesmask) {   AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u,   AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u,   AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | 音频采样频率MASK [更多...](#audiosampleratesmask) | -| [AudioPortPassthroughMode](#audioportpassthroughmode) { PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端口的数据透传模式 [更多...](#audioportpassthroughmode) | -| [AudioSampleFormat](#audiosampleformat) {   AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 原始音频样本格式 [更多...](#audiosampleformat) | -| [AudioChannelMode](#audiochannelmode) {   AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE,   AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频播放的通道模式 [更多...](#audiochannelmode) | -| [AudioDrainNotifyType](#audiodrainnotifytype) { AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结束类型 [更多...](#audiodrainnotifytype) | -| [AudioCallbackType](#audiocallbacktype) {   AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL,   AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 [更多...](#audiocallbacktype) | -| [AudioPortRole](#audioportrole) { AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端口角色 [更多...](#audioportrole) | -| [AudioPortType](#audioporttype) { AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端口类型 [更多...](#audioporttype) | -| [AudioSessionType](#audiosessiontype) { AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端口会话类型 [更多...](#audiosessiontype) | +| [AudioPortDirection](#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端口的类型 | +| [AudioPortPin](#audioportpin) { PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u,   PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u,   PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适配器端口的PIN脚 | +| [AudioCategory](#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) | +| [AudioFormat](#audioformat){ AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u,   AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u,   AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u,   AUDIO_FORMAT_G726 = 0x2000003u } | 音频格式 | +| [AudioChannelMask](#audiochannelmask){ AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通道掩码(mask) | +| [AudioSampleRatesMask](#audiosampleratesmask){ AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u,   AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u,   AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | 音频采样频率MASK | +| [AudioPortPassthroughMode](#audioportpassthroughmode){ PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端口的数据透传模式 | +| [AudioSampleFormat](#audiosampleformat){ AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P } | 原始音频样本格式 | +| [AudioChannelMode](#audiochannelmode){  AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE,   AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频播放的通道模式 | +| [AudioDrainNotifyType](#audiodrainnotifytype){ AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结束类型 | +| [AudioCallbackType](#audiocallbacktype){ AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL,   AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 | +| [AudioPortRole](#audioportrole){ AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端口角色 | +| [AudioPortType](#audioporttype){ AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端口类型. | +| [AudioSessionType](#audiosessiontype){ AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端口会话类型 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GetAudioManagerFuncs](#getaudiomanagerfuncs) (void) | 获取音频适配器管理接口的操作函数列表,详情参考[AudioManager](_audio_manager.md)[更多...](#getaudiomanagerfuncs) | +| [GetAudioManagerFuncs](#getaudiomanagerfuncs)(void) | 获取音频适配器管理接口的操作函数列表,详情参考[AudioManager](_audio_manager.md)。 | ### 变量 - | 变量 | 描述 | + | 变量 名称 | 描述 | | -------- | -------- | | [AudioPort::dir](#dir) | 音频端口的类型。 | | [AudioPort::portId](#portid-14) | 音频端口的ID。 | @@ -153,21 +168,6 @@ | [AudioRoute::sinks](#sinks) | 接受端列表。 | -## **详细描述** - -Audio模块接口定义。 - -音频接口涉及自定义类型、驱动加载接口、驱动适配器接口、音频播放(render)接口、音频录音(capture)接口等。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - ## **类型定义说明** @@ -178,11 +178,11 @@ Audio模块接口定义。 typedef int32_t(* RenderCallback) (enum AudioCallbackType, void *reserved, void *cookie) ``` -**描述:** +**描述:** 回调函数指针。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -190,13 +190,13 @@ typedef int32_t(* RenderCallback) (enum AudioCallbackType, void *reserved, void | reserved | 保留字段 | | cookie | 用于传递数据 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** -RegCallback +[RegCallback](_audio_render.md#regcallback) ## **枚举类型说明** @@ -209,7 +209,7 @@ RegCallback enum AudioCallbackType ``` -**描述:** +**描述:** 回调函数通知事件类型。 @@ -229,7 +229,7 @@ enum AudioCallbackType enum AudioCategory ``` -**描述:** +**描述:** 音频类型(category)。 @@ -248,7 +248,7 @@ enum AudioCategory enum AudioChannelMask ``` -**描述:** +**描述:** 音频通道掩码(mask)。 @@ -269,12 +269,13 @@ enum AudioChannelMask enum AudioChannelMode ``` -**描述:** +**描述:** 音频播放的通道模式。 -> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **须知:** -> 下面的模式是针对双通道立体声的音频播放而设置,其他不支持。 +**注意:** + +下面的模式是针对双通道立体声的音频播放而设置,其他不支持。 | 枚举值 | 描述 | | -------- | -------- | @@ -295,7 +296,7 @@ enum AudioChannelMode enum AudioDrainNotifyType ``` -**描述:** +**描述:** DrainBuffer函数结束类型。 @@ -312,7 +313,7 @@ DrainBuffer函数结束类型。 enum AudioFormat ``` -**描述:** +**描述:** 音频格式。 @@ -340,15 +341,15 @@ enum AudioFormat enum AudioPortDirection ``` -**描述:** +**描述:** 音频端口的类型。 | 枚举值 | 描述 | | -------- | -------- | -| PORT_OUT | 音频输出端口。 | -| PORT_IN | 音频输入端口。 | -| PORT_OUT_IN | 音频输出/入端口,同时支持输出和输入能力(OUT \| IN)。 | +| PORT_OUT | 音频输出端口 | +| PORT_IN | 音频输入端口 | +| PORT_OUT_IN | 音频输出/入端口, 同时支持输出和输入能力(OUT \| IN) | ### AudioPortPassthroughMode @@ -358,7 +359,7 @@ enum AudioPortDirection enum AudioPortPassthroughMode ``` -**描述:** +**描述:** 音频端口的数据透传模式。 @@ -377,7 +378,7 @@ enum AudioPortPassthroughMode enum AudioPortPin ``` -**描述:** +**描述:** 音频适配器端口的PIN脚。 @@ -403,7 +404,7 @@ enum AudioPortPin enum AudioPortRole ``` -**描述:** +**描述:** 音频端口角色。 @@ -421,7 +422,7 @@ enum AudioPortRole enum AudioPortType ``` -**描述:** +**描述:** 音频端口类型。 @@ -440,7 +441,7 @@ enum AudioPortType enum AudioSampleFormat ``` -**描述:** +**描述:** 原始音频样本格式。 @@ -470,17 +471,6 @@ enum AudioSampleFormat | AUDIO_SAMPLE_FORMAT_F32P | 64bit位宽浮点型非交织样本 | | AUDIO_SAMPLE_FORMAT_F64 | 64bit位宽双精度浮点型交织样本 | | AUDIO_SAMPLE_FORMAT_F64P | 64bit位宽双精度浮点型非交织样本 | -| AUDIO_SAMPLE_FMT_U8 | 无符号8位整型,打包格式 | -| AUDIO_SAMPLE_FMT_S16 | 带符号16位整型,打包格式 | -| AUDIO_SAMPLE_FMT_S32 | 带符号32位整型,打包格式 | -| AUDIO_SAMPLE_FMT_FLOAT | 浮点型,打包格式 | -| AUDIO_SAMPLE_FMT_DOUBLE | 双精度浮点型,打包格式 | -| AUDIO_SAMPLE_FMT_U8P | 无符号8位整型,平面格式 | -| AUDIO_SAMPLE_FMT_S16P | 带符号16位整型,平面格式 | -| AUDIO_SAMPLE_FMT_S32P | 带符号32位整型,平面格式 | -| AUDIO_SAMPLE_FMT_FLOATP | 浮点型,平面格式 | -| AUDIO_SAMPLE_FMT_DOUBLEP | 双精度浮点型,平面格式 | -| AUDIO_SAMPLE_FMT_INVALID | 无效采样格式 | ### AudioSampleRatesMask @@ -490,7 +480,7 @@ enum AudioSampleFormat enum AudioSampleRatesMask ``` -**描述:** +**描述:** 音频采样频率MASK。 @@ -517,7 +507,7 @@ enum AudioSampleRatesMask enum AudioSessionType ``` -**描述:** +**描述:** 端口会话类型。 @@ -539,11 +529,11 @@ enum AudioSessionType struct AudioManager* GetAudioManagerFuncs (void ) ``` -**描述:** +**描述:** 获取音频适配器管理接口的操作函数列表,详情参考[AudioManager](_audio_manager.md)。 -**返回:** +**返回:** 成功返回一个音频适配器管理接口的对象,失败返回NULL。 @@ -558,9 +548,9 @@ struct AudioManager* GetAudioManagerFuncs (void ) const char* AudioAdapterDescriptor::adapterName ``` -**描述:** +**描述:** -音频适配器的名称。 +音频适配器的名称 ### channelCount [1/2] @@ -570,7 +560,7 @@ const char* AudioAdapterDescriptor::adapterName uint32_t AudioSampleAttributes::channelCount ``` -**描述:** +**描述:** 音频通道数目,如单通道(mono)为1、立体声(stereo)为2。 @@ -582,9 +572,9 @@ uint32_t AudioSampleAttributes::channelCount unsigned int AudioPortCapability::channelCount ``` -**描述:** +**描述:** -支持的最大声道总数。 +支持的最大声道总数 ### channelMasks @@ -594,7 +584,7 @@ unsigned int AudioPortCapability::channelCount enum AudioChannelMask AudioPortCapability::channelMasks ``` -**描述:** +**描述:** 设备的声道布局掩码(mask),详情参考[AudioChannelMask](#audiochannelmask)。 @@ -606,9 +596,9 @@ enum AudioChannelMask AudioPortCapability::channelMasks const char* AudioDeviceDescriptor::desc ``` -**描述:** +**描述:** -以字符串命名的音频设备。 +以字符串命名的音频设备 ### desc [2/5] @@ -618,9 +608,9 @@ const char* AudioDeviceDescriptor::desc struct AudioDeviceDescriptor AudioSceneDescriptor::desc ``` -**描述:** +**描述:** -音频设备描述符。 +音频设备描述符 ### desc [3/5] @@ -630,9 +620,9 @@ struct AudioDeviceDescriptor AudioSceneDescriptor::desc const char* AudioSceneDescriptor::SceneDesc::desc ``` -**描述:** +**描述:** -以字符串命名的音频场景。 +以字符串命名的音频场景 ### desc [4/5] @@ -642,9 +632,9 @@ const char* AudioSceneDescriptor::SceneDesc::desc const char* AudioSubPortCapability::desc ``` -**描述:** +**描述:** -以字符串命名的子端口。 +以字符串命名的子端口 ### desc [5/5] @@ -654,9 +644,21 @@ const char* AudioSubPortCapability::desc const char* AudioDevExtInfo::desc ``` -**描述:** +**描述:** + +地址描述 + + +### device + + +``` +struct AudioDevExtInfo AudioRouteNode::ext::device +``` + +**描述:** -地址描述。 +设备特定信息。 ### deviceId @@ -666,7 +668,7 @@ const char* AudioDevExtInfo::desc unsigned int AudioPortCapability::deviceId ``` -**描述:** +**描述:** 绑定(bind)设备ID,唯一的设备识别符。 @@ -678,7 +680,7 @@ unsigned int AudioPortCapability::deviceId unsigned int AudioPortCapability::deviceType ``` -**描述:** +**描述:** 设备输出、输入类型。 @@ -690,7 +692,7 @@ unsigned int AudioPortCapability::deviceType enum AudioPortDirection AudioPort::dir ``` -**描述:** +**描述:** 音频端口的类型,详情参考[AudioPortDirection](#audioportdirection)。 @@ -702,7 +704,7 @@ enum AudioPortDirection AudioPort::dir enum AudioFormat AudioSampleAttributes::format ``` -**描述:** +**描述:** 音频数据格式,详情参考[AudioFormat](#audioformat)。 @@ -714,9 +716,9 @@ enum AudioFormat AudioSampleAttributes::format unsigned int AudioPortCapability::formatNum ``` -**描述:** +**描述:** -支持的音频格式数目。 +支持的音频格式数目 ### formats @@ -726,7 +728,7 @@ unsigned int AudioPortCapability::formatNum enum AudioFormat* AudioPortCapability::formats ``` -**描述:** +**描述:** 支持的音频格式,详情参考[AudioFormat](#audioformat)。 @@ -738,9 +740,9 @@ enum AudioFormat* AudioPortCapability::formats uint32_t AudioSampleAttributes::frameSize ``` -**描述:** +**描述:** -音频数据的帧大小。 +音频数据的帧大小 ### hardwareMode @@ -750,9 +752,9 @@ uint32_t AudioSampleAttributes::frameSize bool AudioPortCapability::hardwareMode ``` -**描述:** +**描述:** -是否支持设备绑定处理。 +是否支持设备绑定处理 ### id @@ -762,9 +764,9 @@ bool AudioPortCapability::hardwareMode unsigned int AudioSceneDescriptor::SceneDesc::id ``` -**描述:** +**描述:** -音频场景的ID。 +音频场景的ID ### interleaved @@ -774,9 +776,9 @@ unsigned int AudioSceneDescriptor::SceneDesc::id bool AudioSampleAttributes::interleaved ``` -**描述:** +**描述:** -音频数据交织的标记。 +音频数据交织的标记 ### isBigEndian @@ -786,9 +788,9 @@ bool AudioSampleAttributes::interleaved bool AudioSampleAttributes::isBigEndian ``` -**描述:** +**描述:** -音频数据的大端标志。 +音频数据的大端标志 ### isShareable @@ -798,9 +800,9 @@ bool AudioSampleAttributes::isBigEndian int32_t AudioMmapBufferDescripter::isShareable ``` -**描述:** +**描述:** -mmap缓冲区是否可以在进程间共享。 +mmap缓冲区是否可以在进程间共享 ### isSignedData @@ -810,7 +812,7 @@ mmap缓冲区是否可以在进程间共享。 bool AudioSampleAttributes::isSignedData ``` -**描述:** +**描述:** 音频数据的有符号或无符号标志 @@ -822,7 +824,7 @@ bool AudioSampleAttributes::isSignedData enum AudioPortPassthroughMode AudioSubPortCapability::mask ``` -**描述:** +**描述:** 数据透传模式,详情参考[AudioPortPassthroughMode](#audioportpassthroughmode)。 @@ -834,9 +836,9 @@ enum AudioPortPassthroughMode AudioSubPortCapability::mask void* AudioMmapBufferDescripter::memoryAddress ``` -**描述:** +**描述:** -指向mmap缓冲区的指针。 +指向mmap缓冲区的指针 ### memoryFd @@ -846,9 +848,21 @@ void* AudioMmapBufferDescripter::memoryAddress int32_t AudioMmapBufferDescripter::memoryFd ``` -**描述:** +**描述:** + +mmap缓冲区的文件描述符 + + +### mix + + +``` +struct AudioMixExtInfo AudioRouteNode::ext::mix +``` + +**描述:** -mmap缓冲区的文件描述符。 +音轨特定信息。 ### moduleId [1/2] @@ -858,9 +872,9 @@ mmap缓冲区的文件描述符。 int32_t AudioDevExtInfo::moduleId ``` -**描述:** +**描述:** -音频流绑定的模块ID。 +音频流绑定的模块ID ### moduleId [2/2] @@ -870,9 +884,9 @@ int32_t AudioDevExtInfo::moduleId int32_t AudioMixExtInfo::moduleId ``` -**描述:** +**描述:** -流所属模块标识符。 +流所属模块标识符 ### period @@ -882,9 +896,9 @@ int32_t AudioMixExtInfo::moduleId uint32_t AudioSampleAttributes::period ``` -**描述:** +**描述:** -音频采样周期。 +音频采样周期 ### pins @@ -894,7 +908,7 @@ uint32_t AudioSampleAttributes::period enum AudioPortPin AudioDeviceDescriptor::pins ``` -**描述:** +**描述:** 音频端口上的PIN脚(输出、输入),详情参考[AudioPortPin](#audioportpin)。 @@ -906,9 +920,9 @@ enum AudioPortPin AudioDeviceDescriptor::pins unsigned int AudioPort::portId ``` -**描述:** +**描述:** -音频端口的ID。 +音频端口的ID ### portId [2/4] @@ -918,9 +932,9 @@ unsigned int AudioPort::portId unsigned int AudioDeviceDescriptor::portId ``` -**描述:** +**描述:** -音频端口ID。 +音频端口ID ### portId [3/4] @@ -930,9 +944,9 @@ unsigned int AudioDeviceDescriptor::portId unsigned int AudioSubPortCapability::portId ``` -**描述:** +**描述:** -子端口ID。 +子端口ID ### portId [4/4] @@ -942,9 +956,9 @@ unsigned int AudioSubPortCapability::portId int32_t AudioRouteNode::portId ``` -**描述:** +**描述:** -音频端口ID。 +音频端口ID ### portName @@ -954,9 +968,9 @@ int32_t AudioRouteNode::portId const char* AudioPort::portName ``` -**描述:** +**描述:** -音频端口的名称。 +音频端口的名称 ### portNum @@ -966,9 +980,9 @@ const char* AudioPort::portName unsigned int AudioAdapterDescriptor::portNum ``` -**描述:** +**描述:** -一个音频适配器支持的端口数目。 +一个音频适配器支持的端口数目 ### ports @@ -978,9 +992,9 @@ unsigned int AudioAdapterDescriptor::portNum struct AudioPort* AudioAdapterDescriptor::ports ``` -**描述:** +**描述:** -一个音频适配器支持的端口列表。 +一个音频适配器支持的端口列表 ### role @@ -990,9 +1004,9 @@ struct AudioPort* AudioAdapterDescriptor::ports enum AudioPortRole AudioRouteNode::role ``` -**描述:** +**描述:** -指定端口角色为sink或source。 +指定端口角色为sink或source ### sampleRate @@ -1002,9 +1016,9 @@ enum AudioPortRole AudioRouteNode::role unsigned int AudioSampleAttributes::sampleRate ``` -**描述:** +**描述:** -音频采样频率。 +音频采样频率 ### sampleRateMasks @@ -1014,9 +1028,9 @@ unsigned int AudioSampleAttributes::sampleRate unsigned int AudioPortCapability::sampleRateMasks ``` -**描述:** +**描述:** -支持的音频采样频率(8k、16k、32k、48k)。 +支持的音频采样频率(8k、16k、32k、48k) ### scene @@ -1026,9 +1040,21 @@ unsigned int AudioPortCapability::sampleRateMasks union AudioSceneDescriptor::SceneDesc AudioSceneDescriptor::scene ``` -**描述:** +**描述:** + +音频场景的名称 + + +### session + + +``` +struct AudioSessionExtInfo AudioRouteNode::ext::session +``` + +**描述:** -音频场景的名称。 +会话特定信息。 ### sessionType @@ -1038,9 +1064,9 @@ union AudioSceneDescriptor::SceneDesc AudioSceneDescriptor::scene enum AudioSessionType AudioSessionExtInfo::sessionType ``` -**描述:** +**描述:** -音频会话类型。 +音频会话类型 ### silenceThreshold @@ -1050,9 +1076,9 @@ enum AudioSessionType AudioSessionExtInfo::sessionType uint32_t AudioSampleAttributes::silenceThreshold ``` -**描述:** +**描述:** -音频捕获缓冲区阈值。 +音频捕获缓冲区阈值 ### sinks @@ -1062,9 +1088,9 @@ uint32_t AudioSampleAttributes::silenceThreshold const struct AudioRouteNode* AudioRoute::sinks ``` -**描述:** +**描述:** -接受端列表。 +接受端列表 ### sinksNum @@ -1074,9 +1100,9 @@ const struct AudioRouteNode* AudioRoute::sinks uint32_t AudioRoute::sinksNum ``` -**描述:** +**描述:** -接受端节点数量。 +接受端节点数量 ### sources @@ -1086,9 +1112,9 @@ uint32_t AudioRoute::sinksNum const struct AudioRouteNode* AudioRoute::sources ``` -**描述:** +**描述:** -发送端列表。 +发送端列表 ### sourcesNum @@ -1098,9 +1124,9 @@ const struct AudioRouteNode* AudioRoute::sources uint32_t AudioRoute::sourcesNum ``` -**描述:** +**描述:** -发送端节点数量。 +发送端节点数量 ### startThreshold @@ -1110,9 +1136,9 @@ uint32_t AudioRoute::sourcesNum uint32_t AudioSampleAttributes::startThreshold ``` -**描述:** +**描述:** -音频渲染开始阈值。 +音频渲染开始阈值 ### stopThreshold @@ -1122,9 +1148,9 @@ uint32_t AudioSampleAttributes::startThreshold uint32_t AudioSampleAttributes::stopThreshold ``` -**描述:** +**描述:** -音频渲染停止阈值。 +音频渲染停止阈值 ### streamId [1/2] @@ -1134,9 +1160,9 @@ uint32_t AudioSampleAttributes::stopThreshold int32_t AudioSampleAttributes::streamId ``` -**描述:** +**描述:** -渲染或捕获的音频标识符。 +渲染或捕获的音频标识符 ### streamId [2/2] @@ -1146,9 +1172,9 @@ int32_t AudioSampleAttributes::streamId int32_t AudioMixExtInfo::streamId ``` -**描述:** +**描述:** -由调用者传递的Render或Capture标识符。 +由调用者传递的Render或Capture标识符 ### subPorts @@ -1158,9 +1184,9 @@ int32_t AudioMixExtInfo::streamId struct AudioSubPortCapability* AudioPortCapability::subPorts ``` -**描述:** +**描述:** -支持的子端口列表。 +支持的子端口列表 ### subPortsNum @@ -1170,9 +1196,9 @@ struct AudioSubPortCapability* AudioPortCapability::subPorts unsigned int AudioPortCapability::subPortsNum ``` -**描述:** +**描述:** -支持的子端口数目(仅用于输出设备)。 +支持的子端口数目(仅用于输出设备) ### supportSampleFormatNum @@ -1182,9 +1208,9 @@ unsigned int AudioPortCapability::subPortsNum uint32_t AudioPortCapability::supportSampleFormatNum ``` -**描述:** +**描述:** -支持的音频样本格式数量。 +支持的音频样本格式数量 ### supportSampleFormats @@ -1194,9 +1220,9 @@ uint32_t AudioPortCapability::supportSampleFormatNum enum AudioSampleFormat* AudioPortCapability::supportSampleFormats ``` -**描述:** +**描述:** -支持的音频样本格式,详请参考[AudioSampleFormat](_codec.md#audiosampleformat)。 +支持的音频样本格式,详请参考[AudioSampleFormat](#audiosampleformat)。 ### totalBufferFrames @@ -1206,7 +1232,7 @@ enum AudioSampleFormat* AudioPortCapability::supportSampleFormats int32_t AudioMmapBufferDescripter::totalBufferFrames ``` -**描述:** +**描述:** 缓冲区总大小,单位:帧。 @@ -1218,7 +1244,7 @@ int32_t AudioMmapBufferDescripter::totalBufferFrames int32_t AudioMmapBufferDescripter::transferFrameSize ``` -**描述:** +**描述:** 传输大小,单位:帧。 @@ -1230,7 +1256,7 @@ int32_t AudioMmapBufferDescripter::transferFrameSize int64_t AudioTimeStamp::tvNSec ``` -**描述:** +**描述:** tvNSec时间,单位:纳秒。 @@ -1242,7 +1268,7 @@ tvNSec时间,单位:纳秒。 int64_t AudioTimeStamp::tvSec ``` -**描述:** +**描述:** tvSec时间,单位:秒。 @@ -1254,7 +1280,7 @@ tvSec时间,单位:秒。 enum AudioCategory AudioSampleAttributes::type ``` -**描述:** +**描述:** 音频类型,详情参考[AudioCategory](#audiocategory)。 @@ -1266,7 +1292,7 @@ enum AudioCategory AudioSampleAttributes::type enum AudioPortPin AudioDevExtInfo::type ``` -**描述:** +**描述:** 音频端口上的PIN脚(输出、输入),详情参考[AudioPortPin](#audioportpin)。 @@ -1278,42 +1304,6 @@ enum AudioPortPin AudioDevExtInfo::type enum AudioPortType AudioRouteNode::type ``` -**描述:** - -指定端口类型。 - - -### device - - -``` - struct AudioDevExtInfo AudioRouteNode::device -``` - -**描述:** - -设备特定信息。 - - -### mix - - -``` - struct AudioMixExtInfo AudioRouteNode::mix -``` - -**描述:** +**描述:** -音轨特定信息。 - - -### session - - -``` - struct AudioSessionExtInfo AudioRouteNode::session -``` - -**描述:** - -会话特定信息。 +指定端口类型为device, mix等。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md index c4ddc25428e9e04cacde47a42b131bec1d9e60cf..21b6213df6b8046579946e9992314dadd360fa22 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md @@ -3,35 +3,21 @@ ## **概述** -**所属模块:** +AudioAdapter音频适配器接口。 -[Audio](_audio.md) - - -## **汇总** +提供音频适配器(声卡)对外支持的驱动能力,包括初始化端口、创建Render、创建Capture、获取端口能力集等。 +**Since:** -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| ( [InitAllPorts](#initallports) )(struct AudioAdapter \*adapter) | 初始化一个音频适配器所有的端口驱动 [更多...](#initallports) | -| ( [CreateRender](#createrender) )(struct AudioAdapter \*adapter, const struct [AudioDeviceDescriptor](_audio_device_descriptor.md) \*desc, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs, struct [AudioRender](_audio_render.md) \*\*render) | 创建一个音频播放(render)接口的对象 [更多...](#createrender) | -| ( [DestroyRender](#destroyrender) )(struct AudioAdapter \*adapter, struct [AudioRender](_audio_render.md) \*render) | 销毁一个音频播放(render)接口的对象 [更多...](#destroyrender) | -| ( [CreateCapture](#createcapture) )(struct AudioAdapter \*adapter, const struct [AudioDeviceDescriptor](_audio_device_descriptor.md) \*desc, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs, struct [AudioCapture](_audio_capture.md) \*\*capture) | 创建一个音频录音(capture)接口的对象 [更多...](#createcapture) | -| ( [DestroyCapture](#destroycapture) )(struct AudioAdapter \*adapter, struct [AudioCapture](_audio_capture.md) \*capture) | 销毁一个音频录音(capture)接口的对象 [更多...](#destroycapture) | -| ( [GetPortCapability](#getportcapability) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, struct [AudioPortCapability](_audio_port_capability.md) \*capability) | 获取一个音频适配器的端口驱动的能力集 [更多...](#getportcapability) | -| ( [SetPassthroughMode](#setpassthroughmode) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, enum [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) mode) | 设置音频端口驱动的数据透传模式 [更多...](#setpassthroughmode) | -| ( [GetPassthroughMode](#getpassthroughmode) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, enum [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) \*mode) | 获取音频端口驱动的数据透传模式 [更多...](#getpassthroughmode) | -| ( [UpdateAudioRoute](#updateaudioroute) )(struct AudioAdapter \*adapter, const struct [AudioRoute](_audio_route.md) \*route, int32_t \*routeHandle) | 更新一个或多个发送端和接受端之间的路由 [更多...](#updateaudioroute) | -| ( [ReleaseAudioRoute](#releaseaudioroute) )(struct  \*adapter, int32_t routeHandle) | 释放一个音频路由. [更多...](#releaseaudioroute) | +1.0 +**Version:** -## **详细描述** +1.0 -AudioAdapter音频适配器接口 +**相关模块:** -提供音频适配器(声卡)对外支持的驱动能力,包括初始化端口、创建render、创建capture、获取端口能力集等 +[Audio](_audio.md) **参见:** @@ -39,13 +25,24 @@ AudioAdapter音频适配器接口 [AudioCapture](_audio_capture.md) -**Since:** -1.0 +## **汇总** -**Version:** -1.0 +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| ([InitAllPorts](#initallports))(struct AudioAdapter \*adapter) | 初始化一个音频适配器所有的端口驱动 | +| ([CreateRender](#createrender) )(struct AudioAdapter \*adapter, const struct AudioDeviceDescriptor \*desc, const struct AudioSampleAttributes \*attrs, struct AudioRender \*\*render) | 创建一个音频播放(Render)接口的对象 | +| ([DestroyRender](#destroyrender) )(struct AudioAdapter \*adapter, struct AudioRender \*render) | 销毁一个音频播放(Render)接口的对象 | +| ([CreateCapture](#createcapture))(struct AudioAdapter \*adapter, const struct AudioDeviceDescriptor \*desc, const struct AudioSampleAttributes \*attrs, struct AudioCapture \*\*capture) | 创建一个音频录音(Capture)接口的对象 | +| ([DestroyCapture](#destroycapture))(struct AudioAdapter \*adapter, struct AudioCapture \*capture) | 销毁一个音频录音(Capture)接口的对象 | +| ([GetPortCapability](#getportcapability) )(struct AudioAdapter \*adapter, struct AudioPort \*port, struct AudioPortCapability \*capability) | 获取一个音频适配器的端口驱动的能力集 | +| ([SetPassthroughMode](#setpassthroughmode) )(struct AudioAdapter \*adapter, struct AudioPort \*port, enum AudioPortPassthroughMode mode) | 设置音频端口驱动的数据透传模式 | +| ([GetPassthroughMode](#getpassthroughmode))(struct AudioAdapter \*adapter, struct AudioPort \*port, enum AudioPortPassthroughMode \*mode) | 获取音频端口驱动的数据透传模式 | +| ([UpdateAudioRoute](#updateaudioroute))(struct AudioAdapter \*adapter, const struct AudioRoute \*route, int32_t \*routeHandle) | 更新一个或多个发送端和接受端之间的路由 | +| ([ReleaseAudioRoute](#releaseaudioroute))(struct AudioAdapter \*adapter, int32_t routeHandle) | 释放一个音频路由 | ## **类成员变量说明** @@ -60,9 +57,9 @@ int32_t(* AudioAdapter::CreateCapture) (struct AudioAdapter *adapter, const stru **描述:** -创建一个音频录音(capture)接口的对象 +创建一个音频录音(Capture)接口的对象。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -71,11 +68,11 @@ int32_t(* AudioAdapter::CreateCapture) (struct AudioAdapter *adapter, const stru | attrs | 指向要打开的音频采样属性的指针 | | capture | 指向AudioCapture对象的二级指针 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetPortCapability](#getportcapability) @@ -91,9 +88,9 @@ int32_t(* AudioAdapter::CreateRender) (struct AudioAdapter *adapter, const struc **描述:** -创建一个音频播放(render)接口的对象 +创建一个音频播放(Render)接口的对象。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -102,11 +99,11 @@ int32_t(* AudioAdapter::CreateRender) (struct AudioAdapter *adapter, const struc | attrs | 待打开的音频采样属性 | | render | 获取的音频播放接口的对象实例保存到render中 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetPortCapability](#getportcapability) @@ -122,9 +119,9 @@ int32_t(* AudioAdapter::DestroyCapture) (struct AudioAdapter *adapter, struct Au **描述:** -销毁一个音频录音(capture)接口的对象 +销毁一个音频录音(Capture)接口的对象。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -133,13 +130,13 @@ int32_t(* AudioAdapter::DestroyCapture) (struct AudioAdapter *adapter, struct Au **注意:** -在音频录音过程中,不能销毁该接口对象 +在音频录音过程中,不能销毁该接口对象。 -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [CreateCapture](#createcapture) @@ -153,9 +150,9 @@ int32_t(* AudioAdapter::DestroyRender) (struct AudioAdapter *adapter, struct Aud **描述:** -销毁一个音频播放(render)接口的对象 +销毁一个音频播放(Render)接口的对象。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -166,11 +163,11 @@ int32_t(* AudioAdapter::DestroyRender) (struct AudioAdapter *adapter, struct Aud 在音频播放过程中,不能销毁该接口对象 -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [CreateRender](#createrender) @@ -184,9 +181,9 @@ int(* AudioAdapter::GetPassthroughMode) (struct AudioAdapter *adapter, struct Au **描述:** -获取音频端口驱动的数据透传模式 +获取音频端口驱动的数据透传模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -194,11 +191,11 @@ int(* AudioAdapter::GetPassthroughMode) (struct AudioAdapter *adapter, struct Au | port | 待获取的端口 | | mode | 获取的传输模式保存到mode中 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SetPassthroughMode](#setpassthroughmode) @@ -212,9 +209,9 @@ int(* AudioAdapter::GetPortCapability) (struct AudioAdapter *adapter, struct Aud **描述:** -获取一个音频适配器的端口驱动的能力集 +获取一个音频适配器的端口驱动的能力集。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -222,9 +219,9 @@ int(* AudioAdapter::GetPortCapability) (struct AudioAdapter *adapter, struct Aud | port | 待获取的端口 | | capability | 获取的端口能力保存到capability中 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### InitAllPorts @@ -236,19 +233,23 @@ int(* AudioAdapter::InitAllPorts) (struct AudioAdapter *adapter) **描述:** -初始化一个音频适配器所有的端口驱动 +初始化一个音频适配器所有的端口驱动。 -在音频服务中,调用其他驱动接口前需要首先调用该接口检查端口是否已经初始化完成,如果端口驱动初始化完成,则函数返回值0, 否则返回负值,如果端口没有初始化完成,则需要等待一段时间(例如100ms)后重新进行检查,直到端口初始化完成后再继续操作 +在音频服务中,调用其他驱动接口前需要首先调用该接口检查端口是否已经初始化完成: -**参数:** +- 如果端口驱动初始化完成,则函数返回值0, 否则返回负值。 + +- 如果端口没有初始化完成,则需要等待一段时间(例如100ms)后重新进行检查,直到端口初始化完成后再继续操作。 + +**参数:** | 名称 | 描述 | | -------- | -------- | | adapter | 待操作的音频适配器对象 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### ReleaseAudioRoute @@ -260,18 +261,18 @@ int32_t(* AudioAdapter::ReleaseAudioRoute) (struct AudioAdapter *adapter, int32_ **描述:** -释放一个音频路由. +释放一个音频路由。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | adapter | 待操作的音频适配器对象 | -| routeHandle | 待释放的路由句柄. | +| routeHandle | 待释放的路由句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### SetPassthroughMode @@ -283,9 +284,9 @@ int(* AudioAdapter::SetPassthroughMode) (struct AudioAdapter *adapter, struct Au **描述:** -设置音频端口驱动的数据透传模式 +设置音频端口驱动的数据透传模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -293,11 +294,11 @@ int(* AudioAdapter::SetPassthroughMode) (struct AudioAdapter *adapter, struct Au | port | 待设置的端口 | | mode | 待设置的传输模式 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetPassthroughMode](#getpassthroughmode) @@ -311,9 +312,9 @@ int32_t(* AudioAdapter::UpdateAudioRoute) (struct AudioAdapter *adapter, const s **描述:** -更新一个或多个发送端和接受端之间的路由 +更新一个或多个发送端和接受端之间的路由。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -321,6 +322,6 @@ int32_t(* AudioAdapter::UpdateAudioRoute) (struct AudioAdapter *adapter, const s | route | 路由信息 | | routeHandle | 生成的路由句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md index 37968692e35f2e2db9256d19583836daad3789e0..93f007349acdeaafcd080489f1cb530cc84da07c 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md @@ -3,7 +3,11 @@ ## **概述** -**所属模块:** +音频适配器描述符。 + +一个音频适配器(adapter)是一个声卡的端口驱动集合,包含输出端口、输入端口, 其中一个端口对应着多个PIN脚,一个PIN脚对应着一个实体的器件(例如喇叭、有线耳机)。 + +**相关模块:** [Audio](_audio.md) @@ -13,13 +17,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [adapterName](_audio.md#adaptername) | 音频适配器的名称。 | -| [portNum](_audio.md#portnum) | 一个音频适配器支持的端口数目。 | -| [ports](_audio.md#ports) | 一个音频适配器支持的端口列表。 | - - -## **详细描述** - -音频适配器描述符。 +| [adapterName](_audio.md#adaptername) | 音频适配器的名称 | +| [portNum](_audio.md#portnum) | 一个音频适配器支持的端口数目 | +| [ports](_audio.md#ports) | 一个音频适配器支持的端口列表 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md b/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md index 668a797efccc85c7f98728f8bef7a6569a17589c..32fb2917b206ae9297f47d920e61a9c1cac27323 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md @@ -3,333 +3,328 @@ ## **概述** -**所属模块:** +AudioAttribute音频属性接口。 -[Audio](_audio.md) - - -## **汇总** +提供音频播放(Render)或录音(Capture)需要的公共属性驱动能力,包括获取帧(frame)信息、设置采样属性等。 +**Since:** -### Public 属性 +1.0 -| Public 属性 | 描述 | -| -------- | -------- | -| ( [GetFrameSize](#getframesize) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*size) | 获取音频帧(frame)的大小 [更多...](#getframesize) | -| ( [GetFrameCount](#getframecount) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*count) | 获取音频buffer中的音频帧数 [更多...](#getframecount) | -| ( [SetSampleAttributes](#setsampleattributes) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs) | 设置音频采样的属性参数 [更多...](#setsampleattributes) | -| ( [GetSampleAttributes](#getsampleattributes) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs) | 获取音频采样的属性参数 [更多...](#getsampleattributes) | -| ( [GetCurrentChannelId](#getcurrentchannelid) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint32_t \*channelId) | 获取音频的数据通道ID [更多...](#getcurrentchannelid) | -| ( [SetExtraParams](#setextraparams) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const char \*keyValueList) | 设置音频拓展参数 [更多...](#setextraparams) | -| ( [GetExtraParams](#getextraparams) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, char \*keyValueList) | 获取音频拓展参数 [更多...](#getextraparams) | -| ( [ReqMmapBuffer](#reqmmapbuffer) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, int32_t reqSize, struct [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) \*desc) | 请求mmap缓冲区 [更多...](#reqmmapbuffer) | -| ( [GetMmapPosition](#getmmapposition) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获取当前mmap的读/写位置 [更多...](#getmmapposition) | -| ( [AddAudioEffect](#addaudioeffect) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*effectid) |添加音频效果算法实例 [更多...](#addaudioeffect) | -| ( [RemoveAudioEffect](#removeaudioeffect) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t effectid) |移除音频效果算法实例 [更多...](#removeaudioeffect) | -| ( [GetFrameBufferSize](#getframebuffersize) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*effectid) |获取播放或录音的缓冲区大小 [更多...](#getframebuffersize) | +**Version:** +1.0 -## **详细描述** +**相关模块:** -AudioAttribute音频属性接口 +[Audio](_audio.md) -提供音频播放(render)或录音(capture)需要的公共属性驱动能力,包括获取帧(frame)信息、设置采样属性等。 -**Since:** +## **汇总** -1.0 -**Version:** +### Public 属性 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| ([GetFrameSize](#getframesize))(AudioHandle handle, uint64_t \*size) | 获取音频帧(frame)的大小 | +| ([GetFrameCount](#getframecount))(AudioHandle handle, uint64_t \*count) | 获取音频buffer中的音频帧数 | +| ([SetSampleAttributes](#setsampleattributes))(AudioHandle handle, const struct AudioSampleAttributes \*attrs) | 设置音频采样的属性参数 | +| ([GetSampleAttributes](#getsampleattributes))(AudioHandle handle, struct AudioSampleAttributes \*attrs) | 获取音频采样的属性参数 | +| ([GetCurrentChannelId](#getcurrentchannelid))(AudioHandle handle, uint32_t \*channelId) | 获取音频的数据通道ID | +| ([SetExtraParams](#setextraparams))(AudioHandle handle, const char \*keyValueList) | 设置音频拓展参数 | +| ([GetExtraParams](#getextraparams))(AudioHandle handle, char \*keyValueList) | 获取音频拓展参数 | +| ([ReqMmapBuffer](#reqmmapbuffer))(AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescripter \*desc) | 请求Mmap缓冲区 | +| ([GetMmapPosition](#getmmapposition))(AudioHandle handle, uint64_t \*frames, struct AudioTimeStamp \*time) | 获取当前Mmap的读/写位置 | +| ([AddAudioEffect](#addaudioeffect))(AudioHandle handle, uint64_t effectid) | 添加音频效果算法实例 | +| ([RemoveAudioEffect](#removeaudioeffect))(AudioHandle handle, uint64_t effectid) | 移除音频效果算法实例 | +| ([GetFrameBufferSize](#getframebuffersize))(AudioHandle handle, uint64_t \*bufferSize) | 获取播放或录音的缓冲区大小 | ## **类成员变量说明** -### GetCurrentChannelId - +### AddAudioEffect + ``` -int32_t(* AudioAttribute::GetCurrentChannelId) (AudioHandle handle, uint32_t *channelId) +int32_t (*AudioAttribute::AddAudioEffect)(AudioHandle handle, uint64_t effectid) ``` **描述:** -获取音频的数据通道ID +添加音频效果算法实例。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| channelId | 获取的通道ID保存到channelId中 | +| handle | 输入参数,待操作的音频句柄。 | +| effectid | 输入参数,待添加的音频效果算法实例ID。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetExtraParams - +### GetCurrentChannelId + ``` -int32_t(* AudioAttribute::GetExtraParams) (AudioHandle handle, char *keyValueList) +int32_t(* AudioAttribute::GetCurrentChannelId) (AudioHandle handle, uint32_t *channelId) ``` **描述:** -获取音频拓展参数。 +获取音频的数据通道ID。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| keyValueList | 拓展参数键值对字符串列表,格式为key=value,多个键值对通过分号分割 | +| handle | 输入参数,待操作的音频句柄。 | +| channelId | 输出参数,获取的通道ID保存到channelId中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetFrameCount - +### GetExtraParams + ``` -int32_t(* AudioAttribute::GetFrameCount) (AudioHandle handle, uint64_t *count) +int32_t(* AudioAttribute::GetExtraParams) (AudioHandle handle, char *keyValueList) ``` **描述:** -获取音频buffer中的音频帧数。 +获取音频拓展参数。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| count | 一个音频buffer中包含的音频帧数,获取后保存到count中 | +| handle | 输入参数,待操作的音频句柄。 | +| keyValueList | 输出参数,拓展参数键值对字符串列表,格式为key=value,多个键值对通过分号分割。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetFrameSize - +### GetFrameBufferSize + ``` -int32_t(* AudioAttribute::GetFrameSize) (AudioHandle handle, uint64_t *size) +int32_t (*AudioAttribute::GetFrameBufferSize)(AudioHandle handle, uint64_t *bufferSize) ``` **描述:** -获取音频帧(frame)的大小 - -获取一帧音频数据的长度(字节数) +获取播放或录音的缓冲区大小。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| size | 获取的音频帧大小(字节数)保存到size中 | +| handle | 输入参数,待操作的音频句柄。 | +| bufferSize | 输出参数,获取的缓冲区大小保存到bufferSize中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetMmapPosition - +### GetFrameCount + ``` -int32_t(* AudioAttribute::GetMmapPosition) (AudioHandle handle, uint64_t *frames, struct AudioTimeStamp *time) +int32_t(* AudioAttribute::GetFrameCount) (AudioHandle handle, uint64_t *count) ``` **描述:** -获取当前mmap的读/写位置 +获取音频buffer中的音频帧数。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| frames | 获取的音频帧计数保存到frames中 | -| time | 获取的关联时间戳保存到time中 | +| handle | 输入参数,待操作的音频句柄。 | +| count | 输出参数,一个音频buffer中包含的音频帧数,获取后保存到count中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetSampleAttributes - +### GetFrameSize + ``` -int32_t(* AudioAttribute::GetSampleAttributes) (AudioHandle handle, struct AudioSampleAttributes *attrs) +int32_t(* AudioAttribute::GetFrameSize) (AudioHandle handle, uint64_t *size) ``` **描述:** -获取音频采样的属性参数。 +获取音频帧(frame)的大小,即一帧音频数据的长度(字节数)。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| attrs | 获取的音频采样属性(例如采样频率、采样精度、通道)保存到attrs中 | +| handle | 输入参数,待操作的音频句柄。 | +| size | 输出参数,获取的音频帧大小(字节数)保存到size中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -**参见:** - -[SetSampleAttributes](#setsampleattributes) - - -### ReqMmapBuffer +### GetMmapPosition + ``` -int32_t(* AudioAttribute::ReqMmapBuffer) (AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescripter *desc) +int32_t(* AudioAttribute::GetMmapPosition) (AudioHandle handle, uint64_t *frames, struct AudioTimeStamp *time) ``` **描述:** -请求mmap缓冲区 +获取当前Mmap的读/写位置。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| reqSize | 请求缓冲区的大小 | -| desc | 缓冲区描述符 | +| handle | 输入参数,待操作的音频句柄。 | +| frames | 输出参数,获取的音频帧计数保存到frames中。 | +| time | 输出参数,获取的关联时间戳保存到time中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### SetExtraParams - +### GetSampleAttributes + ``` -int32_t(* AudioAttribute::SetExtraParams) (AudioHandle handle, const char *keyValueList) +int32_t(* AudioAttribute::GetSampleAttributes) (AudioHandle handle, struct AudioSampleAttributes *attrs) ``` **描述:** -设置音频拓展参数。 +获取音频采样的属性参数。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| keyValueList | 拓展参数键值对字符串列表,格式为key=value,多个键值对通过分号分割 | +| handle | 输入参数,待操作的音频句柄。 | +| attrs | 输出参数,获取的音频采样属性(例如采样频率、采样精度、通道)保存到attrs中。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 +**参见:** + +[GetSampleAttributes](#getsampleattributes) -### SetSampleAttributes +### RemoveAudioEffect + ``` -int32_t(* AudioAttribute::SetSampleAttributes) (AudioHandle handle, const struct AudioSampleAttributes *attrs) +int32_t (*AudioAttribute::RemoveAudioEffect)(AudioHandle handle, uint64_t effectid) ``` **描述:** -设置音频采样的属性参数。 +移除音频效果算法实例。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| attrs | 待设置的音频采样属性,例如采样频率、采样精度、通道 | +| handle | 输入参数,待操作的音频句柄。 | +| effectid | 输入参数,待移除的音频效果算法实例ID。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -**参见:** - -[GetSampleAttributes](#getsampleattributes) - - -### AddAudioEffect +### ReqMmapBuffer + ``` -int32_t (* AudioAttribute::AddAudioEffect)(AudioHandle handle, uint64_t effectid) +int32_t(* AudioAttribute::ReqMmapBuffer) (AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescripter *desc) ``` **描述:** -添加音频效果算法实例。 +请求Mmap缓冲区。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| effectid | 待添加的音频效果算法实例ID | +| handle | 输入参数,待操作的音频句柄。 | +| reqSize | 输入参数,请求缓冲区的大小。 | +| desc | 输出参数,缓冲区描述符。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### RemoveAudioEffect - +### SetExtraParams + ``` -int32_t (* AudioAttribute::RemoveAudioEffect)(AudioHandle handle, uint64_t effectid) +int32_t(* AudioAttribute::SetExtraParams) (AudioHandle handle, const char *keyValueList) ``` **描述:** -移除音频效果算法实例。 +设置音频拓展参数。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| effectid | 待移除的音频效果算法实例ID | +| handle | 输入参数,待操作的音频句柄。 | +| keyValueList | 输入参数,拓展参数键值对字符串列表,格式为key=value,多个键值对通过分号分割。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 -### GetFrameBufferSize - +### SetSampleAttributes + ``` -int32_t (* AudioAttribute::GetFrameBufferSize)(AudioHandle handle, uint64_t *bufferSize) +int32_t(* AudioAttribute::SetSampleAttributes) (AudioHandle handle, const struct AudioSampleAttributes *attrs) ``` **描述:** -获取播放或录音的缓冲区大小。 +设置音频采样的属性参数。 -**参数:** +**参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| bufferSize | 获取的缓冲区大小保存到bufferSize中 | +| handle | 输入参数,待操作的音频句柄。 | +| attrs | 输入参数,待设置的音频采样属性,例如采样频率、采样精度、通道。 | -**返回:** +**返回:** 成功返回值0,失败返回负值。 + +**参见:** + +[GetSampleAttributes](#getsampleattributes) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md b/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md index 0cc96d36c54f5325f93f26beb4f2e8ec7daffd6f..c3cecd48016cf8819856ae7cf1eccf85fe778c86 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +AudioCapture录音接口。 + +**相关模块:** [Audio](_audio.md) @@ -13,19 +15,14 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| control | 音频控制能力接口,详情参考[AudioControl](_audio_control.md) | -| attr | 音频属性能力接口,详情参考[AudioAttribute](_audio_attribute.md) | -| scene | 音频场景能力接口,详情参考[AudioScene](_audio_scene.md) | -| volume | 音频音量能力接口,详情参考[AudioVolume](_audio_volume.md) | -| ( [CaptureFrame](#captureframe) )(struct AudioCapture \*capture, void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 从音频驱动中录制(capture)一帧输入数据(录音,音频上行数据) [更多...](#captureframe) | -| ( [GetCapturePosition](#getcaptureposition) )(struct AudioCapture \*capture, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获取音频输入帧数的上一次计数 [更多...](#getcaptureposition) | - - -## **详细描述** - -AudioCapture音频录音接口。 +| control | 音频控制能力接口,详情参考[AudioControl](_audio_control.md)。 | +| attr | 音频属性能力接口,详情参考[AudioAttribute](_audio_attribute.md)。 | +| scene | 音频场景能力接口,详情参考[AudioScene](_audio_scene.md)。 | +| volume | 音频音量能力接口,详情参考[AudioVolume](_audio_volume.md)。 | +| ([CaptureFrame](#captureframe))(struct AudioCapture \*capture, void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 从音频驱动中录制(Capture)一帧输入数据(录音,音频上行数据)。 | +| ([GetCapturePosition](#getcaptureposition))(struct AudioCapture \*capture, uint64_t \*frames, struct AudioTimeStamp \*time) | 获取音频输入帧数的上一次计数。 | ## **类成员变量说明** @@ -40,20 +37,20 @@ int32_t(* AudioCapture::CaptureFrame) (struct AudioCapture *capture, void *frame **描述:** -从音频驱动中录制(capture)一帧输入数据(录音,音频上行数据) +从音频驱动中录制(Capture)一帧输入数据(录音,音频上行数据)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| capture | 待操作的音频录音接口对象 | -| frame | 待存放输入数据的音频frame | -| requestBytes | 待存放输入数据的音频frame大小(字节数) | -| replyBytes | 实际读取到的音频数据长度(字节数),获取后保存到replyBytes中 | +| capture | 输入参数,待操作的音频录音接口对象。 | +| frame | 输入参数,待存放输入数据的音频frame。 | +| requestBytes | 输入参数,待存放输入数据的音频frame大小(字节数)。 | +| replyBytes | 输出参数,实际读取到的音频数据长度(字节数),获取后保存到replyBytes中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### GetCapturePosition @@ -65,20 +62,20 @@ int32_t(* AudioCapture::GetCapturePosition) (struct AudioCapture *capture, uint6 **描述:** -获取音频输入帧数的上一次计数 +获取音频输入帧数的上一次计数。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| capture | 待操作的音频录音接口对象 | -| frames | 获取的音频帧计数保存到frames中 | -| time | 获取的关联时间戳保存到time中 | +| capture | 输入参数,待操作的音频录音接口对象。| +| frames | 输出参数,获取的音频帧计数保存到frames中。 | +| time | 输出参数,获取的关联时间戳保存到time中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [CaptureFrame](#captureframe) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_control.md b/zh-cn/device-dev/reference/hdi-apis/_audio_control.md index 1d4d71c6d86d3874b823102ae0d71b296daa5794..368c9f34b2028cbd0a4b99d7abf6bb0ebe502fdc 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_control.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_control.md @@ -3,40 +3,37 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +AudioControl音频控制接口。 -## **汇总** +提供音频播放(Render)或录音(Capture)需要的公共控制驱动能力,包括Start、Stop、Pause、Resume、Flush等。 +**Since:** -### Public 属性 +1.0 - | Public 属性 | 描述 | -| -------- | -------- | -| ( [Start](#start) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 启动一个音频播放(render)或录音(capture)处理 [更多...](#start) | -| ( [Stop](#stop) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 停止一个音频播放(render)或录音(capture)处理 [更多...](#stop) | -| ( [Pause](#pause) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 暂停一个音频播放(render)或录音(capture)处理 [更多...](#pause) | -| ( [Resume](#resume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 恢复一个音频播放(render)或录音(capture)处理 [更多...](#resume) | -| ( [Flush](#flush) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 刷新音频缓冲区buffer中的数据 [更多...](#flush) | -| ( [TurnStandbyMode](#turnstandbymode) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 设置或去设置设备的待机模式 [更多...](#turnstandbymode) | -| ( [AudioDevDump](#audiodevdump) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, int32_t range, int32_t fd) | Dump音频设备信息 [更多...](#audiodevdump) | +**Version:** +1.0 -## **详细描述** +**相关模块:** -AudioControl音频控制接口。 +[Audio](_audio.md) -提供音频播放(render)或录音(capture)需要的公共控制驱动能力,包括Start、Stop、Pause、Resume、Flush等。 -**Since:** +## **汇总** -1.0 -**Version:** +### Public 属性 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| ([Start](#start))(AudioHandle handle) | 启动一个音频播放(Render)或录音(Capture)处理。 | +| ([Stop](#stop))(AudioHandle handle) | 停止一个音频播放(Render)或录音(Capture)处理。 | +| ([Pause](#pause))(AudioHandle handle) | 暂停一个音频播放(Render)或录音(Capture)处理。 | +| ([Resume](#resume))(AudioHandle handle) | 恢复一个音频播放(Render)或录音(Capture)处理。 | +| ([Flush](#flush))(AudioHandle handle) | 刷新音频缓冲区buffer中的数据。 | +| ([TurnStandbyMode](#turnstandbymode))(AudioHandle handle) | 设置或去设置设备的待机模式。 | +| ([AudioDevDump](#audiodevdump))(AudioHandle handle, int32_t range, int32_t fd) | Dump音频设备信息。 | ## **类成员变量说明** @@ -51,9 +48,9 @@ int32_t(* AudioControl::AudioDevDump) (AudioHandle handle, int32_t range, int32_ **描述:** -Dump音频设备信息 +Dump音频设备信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -61,9 +58,9 @@ Dump音频设备信息 | range | Dump信息范围,分为简要信息、全量信息 | | fd | 指定Dump目标文件 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### Flush @@ -75,17 +72,17 @@ int32_t(* AudioControl::Flush) (AudioHandle handle) **描述:** -刷新音频缓冲区buffer中的数据 +刷新音频缓冲区buffer中的数据。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### Pause @@ -97,19 +94,19 @@ int32_t(* AudioControl::Pause) (AudioHandle handle) **描述:** -暂停一个音频播放(render)或录音(capture)处理 +暂停一个音频播放(Render)或录音(Capture)处理。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [Resume](#resume) @@ -123,19 +120,19 @@ int32_t(* AudioControl::Resume) (AudioHandle handle) **描述:** -恢复一个音频播放(render)或录音(capture)处理 +恢复一个音频播放(Render)或录音(Capture)处理。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [Pause](#pause) @@ -149,19 +146,19 @@ int32_t(* AudioControl::Start) (AudioHandle handle) **描述:** -启动一个音频播放(render)或录音(capture)处理 +启动一个音频播放(Render)或录音(Capture)处理。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [Stop](#stop) @@ -175,19 +172,19 @@ int32_t(* AudioControl::Stop) (AudioHandle handle) **描述:** -停止一个音频播放(render)或录音(capture)处理 +停止一个音频播放(Render)或录音(Capture)处理。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [Start](#start) @@ -201,14 +198,14 @@ int32_t(* AudioControl::TurnStandbyMode) (AudioHandle handle) **描述:** -设置或去设置设备的待机模式 +设置或去设置设备的待机模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 待操作的音频句柄 | -**返回:** +**返回:** -设置设备待机模式成功返回值0,再次执行后去设置待机模式成功返回正值,失败返回负值 +设置设备待机模式成功返回值0,再次执行后去设置待机模式成功返回正值,失败返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md index 1a4a421f8463c9ce844d987f98c89b4cce8cffe9..d3f01acc1f1826b366fbfa92b6370b86ebc480fe 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频设备拓展信息。 + +**相关模块:** [Audio](_audio.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [moduleId](_audio.md#moduleid-12) | 音频流绑定的模块ID。 | -| [type](_audio.md#type-23) | 音频端口上的PIN脚(输出、输入),详情参考[AudioPortPin](_audio.md#audioportpin)。 | -| [desc](_audio.md#desc-55) | 地址描述。 | - - -## **详细描述** - -音频设备拓展信息。 +| [moduleId](_audio.md#moduleid-12) | 音频流绑定的模块ID | +| [type](_audio.md#type-23) | 音频端口上的PIN脚(输出、输入) | +| [desc](_audio.md#desc-55) | 地址描述 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md index 5e10acce99f5c951a1daf983a6b01e36fe84b3de..3046db7ba8f824722145bb83855dc5cc53d60a42 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频设备描述符 + +**相关模块:** [Audio](_audio.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [portId](_audio.md#portid-24) | 频端口ID。 | -| [pins](_audio.md#pins) | 音频端口上的PIN脚(输出、输入),详情参考[AudioPortPin](_audio.md#audioportpin)。 | -| [desc](_audio.md#desc-15) | 以字符串命名的音频设备。 | - - -## **详细描述** - -音频场景描述符。 +| [portId](_audio.md#portid-24) | 音频端口ID | +| [pins](_audio.md#pins) | 音频端口上的PIN脚(输出、输入) | +| [desc](_audio.md#desc-15) | 以字符串命名的音频设备 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md b/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md index e0fe9486e137112c5ec00cd05a7169c36039e256..c809c03c0b8835dcea26e5d18c48cf05d59f3211 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md @@ -3,41 +3,38 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - - -## **汇总** +AudioManager音频适配器管理接口。 +按照音频服务下发的音频适配器(声卡)描述符加载一个具体的音频适配器驱动程序。 -### Public 属性 +**Since:** - | Public 属性 | 描述 | -| -------- | -------- | -| ( [GetAllAdapters](#getalladapters) )(struct AudioAdapterManager \*manager, struct [AudioAdapterDescriptor](_audio_adapter_descriptor.md) \*\*descs, int \*size) | 获取音频驱动中支持的所有适配器的列表 [更多...](#getalladapters) | -| ( [LoadAdapter](#loadadapter) )(struct AudioAdapterManager \*manager, const struct [AudioAdapterDescriptor](_audio_adapter_descriptor.md) \*desc, struct [AudioAdapter](_audio_adapter.md) \*\*adapter) | 加载一个音频适配器(声卡)的驱动 [更多...](#loadadapter) | -| ( [UnloadAdapter](#unloadadapter) )(struct AudioAdapterManager \*manager, struct [AudioAdapter](_audio_adapter.md) \*adapter) | 卸载音频适配器(声卡)的驱动 [更多...](#unloadadapter) | -| ( [ReleaseAudioManagerObject](#releaseaudiomanagerobject) )(struct AudioManager \*object) | 释放音频管理接口对象 [更多...](#releaseaudiomanagerobject) | +1.0 +**Version:** -## **详细描述** +1.0 -AudioManager音频适配器管理接口 +**相关模块:** -按照音频服务下发的音频适配器(声卡)描述符加载一个具体的音频适配器驱动程序 +[Audio](_audio.md) -参见: +**参见:** [AudioAdapter](_audio_adapter.md) -**Since:** -1.0 +## **汇总** -**Version:** -1.0 +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| ([GetAllAdapters](#getalladapters))(struct AudioAdapterManager \*manager, struct AudioAdapterDescriptor \*\*descs, int \*size) | 获取音频驱动中支持的所有适配器的列表 | +| ([LoadAdapter](#loadadapter))(struct AudioAdapterManager \*manager, const struct AudioAdapterDescriptor \*desc, struct AudioAdapter \*\*adapter) | 加载一个音频适配器(声卡)的驱动 | +| ([UnloadAdapter](#unloadadapter))(struct AudioAdapterManager \*manager, struct AudioAdapter \*adapter) | 卸载音频适配器(声卡)的驱动 | +| ([ReleaseAudioManagerObject](#releaseaudiomanagerobject))(struct AudioManager \*object) | 释放音频管理接口对象 | ## **类成员变量说明** @@ -52,21 +49,21 @@ int(* AudioManager::GetAllAdapters) (struct AudioAdapterManager *manager, struct **描述:** -获取音频驱动中支持的所有适配器的列表 +获取音频驱动中支持的所有适配器的列表。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| manager | 待操作的音频管理接口对象 | -| descs | 获取到的音频适配器列表保存到descs中 | -| size | 获取到的音频适配器列表的长度保存到size中 | +| manager | 输入参数,待操作的音频管理接口对象。 | +| descs | 输出参数,获取到的音频适配器列表保存到descs中。 | +| size | 输出参数,获取到的音频适配器列表的长度保存到size中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [LoadAdapter](#loadadapter) @@ -80,23 +77,23 @@ int(* AudioManager::LoadAdapter) (struct AudioAdapterManager *manager, const str **描述:** -加载一个音频适配器(声卡)的驱动 +加载一个音频适配器(声卡)的驱动。 -加载一个具体的音频驱动,例如USB驱动,在具体实现中可能加载的是一个动态链接库(\*.so) +加载一个具体的音频驱动,例如USB驱动,在具体实现中可能加载的是一个动态链接库(\*.so)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| manager | 待操作的音频管理接口对象 | -| desc | 待加载的音频适配器描述符 | -| adapter | 获取的音频适配器接口的对象实例保存到adapter中 | +| manager | 输入参数,待操作的音频管理接口对象。 | +| desc | 输入参数,待加载的音频适配器描述符。 | +| adapter | 输出参数,获取的音频适配器接口的对象实例保存到adapter中。| -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetAllAdapters](#getalladapters) @@ -112,17 +109,17 @@ bool(* AudioManager::ReleaseAudioManagerObject) (struct AudioManager *object) **描述:** -释放音频管理接口对象 +释放音频管理接口对象。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| object | 待操作的音频管理接口对象 | +| object | 输入参数,待操作的音频管理接口对象。 | -**返回:** +**返回:** -成功返回true,失败返回false +成功返回true,失败返回false。 ### UnloadAdapter @@ -134,15 +131,15 @@ void(* AudioManager::UnloadAdapter) (struct AudioAdapterManager *manager, struct **描述:** -卸载音频适配器(声卡)的驱动 +卸载音频适配器(声卡)的驱动。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| manager | 待操作的音频管理接口对象 | -| adapter | 待卸载的音频适配器接口的对象 | +| manager | 输入参数,待操作的音频管理接口对象。 | +| adapter | 输入参数,待卸载的音频适配器接口的对象。 | -**参见:** +**参见:** [LoadAdapter](#loadadapter) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md index fcf31a50003dfd54672b80acc06b907f1f80295b..50032fae465492d88b676b63a14a54d8a5b3cb87 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音轨拓展信息。 + +**相关模块:** [Audio](_audio.md) @@ -13,12 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [moduleId](_audio.md#moduleid-22) | 流所属模块标识符。 | -| [streamId](_audio.md#streamid-22) | 由调用者传递的Render或Capture标识符。 | - - -## **详细描述** - -音轨拓展信息。 +| [moduleId](_audio.md#moduleid-22) | 流所属模块标识符 | +| [streamId](_audio.md#streamid-22) | 由调用者传递的Render或Capture标识符 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md b/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md index cd301a7d69f96715c46423c1ed984d7b59b17173..93470c6b005a438663e7efd1b8e6ec204701af20 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +Mmap缓冲区描述符。 + +**相关模块:** [Audio](_audio.md) @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [memoryAddress](_audio.md#memoryaddress) | 指向mmap缓冲区的指针。 | -| [memoryFd](_audio.md#memoryfd) | mmap缓冲区的文件描述符。 | -| [totalBufferFrames](_audio.md#totalbufferframes) | 缓冲区总大小,单位:帧。 | -| [transferFrameSize](_audio.md#transferframesize) | 传输大小,单位:帧。 | -| [isShareable](_audio.md#isshareable) | mmap缓冲区是否可以在进程间共享。 | - - -## **详细描述** - -mmap缓冲区描述符。 +| [memoryAddress](_audio.md#memoryaddress) | 指向Mmap缓冲区的指针 | +| [memoryFd](_audio.md#memoryfd) | Mmap缓冲区的文件描述符 | +| [totalBufferFrames](_audio.md#totalbufferframes) | 缓冲区总大小,单位:帧 | +| [transferFrameSize](_audio.md#transferframesize) | 传输大小,单位:帧 | +| [isShareable](_audio.md#isshareable) | Mmap缓冲区是否可以在进程间共享 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port.md index 5ad207379d352367e346ca39e607789e4d38207a..4cf79c86ea3854c602904c120e54a43e7abd1779 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_port.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_port.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频端口。 + +**相关模块:** [Audio](_audio.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [dir](_audio.md#dir) | 音频端口的类型,详情参考[AudioPortDirection](_audio.md#audioportdirection)。 | +| [dir](_audio.md#dir) | 音频端口的类型。 | | [portId](_audio.md#portid-14) | 音频端口的ID。 | | [portName](_audio.md#portname) | 音频端口的名称。 | - - -## **详细描述** - -音频端口。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md deleted file mode 100644 index 6545ac35c4833ef5e247a78a03361ce016574928..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md +++ /dev/null @@ -1,77 +0,0 @@ -# AudioPortCap - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [sampleFormats](#sampleformats) [[SAMPLE_FMT_NUM](_codec.md#ga9bda75c363e9bcff915cdd521dd7ba84)] | 支持的音频采样格式,详见[AudioSampleFormat](_codec.md#audiosampleformat)。 | -| [sampleRate](#samplerate) [[SAMPLE_RATE_NUM](_codec.md#ga0d905eaa05b4b6fcec76924eb795d7fe)] | 支持的音频采样率,详见[AudioSampleRate](_codec.md#audiosamplerate)。 | -| [channelLayouts](#channellayouts) [[CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1)] | 支持的音频通道数channel layouts。 | -| [channelCount](#channelcount) [[CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1)] | 支持的音频通道数。 | - - -## **详细描述** - -定义音频编解码能力。 - - -## **类成员变量说明** - - -### channelCount - - -``` -int32_t AudioPortCap::channelCount[CHANNEL_NUM] -``` - -**描述:** - -支持的音频通道数 - - -### channelLayouts - - -``` -int32_t AudioPortCap::channelLayouts[CHANNEL_NUM] -``` - -**描述:** - -支持的音频通道数channel layouts - - -### sampleFormats - - -``` -int32_t AudioPortCap::sampleFormats[SAMPLE_FMT_NUM] -``` - -**描述:** - -支持的音频采样格式,详见[AudioSampleFormat](_codec.md#audiosampleformat) - - -### sampleRate - - -``` -int32_t AudioPortCap::sampleRate[SAMPLE_RATE_NUM] -``` - -**描述:** - -支持的音频采样率,详见[AudioSampleRate](_codec.md#audiosamplerate) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md index 4fbfb7c94e6286adf5b6d23a34f2d2ecd0d239f9..bcd0d457ef2599dde89fc1a3e8d89248800328fb 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频端口的支持能力。 + +**相关模块:** [Audio](_audio.md) @@ -13,22 +15,17 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [deviceType](_audio.md#devicetype) | 设备输出、输入类型。 | | [deviceId](_audio.md#deviceid) | 绑定(bind)设备ID,唯一的设备识别符。 | | [hardwareMode](_audio.md#hardwaremode) | 是否支持设备绑定处理。 | | [formatNum](_audio.md#formatnum) | 支持的音频格式数目。 | -| [formats](_audio.md#formats) | 支持的音频格式,详情参考[AudioFormat](_audio.md#audioformat)。 | +| [formats](_audio.md#formats) | 支持的音频格式。 | | [sampleRateMasks](_audio.md#sampleratemasks) | 支持的音频采样频率(8k、16k、32k、48k)。 | -| [channelMasks](_audio.md#channelmasks) | 设备的声道布局掩码(mask),详情参考[AudioChannelMask](_audio.md#audiochannelmask)。 | +| [channelMasks](_audio.md#channelmasks) | 设备的声道布局掩码(mask)。 | | [channelCount](_audio.md#channelcount-22) | 支持的最大声道总数。 | | [subPortsNum](_audio.md#subportsnum) | 支持的子端口数目(仅用于输出设备)。 | | [subPorts](_audio.md#subports) | 支持的子端口列表。 | | [supportSampleFormatNum](_audio.md#supportsampleformatnum) | 支持的音频样本格式数量。 | -| [supportSampleFormats](_audio.md#supportsampleformats) | 支持的音频样本格式,详请参考[AudioSampleFormat](_audio.md#audiosampleformat)。 | - - -## **详细描述** - -音频端口的支持能力。 +| [supportSampleFormats](_audio.md#supportsampleformats) | 支持的音频样本格式。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_render.md b/zh-cn/device-dev/reference/hdi-apis/_audio_render.md index 8f2fbb7f23b9011a2a2c0949356cafd80e58c7c0..c7aed448a1393871e2325b41f47be8edeae7bfee 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_render.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_render.md @@ -3,38 +3,21 @@ ## **概述** -**所属模块:** +AudioRender音频播放接口。 -[Audio](_audio.md) - - -## **汇总** +提供音频播放支持的驱动能力,包括音频控制、音频属性、音频场景、音频音量、获取硬件延迟时间、播放音频帧数据(Render frame)等。 +**Since:** -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| control | 音频控制能力接口,详情参考[AudioControl](_audio_control.md) | -| attr | 音频属性能力接口,详情参考[AudioAttribute](_audio_attribute.md) | -| scene | 音频场景能力接口,详情参考[AudioScene](_audio_scene.md) | -| volume | 音频音量能力接口,详情参考[AudioVolume](_audio_volume.md) | -| ( [GetLatency](#getlatency) )(struct AudioRender \*render, uint32_t \*ms) | 获取音频硬件驱动估计的延迟时间 [更多...](#getlatency) | -| ( [RenderFrame](#renderframe) )(struct AudioRender \*render, const void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 往音频驱动中播放(render)一帧输出数据(放音,音频下行数据) [更多...](#renderframe) | -| ( [GetRenderPosition](#getrenderposition) )(struct AudioRender \*render, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获取音频输出帧数的上一次计数 [更多...](#getrenderposition) | -| ( [SetRenderSpeed](#setrenderspeed) )(struct AudioRender \*render, float speed) | 设置一个音频的播放速度 [更多...](#setrenderspeed) | -| ( [GetRenderSpeed](#getrenderspeed) )(struct AudioRender \*render, float \*speed) | 获取一个音频当前的播放速度 [更多...](#getrenderspeed) | -| ( [SetChannelMode](#setchannelmode) )(struct AudioRender \*render, enum [AudioChannelMode](_audio.md#audiochannelmode) mode) | 设置音频播放的通道模式 [更多...](#setchannelmode) | -| ( [GetChannelMode](#getchannelmode) )(struct AudioRender \*render, enum [AudioChannelMode](_audio.md#audiochannelmode) \*mode) | 获取音频播放当前的通道模式 [更多...](#getchannelmode) | -| ( [RegCallback](#regcallback) )(struct AudioRender \*render, [RenderCallback](_audio.md#rendercallback) callback, void \*cookie) | 注册音频回调函数,用于放音过程中缓冲区数据写、DrainBuffer完成通知 [更多...](#regcallback) | -| ( [DrainBuffer](#drainbuffer) )(struct AudioRender \*render, enum [AudioDrainNotifyType](_audio.md#audiodrainnotifytype) \*type) | 排空缓冲区中的数据 [更多...](#drainbuffer) | +1.0 +**Version:** -## **详细描述** +1.0 -AudioRender音频播放接口 +**相关模块:** -提供音频播放支持的驱动能力,包括音频控制、音频属性、音频场景、音频音量、获取硬件延迟时间、播放音频帧数据(render frame)等 +[Audio](_audio.md) **参见:** @@ -46,13 +29,27 @@ AudioRender音频播放接口 [AudioVolume](_audio_volume.md) -**Since:** -1.0 +## **汇总** -**Version:** -1.0 +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| control | 音频控制能力接口,详情参考[AudioControl](_audio_control.md)。 | +| attr | 音频属性能力接口,详情参考[AudioAttribute](_audio_attribute.md)。 | +| scene | 音频场景能力接口,详情参考[AudioScene](_audio_scene.md)。 | +| volume | 音频音量能力接口,详情参考[AudioVolume](_audio_volume.md)。 | +| ([GetLatency](#getlatency))(struct AudioRender \*render, uint32_t \*ms) | 获取音频硬件驱动估计的延迟时间。 | +| ([RenderFrame](#renderframe))(struct AudioRender \*render, const void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 往音频驱动中播放(Render)一帧输出数据(放音,音频下行数据)。 | +| ([GetRenderPosition](#getrenderposition))(struct AudioRender \*render, uint64_t \*frames, struct AudioTimeStamp \*time) | 获取音频输出帧数的上一次计数。 | +| ([SetRenderSpeed](#setrenderspeed))(struct AudioRender \*render, float speed) | 设置一个音频的播放速度。 | +| ([GetRenderSpeed](#getrenderspeed))(struct AudioRender \*render, float \*speed) | 获取一个音频当前的播放速度。 | +| ([SetChannelMode](#setchannelmode))(struct AudioRender \*render, enum AudioChannelMode mode) | 设置音频播放的通道模式。 | +| ([GetChannelMode](#getchannelmode))(struct AudioRender \*render, enum AudioChannelMode \*mode) | 获取音频播放当前的通道模式。 | +| ([RegCallback](#regcallback) )(struct AudioRender \*render, RenderCallback callback, void \*cookie) | 注册音频回调函数,用于放音过程中缓冲区数据写、DrainBuffer完成通知。 | +| ([DrainBuffer](#drainbuffer))(struct AudioRender \*render, enum AudioDrainNotifyType \*type) | 排空缓冲区中的数据。 | ## **类成员变量说明** @@ -67,20 +64,20 @@ int32_t(* AudioRender::DrainBuffer) (struct AudioRender *render, enum AudioDrain **描述:** -排空缓冲区中的数据 +排空缓冲区中的数据。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| type | DrainBuffer的操作类型,详情请参考[AudioDrainNotifyType](_audio.md#audiodrainnotifytype) | +| render | 输入参数,待操作的音频播放接口对象。 | +| type | 输入参数,DrainBuffer的操作类型,详情请参考[AudioDrainNotifyType](_audio.md#audiodrainnotifytype)。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [RegCallback](#regcallback) @@ -94,20 +91,20 @@ int32_t(* AudioRender::GetChannelMode) (struct AudioRender *render, enum AudioCh **描述:** -获取音频播放当前的通道模式 +获取音频播放当前的通道模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| mode | 获取的通道模式保存到mode中 | +| render | 输入参数,待操作的音频播放接口对象。| +| mode | 输出参数,获取的通道模式保存到mode中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SetChannelMode](#setchannelmode) @@ -121,18 +118,18 @@ int32_t(* AudioRender::GetLatency) (struct AudioRender *render, uint32_t *ms) **描述:** -获取音频硬件驱动估计的延迟时间 +获取音频硬件驱动估计的延迟时间。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| ms | 获取的延迟时间(单位:毫秒)保存到ms中 | +| render | 输入参数,待操作的音频播放接口对象。 | +| ms | 输出参数,获取的延迟时间(单位:毫秒)保存到ms中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### GetRenderPosition @@ -144,21 +141,21 @@ int32_t(* AudioRender::GetRenderPosition) (struct AudioRender *render, uint64_t **描述:** -获取音频输出帧数的上一次计数 +获取音频输出帧数的上一次计数。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| frames | 获取的音频帧计数保存到frames中 | -| time | 获取的关联时间戳保存到time中 | +| render | 输入参数,待操作的音频播放接口对象。 | +| frames | 输出参数,获取的音频帧计数保存到frames中。 | +| time | 输出参数,获取的关联时间戳保存到time中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [RenderFrame](#renderframe) @@ -172,20 +169,20 @@ int32_t(* AudioRender::GetRenderSpeed) (struct AudioRender *render, float *speed **描述:** -获取一个音频当前的播放速度 +获取一个音频当前的播放速度。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| speed | 获取的播放速度保存到speed中 | +| render | 输入参数,待操作的音频播放接口对象。 | +| speed | 输出参数,获取的播放速度保存到speed中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SetRenderSpeed](#setrenderspeed) @@ -199,21 +196,21 @@ int32_t(* AudioRender::RegCallback) (struct AudioRender *render, RenderCallback **描述:** -注册音频回调函数,用于放音过程中缓冲区数据写、DrainBuffer完成通知 +注册音频回调函数,用于放音过程中缓冲区数据写、DrainBuffer完成通知。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| callback | 注册的回调函数 | -| cookie | 回调函数的入参 | +| render | 输入参数,待操作的音频播放接口对象。 | +| callback | 输入参数,注册的回调函数。 | +| cookie | 输入参数,回调函数的入参。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [RegCallback](#regcallback) @@ -227,20 +224,20 @@ int32_t(* AudioRender::RenderFrame) (struct AudioRender *render, const void *fra **描述:** -往音频驱动中播放(render)一帧输出数据(放音,音频下行数据) +向音频驱动中播放(Render)一帧输出数据(放音,音频下行数据)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| frame | 待写入的输出数据的音频frame | -| requestBytes | 待写入的输出数据的音频frame大小(字节数) | -| replyBytes | 实际写入的音频数据长度(字节数),获取后保存到replyBytes中 | +| render | 输入参数,待操作的音频播放接口对象。 | +| frame | 输入参数,待写入的输出数据的音频frame。 | +| requestBytes | 输入参数,待写入的输出数据的音频frame大小(字节数)。 | +| replyBytes | 输出参数,实际写入的音频数据长度(字节数),获取后保存到replyBytes中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 ### SetChannelMode @@ -252,20 +249,20 @@ int32_t(* AudioRender::SetChannelMode) (struct AudioRender *render, enum AudioCh **描述:** -设置音频播放的通道模式 +设置音频播放的通道模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| speed | 待设置的通道模式 | +| render | 输入参数,待操作的音频播放接口对象。 | +| speed | 输入参数,待设置的通道模式。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetChannelMode](#getchannelmode) @@ -279,19 +276,19 @@ int32_t(* AudioRender::SetRenderSpeed) (struct AudioRender *render, float speed) **描述:** -设置一个音频的播放速度 +设置一个音频的播放速度。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| render | 待操作的音频播放接口对象 | -| speed | 待设置的播放速度 | +| render | 输入参数,待操作的音频播放接口对象。 | +| speed | 输入参数,待设置的播放速度。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetRenderSpeed](#getrenderspeed) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_route.md b/zh-cn/device-dev/reference/hdi-apis/_audio_route.md index d4db5ceddec9bf88fbeb75fa15f6c1a61dc57ac5..52fe8436dc04d9761877f4a8c652ccc30cfc916d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_route.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_route.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频路由信息。 + +**相关模块:** [Audio](_audio.md) @@ -13,14 +15,9 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [sourcesNum](_audio.md#sourcesnum) | 发送端节点数量。 | | [sources](_audio.md#sources) | 发送端列表。 | | [sinksNum](_audio.md#sinksnum) | 接受端节点数量。 | | [sinks](_audio.md#sinks) | 接受端列表。 | - - -## **详细描述** - -音频路由信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md b/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md index 2686ecf9b5d43ab44660185531ecc550aca6cc71..ac409be4c4343dfec9cd459820adaaa74bd5ae01 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md @@ -1,9 +1,11 @@ # AudioRouteNode -## **述** +## **概述** -**所属模块:** +音频路由节点。 + +**相关模块:** [Audio](_audio.md) @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [portId](_audio.md#portid-44) | 音频端口ID。 | | [role](_audio.md#role) | 指定端口角色为sink或source。 | @@ -21,8 +23,3 @@ | [device](_audio.md#device) | 设备特定信息。 | | [mix](_audio.md#mix) | 音轨特定信息。 | | [session](_audio.md#session) | 会话特定信息。 | - - -## **详细描述** - -音频路由节点。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md b/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md index 8b2c871f1cf272d6f90fbc43ce08b37e108da7f3..4ac66a50a5523a64b15e4f61822c817461bf60c1 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频采样属性。 + +**相关模块:** [Audio](_audio.md) @@ -13,11 +15,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [type](_audio.md#type-13) | 音频类型,详情参考[AudioCategory](_audio.md#audiocategory)。 | +| [type](_audio.md#type-13) | 音频类型。 | | [interleaved](_audio.md#interleaved) | 音频数据交织的标记。 | -| [format](_audio.md#format) | 音频数据格式,详情参考[AudioFormat](_audio.md#audioformat)。 | +| [format](_audio.md#format) | 音频数据格式。 | | [sampleRate](_audio.md#samplerate) | 音频采样频率。 | | [channelCount](_audio.md#channelcount-12) | 音频通道数目,如单通道(mono)为1、立体声(stereo)为2。 | | [period](_audio.md#period) | 音频采样周期。 | @@ -28,8 +30,3 @@ | [stopThreshold](_audio.md#stopthreshold) | 音频渲染停止阈值。 | | [silenceThreshold](_audio.md#silencethreshold) | 音频捕获缓冲区阈值。 | | [streamId](_audio.md#streamid-12) | 渲染或捕获的音频标识符。 | - - -## **详细描述** - -音频采样属性。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md b/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md index 520381a9b410129142f620ecb394f8fa2183ce94..f2bf7f3c7639d81dbe4f3ef17c511659dbcf02d3 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md @@ -3,35 +3,32 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +AudioScene音频场景接口。 -## **汇总** +提供音频播放(Render)或录音(Capture)需要的公共场景驱动能力,包括选择音频场景等。 +**Since:** -### Public 属性 +1.0 - | Public 属性 | 描述 | -| -------- | -------- | -| ( [CheckSceneCapability](#checkscenecapability) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSceneDescriptor](_audio_scene_descriptor.md) \*scene, bool \*supported) | 是否支持某个音频场景的配置 [更多...](#checkscenecapability) | -| ( [SelectScene](#selectscene) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSceneDescriptor](_audio_scene_descriptor.md) \*scene) | 选择音频场景 [更多...](#selectscene) | +**Version:** +1.0 -## **详细描述** +**相关模块:** -AudioScene音频场景接口。 +[Audio](_audio.md) -提供音频播放(render)或录音(capture)需要的公共场景驱动能力,包括选择音频场景等。 -**Since:** +## **汇总** -1.0 -**Version:** +### Public 属性 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| ([CheckSceneCapability](#checkscenecapability))(AudioHandle handle, const struct AudioSceneDescriptor \*scene, bool \*supported) | 是否支持某个音频场景的配置 | +| ([SelectScene](#selectscene))(AudioHandle handle, const struct AudioSceneDescriptor \*scene) | 选择音频场景 | ## **类成员变量说明** @@ -46,21 +43,21 @@ int32_t(* AudioScene::CheckSceneCapability) (AudioHandle handle, const struct Au **描述:** -是否支持某个音频场景的配置 +是否支持某个音频场景的配置。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| scene | 待获取的音频场景描述符 | -| supported | 是否支持的状态保存到supported中,true表示支持,false表示不支持 | +| handle | 输入参数,待操作的音频句柄。 | +| scene | 输入参数,待获取的音频场景描述符。 | +| supported | 输出参数,是否支持的状态保存到supported中,true表示支持,false表示不支持。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SelectScene](#selectscene) @@ -74,27 +71,27 @@ int32_t(* AudioScene::SelectScene) (AudioHandle handle, const struct AudioSceneD **描述:** -选择音频场景 +选择音频场景。 -- 1. 选择一个非常具体的音频场景(应用场景和输出设备的组合),例如同样是使用手机中的喇叭作为输出设备 +- 选择一个非常具体的音频场景(应用场景和输出设备的组合),例如同样是使用手机中的喇叭作为输出设备: - 在媒体播放场景scene为media_speaker - 在语音通话免提场景scene为voice_speaker -- 2. 只是选择一个音频场景,例如使用场景为媒体播放(media)、电影播放(movie)、游戏播放(game) +- 只是选择一个音频场景,例如使用场景为媒体播放(media)、电影播放(movie)、游戏播放(game)。 -- 3. 只是选择一个音频输出设备,例如输出设备为听筒(receiver)、喇叭(speaker)、有线耳机(headset) +- 只是选择一个音频输出设备,例如输出设备为听筒(receiver)、喇叭(speaker)、有线耳机(headset)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| scene | 待设置的音频场景描述符 | +| handle | 输入参数,待操作的音频句柄。 | +| scene | 输入参数,待设置的音频场景描述符。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [CheckSceneCapability](#checkscenecapability) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md index 624073d4aec715fb57f5695527a5d8cd662c5d05..3910b9897ea0b8337de6762bd93282530c1620c8 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md @@ -3,28 +3,26 @@ ## **概述** -**所属模块:** +音频场景描述符。 + +**相关模块:** [Audio](_audio.md) + ## **汇总** ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | +| [SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 | ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [scene](_audio.md#scene) | 音频场景的名称。 | | [desc](_audio.md#desc-25) | 音频设备描述符。 | - - -## **详细描述** - -音频场景描述符。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md index d48ad307922f7be094c3e4492497e7564a9a70e3..dbb96a35bdb71174a5dd356e90dadecc45bb7c75 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +会话拓展信息。 + +**相关模块:** [Audio](_audio.md) @@ -13,11 +15,6 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [sessionType](_audio.md#sessiontype) | 音频会话类型。 | - - -## **详细描述** - -会话拓展信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md b/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md index 1bc223b1d5f70bb6b1725cf4d184216cc1c93e3f..33da2e3ebea88ca10826c778d97f7d71d9904844 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频子端口的支持能力。 + +**相关模块:** [Audio](_audio.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [portId](_audio.md#portid-34) | 子端口ID。 | | [desc](_audio.md#desc-45) | 以字符串命名的子端口。 | -| [mask](_audio.md#mask) | 数据透传模式,详情参考[AudioPortPassthroughMode](_audio.md#audioportpassthroughmode)。 | - - -## **详细描述** - -音频子端口的支持能力。 +| [mask](_audio.md#mask) | 数据透传模式。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md b/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md index ec53fdefc97c8e41d22e4b68f00796577b63b74e..72f9c7d1b2bb9ef87d876e46620328874560c25d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md @@ -3,7 +3,11 @@ ## **概述** -**所属模块:** +音频时间戳。 + +时间定义,POSIX timespec的替代品。 + +**相关模块:** [Audio](_audio.md) @@ -13,14 +17,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [tvSec](_audio.md#tvsec) | tvSec时间,单位:秒。 | | [tvNSec](_audio.md#tvnsec) | tvNSec时间,单位:纳秒。 | - - -## **详细描述** - -音频时间戳。 - -时间定义,POSIX timespec的替代品。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md b/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md index 2766ba7eb2bb60cb95e4281799707f2ceb81abd1..677f5f1999aee3d67a1d6ed0df577ca08eafde16 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md @@ -3,40 +3,37 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +AudioVolume音频音量接口。 -## **汇总** +提供音频播放(Render)或录音(Capture)需要的公共音量驱动能力,包括静音操作、设置音量、设置增益等。 +**Since:** -### Public 属性 +1.0 - | Public 属性 | 描述 | -| -------- | -------- | -| ( [SetMute](#setmute) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool mute) | 设置音频的静音状态 [更多...](#setmute) | -| ( [GetMute](#getmute) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool \*mute) | 获取音频的静音状态 [更多...](#getmute) | -| ( [SetVolume](#setvolume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float volume) | 设置一个音频流的音量 [更多...](#setvolume) | -| ( [GetVolume](#getvolume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*volume) | 获取一个音频流的音量 [更多...](#getvolume) | -| ( [GetGainThreshold](#getgainthreshold) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*min, float \*max) | 获取音频流增益的阈值 [更多...](#getgainthreshold) | -| ( [GetGain](#getgain) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*gain) | 获取音频流的增益 [更多...](#getgain) | -| ( [SetGain](#setgain) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float gain) | 设置音频流的增益 [更多...](#setgain) | +**Version:** +1.0 -## **详细描述** +**相关模块:** -AudioVolume音频音量接口。 +[Audio](_audio.md) -提供音频播放(render)或录音(capture)需要的公共音量驱动能力,包括静音操作、设置音量、设置增益等。 -**Since:** +## **汇总** -1.0 -**Version:** +### Public 属性 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| ([SetMute](#setmute))(AudioHandle handle, bool mute) | 设置音频的静音状态 | +| ([GetMute](#getmute))(AudioHandle handle, bool \*mute) | 获取音频的静音状态 | +| ([SetVolume](#setvolume))(AudioHandle handle, float volume) | 设置一个音频流的音量 | +| ([GetVolume](#getvolume))(AudioHandle handle, float \*volume) | 获取一个音频流的音量 | +| ([GetGainThreshold](#getgainthreshold))(AudioHandle handle, float \*min, float \*max) | 获取音频流增益的阈值 | +| ([GetGain](#getgain))(AudioHandle handle, float \*gain) | 获取音频流的增益 | +| ([SetGain](#setgain))(AudioHandle handle, float gain) | 设置音频流的增益 | ## **类成员变量说明** @@ -51,20 +48,20 @@ int32_t(* AudioVolume::GetGain) (AudioHandle handle, float *gain) **描述:** -获取音频流的增益 +获取音频流的增益。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| gain | 保存当前获取到的增益到gain中 | +| handle | 输入参数,待操作的音频句柄。 | +| gain | 输出参数,保存当前获取到的增益到gain中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetGainThreshold](#getgainthreshold) @@ -80,27 +77,27 @@ int32_t(* AudioVolume::GetGainThreshold) (AudioHandle handle, float *min, float **描述:** -获取音频流增益的阈值 +获取音频流增益的阈值。 在具体的功能实现中,可以根据芯片平台的实际情况来进行处理: -- 1. 可以使用实际的增益值,例如增益的范围为-50db ~ 6db +- 可以使用实际的增益值,例如增益的范围为-50db ~ 6db。 -- 2. 也可以将增益范围设定为0.0~1.0,如果增益的范围为-50db ~ 6db, 则增益的映射关系为0.0表示静音,1.0表示最大增益(6db) +- 也可以将增益范围设定为0.0~1.0,如果增益的范围为-50db ~ 6db, 则增益的映射关系为0.0表示静音,1.0表示最大增益(6db)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| min | 获取的音频增益的阈值下限保存到min中 | -| max | 获取的音频增益的阈值上限保存到max中 | +| handle | 输入参数,待操作的音频句柄。 | +| min | 输出参数,获取的音频增益的阈值下限保存到min中。 | +| max | 输出参数,获取的音频增益的阈值上限保存到max中。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetGain](#getgain) @@ -116,20 +113,20 @@ int32_t(* AudioVolume::GetMute) (AudioHandle handle, bool *mute) **描述:** -获取音频的静音状态 +获取音频的静音状态。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| mute | 获取的静音状态保存到mute中,true表示静音操作、false表示取消静音操作 | +| handle | 输入参数,待操作的音频句柄。 | +| mute | 输出参数,获取的静音状态保存到mute中,true表示静音操作,false表示取消静音操作。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SetMute](#setmute) @@ -143,20 +140,20 @@ int32_t(* AudioVolume::GetVolume) (AudioHandle handle, float *volume) **描述:** -获取一个音频流的音量 +获取一个音频流的音量。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| volume | 获取的音量保存到volume中,范围0.0~1.0 | +| handle | 输入参数,待操作的音频句柄。 | +| volume | 输出参数,获取的音量保存到volume中,范围0.0~1.0。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [SetVolume](#setvolume) @@ -170,20 +167,20 @@ int32_t(* AudioVolume::SetGain) (AudioHandle handle, float gain) **描述:** -设置音频流的增益 +设置音频流的增益。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| gain | gain 待设置的增益 | +| handle | 输入参数,待操作的音频句柄。 | +| gain | 输入参数,待设置的增益。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetGainThreshold](#getgainthreshold) @@ -199,20 +196,20 @@ int32_t(* AudioVolume::SetMute) (AudioHandle handle, bool mute) **描述:** -设置音频的静音状态 +设置音频的静音状态。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| mute | 待设置的静音状态,true表示静音操作、false表示取消静音操作 | +| handle | 输入参数,待操作的音频句柄。 | +| mute | 输入参数,待设置的静音状态,true表示静音操作,false表示取消静音操作。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 -**参见:** +**参见:** [GetMute](#getmute) @@ -228,15 +225,15 @@ int32_t(* AudioVolume::SetVolume) (AudioHandle handle, float volume) 设置一个音频流的音量。 -音量的取值范围是0.0~1.0,如果音频服务中的音量等级为15级(0 ~ 15), 则音量的映射关系为0.0表示静音,1.0表示最大音量等级(15) +音量的取值范围是0.0~1.0,如果音频服务中的音量等级为15级(0 ~ 15),则音量的映射关系为0.0表示静音,1.0表示最大音量等级(15)。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| handle | 待操作的音频句柄 | -| volume | 待设置的音量,范围0.0~1.0 | +| handle | 输入参数,待操作的音频句柄。 | +| volume | 输入参数,待设置的音量,范围0.0~1.0。 | -**返回:** +**返回:** -成功返回值0,失败返回负值 +成功返回值0,失败返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md b/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md index fe4a3ac63ff19429153d7ad7d60f8c7c62066e1b..add4d4a1fa15af78a2eea1d0258a4d3966ff6d63 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md @@ -3,6 +3,16 @@ ## **概述** +用户身份认证结果信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,37 +23,24 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [result](#result) | 用户身份认证结果。 | -| [lockoutDuration](#lockoutduration) | 认证方式被冻结的时间。 | -| [remainAttempts](#remainattempts) | 认证方式距离被冻结的可处理认证请求次数。 | +| [freezingTime](#freezingtime) | 认证方式被冻结的时间。 | +| [remainTimes](#remaintimes) | 认证方式距离被冻结的可处理认证请求次数。 | | [msgs](#msgs) | 执行器发送的消息。 | | [token](#token) | 用户身份认证令牌。 | -| rootSecret | 保护文件加密密钥的密钥。 | - - -## **详细描述** - -用户身份认证结果信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 +| [rootSecret](#rootsecret) | 保护文件加密密钥的密钥。 | ## **类成员变量说明** -### lockoutDuration +### freezingTime ``` -int AuthResultInfo::lockoutDuration +int AuthResultInfo::freezingTime ``` **描述:** @@ -63,11 +60,11 @@ struct ExecutorSendMsg [] AuthResultInfo::msgs 执行器发送的消息。 -### remainAttempts +### remainTimes ``` -int AuthResultInfo::remainAttempts +int AuthResultInfo::remainTimes ``` **描述:** diff --git a/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md b/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md index 8a43490939301ffa64c3dc9b11ce588041ee6e69..623a2e8497137c71597eaafada3341487173630f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md +++ b/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md @@ -3,6 +3,16 @@ ## **概述** +认证方案。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,28 +23,15 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [userId](#userid) | 用户ID。 | | [authTrustLevel](#authtrustlevel) | 认证结果可信等级。 | -| [authType](#authtype) | 用户认证凭据类型AuthType}。 | +| [authType](#authtype) | 用户认证凭据类型。 | | [executorSensorHint](#executorsensorhint) | 既定用户认证凭据类型的执行器传感器提示,用于找到对应认证方式的传感器。 | | [challenge](#challenge) | 挑战值,用于签发认证令牌。 | -## **详细描述** - -认证方案。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** @@ -59,7 +56,7 @@ enum AuthType AuthSolution::authType **描述:** -用户认证凭据类型AuthType}。 +用户认证凭据类型[AuthType](_hdf_user_auth.md#authtype)。 ### challenge diff --git a/zh-cn/device-dev/reference/hdi-apis/_battery_info.md b/zh-cn/device-dev/reference/hdi-apis/_battery_info.md index 8373d179faf623504f0e9deee42a05dd4be0ca68..adc0e59b43be9c41ad81db6d428b7a3a6f26cbb9 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_battery_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_battery_info.md @@ -3,7 +3,13 @@ ## **概述** -**所属模块:** +电池相关信息。 + +**Since:** + +3.1 + +**相关模块:** [Battery](battery.md) @@ -13,11 +19,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [capacity](#capacity) | 表示电池的电量百分比。 | | [voltage](#voltage) | 表示电池的电压。 | -| [temperature](#temperature) | 表示电池的温度 | +| [temperature](#temperature) | 表示电池的温度。 | | [healthState](#healthstate) | 表示电池的健康状态。 | | [pluggedType](#pluggedtype) | 表示电池的充电设备类型。 | | [pluggedMaxCurrent](#pluggedmaxcurrent) | 表示电池的最大充电电流。 | @@ -32,15 +38,6 @@ | [technology](#technology) | 表示电池的技术型号。 | -## **详细描述** - -电池相关信息。 - -**Since:** - -3.1 - - ## **类成员变量说明** @@ -197,7 +194,7 @@ int BatteryInfo::temperature **描述:** -表示电池的温度 +表示电池的温度。 ### totalEnergy diff --git a/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md b/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md index 667b9b2a71c852b359534877e1f4c7294afa1137..4d24eb0e40a3453cec07111e758312f454407ddd 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md +++ b/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md @@ -3,6 +3,8 @@ ## **概述** +定义一层的缓冲区数据,包括虚拟和物理内存地址。 + **所属模块:** [Display](_display.md) @@ -13,10 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [phyAddr](_display.md#phyaddr-12) | 物理内存地址。 | -| [virAddr](_display.md#viraddr) | 虚拟内存地址。 | +| [phyAddr](_display.md#phyaddr-13) | 物理内存地址。 | +| [virAddr](_display.md#viraddr-12) | 虚拟内存地址。 | ## **详细描述** diff --git a/zh-cn/device-dev/reference/hdi-apis/_camera.md b/zh-cn/device-dev/reference/hdi-apis/_camera.md deleted file mode 100644 index 066935359619d140db859247ec934dc16ac93ad6..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_camera.md +++ /dev/null @@ -1,1837 +0,0 @@ -# Camera - - -## **汇总** - - -### 文件 - -| 文件 | 描述 | -| -------- | -------- | -| [icamera_device.h](icamera__device_8h.md) | Camera设备操作接口。 | -| [icamera_device_callback.h](icamera__device__callback_8h.md) | Camera设备的回调接口,主要包含Camera设备发生错误时和上报metadata的回调函数。 | -| [icamera_host.h](icamera__host_8h.md) | Camera服务的管理类,对上层提供HDI接口。 | -| [icamera_host_callback.h](icamera__host__callback_8h.md) | ICameraHost的回调接口,提供Camera设备和闪关灯状态变化的回调函数,回调函数由调用者实现。 | -| [ioffline_stream_operator.h](ioffline__stream__operator_8h.md) | 离线流的操作接口。 | -| [istream_operator.h](istream__operator_8h.md) | 流的操作接口。 | -| [istream_operator_callback.h](istream__operator__callback_8h.md) | [IStreamOperator](istream__operator_8h.md)相关的回调,这些回调均由调用者实现。 | -| [types.h](types_8h.md) | Camera模块HDI接口使用的数据类型。 | - - -### 类 - -| 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | Camera设备操作。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | -| [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | Camera设备操作回调。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | -| [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | Camera服务的管理类。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | -| [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | Camera服务的管理回调。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | -| [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | 离线流的操作类。[更多...](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | -| [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | 流的操作类。[更多...](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | -| [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | 流的操作回调类。[更多...](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | -| [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) | 流信息,用于创建流时传入相关的配置参数。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_info.md) | -| [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | 流的属性。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | -| [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) | 捕获请求的相关信息。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_info.md) | -| [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | 捕获结束相关信息,用于捕获结束回调 **OnCaptureEnded**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | -| [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | 流错误信息,用于回调 **OnCaptureError**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | - - -### 类型定义 - -| 类型定义 | 描述 | -| -------- | -------- | -| **OHOS::Camera::CameraAbility** = CameraMetadata | Camera设备能力集合。 | -| **OHOS::Camera::CameraSetting** = CameraMetadata | Camera设置参数,包括sensor帧率,3A相关参数等。 | -| **OHOS::Camera::MetaType** = int32_t | 整型。 | - - -### 枚举 - -| 枚举 | 描述 | -| -------- | -------- | -| [OHOS::Camera::CamRetCode](#camretcode) : int32_t {   OHOS::Camera::NO_ERROR = 0, OHOS::Camera::CAMERA_BUSY = -1, OHOS::Camera::INSUFFICIENT_RESOURCES = -2, OHOS::Camera::INVALID_ARGUMENT = -3,   OHOS::Camera::METHOD_NOT_SUPPORTED = -4, OHOS::Camera::CAMERA_CLOSED = -5, OHOS::Camera::DEVICE_ERROR = -6 } | HDI接口的返回值。 [更多...](#camretcode) | -| [OHOS::Camera::ResultCallbackMode](#resultcallbackmode) : int32_t { OHOS::Camera::PER_FRAME, OHOS::Camera::ON_CHANGED } | metadata的上报模式。 [更多...](#resultcallbackmode) | -| [OHOS::Camera::OperationMode](#operationmode) : int32_t { OHOS::Camera::NORMAL = 0 } | 流的使用模式。 [更多...](#operationmode) | -| [OHOS::Camera::StreamIntent](#streamintent) : int32_t {   OHOS::Camera::PREVIEW = 0, OHOS::Camera::VIDEO = 1, OHOS::Camera::STILL_CAPTURE = 2, OHOS::Camera::POST_VIEW = 3,   OHOS::Camera::ANALYZE = 4, OHOS::Camera::CUSTOM = 5 } | 流的类型。 [更多...](#streamintent) | -| [OHOS::Camera::EncodeType](#encodetype) : int32_t { OHOS::Camera::ENCODE_TYPE_NULL = 0, OHOS::Camera::ENCODE_TYPE_H264 = 1, OHOS::Camera::ENCODE_TYPE_H265 = 2, OHOS::Camera::ENCODE_TYPE_JPEG = 3 } | 流数据的编码类型。 [更多...](#encodetype) | -| [OHOS::Camera::StreamSupportType](#streamsupporttype) : int32_t { OHOS::Camera::DYNAMIC_SUPPORTED, OHOS::Camera::RE_CONFIGURED_REQUIRED, OHOS::Camera::NOT_SUPPORTED } | 动态配置流的切换方式,使用场景参考 [IsStreamsSupported](#isstreamssupported) 。 [更多...](#streamsupporttype) | -| [OHOS::Camera::CameraStatus](#camerastatus) { OHOS::Camera::UN_AVAILABLE = 0, OHOS::Camera::AVAILABLE = 1 } | Camera设备状态。 [更多...](#camerastatus) | -| [OHOS::Camera::FlashlightStatus](#flashlightstatus) : uint32_t { OHOS::Camera::FLASHLIGHT_OFF = 0, OHOS::Camera::FLASHLIGHT_ON = 1, OHOS::Camera::FLASHLIGHT_UNAVAILABLE = 2 } | 闪光灯状态。 [更多...](#flashlightstatus) | -| [OHOS::Camera::CameraEvent](#cameraevent): uint32_t { OHOS::Camera::CAMERA_EVENT_DEVICE_ADD = 0, OHOS::Camera::CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 [更多...](#cameraevent) | -| [OHOS::Camera::ErrorType](#errortype) : uint32_t { OHOS::Camera::FATAL_ERROR = 0, OHOS::Camera::REQUEST_TIMEOUT = 1 } | 设备错误类型,用于设备错误回调 [OnError](#onerror)。 [更多...](#errortype) | -| [OHOS::Camera::StreamError](#streamerror) { OHOS::Camera::UNKNOWN_ERROR = 0, OHOS::Camera::BUFFER_LOST = 1 } | 流错误类型,用于流错误类型 [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md)。 [更多...](#streamerror) | - - -### 函数 - -| 函数 | 描述 | -| -------- | -------- | -| **OHOS::Camera::ICameraDevice::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Device") | IPC通信token校验。 | -| [OHOS::Camera::ICameraDevice::GetStreamOperator](#getstreamoperator) (const OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) > &streamOperator)=0 | 获取流操作句柄。 [更多...](#getstreamoperator) | -| [OHOS::Camera::ICameraDevice::UpdateSettings](#updatesettings) (const std::shared_ptr< CameraSetting > &settings)=0 | 更新设备控制参数。 [更多...](#updatesettings) | -| [OHOS::Camera::ICameraDevice::SetResultMode](#setresultmode) (const [ResultCallbackMode](#resultcallbackmode) &mode)=0 | 设置metadata上报模式,逐帧上报还是设备状态变化时上报。 [更多...](#setresultmode) | -| [OHOS::Camera::ICameraDevice::GetEnabledResults](#getenabledresults) (std::vector< MetaType > &results)=0 | 查询使能的metadata。 [更多...](#getenabledresults) | -| [OHOS::Camera::ICameraDevice::EnableResult](#enableresult) (const std::vector< MetaType > &results)=0 | 打开metadata上报开关。 [更多...](#enableresult) | -| [OHOS::Camera::ICameraDevice::DisableResult](#disableresult) (const std::vector< MetaType > &results)=0 | 关闭metadata上报开关。 [更多...](#disableresult) | -| [OHOS::Camera::ICameraDevice::Close](#close) ()=0 | 关闭Camera设备。 [更多...](#close) | -| **OHOS::Camera::ICameraDeviceCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.DeviceCallback") | IPC通信token校验。 | -| [OHOS::Camera::ICameraDeviceCallback::OnError](#onerror) ([ErrorType](#errortype) type, int32_t errorCode)=0 | 设备发生错误时调用,由调用者实现,用于返回错误信息给调用者。 [更多...](#onerror) | -| [OHOS::Camera::ICameraDeviceCallback::OnResult](#onresult) (uint64_t timestamp, const std::shared_ptr< CameraMetadata > &result)=0 | 上报Camera设备相关的metadata的回调,上报方式查看 [SetResultMode](#setresultmode)。 [更多...](#onresult) | -| **OHOS::Camera::ICameraHost::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Host") | IPC通信token校验。 | -| [OHOS::Camera::ICameraHost::Get](#get) (const char \*serviceName) | 获取ICameraHost实例。 [更多...](#get) | -| [OHOS::Camera::ICameraHost::SetCallback](#setcallback) (const OHOS::sptr< [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) > &callback)=0 | 设置ICameraHost回调接口,回调函数参考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 [更多...](#setcallback) | -| [OHOS::Camera::ICameraHost::GetCameraIds](#getcameraids) (std::vector< std::string > &cameraIds)=0 | 获取当前可用的Camera设备ID列表。 [更多...](#getcameraids) | -| [OHOS::Camera::ICameraHost::GetCameraAbility](#getcameraability) (const std::string &cameraId, std::shared_ptr< CameraAbility > &ability)=0 | 获取Camera设备能力集合。 [更多...](#getcameraability) | -| [OHOS::Camera::ICameraHost::OpenCamera](#opencamera) (const std::string &cameraId, const OHOS::sptr< [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) > &callback, OHOS::sptr< [ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) > &device)=0 | 打开Camera设备。 [更多...](#opencamera) | -| [OHOS::Camera::ICameraHost::SetFlashlight](#setflashlight) (const std::string &cameraId, bool &isEnable)=0 | 打开或关闭闪光灯。 [更多...](#setflashlight) | -| **OHOS::Camera::ICameraHostCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.HostCallback") | IPC通信token校验。 | -| [OHOS::Camera::ICameraHostCallback::OnCameraStatus](#oncamerastatus) (const std::string &cameraId, [CameraStatus](#camerastatus) status)=0 | 用于Camera设备状态变化时上报状态信息给调用者。 [更多...](#oncamerastatus) | -| [OHOS::Camera::ICameraHostCallback::OnFlashlightStatus](#onflashlightstatus) (const std::string &cameraId, [FlashlightStatus](#flashlightstatus) status)=0 | 用于在闪光灯状态变化时上报状态信息给调用者。 [更多...](#onflashlightstatus) | -| [OHOS::Camera::ICameraHostCallback::OnCameraEvent](#oncameraevent) (const std::string &cameraId, [CameraEvent](#cameraevent) event)=0 | 在相机事件发生时调用。 [更多...](#oncameraevent) | -| **OHOS::Camera::IOfflineStreamOperator::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.OfflineStreamOperator") | IPC通信token校验。 | -| [OHOS::Camera::IOfflineStreamOperator::CancelCapture](#cancelcapture-12) (int captureId)=0 | 取消捕获请求。 [更多...](#cancelcapture-12) | -| [OHOS::Camera::IOfflineStreamOperator::ReleaseStreams](#releasestreams-12) (const std::vector< int > &streamIds)=0 | 释放离线流。 [更多...](#releasestreams-12) | -| [OHOS::Camera::IOfflineStreamOperator::Release](#release) ()=0 | 释放所有离线流。 [更多...](#release) | -| **OHOS::Camera::IStreamOperator::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperator") | IPC通信token校验。 | -| [OHOS::Camera::IStreamOperator::IsStreamsSupported](#isstreamssupported) ([OperationMode](#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting, const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &info, [StreamSupportType](#streamsupporttype) &type)=0 | 查询是否支持添加参数对应的流 [更多...](#isstreamssupported) | -| [OHOS::Camera::IStreamOperator::CreateStreams](#createstreams) (const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &streamInfos)=0 | 创建流。 [更多...](#createstreams) | -| [OHOS::Camera::IStreamOperator::ReleaseStreams](#releasestreams-22) (const std::vector< int > &streamIds)=0 | 释放流。 [更多...](#releasestreams-22) | -| [OHOS::Camera::IStreamOperator::CommitStreams](#commitstreams) ([OperationMode](#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting)=0 | 配置流。 [更多...](#commitstreams) | -| [OHOS::Camera::IStreamOperator::GetStreamAttributes](#getstreamattributes) (std::vector< std::shared_ptr< [StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) >> &attributes)=0 | 获取流的属性。 [更多...](#getstreamattributes) | -| [OHOS::Camera::IStreamOperator::AttachBufferQueue](#attachbufferqueue) (int streamId, const OHOS::sptr< OHOS::IBufferProducer > &producer)=0 | 绑定生产者句柄和指定流。 [更多...](#attachbufferqueue) | -| [OHOS::Camera::IStreamOperator::DetachBufferQueue](#detachbufferqueue) (int streamId)=0 | 解除生产者句柄和指定流的绑定关系。 [更多...](#detachbufferqueue) | -| [OHOS::Camera::IStreamOperator::Capture](#capture) (int captureId, const std::shared_ptr< [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) > &info, bool isStreaming)=0 | 捕获图像。 [更多...](#capture) | -| [OHOS::Camera::IStreamOperator::CancelCapture](#cancelcapture-22) (int captureId)=0 | 取消捕获。 [更多...](#cancelcapture-22) | -| [OHOS::Camera::IStreamOperator::ChangeToOfflineStream](#changetoofflinestream) (const std::vector< int > &streamIds, OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) > &offlineOperator)=0 | 将指定流转换成离线流。 [更多...](#changetoofflinestream) | -| **OHOS::Camera::IStreamOperatorCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperatorCallback") | IPC通信token校验。 | -| [OHOS::Camera::IStreamOperatorCallback::OnCaptureStarted](#oncapturestarted) (int32_t captureId, const std::vector< int32_t > &streamIds)=0 | 捕获开始回调,在捕获开始时调用。 [更多...](#oncapturestarted) | -| [OHOS::Camera::IStreamOperatorCallback::OnCaptureEnded](#oncaptureended) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) >> &infos)=0 | 捕获结束回调,在捕获结束时调用。 [更多...](#oncaptureended) | -| [OHOS::Camera::IStreamOperatorCallback::OnCaptureError](#oncaptureerror) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) >> &infos)=0 | 捕获错误回调,在捕获过程中发生错误时调用。 [更多...](#oncaptureerror) | -| [OHOS::Camera::IStreamOperatorCallback::OnFrameShutter](#onframeshutter) (int32_t captureId, const std::vector< int32_t > &streamIds, uint64_t timestamp)=0 | 帧捕获回调。 [更多...](#onframeshutter) | - - -### 变量 - -| 变量 | 描述 | -| -------- | -------- | -| [OHOS::Camera::StreamInfo::streamId_](#streamid-14) | 流的ID,用于在设备内唯一标识一条流。 | -| [OHOS::Camera::StreamInfo::width_](#width-12) | 图像宽度。 | -| [OHOS::Camera::StreamInfo::height_](#height-12) | 图像高度。 | -| [OHOS::Camera::StreamInfo::format_](#format) | 图像格式。 | -| [OHOS::Camera::StreamInfo::dataspace_](#dataspace) | 图像颜色空间。 | -| [OHOS::Camera::StreamInfo::intent_](#intent) | 流类型。 | -| [OHOS::Camera::StreamInfo::tunneledMode_](#tunneledmode) | 隧道模式,值为true时开启,false关闭。 | -| [OHOS::Camera::StreamInfo::bufferQueue_](#bufferqueue) | 图形提供的生产者句柄。 | -| [OHOS::Camera::StreamInfo::minFrameDuration_](#minframeduration) | 最小帧间隔。 | -| [OHOS::Camera::StreamInfo::encodeType_](#encodetype) | 编码类型。 | -| [OHOS::Camera::StreamAttribute::streamId_](#streamid-24) | 流的ID,用于在设备内唯一标识一条流。 | -| [OHOS::Camera::StreamAttribute::width_](#width-22) | 图像宽度。 | -| [OHOS::Camera::StreamAttribute::height_](#height-22) | 图像高度。 | -| [OHOS::Camera::StreamAttribute::overrideFormat_](#overrideformat) | 重写的图像格式。 | -| [OHOS::Camera::StreamAttribute::overrideDataspace_](#overridedataspace) | 重写的图像颜色空间。 | -| [OHOS::Camera::StreamAttribute::producerUsage_](#producerusage) | 重写后的生产者的使用方式。 | -| [OHOS::Camera::StreamAttribute::producerBufferCount_](#producerbuffercount) | 重写后的生产者缓存数量。 | -| [OHOS::Camera::StreamAttribute::maxBatchCaptureCount_](#maxbatchcapturecount) | 连拍支持的最大捕获帧数量。 | -| [OHOS::Camera::StreamAttribute::maxCaptureCount_](#maxcapturecount) | 最大的并发捕获请求个数,默认为1。 | -| [OHOS::Camera::CaptureInfo::streamIds_](#streamids) | 捕获的流ID集合。 | -| [OHOS::Camera::CaptureInfo::captureSetting_](#capturesetting) | 捕获的配置信息。 | -| [OHOS::Camera::CaptureInfo::enableShutterCallback_](#enableshuttercallback) | 使能捕获回调。 | -| [OHOS::Camera::CaptureEndedInfo::streamId_](#streamid-34) | 捕获的流ID。 | -| [OHOS::Camera::CaptureEndedInfo::frameCount_](#framecount) | 捕获结束时已经抓取的帧数。 | -| [OHOS::Camera::CaptureErrorInfo::streamId_](#streamid-44) | 流ID。 | -| [OHOS::Camera::CaptureErrorInfo::error_](#error) | 错误类型。 | - - -## **详细描述** - -Camera模块接口定义。 - -Camera模块涉及相机设备的操作、流的操作、离线流的操作和各种回调等。 - -**Since:** - -1.0 - - -## **枚举类型说明** - - -### CameraEvent - - -``` -enum OHOS::Camera::CameraEvent : uint32_t -``` - -**描述:** - -Camera事件。 - -| 枚举值 | **描述** | -| -------- | -------- | -| CAMERA_EVENT_DEVICE_ADD | Camera设备增加事件。 | -| CAMERA_EVENT_DEVICE_RMV | Camera设备删除事件。 | - - -### CameraStatus - - -``` -enum OHOS::Camera::CameraStatus -``` - -**描述:** - -Camera设备状态。 - -| 枚举值 | **描述** | -| -------- | -------- | -| UN_AVAILABLE | 设备当前不在位或者不可用。 | -| AVAILABLE | 设备当前可用。 | - - -### CamRetCode - - -``` -enum OHOS::Camera::CamRetCode : int32_t -``` - -**描述:** - -HDI接口的返回值。 - -| 枚举值 | **描述** | -| -------- | -------- | -| NO_ERROR | 调用成功。 | -| CAMERA_BUSY | 设备当前忙。 | -| INSUFFICIENT_RESOURCES | 资源不足。 | -| INVALID_ARGUMENT | 参数错误。 | -| METHOD_NOT_SUPPORTED | 不支持当前调用方法。 | -| CAMERA_CLOSED | Camera设备已经关闭。 | -| DEVICE_ERROR | 驱动层发生严重错误。 | - - -### EncodeType - - -``` -enum OHOS::Camera::EncodeType : int32_t -``` - -**描述:** - -流数据的编码类型。 - -| 枚举值 | **描述** | -| -------- | -------- | -| ENCODE_TYPE_NULL | 未设置编码类型。 | -| ENCODE_TYPE_H264 | 编码类型为H264。 | -| ENCODE_TYPE_H265 | 编码类型为H265。 | -| ENCODE_TYPE_JPEG | 编码类型为JPEG。 | - - -### ErrorType - - -``` -enum OHOS::Camera::ErrorType : uint32_t -``` - -**描述:** - -设备错误类型,用于设备错误回调 **OnError**。 - -| 枚举值 | **描述** | -| -------- | -------- | -| FATAL_ERROR | 严重错误,需要关闭Camera设备。 | -| REQUEST_TIMEOUT | 请求超时,需要关闭Camera设备。 | - - -### FlashlightStatus - - -``` -enum OHOS::Camera::FlashlightStatus : uint32_t -``` - -**描述:** - -闪光灯状态。 - -| 枚举值 | **描述** | -| -------- | -------- | -| FLASHLIGHT_OFF | 闪光灯关闭。 | -| FLASHLIGHT_ON | 闪光灯开启。 | -| FLASHLIGHT_UNAVAILABLE | 闪光灯当前不可用。 | - - -### OperationMode - - -``` -enum OHOS::Camera::OperationMode : int32_t -``` - -**描述:** - -流的使用模式。 - -| 枚举值 | **描述** | -| -------- | -------- | -| NORMAL | 普通模式。 | - - -### ResultCallbackMode - - -``` -enum OHOS::Camera::ResultCallbackMode : int32_t -``` - -**描述:** - -metadata的上报模式。 - -| 枚举值 | **描述** | -| -------- | -------- | -| PER_FRAME | 每帧上报。 | -| ON_CHANGED | 设备状态变化时上报。 | - - -### StreamError - - -``` -enum OHOS::Camera::StreamError -``` - -**描述:** - -流错误类型,用于流错误类型 [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md)。 - -| 枚举值 | **描述** | -| -------- | -------- | -| UNKNOWN_ERROR | 流未知错误。 | -| BUFFER_LOST | 丢包。 | - - -### StreamIntent - - -``` -enum OHOS::Camera::StreamIntent : int32_t -``` - -**描述:** - -流的类型。 - -| 枚举值 | **描述** | -| -------- | -------- | -| PREVIEW | 流数据用于显示,即预览流。 | -| VIDEO | 流数据用于编码生成录像,即录像流。 | -| STILL_CAPTURE | 流数据用于编码生成照片,即拍照流。 | -| POST_VIEW | 流数据用于保存缩略图。 | -| ANALYZE | 流数据用于图像分析。 | -| CUSTOM | 自定义类型。 | - - -### StreamSupportType - - -``` -enum OHOS::Camera::StreamSupportType : int32_t -``` - -**描述:** - -动态配置流的切换方式,使用场景参考 [IsStreamsSupported](#isstreamssupported) 。 - -| 枚举值 | 描述 | -| -------- | -------- | -| DYNAMIC_SUPPORTED | 支持动态配置流,对应的流参数直接生效。 | -| RE_CONFIGURED_REQUIRED | 不支持动态配置流,对应的参数需要停止流然后重新配置流才能生效。 | -| NOT_SUPPORTED | 不支持对应的流参数配置。 | - - -## **函数说明** - - -### AttachBufferQueue() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::AttachBufferQueue (int streamId, const OHOS::sptr < OHOS::IBufferProducer > & producer ) -``` - -**描述:** - -绑定生产者句柄和指定流。 - -如果在 [CreateStreams](#createstreams) 创建流时已经指定了生产者句柄,则不需要调用该接口。如果需要重新绑定, 需先调用 [DetachBufferQueue](#detachbufferqueue) 进行解绑,然后再绑定。 对于一些IOT设备,可能不需要或者不支持预览流的图像数据缓存流转,那么不需要绑定生产者句柄, 此时在创建流时 [CreateStreams](#createstreams) 的 [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) 参数的生产者句柄bufferQueue_为空,而 tunneledMode_需设置为false。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamId | [IN] 用于标识要绑定的流。 | -| producer | [IN] 生产者句柄。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[DetachBufferQueue](#detachbufferqueue) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### CancelCapture() [1/2] - - -``` -virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::CancelCapture (int captureId) -``` - -**描述:** - -取消捕获请求。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 用于标识要取消的捕获请求。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - - -### CancelCapture() [2/2] - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::CancelCapture (int captureId) -``` - -**描述:** - -取消捕获。 - -取消连续捕获时会调用 **OnCaptureEnded**。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | 用于标识要取消的捕获请求 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[Capture](#capture) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### Capture() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::Capture (int captureId, const std::shared_ptr< CaptureInfo > & info, bool isStreaming ) -``` - -**描述:** - -捕获图像。 - -本接口必须在调用 [CommitStreams](#commitstreams) 配置流之后调用。 图像捕获有两种模式,分别是连续捕获和单次捕获。 - -- 连续捕获即触发之后模块内部进行连续的捕获, 消费者可以连续收到图像数据,不需要多次调用本接口,若再次调用了本接口, 则停止当前捕获,更新捕获信息,再进行一次新的捕获,多用于预览、录像或者连拍场景。 - -- 单次捕获即触发之后只捕获一帧图像数据,用于单次拍照场景。 捕获启动时,会调用 **OnCaptureStarted** 来通知调用者捕获已经启动。 - -连续捕获需调用 [CancelCapture](#cancelcapture-22) 来停止捕获。 捕获结束时,会调用 **OnCaptureEnded** 来通知调用者捕获的帧计数等信息。 [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) 的 enableShutterCallback_ 使能 **OnFrameShutter**,使能后每次捕获触发 **OnFrameShutter** 对于多个流同时捕获的场景,本模块内部保证同时上报多路流捕获数据。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 捕获请求的唯一标识,由调用者指定,调用者需保证在Camera设备打开期间,捕获请求ID是唯一的。 | -| info | [IN] 捕获请求的参数信息,具体信息查看 [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md)。 | -| isStreaming | [IN] 是否连续捕获,true表示连续捕获,否则为单次捕获。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -OnFrameShutter - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### ChangeToOfflineStream() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::ChangeToOfflineStream (const std::vector< int > & streamIds, OHOS::sptr< IStreamOperatorCallback > & callback, OHOS::sptr< IOfflineStreamOperator > & offlineOperator ) -``` - -**描述:** - -将指定流转换成离线流。 - -离线流只能由拍照流转换而来,其他流不支持。 一些设备处理能力有限,可能导致拍照时算法处理时间较长,从而引起捕获请求堆积在模块内部,而转换为离线 流之后,可关闭底层设备,由离线流接替,进行后续的处理。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamIds | [IN] 用于指定要转换成离线流的流集合。 | -| callback | [IN] 用于设置离线流的回调。 | -| offlineOperator | [OUT] 转换后的离线流。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### Close() - - -``` -virtual void OHOS::Camera::ICameraDevice::Close () -``` - -**描述:** - -关闭Camera设备。 - -**参见:** - -[OpenCamera](#opencamera) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### CommitStreams() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::CommitStreams (OperationMode mode, const std::shared_ptr< CameraMetadata > & modeSetting ) -``` - -**描述:** - -配置流。 - -本接口需在调用 [CreateStreams](#createstreams) 创建流之后调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| mode | [IN] 流运行的模式,支持的模式定义在 **OperationMode**。 | -| modeSetting | [IN] 流的配置参数,包括帧率,ZOOM等信息。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### CreateStreams() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::CreateStreams (const std::vector< std::shared_ptr< StreamInfo >> & streamInfos) -``` - -**描述:** - -创建流。 - -此函数接口依据输入的流信息创建流,调用该接口之前需先通过 [IsStreamsSupported](#isstreamssupported) 查询HAL是否支持要创建的流。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamInfos | [IN] 流信息列表,流信息定义在 [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md)。输入的流信息可能会被修改,需通过 [GetStreamAttributes](#getstreamattributes) 获取最新的流属性。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### DetachBufferQueue() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::DetachBufferQueue (int streamId) -``` - -**描述:** - -解除生产者句柄和指定流的绑定关系。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamId | [IN] 用于标识要解除绑定的流。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看[CamRetCode](#camretcode)。 - -**参见:** - -[AttachBufferQueue](#attachbufferqueue) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### DisableResult() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::DisableResult (const std::vector< MetaType > & results) -``` - -**描述:** - -关闭metadata上报开关。 - -屏蔽之后,相应的**OnResult**不再上报,需 [EnableResult](#enableresult) 使能之后才上报。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| results | [IN] 需要关闭上报开关的metadata。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[EnableResult](#enableresult) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### EnableResult() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::EnableResult (const std::vector< MetaType > & results) -``` - -**描述:** - -打开metadata上报开关。 - -**OnResult** 只上报此接口使能后的metadata。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| results | [IN] 需要打开上报开关的metadata。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[DisableResult](#disableresult) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### Get() - - -``` -static sptr OHOS::Camera::ICameraHost::Get (const char * serviceName) -``` - -**描述:** - -获取ICameraHost实例。 - -此接口为Camera调用入口,需要先通过该接口获取ICameraHost实例,然后通过ICameraHost实例进行其它操作。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| serviceName | [IN] 要获取的ICameraHost实例的名称,当前实现中实例名称固定为camera_service。 | - -**返回:** - -成功返回ICameraHost实例,失败返回nullptr。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### GetCameraAbility() - - -``` -virtual CamRetCode OHOS::Camera::ICameraHost::GetCameraAbility (const std::string & cameraId, std::shared_ptr< CameraAbility > & ability ) -``` - -**描述:** - -获取Camera设备能力集合。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | [IN] 用于指定要操作的Camera设备,通过 [GetCameraIds](#getcameraids) 获取。 | -| ability | [OUT] 返回cameraId对应Camera设备的能力集合。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[GetCameraIds](#getcameraids) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### GetCameraIds() - - -``` -virtual CamRetCode OHOS::Camera::ICameraHost::GetCameraIds (std::vector< std::string > & cameraIds) -``` - -**描述:** - -获取当前可用的Camera设备ID列表。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraIds | [OUT] 返回当前可用的设备列表 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[GetCameraAbility](#getcameraability) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### GetEnabledResults() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::GetEnabledResults (std::vector< MetaType > & results) -``` - -**描述:** - -查询使能的metadata。 - -[EnableResult](#enableresult) 使能需要上报的metadata之后,可通过此接口查询使能的metadata。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| results | [OUT] 所有使能的metadata。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### GetStreamAttributes() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::GetStreamAttributes (std::vector< std::shared_ptr< StreamAttribute >> & attributes) -``` - -**描述:** - -获取流的属性。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| attributes | [OUT] 用于获取流的属性。在调用[CreateStreams](#createstreams) 时,通过参数streamInfos携带的流信息可能会被重写,因此通过该接口获取的流属性可能会和 [CreateStreams](#createstreams) 输入的流信息存在差异。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### GetStreamOperator() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::GetStreamOperator (const OHOS::sptr< IStreamOperatorCallback > & callback, OHOS::sptr< IStreamOperator > & streamOperator ) -``` - -**描述:** - -获取流操作句柄。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| callback | [IN] 设置流回调接口,详细可查看 [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md), 用于上报捕获开始 **OnCaptureStarted**,捕获结束 **OnCaptureEnded**, **OnCaptureError** 捕获错误等信息。 | -| streamOperator | [OUT] 返回流操作句柄。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### IsStreamsSupported() - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::IsStreamsSupported (OperationMode mode, const std::shared_ptr< CameraMetadata > & modeSetting, const std::vector< std::shared_ptr< StreamInfo >> & info, StreamSupportType & type ) -``` - -**描述:** - -查询是否支持添加参数对应的流。 - -流是指从底层设备输出,经本模块内部各环节处理,最终传递到上层服务或者应用的一组数据序列 本模块支持的流的类型有预览流,录像流,拍照流等,更多类型可查看 **StreamIntent**。 - -此函数接口根据输入的运行模式和配置信息以及当前模块中正在运行的流,查询是否支持动态添加流。 - -- 如果本模块支持在不停止其他流的情况下添加新流,或者即使停止其他流但上层服务或应用不感知,则通过type参数返回DYNAMIC_SUPPORTED,上层服务或应用可以直接添加新流。 - -- 如果本模块支持添加新流但需要上层服务或应用先停止所有流的捕获,则通过type参数返回RE_CONFIGURED_REQUIRED。 - -- 如果不支持添加输入的新流,则返回NOT_SUPPORTED。 - -此函数需要在调用 [CreateStreams](#createstreams) 创建流之前调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| mode | [IN] 流运行的模式,支持的模式参考 **OperationMode**。 | -| modeSetting | [IN] 流的配置,包括帧率,3A等配置信息。 | -| info | [IN] 流的配置信息,具体参考 [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md)。 | -| type | [OUT] 对动态配置流的支持类型,支持类型定义在 **StreamSupportType**。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnCameraEvent() - - -``` -virtual void OHOS::Camera::ICameraHostCallback::OnCameraEvent (const std::string & cameraId, CameraEvent event ) -``` - -**描述:** - -在相机事件发生时调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | 表示相机事件绑定的相机ID。 | -| event | 表示相机事件类型。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnCameraStatus() - - -``` -virtual void OHOS::Camera::ICameraHostCallback::OnCameraStatus (const std::string & cameraId, CameraStatus status ) -``` - -**描述:** - -用于Camera设备状态变化时上报状态信息给调用者。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | [IN] 状态发生变化的Camera设备ID。 | -| status | [IN] 最新的设备状态。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnCaptureEnded() - - -``` -virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureEnded (int32_t captureId, const std::vector< std::shared_ptr< CaptureEndedInfo >> & infos ) -``` - -**描述:** - -捕获结束回调,在捕获结束时调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 用于标识回调对应的捕获请求。 | -| infos | [IN] 捕获结束相关信息。 | - -**参见:** - -[OnCaptureStarted](#oncapturestarted) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnCaptureError() - - -``` -virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureError (int32_t captureId, const std::vector< std::shared_ptr< CaptureErrorInfo >> & infos ) -``` - -**描述:** - -捕获错误回调,在捕获过程中发生错误时调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 用于标识回调对应的捕获请求。 | -| infos | [IN] 捕获错误信息列表。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnCaptureStarted() - - -``` -virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureStarted (int32_t captureId, const std::vector< int32_t > & streamIds ) -``` - -**描述:** - -捕获开始回调,在捕获开始时调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 用于标识回调对应的捕获请求。 | -| streamIds | [IN] 回调对应的流集合。 | - -**参见:** - -[OnCaptureEnded](#oncaptureended) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnError() - - -``` -virtual void OHOS::Camera::ICameraDeviceCallback::OnError (ErrorType type, int32_t errorCode ) -``` - -**描述:** - -设备发生错误时调用,由调用者实现,用于返回错误信息给调用者。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| type | [IN] 错误类型,具体错误类型可参考 **ErrorType**。 | -| errorCode | [IN] 错误码,当前暂未使用。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnFlashlightStatus() - - -``` -virtual void OHOS::Camera::ICameraHostCallback::OnFlashlightStatus (const std::string & cameraId, FlashlightStatus status ) -``` - -**描述:** - -用于在闪光灯状态变化时上报状态信息给调用者。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | [IN] 状态发生变化的闪关灯所绑定的Camera设备ID。 | -| status | [IN] 最新的闪光灯状态。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnFrameShutter() - - -``` -virtual void OHOS::Camera::IStreamOperatorCallback::OnFrameShutter (int32_t captureId, const std::vector< int32_t > & streamIds, uint64_t timestamp ) -``` - -**描述:** - -帧捕获回调。 - -通过 **Capture** 的输入参数 [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) 的enableShutterCallback_使能该回调, 使能后每次捕获均会触发此回调。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| captureId | [IN] 用于标识回调对应的捕获请求。 | -| streamIds | [IN] 回调对应的流集合。 | -| timestamp | [IN] 该接口被调用时的时间戳。 | - -**参见:** - -Capture - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OnResult() - - -``` -virtual void OHOS::Camera::ICameraDeviceCallback::OnResult (uint64_t timestamp, const std::shared_ptr< CameraMetadata > & result ) -``` - -**描述:** - -上报Camera设备相关的metadata的回调,上报方式查看 [SetResultMode](#setresultmode)。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| timestamp | [IN] metadata上报的时间戳。 | -| result | [IN] 上报的metadata,上报的metadata由 **EnableResult** 指定, 可通过 **GetEnabledResults** 查询,**DisableResult** 关闭上报开关。 | - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### OpenCamera() - - -``` -virtual CamRetCode OHOS::Camera::ICameraHost::OpenCamera (const std::string & cameraId, const OHOS::sptr< ICameraDeviceCallback > & callback, OHOS::sptr< ICameraDevice > & device ) -``` - -**描述:** - -打开Camera设备。 - -打开指定的Camera设备,通过此接口可以获取到ICameraDevice对象,通过ICameraDevice对象可以操作具体的Camera设备。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | [IN] 需要打开的Camera设备ID,可通过 [GetCameraIds](#getcameraids) 接口获取当前已有Camera设备列表。 | -| callback | [IN] Camera设备相关的回调函数,具体参见 [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md)。 | -| device | [OUT] 返回当前要打开的Camera设备ID对应的ICameraDevice对象。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[GetCameraIds](#getcameraids) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### Release() - - -``` -virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::Release () -``` - -**描述:** - -释放所有离线流。 - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### ReleaseStreams() [1/2] - - -``` -virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::ReleaseStreams (const std::vector< int > & streamIds) -``` - -**描述:** - -释放离线流。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamIds | 用于标识要释放的离线流集合。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### ReleaseStreams() [2/2] - - -``` -virtual CamRetCode OHOS::Camera::IStreamOperator::ReleaseStreams (const std::vector< int > & streamIds) -``` - -**描述:** - -释放流。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| streamIds | [IN] 要释放的流ID列表。 | - -**返回:** - -NO_ERROR 表示执行成功; - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### SetCallback() - - -``` -virtual CamRetCode OHOS::Camera::ICameraHost::SetCallback (const OHOS::sptr< ICameraHostCallback > & callback) -``` - -**描述:** - -设置ICameraHost回调接口,回调函数参考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| callback | [IN] 要设置的回调函数。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### SetFlashlight() - - -``` -virtual CamRetCode OHOS::Camera::ICameraHost::SetFlashlight (const std::string & cameraId, bool & isEnable ) -``` - -**描述:** - -打开或关闭闪光灯。 - -该接口只能由打开cameraId指定Camera设备的调用者调用。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| cameraId | [IN] 闪光灯对应的Camera设备ID。 | -| isEnable | [IN] true打开闪光灯,false关闭闪光灯。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**参见:** - -[GetCameraIds](#getcameraids) - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### SetResultMode() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::SetResultMode (const ResultCallbackMode & mode) -``` - -**描述:** - -设置metadata上报模式,逐帧上报还是设备状态变化时上报。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| mode | [IN] metadata的上报模式,逐帧上报或者设备状态变化时上报,查看 **ResultCallbackMode**。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### UpdateSettings() - - -``` -virtual CamRetCode OHOS::Camera::ICameraDevice::UpdateSettings (const std::shared_ptr< CameraSetting > & settings) -``` - -**描述:** - -更新设备控制参数。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| settings | [IN] Camera设置参数,包括sensor帧率,3A相关参数等。 | - -**返回:** - -NO_ERROR 表示执行成功。 - -其他值表示执行失败,具体错误码查看 [CamRetCode](#camretcode)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **变量说明** - - -### bufferQueue_ - - -``` -OHOS::sptr OHOS::Camera::StreamInfo::bufferQueue_ -``` - -**描述:** - -图形提供的生产者句柄。 - - -### captureSetting_ - - -``` -std::shared_ptr OHOS::Camera::CaptureInfo::captureSetting_ -``` - -**描述:** - -捕获的配置信息。 - - -### dataspace_ - - -``` -int OHOS::Camera::StreamInfo::dataspace_ -``` - -**描述:** - -图像颜色空间。 - - -### enableShutterCallback_ - - -``` -bool OHOS::Camera::CaptureInfo::enableShutterCallback_ -``` - -**描述:** - -使能捕获回调,每一次捕获后都会触发 **OnFrameShutter**。 - - -### encodeType_ - - -``` -EncodeType OHOS::Camera::StreamInfo::encodeType_ -``` - -**描述:** - -编码类型。 - - -### error_ - - -``` -StreamError OHOS::Camera::CaptureErrorInfo::error_ -``` - -**描述:** - -错误类型。 - - -### format_ - - -``` -int OHOS::Camera::StreamInfo::format_ -``` - -**描述:** - -图像格式。 - - -### frameCount_ - - -``` -int OHOS::Camera::CaptureEndedInfo::frameCount_ -``` - -**描述:** - -捕获结束时已经抓取的帧数。 - - -### height_ [1/2] - - -``` -int OHOS::Camera::StreamInfo::height_ -``` - -**描述:** - -图像高度。 - - -### height_ [2/2] - - -``` -int OHOS::Camera::StreamAttribute::height_ -``` - -**描述:** - -图像高度。 - - -### intent_ - - -``` -StreamIntent OHOS::Camera::StreamInfo::intent_ -``` - -**描述:** - -流类型。 - - -### maxBatchCaptureCount_ - - -``` -int OHOS::Camera::StreamAttribute::maxBatchCaptureCount_ -``` - -**描述:** - -连拍支持的最大捕获帧数量。 - - -### maxCaptureCount_ - - -``` -int OHOS::Camera::StreamAttribute::maxCaptureCount_ -``` - -**描述:** - -最大的并发捕获请求个数,默认为1。 - - -### minFrameDuration_ - - -``` -int OHOS::Camera::StreamInfo::minFrameDuration_ -``` - -**描述:** - -最小帧间隔。 - - -### overrideDataspace_ - - -``` -int OHOS::Camera::StreamAttribute::overrideDataspace_ -``` - -**描述:** - -重写的图像颜色空间。 - - -### overrideFormat_ - - -``` -int OHOS::Camera::StreamAttribute::overrideFormat_ -``` - -**描述:** - -重写的图像格式。 - - -### producerBufferCount_ - - -``` -int OHOS::Camera::StreamAttribute::producerBufferCount_ -``` - -**描述:** - -重写后的生产者缓存数量。 - - -### producerUsage_ - - -``` -int OHOS::Camera::StreamAttribute::producerUsage_ -``` - -**描述:** - -重写后的生产者的使用方式。 - - -### streamId_ [1/4] - - -``` -int OHOS::Camera::StreamInfo::streamId_ -``` - -**描述:** - -流的ID,用于在设备内唯一标识一条流。 - - -### streamId_ [2/4] - - -``` -int OHOS::Camera::StreamAttribute::streamId_ -``` - -**描述:** - -流的ID,用于在设备内唯一标识一条流。 - - -### streamId_ [3/4] - - -``` -int OHOS::Camera::CaptureEndedInfo::streamId_ -``` - -**描述:** - -捕获的流ID。 - - -### streamId_ [4/4] - - -``` -int OHOS::Camera::CaptureErrorInfo::streamId_ -``` - -**描述:** - -流ID。 - - -### streamIds_ - - -``` -std::vector OHOS::Camera::CaptureInfo::streamIds_ -``` - -**描述:** - -捕获的流ID集合。 - - -### tunneledMode_ - - -``` -bool OHOS::Camera::StreamInfo::tunneledMode_ -``` - -**描述:** - -隧道模式,值为true时开启,false关闭。 - -开启隧道模式后,HAL不直接和上层交互,通过图形提供的生产者句柄来传递帧数据, 对于一些IOT设备,可能不需要或者不支持预览流的图像数据缓存流转,此时需要关闭隧道模式。 - - -### width_ [1/2] - - -``` -int OHOS::Camera::StreamInfo::width_ -``` - -**描述:** - -图像宽度。 - - -### width_ [2/2] - - -``` -int OHOS::Camera::StreamAttribute::width_ -``` - -**描述:** - -图像宽度。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_capture_ended_info.md b/zh-cn/device-dev/reference/hdi-apis/_capture_ended_info.md new file mode 100644 index 0000000000000000000000000000000000000000..d7e78cd69f34dee27853269c19d48b5589951e0d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_capture_ended_info.md @@ -0,0 +1,48 @@ +# CaptureEndedInfo + + +## **概述** + +捕获结束相关信息,用于捕获结束回调[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [streamId_](#streamid) | 捕获的流ID。 | +| [frameCount_](#framecount) | 捕获结束时已经抓取的帧数。 | + + +## **类成员变量说明** + + +### frameCount_ + + +``` +int CaptureEndedInfo::frameCount_ +``` + +**描述:** + +捕获结束时已经抓取的帧数。 + + +### streamId_ + + +``` +int CaptureEndedInfo::streamId_ +``` + +**描述:** + +捕获的流ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_capture_error_info.md b/zh-cn/device-dev/reference/hdi-apis/_capture_error_info.md new file mode 100644 index 0000000000000000000000000000000000000000..76cda626af0b840ad2d2ebe5e8493c2bfa5714b2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_capture_error_info.md @@ -0,0 +1,48 @@ +# CaptureErrorInfo + + +## **概述** + +流错误信息,用于回调[OnCaptureError](interface_i_stream_operator_callback.md#oncaptureerror)。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [streamId_](#streamid) | 流ID。 | +| [error_](#error) | 错误类型。 | + + +## **类成员变量说明** + + +### error_ + + +``` +enum StreamError CaptureErrorInfo::error_ +``` + +**描述:** + +错误类型。 + + +### streamId_ + + +``` +int CaptureErrorInfo::streamId_ +``` + +**描述:** + +流ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_capture_info.md b/zh-cn/device-dev/reference/hdi-apis/_capture_info.md new file mode 100644 index 0000000000000000000000000000000000000000..b6b69fa0dc996f00361e19f6927c7a48ae7999dc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_capture_info.md @@ -0,0 +1,61 @@ +# CaptureInfo + + +## **概述** + +捕获请求的相关信息。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [streamIds_](#streamids) | 捕获的流ID集合。 | +| [captureSetting_](#capturesetting) | 捕获的配置信息。 | +| [enableShutterCallback_](#enableshuttercallback) | 使能捕获回调。 | + + +## **类成员变量说明** + + +### captureSetting_ + + +``` +unsigned char [] CaptureInfo::captureSetting_ +``` + +**描述:** + +捕获的配置信息。 + + +### enableShutterCallback_ + + +``` +boolean CaptureInfo::enableShutterCallback_ +``` + +**描述:** + +使能捕获回调,每一次捕获后都会触发[OnFrameShutter](interface_i_stream_operator_callback.md#onframeshutter)。 + + +### streamIds_ + + +``` +int [] CaptureInfo::streamIds_ +``` + +**描述:** + +捕获的流ID集合。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec.md b/zh-cn/device-dev/reference/hdi-apis/_codec.md deleted file mode 100644 index f3eea39775c59854ce737f602b09aed8711e69fd..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_codec.md +++ /dev/null @@ -1,1346 +0,0 @@ -# Codec - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [codec_callback_if.h](codec__callback__if_8h.md) | 主要包括回调函数接口定义。 | -| [codec_common_type.h](codec__common__type_8h.md) | Codec模块接口定义中使用的自定义数据类型。 | -| [codec_component_if.h](codec__component__if_8h.md) | 主要包括Codec组件接口定义。 | -| [codec_component_manager.h](codec__component__manager_8h.md) | 主要包括Codec组件管理类接口。 | -| [codec_component_type.h](codec__component__type_8h.md) | Codec模块接口定义中使用的自定义数据类型。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [CodecCallbackType](_codec_callback_type.md) | Codec回调接口定义。 [更多...](_codec_callback_type.md) | -| [Alignment](_alignment.md) | 对齐结构定义,包含宽高的对齐值。 [更多...](_alignment.md) | -| [Rect](_rect.md) | 矩形的定义。 [更多...](_rect.md) | -| [RangeValue](_range_value.md) | 取值范围的定义。 [更多...](_range_value.md) | -| [CodecComponentType](_codec_component_type.md) | Codec组件接口定义。 [更多...](_codec_component_type.md) | -| [CodecComponentManager](_codec_component_manager.md) | Codec组件管理类接口定义。 [更多...](_codec_component_manager.md) | -| [VideoPortCap](_video_port_cap.md) | 定义视频编解码能力。 [更多...](_video_port_cap.md) | -| [AudioPortCap](_audio_port_cap.md) | 定义音频编解码能力。 [更多...](_audio_port_cap.md) | -| [PortCap](union_port_cap.md) | 定义音视频编解码能力。 [更多...](union_port_cap.md) | -| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解码能力。 [更多...](_codec_comp_capability.md) | -| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec buffer信息的定义。 [更多...](_omx_codec_buffer.md) | -| [CompVerInfo](_comp_ver_info.md) | 定义组件版本信息。 [更多...](_comp_ver_info.md) | -| [EventInfo](_event_info.md) | 定义事件上报信息。 [更多...](_event_info.md) | -| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义。 [更多...](_support_buffer_type.md) | -| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义。 [更多...](_use_buffer_type.md) | -| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义。 [更多...](_get_buffer_handle_usage_params.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| SAMPLE_FMT_NUM    32 | 采样格式最大值。 | -| UUID_LENGTH    128 | 定义UUID长度。 | -| PIX_FORMAT_NUM    16 | 支持的像素格式数组大小。 | -| SAMPLE_FORMAT_NUM    12 | 支持的音频采样格式数组大小。 | -| SAMPLE_RATE_NUM    16 | 支持的音频采样率数组大小。 | -| CHANNEL_NUM    16 | 支持的音频通道数组大小。 | -| NAME_LENGTH    32 | 组件名称大小。 | -| PROFILE_NUM    256 | 支持的profile数组大小。 | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [CodecType](#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER,   INVALID_TYPE } | 枚举编解码的类型。 [更多...](#codectype) | -| [Profile](#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE,   AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000,   AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codec规格。 [更多...](#profile) | -| [AudioSampleRate](#audiosamplerate) {   AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000,   AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100,   AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | 枚举音频采样率。 [更多...](#audiosamplerate) | -| [CodecCapsMask](#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举播放能力。 [更多...](#codeccapsmask) | -| [CodecProcessMode](#codecprocessmode) {   PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100,   PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解码处理模式。 [更多...](#codecprocessmode) | -| [AvCodecRole](#avcodecrole) {   MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000,   MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726,   MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解码组件类型。 [更多...](#avcodecrole) | -| [AudioSampleFormat](#audiosampleformat) {   AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 枚举音频采样格式。 [更多...](#audiosampleformat) | -| [CodecBufferType](#codecbuffertype) {   CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4,   CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型。 [更多...](#codecbuffertype) | -| [ShareMemTypes](#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内存类型。 [更多...](#sharememtypes) | -| [OmxIndexCodecExType](#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index。 [更多...](#omxindexcodecextype) | -| [OmxVideoExType](#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编码类型。 [更多...](#omxvideoextype) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [CodecCallbackTypeGet](#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 [更多...](#codeccallbacktypeget) | -| [CodecCallbackTypeRelease](#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 [更多...](#codeccallbacktyperelease) | -| [CodecComponentTypeGet](#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 [更多...](#codeccomponenttypeget) | -| [CodecComponentTypeRelease](#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 [更多...](#codeccomponenttyperelease) | -| [GetCodecComponentManager](#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 [更多...](#getcodeccomponentmanager) | -| [CodecComponentManagerRelease](#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 [更多...](#codeccomponentmanagerrelease) | - - -### 变量 - - | 变量 | 描述 | -| -------- | -------- | -| [CodecCallbackType::remote](#remote) | 指向HdfRemoteService的指针。 [更多...](#remote) | -| ( [CodecCallbackType::EventHandler](#eventhandler) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, enum OMX_EVENTTYPE event, struct [EventInfo](_event_info.md) \*info) | 事件上报。 [更多...](#eventhandler) | -| ( [CodecCallbackType::EmptyBufferDone](#emptybufferdone) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, int8_t \*appData, uint32_t appDataLen, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输入buffer编码或者解码处理完毕。 [更多...](#emptybufferdone) | -| ( [CodecCallbackType::FillBufferDone](#fillbufferdone) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, int8_t \*appData, uint32_t appDataLen, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输出buffer填充完毕。 [更多...](#fillbufferdone) | -| ( [CodecComponentType::GetComponentVersion](#getcomponentversion) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [CompVerInfo](_comp_ver_info.md) \*verInfo) | 获取Codec组件版本号。 [更多...](#getcomponentversion) | -| ( [CodecComponentType::SendCommand](#sendcommand) )(struct [CodecComponentType](_codec_component_type.md) \*self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t \*cmdData, uint32_t cmdDataLen) | 发送命令给组件。 [更多...](#sendcommand) | -| ( [CodecComponentType::GetParameter](#getparameter) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t paramIndex, int8_t \*paramStruct, uint32_t paramStructLen) | 获取组件参数设置。 [更多...](#getparameter) | -| ( [CodecComponentType::SetParameter](#setparameter) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*paramStruct, uint32_t paramStructLen) | 设置组件需要的参数。 [更多...](#setparameter) | -| ( [CodecComponentType::GetConfig](#getconfig) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 获取组件的配置结构。 [更多...](#getconfig) | -| ( [CodecComponentType::SetConfig](#setconfig) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 设置组件的配置。 [更多...](#setconfig) | -| ( [CodecComponentType::GetExtensionIndex](#getextensionindex) )(struct [CodecComponentType](_codec_component_type.md) \*self, const char \*paramName, uint32_t \*indexType) | 根据字符串获取组件的扩展索引。 [更多...](#getextensionindex) | -| ( [CodecComponentType::GetState](#getstate) )(struct [CodecComponentType](_codec_component_type.md) \*self, enum OMX_STATETYPE \*state) | 获取组件的当前状态。 [更多...](#getstate) | -| ( [CodecComponentType::ComponentTunnelRequest](#componenttunnelrequest) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE \*tunnelSetup) | 设置组件采用Tunnel方式通信。 [更多...](#componenttunnelrequest) | -| ( [CodecComponentType::UseBuffer](#usebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 指定组件端口的buffer。 [更多...](#usebuffer) | -| ( [CodecComponentType::AllocateBuffer](#allocatebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 向组件申请端口buffer。 [更多...](#allocatebuffer) | -| ( [CodecComponentType::FreeBuffer](#freebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 释放buffer。 [更多...](#freebuffer) | -| ( [CodecComponentType::EmptyThisBuffer](#emptythisbuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解码输入待处理buffer。 [更多...](#emptythisbuffer) | -| ( [CodecComponentType::FillThisBuffer](#fillthisbuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解码输出填充buffer。 [更多...](#fillthisbuffer) | -| ( [CodecComponentType::SetCallbacks](#setcallbacks) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [CodecCallbackType](_codec_callback_type.md) \*callback, int8_t \*appData, uint32_t appDataLen) | 设置Codec组件的回调函数。 [更多...](#setcallbacks) | -| ( [CodecComponentType::ComponentDeInit](#componentdeinit) )(struct [CodecComponentType](_codec_component_type.md) \*self) | 组件去初始化。 [更多...](#componentdeinit) | -| ( [CodecComponentType::UseEglImage](#useeglimage) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer, uint32_t portIndex, int8_t \*eglImage, uint32_t eglImageLen) | 使用已在EGL中申请的空间。 [更多...](#useeglimage) | -| ( [CodecComponentType::ComponentRoleEnum](#componentroleenum) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint8_t \*role, uint32_t roleLen, uint32_t index) | 获取组件角色。 [更多...](#componentroleenum) | - - -## **详细描述** - -Codec模块接口定义。 - -Codec模块涉及自定义类型、音视频编解码组件初始化、参数设置、数据的轮转和控制等。 - -**Since:** - -3.1 - -**Version:** - -2.0 - - -## **枚举类型说明** - - -### AudioSampleFormat - - -``` -enum AudioSampleFormat -``` - -**描述:** - -枚举音频采样格式。 - -- 对于planar的采样格式,每个声道的数据是独立存储在data中。 - -- 对于packed的采样格式,只使用第一个data,每个声道的数据是交错存储的。 - -| 枚举值 | 描述 | -| -------- | -------- | -| AUDIO_SAMPLE_FORMAT_S8 | 8bit位宽有符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_S8P | 8bit位宽有符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_U8 | 8bit位宽无符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_U8P | 8bit位宽无符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_S16 | 16bit位宽有符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_S16P | 16bit位宽有符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_U16 | 16bit位宽无符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_U16P | 16bit位宽无符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_S24 | 24bit位宽有符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_S24P | 24bit位宽有符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_U24 | 24bit位宽无符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_U24P | 24bit位宽无符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_S32 | 32bit位宽有符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_S32P | 32bit位宽有符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_U32 | 32bit位宽无符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_U32P | 32bit位宽无符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_S64 | 64bit位宽有符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_S64P | 64bit位宽有符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_U64 | 64bit位宽无符号交织样本。 | -| AUDIO_SAMPLE_FORMAT_U64P | 64bit位宽无符号非交织样本。 | -| AUDIO_SAMPLE_FORMAT_F32 | 32bit位宽浮点型交织样本。 | -| AUDIO_SAMPLE_FORMAT_F32P | 64bit位宽浮点型非交织样本。 | -| AUDIO_SAMPLE_FORMAT_F64 | 64bit位宽双精度浮点型交织样本。 | -| AUDIO_SAMPLE_FORMAT_F64P | 64bit位宽双精度浮点型非交织样本。 | -| AUDIO_SAMPLE_FMT_U8 | 无符号8位整型,打包格式。 | -| AUDIO_SAMPLE_FMT_S16 | 带符号16位整型,打包格式。 | -| AUDIO_SAMPLE_FMT_S32 | 带符号32位整型,打包格式。 | -| AUDIO_SAMPLE_FMT_FLOAT | 浮点型,打包格式。 | -| AUDIO_SAMPLE_FMT_DOUBLE | 双精度浮点型,打包格式。 | -| AUDIO_SAMPLE_FMT_U8P | 无符号8位整型,平面格式。 | -| AUDIO_SAMPLE_FMT_S16P | 带符号16位整型,平面格式。 | -| AUDIO_SAMPLE_FMT_S32P | 带符号32位整型,平面格式。 | -| AUDIO_SAMPLE_FMT_FLOATP | 浮点型,平面格式。 | -| AUDIO_SAMPLE_FMT_DOUBLEP | 双精度浮点型,平面格式。 | -| AUDIO_SAMPLE_FMT_INVALID | 无效采样格式。 | - - -### AudioSampleRate - - -``` -enum AudioSampleRate -``` - -**描述:** - -枚举音频采样率 - - | 枚举值 | 描述 | -| -------- | -------- | -| AUD_SAMPLE_RATE_8000 | 8K采样率 | -| AUD_SAMPLE_RATE_12000 | 12K采样率 | -| AUD_SAMPLE_RATE_11025 | 11.025K采样率 | -| AUD_SAMPLE_RATE_16000 | 16K采样率 | -| AUD_SAMPLE_RATE_22050 | 22.050K采样率 | -| AUD_SAMPLE_RATE_24000 | 24K采样率 | -| AUD_SAMPLE_RATE_32000 | 32K采样率 | -| AUD_SAMPLE_RATE_44100 | 44.1K采样率 | -| AUD_SAMPLE_RATE_48000 | 48K采样率 | -| AUD_SAMPLE_RATE_64000 | 64K采样率 | -| AUD_SAMPLE_RATE_96000 | 96K采样率 | -| AUD_SAMPLE_RATE_INVALID | 无效采样率 | - - -### AvCodecRole - - -``` -enum AvCodecRole -``` - -**描述:** - -枚举音视频编解码组件类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| MEDIA_ROLETYPE_IMAGE_JPEG | 图像JPEG媒体类型 | -| MEDIA_ROLETYPE_VIDEO_AVC | 视频H.264媒体类型 | -| MEDIA_ROLETYPE_VIDEO_HEVC | 视频H.265媒体类型 | -| MEDIA_ROLETYPE_AUDIO_FIRST | 音频编解码器类型 | -| MEDIA_ROLETYPE_AUDIO_AAC | 音频AAC媒体类型 | -| MEDIA_ROLETYPE_AUDIO_G711A | 音频G711A媒体类型 | -| MEDIA_ROLETYPE_AUDIO_G711U | 音频G711U媒体类型 | -| MEDIA_ROLETYPE_AUDIO_G726 | 音频G726媒体类型 | -| MEDIA_ROLETYPE_AUDIO_PCM | 音频PCM媒体类型 | -| MEDIA_ROLETYPE_AUDIO_MP3 | 音频MP3媒体类型 | -| MEDIA_ROLETYPE_INVALID | 无效媒体类型 | - - -### CodecBufferType - - -``` -enum CodecBufferType -``` - -**描述:** - -定义buffer类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| CODEC_BUFFER_TYPE_INVALID | 无效buffer类型 | -| CODEC_BUFFER_TYPE_VIRTUAL_ADDR | 虚拟地址类型 | -| CODEC_BUFFER_TYPE_AVSHARE_MEM_FD | 共享内存类型 | -| CODEC_BUFFER_TYPE_HANDLE | handle类型 | -| CODEC_BUFFER_TYPE_DYNAMIC_HANDLE | 动态handle类型 | - - -### CodecCapsMask - - -``` -enum CodecCapsMask -``` - -**描述:** - -枚举播放能力。 - - | 枚举值 | 描述 | -| -------- | -------- | -| CODEC_CAP_ADAPTIVE_PLAYBACK | 自适应播放能力 | -| CODEC_CAP_SECURE_PLAYBACK | 安全播放能力 | -| CODEC_CAP_TUNNEL_PLAYBACK | 通道播放能力 | -| CODEC_CAP_MULTI_PLANE | 视频图像平面/音频通道平面能力 | - - -### CodecProcessMode - - -``` -enum CodecProcessMode -``` - -**描述:** - -枚举编解码处理模式。 - - | 枚举值 | 描述 | -| -------- | -------- | -| PROCESS_BLOCKING_INPUT_BUFFER | 同步模式输入buffer | -| PROCESS_BLOCKING_OUTPUT_BUFFER | 同步模式输出buffer | -| PROCESS_BLOCKING_CONTROL_FLOW | 同步模式控制流 | -| PROCESS_NONBLOCKING_INPUT_BUFFER | 异步模式输入buffer | -| PROCESS_NONBLOCKING_OUTPUT_BUFFER | 异步模式输出buffer | -| PROCESS_NONBLOCKING_CONTROL_FLOW | 异步模式控制流 | - - -### CodecType - - -``` -enum CodecType -``` - -**描述:** - -枚举编解码的类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| VIDEO_DECODER | 视频解码类型 | -| VIDEO_ENCODER | 视频编码类型 | -| AUDIO_DECODER | 音频解码类型 | -| AUDIO_ENCODER | 音频编码类型 | -| INVALID_TYPE | 无效类型 | - - -### OmxIndexCodecExType - - -``` -enum OmxIndexCodecExType -``` - -**描述:** - -枚举Codec扩展index。 - - | 枚举值 | 描述 | -| -------- | -------- | -| OMX_IndexExtBufferTypeStartUnused | BufferType 扩展index | -| OMX_IndexParamSupportBufferType | SupportBuffer类型 | -| OMX_IndexParamUseBufferType | UseBuffer类型 | -| OMX_IndexParamGetBufferHandleUsage | GetBufferHandleUsage类型 | - - -### OmxVideoExType - - -``` -enum OmxVideoExType -``` - -**描述:** - -枚举Codec扩展编码类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| OMX_VIDEO_CodingHEVC | HEVC编码类型 | - - -### Profile - - -``` -enum Profile -``` - -**描述:** - -枚举Codec规格。 - - | 枚举值 | 描述 | -| -------- | -------- | -| INVALID_PROFILE | 无效的规格。 | -| AAC_LC_PROFILE | AAC低复杂度规格。 | -| AAC_MAIN_PROFILE | AAC主规格。 | -| AAC_HE_V1_PROFILE | AAC高效率和频带重现规格,又称为HEAAC,AAC+,或者AACPlusV1。 | -| AAC_HE_V2_PROFILE | AAC高效率和频带重现以及变量立体声规格,又称为AAC++或者AACPlusV2。 | -| AAC_LD_PROFILE | AAC低延迟规格。 | -| AAC_ELD_PROFILE | AAC增强型低延迟规格。 | -| AVC_BASELINE_PROFILE | H.264低规格。 | -| AVC_MAIN_PROFILE | H.264主规格。 | -| AVC_HIGH_PROFILE | H.264高规格。 | -| HEVC_MAIN_PROFILE | H.265主规格。 | -| HEVC_MAIN_10_PROFILE | H.265 10比特主规格。 | - - -### ShareMemTypes - - -``` -enum ShareMemTypes -``` - -**描述:** - -枚举共享内存类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| READ_WRITE_TYPE | 可读可写的共享内存类型 | -| READ_ONLY_TYPE | 可读的共享内存类型 | - - -## **函数说明** - - -### CodecCallbackTypeGet() - - -``` -struct CodecCallbackType* CodecCallbackTypeGet (struct HdfRemoteService * remote) -``` - -**描述:** - -实例化CodecCallbackType对象。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| remote | 输入参数,指向HdfRemoteService的指针。 | - -**返回:** - -实例化CodecCallbackType对象。 - -**Since:** - -3.1 - - -### CodecCallbackTypeRelease() - - -``` -void CodecCallbackTypeRelease (struct CodecCallbackType * instance) -``` - -**描述:** - -释放CodecCallbackType对象。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| instance | 输入参数,指向CodecCallbackType实例的指针。 | - -**Since:** - -3.1 - - -### CodecComponentManagerRelease() - - -``` -void CodecComponentManagerRelease (void ) -``` - -**描述:** - -释放CodecComponentManager对象。 - -**Since:** - -3.1 - - -### CodecComponentTypeGet() - - -``` -struct CodecComponentType* CodecComponentTypeGet (struct HdfRemoteService * remote) -``` - -**描述:** - -实例化CodecComponentType对象。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| remote | 输入参数,指向RemoteService的指针。 | - -**返回:** - -实例化的CodecComponentType对象。 - -**Since:** - -3.1 - - -### CodecComponentTypeRelease() - - -``` -void CodecComponentTypeRelease (struct CodecComponentType * instance) -``` - -**描述:** - -释放CodecComponentType对象。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| instance | 输入参数,指向CodecComponentType实例的指针。 | - -**Since:** - -3.1 - - -### GetCodecComponentManager() - - -``` -struct CodecComponentManager* GetCodecComponentManager (void ) -``` - -**描述:** - -实例化CodecComponentManager对象。 - -**返回:** - -实例化的CodecComponentManager对象。 - -**Since:** - -3.1 - - -## **变量说明** - - -### AllocateBuffer - - -``` -int32_t(* CodecComponentType::AllocateBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) -``` - -**描述:** - -向组件申请端口buffer。 - -向组件申请分配新的buffer,此接口在以下情况下使用: - -- 当组件处于OMX_StateLoaded状态,并且用户已经向组件发送OMX_StateIdle状态转换请求。 - -- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 - -- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| portIndex | 输入参数,指定的组件端口。 | -| buffer | 输入输出参数,指向要申请的buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | - -**返回:** - -HDF_SUCCESS 表示申请buffer成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,申请buffer失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,申请buffer失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,申请buffer失败。 - -**Since:** - -3.1 - - -### ComponentDeInit - - -``` -int32_t(* CodecComponentType::ComponentDeInit) (struct CodecComponentType *self) -``` - -**描述:** - -组件去初始化。 - -调用此接口使组件去初始化,当组件处于OMX_StateLoaded状态时,将直接关闭组件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | - -**返回:** - -HDF_SUCCESS 表示去初始化成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,去初始化失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,去初始化失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,去初始化失败。 - -**Since:** - -3.1 - - -### ComponentRoleEnum - - -``` -int32_t(* CodecComponentType::ComponentRoleEnum) (struct CodecComponentType *self, uint8_t *role, uint32_t roleLen, uint32_t index) -``` - -**描述:** - -获取组件角色。 - -根据组件角色索引获取对应组件角色。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| role | 输出参数,角色名称。 | -| roleLen | 输入参数,role字节数。 | -| index | 输入参数,角色的索引,一个组件可能支持多种角色。 | - -**返回:** - -HDF_SUCCESS 表示获取角色成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取角色失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取角色失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取角色失败。 - -**Since:** - -3.1 - - -### ComponentTunnelRequest - - -``` -int32_t(* CodecComponentType::ComponentTunnelRequest) (struct CodecComponentType *self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup) -``` - -**描述:** - -设置组件采用Tunnel方式通信。 - -当组件处于OMX_StateLoaded 状态时,用户通过调用此接口确定组件是否可以进行Tunnel传输,如果可以则设置组件的Tunnel传输。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| port | 输入参数,组件设置的端口。 | -| tunneledComp | 输入参数,组件的tunnel handle。 | -| tunneledPort | 输入参数,组件用来Tunnel通信的端口。 | -| tunnelSetup | 输入输出参数,指向Tunnel设置的结构体**OMX_TUNNELSETUPTYPE**指针。 | - -**返回:** - -HDF_SUCCESS 表示设置成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,设置失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,设置失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置失败。 - -**Since:** - -3.1 - - -### EmptyBufferDone - - -``` -int32_t(* CodecCallbackType::EmptyBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, const struct OmxCodecBuffer *buffer) -``` - -**描述:** - -上报输入buffer编码或者解码处理完毕。 - -组件运行过程中向上报告输入buffer已经使用完毕。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的callback指针。 | -| appData | 输入参数,上层数据,通常是设置回调时给入的上层实例。 | -| appDataLen | 输入参数,appData字节数。 | -| buffer | 输入参数,已经处理完毕的输入buffer信息[OmxCodecBuffer](_omx_codec_buffer.md)。 | - -**返回:** - -HDF_SUCCESS 表示上报成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,上报失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,上报失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,上报失败。 - -**Since:** - -3.1 - - -### EmptyThisBuffer - - -``` -int32_t(* CodecComponentType::EmptyThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) -``` - -**描述:** - -编解码输入待处理buffer。 - -此接口在组件处于OMX_StateExecuting或者OMX_StatePause状态时调用。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | - -**返回:** - -HDF_SUCCESS 表示输入buffer成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,输入buffer失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,输入buffer失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,输入buffer失败。 - -**Since:** - -3.1 - - -### EventHandler - - -``` -int32_t(* CodecCallbackType::EventHandler) (struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) -``` - -**描述:** - -事件上报。 - -组件运行过程中向上报告错误事件、命令完成事件、端口设置更改事件等。 - -- 当eEvent为OMX_EventCmdComplete,eventData为NULL,data1数据为OMX_COMMANDTYPE,此时,当data1为OMX_CommandStateSet,data2表示状态,其它情况下,data2表示端口。 - -- 当event为OMX_EventError时,data1表示错误码,data2和eventData都为0。 - -- 当event为OMX_EventMark时,data1和data2都为0,eventData指向mark指针。 - -- 当event为OMX_EventPortSettingsChanged时,data1表示端口,data2和eventData为0。 - -- 当event为OMX_EventBufferFlag时,data1表示端口,data2表示flag,eventData为0。 - -- 当event为OMX_EventResourcesAcquired或OMX_EventDynamicResourcesAvailable时,data1、data2和eventData都为0。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的callback指针。 | -| event | 输入参数,要通知的事件类型,详见**OMX_EVENTTYPE**。 | -| info | 输入参数,指向事件上报携带的信息指针,详见[EventInfo](_event_info.md)。 | - -**返回:** - -HDF_SUCCESS 表示事件上报成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,事件上报失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,事件上报失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,事件上报失败。 - -**Since:** - -3.1 - - -### FillBufferDone - - -``` -int32_t(* CodecCallbackType::FillBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, struct OmxCodecBuffer *buffer) -``` - -**描述:** - -上报输出buffer填充完毕。 - -组件运行过程中向上报告输出buffer已经填充完毕。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的callback指针。 | -| appData | 输入参数,上层数据,通常是设置回调时给入的上层实例。 | -| appDataLen | 输入参数,appData字节数。 | -| buffer | 输入参数,已经填充完毕的buffer信息[OmxCodecBuffer](_omx_codec_buffer.md)。 | - -**返回:** - -HDF_SUCCESS 表示上报成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,上报失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,上报失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,上报失败。 - -**Since:** - -3.1 - - -### FillThisBuffer - - -``` -int32_t(* CodecComponentType::FillThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) -``` - -**描述:** - -编解码输出填充buffer。 - -此接口在组件处于OMX_StateExecuting或者OMX_StatePause状态时调用。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | - -**返回:** - -HDF_SUCCESS 表示填充buffer成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,填充buffer失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,填充buffer失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,填充buffer失败。 - -**Since:** - -3.1 - - -### FreeBuffer - - -``` -int32_t(* CodecComponentType::FreeBuffer) (struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer) -``` - -**描述:** - -释放buffer。 - -此接口在以下情况下使用: - -- 当组件处于OMX_StateIdle状态,并且已经向组件发送OMX_StateLoaded状态转换请求。 - -- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle时调用。 - -- 此接口调用可随时进行,但是如果未在上述情况下执行,可能会导致组件上报OMX_ErrorPortUnpopulated事件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| portIndex | 输入参数,指定的组件端口。 | -| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | - -**返回:** - -HDF_SUCCESS 表示释放buffer成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,释放buffer失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,释放buffer失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,释放buffer失败。 - -**Since:** - -3.1 - - -### GetComponentVersion - - -``` -int32_t(* CodecComponentType::GetComponentVersion) (struct CodecComponentType *self, struct CompVerInfo *verInfo) -``` - -**描述:** - -获取Codec组件版本号。 - -通过查询组件,返回组件版本信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| verInfo | 输出参数,指向组件版本信息的指针,详见[CompVerInfo](_comp_ver_info.md)。 | - -**返回:** - -HDF_SUCCESS 表示获取版本号成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取版本号失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取版本号失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取版本号失败。 - -**Since:** - -3.1 - - -### GetConfig - - -``` -int32_t(* CodecComponentType::GetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) -``` - -**描述:** - -获取组件的配置结构。 - -加载组件后可以随时调用此接口获取组件的配置。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| index | 输入参数,待填充结构的索引,详见**OMX_INDEXTYPE**。 | -| cfgStruct | 输入输出参数,指向由组件填充的应用程序分配的结构体指针。 | -| cfgStructLen | 输入参数,上层传入的cfgStruct字节数。 | - -**返回:** - -HDF_SUCCESS 表示获取配置成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取配置失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取配置失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取配置失败。 - -**Since:** - -3.1 - - -### GetExtensionIndex - - -``` -int32_t(* CodecComponentType::GetExtensionIndex) (struct CodecComponentType *self, const char *paramName, uint32_t *indexType) -``` - -**描述:** - -根据字符串获取组件的扩展索引。 - -将扩展字符串转换为Openmax IL结构索引。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| paramName | 输入参数,组件用来转换为配置索引的字符串。 | -| indexType | 输出参数,由paramName转换的配置索引,详见**OMX_INDEXTYPE**。 | - -**返回:** - -HDF_SUCCESS 表示获取扩展索引成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取扩展索引失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取扩展索引失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取扩展索引失败。 - -**Since:** - -3.1 - - -### GetParameter - - -``` -int32_t(* CodecComponentType::GetParameter) (struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) -``` - -**描述:** - -获取组件参数设置。 - -当组件处于除了OMX_StateInvalid(组件状态异常)之外的其他状态,用户可通过此接口获取组件参数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| paramIndex | 输入参数,待填充结构的索引,详见**OMX_INDEXTYPE**。 | -| paramStruct | 输入输出参数,指向由组件填充的应用程序分配的结构体指针。 | -| paramStructLen | 输入参数,paramStruct字节数。 | - -**返回:** - -HDF_SUCCESS 表示获取参数成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取参数失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取参数失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取参数失败。 - -**Since:** - -3.1 - - -### GetState - - -``` -int32_t(* CodecComponentType::GetState) (struct CodecComponentType *self, enum OMX_STATETYPE *state) -``` - -**描述:** - -获取组件的当前状态。 - -用户可调用此接口获取组件的当前状态,组件状态详见**OMX_STATETYPE**。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| state | 输出参数,指向获取到的状态指针,组件状态详见**OMX_STATETYPE**。 | - -**返回:** - -HDF_SUCCESS 表示获取状态成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,获取状态失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,获取状态失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取状态失败。 - -**Since:** - -3.1 - - -### remote - - -``` -struct HdfRemoteService* CodecCallbackType::remote -``` - -**描述:** - -指向HdfRemoteService的指针。 - -**Since:** - -3.1 - - -### SendCommand - - -``` -int32_t(* CodecComponentType::SendCommand) (struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen) -``` - -**描述:** - -发送命令给组件。 - -发送命令给组件,当命令为设置状态时,会有事件回调通知结果给上层,其他命令则没有事件上报。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| cmd | 输入参数,组件要执行的命令,详见**OMX_COMMANDTYPE**。 | -| param | 输入参数,组件要执行的命令携带的参数。
- 当cmd为OMX_CommandStateSet时,param的值详见**OMX_STATETYPE**。
- 当cmd为OMX_CommandFlush、OMX_CommandPortDisable、OMX_CommandPortEnable、OMX_CommandMarkBuffer时,param为目标端口。 | -| cmdData | 输入参数,当cmd为OMX_CommandMarkBuffer时,指向OMX_MARKTYPE结构体指针。 | -| cmdDataLen | 输入参数,上层传递的cmdData字节数。 | - -**返回:** - -HDF_SUCCESS 表示发送命令成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,发送命令失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,发送命令失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,发送命令失败。 - -**Since:** - -3.1 - - -### SetCallbacks - - -``` -int32_t(* CodecComponentType::SetCallbacks) (struct CodecComponentType *self, struct CodecCallbackType *callback, int8_t *appData, uint32_t appDataLen) -``` - -**描述:** - -设置Codec组件的回调函数。 - -当组件处于OMX_StateLoaded状态时,使用此回调函数向上通知事件以及上报可用的输入输出信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| callback | 输入参数,指向回调函数[CodecCallbackType](_codec_callback_type.md)对象指针。 | -| appData | 输入参数,指向应用程序定义的值的指针,该值将在回调期间返回。 | -| appDataLen | 输入参数,上层传递的appData字节数。 | - -**返回:** - -HDF_SUCCESS 表示设置回调成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,设置回调失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,设置回调失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置回调失败。 - -**Since:** - -3.1 - - -### SetConfig - - -``` -int32_t(* CodecComponentType::SetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) -``` - -**描述:** - -设置组件的配置。 - -加载组件后可以随时调用此接口设置组件的配置。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| index | 输入参数,要设置的结构索引,详见**OMX_INDEXTYPE**。 | -| cfgStruct | 输入参数,指向组件用于初始化的应用程序分配结构的指针。 | -| cfgStructLen | 输入参数,cfgStruct字节数。 | - -**返回:** - -HDF_SUCCESS 表示设置配置成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,设置失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,设置失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置失败。 - -**Since:** - -3.1 - - -### SetParameter - - -``` -int32_t(* CodecComponentType::SetParameter) (struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen) -``` - -**描述:** - -设置组件需要的参数。 - -当组件处于OMX_StateLoaded、OMX_StateWaitForResources状态或者端口是去使能状态,用户可通过此接口设置组件参数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| index | 输入参数,要设置的结构索引,详见**OMX_INDEXTYPE**。 | -| paramStruct | 输入参数,指向组件用于初始化的应用程序分配结构的指针。 | -| paramStructLen | 输入参数,paramStruct字节数。 | - -**返回:** - -HDF_SUCCESS 表示设置参数成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,设置参数失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,设置参数失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置参数失败。 - -**Since:** - -3.1 - - -### UseBuffer - - -``` -int32_t(* CodecComponentType::UseBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) -``` - -**描述:** - -指定组件端口的buffer。 - -此接口在以下情况下使用: - -- 当组件处于OMX_StateLoaded状态,并且用户已经向组件发送OMX_StateIdle状态转换请求。 - -- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 - -- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| portIndex | 输入参数,指定的组件端口。 | -| buffer | 输入输出参数,指向要使用的buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | - -**返回:** - -HDF_SUCCESS 表示指定成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,指定失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,指定失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,指定失败。 - -**Since:** - -3.1 - - -### UseEglImage - - -``` -int32_t(* CodecComponentType::UseEglImage) (struct CodecComponentType *self, struct OmxCodecBuffer *buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen) -``` - -**描述:** - -使用已在EGL中申请的空间。 - -此接口在以下情况下使用: - -- 当组件处于OMX_StateLoaded状态,并且已经向组件发送OMX_StateIdle状态转换请求。 - -- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 - -- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| self | 输入参数,指向要操作的Codec组件指针。 | -| buffer | 输入输出参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | -| portIndex | 输入参数,指定的组件端口。 | -| eglImage | 输入参数,EGL申请的图像指针。 | -| eglImageLen | 输入参数,eglImage字节数。 | - -**返回:** - -HDF_SUCCESS 表示使用成功。 - -HDF_ERR_INVALID_PARAM 表示参数无效,使用失败。 - -HDF_ERR_INVALID_OBJECT 表示对象无效,使用失败。 - -HDF_ERR_MALLOC_FAIL 表示申请内存失败,使用失败。 - -**Since:** - -3.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md b/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md index adf3edf8dd060694cd88c7d590360ca591ec7527..a8e953b4c83018037268342dcbe6d7abf7d5e3c5 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md @@ -3,9 +3,21 @@ ## **概述** -**所属模块:** +Codec回调接口定义。 + +提供了以下3种回调函数: + +- 组件错误事件、命令完成事件、端口设置等事件回调,详见[EventHandler](#eventhandler)。 + +- 输入端口处理完buffer回调,详见[EmptyBufferDone](#emptybufferdone)。 + +- 输出端口填充完buffer回调,详见[FillBufferDone](#fillbufferdone)。 通过以下两种方式注册回调: + - 创建组件时,通过[CreateComponent](_codec_component_manager.md#createcomponent)方法。 + - 当组件处于OMX_StateLoaded状态时,通过[SetCallbacks](_codec_component_type.md#setcallbacks)方法注册回调。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,26 +25,134 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [remote](_codec.md#remote) | 指向HdfRemoteService的指针。 [更多...](_codec.md#remote) | -| ( [EventHandler](_codec.md#eventhandler) )(struct CodecCallbackType \*self, enum OMX_EVENTTYPE event, struct [EventInfo](_event_info.md) \*info) | 事件上报。 [更多...](_codec.md#eventhandler) | -| ( [EmptyBufferDone](_codec.md#emptybufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输入buffer编码或者解码处理完毕。 [更多...](_codec.md#emptybufferdone) | -| ( [FillBufferDone](_codec.md#fillbufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输出buffer填充完毕。 [更多...](_codec.md#fillbufferdone) | +| [remote](#remote) | 指向HdfRemoteService的指针。 | +| ([EventHandler](#eventhandler) )(struct CodecCallbackType \*self, enum OMX_EVENTTYPE event, struct EventInfo \*info) | 事件上报。 | +| ([EmptyBufferDone](#emptybufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, const struct OmxCodecBuffer \*buffer) | 上报输入buffer编码或者解码处理完毕。 | +| ([FillBufferDone](#fillbufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, struct OmxCodecBuffer \*buffer) | 上报输出buffer填充完毕。 | -## **详细描述** +## **类成员变量说明** -Codec回调接口定义。 -提供了以下3种回调函数: +### EmptyBufferDone + + +``` +int32_t(* CodecCallbackType::EmptyBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, const struct OmxCodecBuffer *buffer) +``` + +**描述:** + +上报输入buffer编码或者解码处理完毕。 + +组件运行过程中向上报告输入buffer已经使用完毕。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的callback指针。 | +| appData | 输入参数,上层数据,通常是设置回调时给入的上层实例。 | +| appDataLen | 输入参数,appData字节数。 | +| buffer | 输入参数,已经处理完毕的输入buffer信息[OmxCodecBuffer](_omx_codec_buffer.md)。 | + +**返回:** + +HDF_SUCCESS 表示上报成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,上报失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,上报失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,上报失败。 + + +### EventHandler + + +``` +int32_t(* CodecCallbackType::EventHandler) (struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) +``` + +**描述:** + +事件上报。 + +组件运行过程中向上报告错误事件、命令完成事件、端口设置更改事件等。 + +- 当eEvent为OMX_EventCmdComplete,eventData为NULL,data1 数据为OMX_COMMANDTYPE, 此时,当data1为OMX_CommandStateSet,data2表示状态,其它情况下,data2表示端口。 + +- 当event为OMX_EventError时,data1表示错误码,data2和eventData都为0。 + +- 当event为OMX_EventMark时,data1和data2都为0,eventData指向mark指针。 + +- 当event为OMX_EventPortSettingsChanged时,data1表示端口,data2和eventData为0。 + +- 当event为OMX_EventBufferFlag时,data1表示端口,data2表示flag,eventData为0。 + +- 当event为OMX_EventResourcesAcquired或OMX_EventDynamicResourcesAvailable时,data1、data2和eventData都为0。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的callback指针。 | +| event | 输入参数,要通知的事件类型。 | +| info | 输入参数,指向事件上报携带的信息指针,详见[EventInfo](_event_info.md)。 | + +**返回:** + +HDF_SUCCESS 表示事件上报成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,事件上报失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,事件上报失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,事件上报失败。 + + +### FillBufferDone + + +``` +int32_t(* CodecCallbackType::FillBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, struct OmxCodecBuffer *buffer) +``` + +**描述:** + +上报输出buffer填充完毕。 + +组件运行过程中向上报告输出buffer已经填充完毕。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的callback指针。 | +| appData | 输入参数,上层数据,通常是设置回调时给入的上层实例。 | +| appDataLen | 输入参数,appData字节数。 | +| buffer | 输入参数,已经填充完毕的buffer信息[OmxCodecBuffer](_omx_codec_buffer.md)。 | + +**返回:** + +HDF_SUCCESS 表示上报成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,上报失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,上报失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,上报失败。 -- 组件错误事件、命令完成事件、端口设置等事件回调,详见EventHandler。 -- 输入端口处理完buffer回调,详见EmptyBufferDone。 +### remote -- 输出端口填充完buffer回调,详见FillBufferDone。 通过以下两种方式注册回调: + +``` +struct HdfRemoteService* CodecCallbackType::remote +``` -- 创建组件时,通过CreateComponent方法。 +**描述:** -- 当组件处于OMX_StateLoaded状态时,通过SetCallbacks方法注册回调。 +指向HdfRemoteService的指针。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md b/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md index f8900208d56a534c34c0204d6d8124024c4fc9b6..90cf2509f95cad1c5cfbb92dc82241320c9a1aa0 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义Codec编解码能力。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,25 +15,20 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [role](#role) | 媒体类型。 | | [type](#type) | 编解码类型。 | -| [compName](#compname) [[NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17)] | 编解码组件名称。 | -| [supportProfiles](#supportprofiles) [[PROFILE_NUM](_codec.md#gaab6353cb3662bdc672ae8ab90df529ce)] | 支持的profiles,详见[Profile](_codec.md#profile)。 | +| [compName](#compname) [NAME_LENGTH] | 编解码组件名称。 | +| [supportProfiles](#supportprofiles) [PROFILE_NUM] | 支持的profiles。 | | [maxInst](#maxinst) | 最大实例。 | | [isSoftwareCodec](#issoftwarecodec) | 软件编解码还是硬件编解码。 | -| [processModeMask](#processmodemask) | 编解码处理模式掩码,详见[CodecProcessMode](_codec.md#codecprocessmode)。 | -| [capsMask](#capsmask) | 编解码播放能力掩码,详见[CodecCapsMask](_codec.md#codeccapsmask)。 | +| [processModeMask](#processmodemask) | 编解码处理模式掩码。 | +| [capsMask](#capsmask) | 编解码播放能力掩码。 | | [bitRate](#bitrate) | 支持的码率范围。 | | [port](#port) | 支持的音视频编解码能力。 | -## **详细描述** - -定义Codec编解码能力。 - - ## **类成员变量说明** @@ -44,7 +41,7 @@ RangeValue CodecCompCapability::bitRate **描述:** -支持的码率范围 +支持的码率范围。 ### capsMask @@ -56,7 +53,7 @@ uint32_t CodecCompCapability::capsMask **描述:** -编解码播放能力掩码,详见[CodecCapsMask](_codec.md#codeccapsmask). +编解码播放能力掩码,详见[CodecCapsMask](codec.md#codeccapsmask)。 ### compName @@ -68,7 +65,7 @@ char CodecCompCapability::compName[NAME_LENGTH] **描述:** -编解码组件名称 +编解码组件名称。 ### isSoftwareCodec @@ -80,7 +77,7 @@ bool CodecCompCapability::isSoftwareCodec **描述:** -软件编解码还是硬件编解码 +软件编解码还是硬件编解码。 ### maxInst @@ -92,7 +89,7 @@ int32_t CodecCompCapability::maxInst **描述:** -最大实例 +最大实例。 ### port @@ -104,7 +101,7 @@ PortCap CodecCompCapability::port **描述:** -支持的音视频编解码能力 +支持的音视频编解码能力。 ### processModeMask @@ -116,7 +113,7 @@ int32_t CodecCompCapability::processModeMask **描述:** -编解码处理模式掩码,详见[CodecProcessMode](_codec.md#codecprocessmode). +编解码处理模式掩码,详见[CodecProcessMode](codec.md#codecprocessmode)。 ### role @@ -128,7 +125,7 @@ AvCodecRole CodecCompCapability::role **描述:** -媒体类型 +媒体类型。 ### supportProfiles @@ -140,7 +137,7 @@ int32_t CodecCompCapability::supportProfiles[PROFILE_NUM] **描述:** -支持的profiles,详见[Profile](_codec.md#profile) +支持的profiles,详见[Profile](codec.md#profile)。 ### type @@ -152,4 +149,4 @@ CodecType CodecCompCapability::type **描述:** -编解码类型 +编解码类型。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md b/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md index 22b2d95f61a7a6529fdf473dcec84ed2a8bedd22..00ea99f6b089455040d9aadc8234222404cabc28 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md @@ -3,33 +3,30 @@ ## **概述** -**所属模块:** - -[Codec](_codec.md) - +Codec组件管理类接口定义。 -## **汇总** +主要提供以下功能: +- 获取Codec编解码组件数量以及编解码能力集表。 -### Public 属性 +- 创建/销毁Codec组件。 - | Public 属性 | 描述 | -| -------- | -------- | -| ([GetComponentNum](#getcomponentnum) )() | 获取Codec编解码组件数量。 [更多...](#getcomponentnum) | -| ( [GetComponentCapabilityList](#getcomponentcapabilitylist) )([CodecCompCapability](_codec_comp_capability.md) \*capList, int32_t count) | 获取编解码能力集表。 [更多...](#getcomponentcapabilitylist) | -| ( [CreateComponent](#createcomponent) )(struct [CodecComponentType](_codec_component_type.md) \*\*component, char \*compName, void \*appData, int32_t appDataSize, struct [CodecCallbackType](_codec_callback_type.md) \*callbacks) | 创建Codec组件实例。 [更多...](#createcomponent) | -| ( [DestroyComponent](#destroycomponent))(struct [CodecComponentType](_codec_component_type.md) \*component) | 销毁组件实例。 [更多...](#destroycomponent) | +**相关模块:** +[Codec](codec.md) -## **详细描述** -Codec组件管理类接口定义。 +## **汇总** -主要提供以下功能: -- 获取Codec编解码组件数量以及编解码能力集表。 +### Public 属性 -- 创建/销毁Codec组件。 + | 名称 | 描述 | +| -------- | -------- | +| ([GetComponentNum](#getcomponentnum) )() | 获取Codec编解码组件数量。 | +| ([GetComponentCapabilityList](#getcomponentcapabilitylist) )(CodecCompCapability \*capList, int32_t count) | 获取编解码能力集表。 | +| ([CreateComponent](#createcomponent) )(struct CodecComponentType \*\*component, char \*compName, void \*appData, int32_t appDataSize, struct CodecCallbackType \*callbacks) | 创建Codec组件实例。 | +| ([DestroyComponent](#destroycomponent) )(struct CodecComponentType \*component) | 销毁组件实例。 | ## **类成员变量说明** @@ -48,7 +45,7 @@ int32_t(* CodecComponentManager::CreateComponent) (struct CodecComponentType **c 根据组件名称创建Codec组件实例。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -58,7 +55,7 @@ int32_t(* CodecComponentManager::CreateComponent) (struct CodecComponentType **c | appDataSize | 输入参数,appData字节数。 | | callbacks | 输入参数,回调接口,指向OMX_CALLBACKTYPE结构的指针,详见[CodecCallbackType](_codec_callback_type.md)。 | -**返回:** +**返回:** HDF_SUCCESS 表示创建组件成功。 @@ -82,13 +79,13 @@ int32_t(* CodecComponentManager::DestroyComponent) (struct CodecComponentType *c 销毁指定的Codec组件。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | component | 输入参数,需要销毁的Codec组件。 | -**返回:** +**返回:** HDF_SUCCESS 表示销毁组件成功。 @@ -112,14 +109,14 @@ int32_t(* CodecComponentManager::GetComponentCapabilityList) (CodecCompCapabilit 用户可通过此接口了解Codec模块提供了哪些编解码能力,对应的能力体现在[CodecCompCapability](_codec_comp_capability.md)结构体。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | capList | 输出参数,返回全部组件的能力集表[CodecCompCapability](_codec_comp_capability.md)。 | | count | 输入参数,编解码组件数量,由[GetComponentNum](#getcomponentnum)获得。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取能力集表成功。 @@ -143,6 +140,6 @@ int32_t(* CodecComponentManager::GetComponentNum) () 通过此接口获取Codec编解码组件数量,用来获取全部编解码能力集。 -**返回:** +**返回:** Codec编解码组件数量。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md b/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md index 0850d4c66221b70819644d1f2d693e094c82d1ed..3840fc5721763eb96cff3ff7d070b3f85ed5fbeb 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md @@ -3,9 +3,25 @@ ## **概述** -**所属模块:** +Codec组件接口定义。 + +主要提供以下功能: + +- 获取组件的版本。 + +- 组件参数配置的获取和设置。 + +- 发送命令至组件及获取组件状态。 + +- 设置回调函数。 + +- 设置/释放组件使用的buffer。 + +- 编解码输入输出buffer处理 具体方法使用详见函数说明。 -[Codec](_codec.md) +**相关模块:** + +[Codec](codec.md) ## **汇总** @@ -13,42 +29,632 @@ ### Public 属性 - | Public 属性 | 描述 | -| -------- | -------- | -| ( [GetComponentVersion](_codec.md#getcomponentversion) )(struct CodecComponentType \*self, struct [CompVerInfo](_comp_ver_info.md) \*verInfo) | 获取Codec组件版本号。 [更多...](_codec.md#getcomponentversion) | -| ( [SendCommand](_codec.md#sendcommand) )(struct CodecComponentType \*self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t \*cmdData, uint32_t cmdDataLen) | 发送命令给组件。 [更多...](_codec.md#sendcommand) | -| ( [GetParameter](_codec.md#getparameter) )(struct CodecComponentType \*self, uint32_t paramIndex, int8_t \*paramStruct, uint32_t paramStructLen) | 获取组件参数设置。 [更多...](_codec.md#getparameter) | -| ( [SetParameter](_codec.md#setparameter) )(struct CodecComponentType \*self, uint32_t index, int8_t \*paramStruct, uint32_t paramStructLen) | 设置组件需要的参数。 [更多...](_codec.md#setparameter) | -| ( [GetConfig](_codec.md#getconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 获取组件的配置结构。 [更多...](_codec.md#getconfig) | -| ( [SetConfig](_codec.md#setconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 设置组件的配置。 [更多...](_codec.md#setconfig) | -| ( [GetExtensionIndex](_codec.md#getextensionindex) )(struct CodecComponentType \*self, const char \*paramName, uint32_t \*indexType) | 根据字符串获取组件的扩展索引。 [更多...](_codec.md#getextensionindex) | -| ( [GetState](_codec.md#getstate) )(struct CodecComponentType \*self, enum OMX_STATETYPE \*state) | 获取组件的当前状态。 [更多...](_codec.md#getstate) | -| ( [ComponentTunnelRequest](_codec.md#componenttunnelrequest) )(struct CodecComponentType \*self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE \*tunnelSetup) | 设置组件采用Tunnel方式通信。 [更多...](_codec.md#componenttunnelrequest) | -| ( [UseBuffer](_codec.md#usebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 指定组件端口的buffer。 [更多...](_codec.md#usebuffer) | -| ( [AllocateBuffer](_codec.md#allocatebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 向组件申请端口buffer。 [更多...](_codec.md#allocatebuffer) | -| ( [FreeBuffer](_codec.md#freebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 释放buffer。 [更多...](_codec.md#freebuffer) | -| ( [EmptyThisBuffer](_codec.md#emptythisbuffer) )(struct CodecComponentType \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解码输入待处理buffer。 [更多...](_codec.md#emptythisbuffer) | -| ( [FillThisBuffer](_codec.md#fillthisbuffer) )(struct CodecComponentType \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解码输出填充buffer。 [更多...](_codec.md#fillthisbuffer) | -| ( [SetCallbacks](_codec.md#setcallbacks) )(struct CodecComponentType \*self, struct [CodecCallbackType](_codec_callback_type.md) \*callback, int8_t \*appData, uint32_t appDataLen) | 设置Codec组件的回调函数。 [更多...](_codec.md#setcallbacks) | -| ( [ComponentDeInit](_codec.md#componentdeinit) )(struct CodecComponentType \*self) | 组件去初始化。 [更多...](_codec.md#componentdeinit) | -| ( [UseEglImage](_codec.md#useeglimage) )(struct CodecComponentType \*self, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer, uint32_t portIndex, int8_t \*eglImage, uint32_t eglImageLen) | 使用已在EGL中申请的空间。 [更多...](_codec.md#useeglimage) | -| ( [ComponentRoleEnum](_codec.md#componentroleenum) )(struct [CodecComponentType \*self, uint8_t \*role, uint32_t roleLen, uint32_t index) | 获取组件角色。 [更多...](_codec.md#componentroleenum) | - - -## **详细描述** + | 名称 | 描述 | +| -------- | -------- | +| ([GetComponentVersion](#getcomponentversion) )(struct CodecComponentType \*self, struct CompVerInfo \*verInfo) | 获取Codec组件版本号。 | +| ([SendCommand](#sendcommand) )(struct CodecComponentType \*self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t \*cmdData, uint32_t cmdDataLen) | 发送命令给组件。 | +| ([GetParameter](#getparameter) )(struct CodecComponentType \*self, uint32_t paramIndex, int8_t \*paramStruct, uint32_t paramStructLen) | 获取组件参数设置。 | +| ([SetParameter](#setparameter) )(struct CodecComponentType \*self, uint32_t index, int8_t \*paramStruct, uint32_t paramStructLen) | 设置组件需要的参数。 | +| ([GetConfig](#getconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 获取组件的配置结构。 | +| ([SetConfig](#setconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 设置组件的配置。 | +| ([GetExtensionIndex](#getextensionindex) )(struct CodecComponentType \*self, const char \*paramName, uint32_t \*indexType) | 根据字符串获取组件的扩展索引。 | +| ([GetState](#getstate) )(struct CodecComponentType \*self, enum OMX_STATETYPE \*state) | 获取组件的当前状态。 | +| ([ComponentTunnelRequest](#componenttunnelrequest) )(struct CodecComponentType \*self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE \*tunnelSetup) | 设置组件采用Tunnel方式通信。 | +| ([UseBuffer](#usebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct OmxCodecBuffer \*buffer) | 指定组件端口的buffer。 | +| ([AllocateBuffer](#allocatebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct OmxCodecBuffer \*buffer) | 向组件申请端口buffer。 | +| ([FreeBuffer](#freebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, const struct OmxCodecBuffer \*buffer) | 释放buffer。 | +| ([EmptyThisBuffer](#emptythisbuffer) )(struct CodecComponentType \*self, const struct OmxCodecBuffer \*buffer) | 编解码输入待处理buffer。 | +| ([FillThisBuffer](#fillthisbuffer) )(struct CodecComponentType \*self, const struct OmxCodecBuffer \*buffer) | 编解码输出填充buffer。 | +| ([SetCallbacks](#setcallbacks) )(struct CodecComponentType \*self, struct CodecCallbackType \*callback, int8_t \*appData, uint32_t appDataLen) | 设置Codec组件的回调函数。 | +| ([ComponentDeInit](#componentdeinit) )(struct CodecComponentType \*self) | 组件去初始化。 | +| ([UseEglImage](#useeglimage) )(struct CodecComponentType \*self, struct OmxCodecBuffer \*buffer, uint32_t portIndex, int8_t \*eglImage, uint32_t eglImageLen) | 使用已在EGL中申请的空间。 | +| ([ComponentRoleEnum](#componentroleenum) )(struct CodecComponentType \*self, uint8_t \*role, uint32_t roleLen, uint32_t index) | 获取组件角色。 | -Codec组件接口定义。 -主要提供以下功能: +## **类成员变量说明** -- 获取组件的版本。 -- 组件参数配置的获取和设置。 +### AllocateBuffer -- 发送命令至组件及获取组件状态。 + +``` +int32_t(* CodecComponentType::AllocateBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) +``` -- 设置回调函数。 +**描述:** -- 设置/释放组件使用的buffer。 +向组件申请端口buffer。 -- 编解码输入输出buffer处理 具体方法使用详见函数说明。 +向组件申请分配新的buffer,此接口在以下情况下使用: + +- 当组件处于OMX_StateLoaded状态,并且用户已经向组件发送OMX_StateIdle状态转换请求。 + +- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 + +- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| portIndex | 输入参数,指定的组件端口。 | +| buffer | 输入输出参数,指向要申请的buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | + +**返回:** + +HDF_SUCCESS 表示申请buffer成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,申请buffer失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,申请buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,申请buffer失败。 + + +### ComponentDeInit + + +``` +int32_t(* CodecComponentType::ComponentDeInit) (struct CodecComponentType *self) +``` + +**描述:** + +组件去初始化。 + +调用此接口使组件去初始化,当组件处于OMX_StateLoaded状态时,将直接关闭组件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | + +**返回:** + +HDF_SUCCESS 表示去初始化成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,去初始化失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,去初始化失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,去初始化失败。 + + +### ComponentRoleEnum + + +``` +int32_t(* CodecComponentType::ComponentRoleEnum) (struct CodecComponentType *self, uint8_t *role, uint32_t roleLen, uint32_t index) +``` + +**描述:** + +获取组件角色。 + +根据组件角色索引获取对应组件角色。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| role | 输出参数,角色名称。 | +| roleLen | 输入参数,role字节数。 | +| index | 输入参数,角色的索引,一个组件可能支持多种角色。 | + +**返回:** + +HDF_SUCCESS 表示获取角色成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取角色失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取角色失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取角色失败。 + + +### ComponentTunnelRequest + + +``` +int32_t(* CodecComponentType::ComponentTunnelRequest) (struct CodecComponentType *self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup) +``` + +**描述:** + +设置组件采用Tunnel方式通信。 + +当组件处于OMX_StateLoaded 状态时,用户通过调用此接口确定组件是否可以进行Tunnel传输,如果可以则设置组件的Tunnel传输。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| port | 输入参数,组件设置的端口。 | +| tunneledComp | 输入参数,组件的tunnel handle。 | +| tunneledPort | 输入参数,组件用来Tunnel通信的端口。 | +| tunnelSetup | 输入输出参数,指向Tunnel设置的结构体**OMX_TUNNELSETUPTYPE**指针。 | + +**返回:** + +HDF_SUCCESS 表示设置成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,设置失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,设置失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置失败。 + + +### EmptyThisBuffer + + +``` +int32_t(* CodecComponentType::EmptyThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) +``` + +**描述:** + +编解码输入待处理buffer。 + +此接口在组件处于OMX_StateExecuting或者OMX_StatePause状态时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示输入buffer成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,输入buffer失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,输入buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,输入buffer失败。 + + +### FillThisBuffer + + +``` +int32_t(* CodecComponentType::FillThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) +``` + +**描述:** + +编解码输出填充buffer。 + +此接口在组件处于OMX_StateExecuting或者OMX_StatePause状态时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示填充buffer成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,填充buffer失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,填充buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,填充buffer失败。 + + +### FreeBuffer + + +``` +int32_t(* CodecComponentType::FreeBuffer) (struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer) +``` + +**描述:** + +释放buffer。 + +此接口在以下情况下使用: + +- 当组件处于OMX_StateIdle状态,并且已经向组件发送OMX_StateLoaded状态转换请求。 + +- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle时调用。 + +- 此接口调用可随时进行,但是如果未在上述情况下执行,可能会导致组件上报OMX_ErrorPortUnpopulated事件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| portIndex | 输入参数,指定的组件端口。 | +| buffer | 输入参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示释放buffer成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,释放buffer失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,释放buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,释放buffer失败。 + + +### GetComponentVersion + + +``` +int32_t(* CodecComponentType::GetComponentVersion) (struct CodecComponentType *self, struct CompVerInfo *verInfo) +``` + +**描述:** + +获取Codec组件版本号。 + +通过查询组件,返回组件版本信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| verInfo | 输出参数,指向组件版本信息的指针,详见[CompVerInfo](_comp_ver_info.md)。 | + +**返回:** + +HDF_SUCCESS 表示获取版本号成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取版本号失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取版本号失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取版本号失败。 + + +### GetConfig + + +``` +int32_t(* CodecComponentType::GetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) +``` + +**描述:** + +获取组件的配置结构。 + +加载组件后可以随时调用此接口获取组件的配置。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| index | 输入参数,待填充结构的索引,详见**OMX_INDEXTYPE**。 | +| cfgStruct | 输入输出参数,指向由组件填充的应用程序分配的结构体指针。 | +| cfgStructLen | 输入参数,上层传入的cfgStruct字节数。 | + +**返回:** + +HDF_SUCCESS 表示获取配置成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取配置失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取配置失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取配置失败。 + + +### GetExtensionIndex + + +``` +int32_t(* CodecComponentType::GetExtensionIndex) (struct CodecComponentType *self, const char *paramName, uint32_t *indexType) +``` + +**描述:** + +根据字符串获取组件的扩展索引。 + +将扩展字符串转换为Openmax IL结构索引。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| paramName | 输入参数,组件用来转换为配置索引的字符串。 | +| indexType | 输出参数,由paramName转换的配置索引,详见**OMX_INDEXTYPE**。 | + +**返回:** + +HDF_SUCCESS 表示获取扩展索引成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取扩展索引失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取扩展索引失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取扩展索引失败。 + + +### GetParameter + + +``` +int32_t(* CodecComponentType::GetParameter) (struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) +``` + +**描述:** + +获取组件参数设置。 + +当组件处于除了OMX_StateInvalid(组件状态异常)之外的其他状态,用户可通过此接口获取组件参数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| paramIndex | 输入参数,待填充结构的索引,详见**OMX_INDEXTYPE**。 | +| paramStruct | 输入输出参数,指向由组件填充的应用程序分配的结构体指针。 | +| paramStructLen | 输入参数,paramStruct字节数。 | + +**返回:** + +HDF_SUCCESS 表示获取参数成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取参数失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取参数失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取参数失败。 + + +### GetState + + +``` +int32_t(* CodecComponentType::GetState) (struct CodecComponentType *self, enum OMX_STATETYPE *state) +``` + +**描述:** + +获取组件的当前状态。 + +用户可调用此接口获取组件的当前状态,组件状态详见**OMX_STATETYPE**。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| state | 输出参数,指向获取到的状态指针,组件状态详见**OMX_STATETYPE**。 | + +**返回:** + +HDF_SUCCESS 表示获取状态成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,获取状态失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,获取状态失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,获取状态失败。 + + +### SendCommand + + +``` +int32_t(* CodecComponentType::SendCommand) (struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen) +``` + +**描述:** + +发送命令给组件。 + +当命令为设置状态时,会有事件回调通知结果给上层,其他命令则没有事件上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| cmd | 输入参数,组件要执行的命令,详见**OMX_COMMANDTYPE**。 | +| param | 输入参数,组件要执行的命令携带的参数。
- 当cmd为OMX_CommandStateSet时,param的值详见**OMX_STATETYPE**。
- 当cmd为OMX_CommandFlush、OMX_CommandPortDisable、OMX_CommandPortEnable、OMX_CommandMarkBuffer时,param为目标端口。 | +| cmdData | 输入参数,当cmd为OMX_CommandMarkBuffer时,指向OMX_MARKTYPE结构体指针。 | +| cmdDataLen | 输入参数,上层传递的cmdData字节数。 | + +**返回:** + +HDF_SUCCESS 表示发送命令成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,发送命令失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,发送命令失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,发送命令失败。 + + +### SetCallbacks + + +``` +int32_t(* CodecComponentType::SetCallbacks) (struct CodecComponentType *self, struct CodecCallbackType *callback, int8_t *appData, uint32_t appDataLen) +``` + +**描述:** + +设置Codec组件的回调函数。 + +当组件处于OMX_StateLoaded状态时,使用此回调函数向上通知事件以及上报可用的输入输出信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| callback | 输入参数,指向回调函数[CodecCallbackType](_codec_callback_type.md)对象指针。 | +| appData | 输入参数,指向应用程序定义的值的指针,该值将在回调期间返回。 | +| appDataLen | 输入参数,上层传递的appData字节数。 | + +**返回:** + +HDF_SUCCESS 表示设置回调成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,设置回调失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,设置回调失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置回调失败。 + + +### SetConfig + + +``` +int32_t(* CodecComponentType::SetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) +``` + +**描述:** + +设置组件的配置。 + +加载组件后可以随时调用此接口设置组件的配置。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| index | 输入参数,要设置的结构索引,详见**OMX_INDEXTYPE**。 | +| cfgStruct | 输入参数,指向组件用于初始化的应用程序分配结构的指针。 | +| cfgStructLen | 输入参数,cfgStruct字节数。 | + +**返回:** + +HDF_SUCCESS 表示设置配置成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,设置失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,设置失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置失败。 + + +### SetParameter + + +``` +int32_t(* CodecComponentType::SetParameter) (struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen) +``` + +**描述:** + +设置组件需要的参数。 + +当组件处于OMX_StateLoaded、OMX_StateWaitForResources状态或者端口是去使能状态,用户可通过此接口设置组件参数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| index | 输入参数,要设置的结构索引,详见**OMX_INDEXTYPE**。 | +| paramStruct | 输入参数,指向组件用于初始化的应用程序分配结构的指针。 | +| paramStructLen | 输入参数,paramStruct字节数。 | + +**返回:** + +HDF_SUCCESS 表示设置参数成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,设置参数失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,设置参数失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,设置参数失败。 + + +### UseBuffer + + +``` +int32_t(* CodecComponentType::UseBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) +``` + +**描述:** + +指定组件端口的buffer。 + +此接口在以下情况下使用: + +- 当组件处于OMX_StateLoaded状态,并且用户已经向组件发送OMX_StateIdle状态转换请求。 + +- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 + +- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| portIndex | 输入参数,指定的组件端口。 | +| buffer | 输入输出参数,指向要使用的buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | + +**返回:** + +HDF_SUCCESS 表示指定成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,指定失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,指定失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,指定失败。 + + +### UseEglImage + + +``` +int32_t(* CodecComponentType::UseEglImage) (struct CodecComponentType *self, struct OmxCodecBuffer *buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen) +``` + +**描述:** + +使用已在EGL中申请的空间。 + +此接口在以下情况下使用: + +- 当组件处于OMX_StateLoaded状态,并且已经向组件发送OMX_StateIdle状态转换请求。 + +- 当组件处于OMX_StateWaitForResources状态,所需的资源可用,并且组件已准备好进入OMX_StateIdle状态。 + +- 在去使能端口上,组件处于OMX_StateExecuting、OMX_StatePause或OMX_StateIdle状态。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| self | 输入参数,指向要操作的Codec组件指针。 | +| buffer | 输入输出参数,指向[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | +| portIndex | 输入参数,指定的组件端口。 | +| eglImage | 输入参数,EGL申请的图像指针。 | +| eglImageLen | 输入参数,eglImage字节数。 | + +**返回:** + +HDF_SUCCESS 表示使用成功。 + +HDF_ERR_INVALID_PARAM 表示参数无效,使用失败。 + +HDF_ERR_INVALID_OBJECT 表示对象无效,使用失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内存失败,使用失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md b/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md index ddf1830d2f8d1634cbe777656fdefd8f61615340..debad98682d7b7c71cb85127947c7af43b5cb1e4 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义组件版本信息。 -[Codec](_codec.md) +**相关模块:** + +[Codec](codec.md) ## **汇总** @@ -13,18 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [compName](#compname) [[NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17)] | 组件名称 | -| [compUUID](#compuuid) [[UUID_LENGTH](_codec.md#ga9226162b034cc837cd977f0fcf611c2c)] | 组件的UUID标识符 | -| [compVersion](#compversion) | OMX组件版本信息 | -| [specVersion](#specversion) | 构建组件所依据的规范的版本信息 | - - -## **Details** - - -## **详细描述** +| [compName](#compname) [[NAME_LENGTH](codec.md#gaf71324c57f05ff9e24bd384925dd6b17)] | 组件名称。 | +| [compUUID](#compuuid) [[UUID_LENGTH](codec.md#ga9226162b034cc837cd977f0fcf611c2c)] | 组件的UUID标识符。 | +| [compVersion](#compversion) | OMX组件版本信息。 | +| [specVersion](#specversion) | 构建组件所依据的规范的版本信息。 | ## **类成员变量说明** @@ -39,7 +35,7 @@ char CompVerInfo::compName[NAME_LENGTH] **描述:** -组件名称 +组件名称。 ### compUUID @@ -51,7 +47,7 @@ uint8_t CompVerInfo::compUUID[UUID_LENGTH] **描述:** -组件的UUID标识符 +组件的UUID标识符。 ### compVersion @@ -63,7 +59,7 @@ union OMX_VERSIONTYPE CompVerInfo::compVersion **描述:** -OMX组件版本信息 +OMX组件版本信息。 ### specVersion @@ -75,4 +71,4 @@ union OMX_VERSIONTYPE CompVerInfo::specVersion **描述:** -构建组件所依据的规范的版本信息 +构建组件所依据的规范的版本信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_credential_info.md b/zh-cn/device-dev/reference/hdi-apis/_credential_info.md index 2d38ca382a44d3e2df74c71b2a33e3dd69ccf44e..0d892d6244b3c69d8bef954895b02886b2f42271 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_credential_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_credential_info.md @@ -3,6 +3,16 @@ ## **概述** +认证凭据信息。 + +**自动:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,7 +23,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [credentialId](#credentialid) | 认证凭据ID。 | | [index](#index) | 用户认证框架的执行器索引。 | @@ -23,19 +33,6 @@ | [executorSensorHint](#executorsensorhint) | 既定用户认证凭据类型的执行器传感器提示,用于找到对应认证方式的传感器。 | -## **详细描述** - -认证凭据信息。 - -**自动:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md index a423b267c59d718dc84d6dd28e3ccc8c884bba7b..4d03b1911cff0d4acde50b7e3379574ca1c454c7 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md +++ b/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +显示设备控制接口结构体,定义显示设备控制接口函数指针。 + +**相关模块:** [Display](_display.md) @@ -13,47 +15,98 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( **RegHotPlugCallback** )(HotPlugCallback callback, void \*data) | 注册热插拔事件回调 | -| ( **RegDisplayVBlankCallback** )(uint32_t devId, VBlankCallback callback, void \*data) | 注册VBlank事件回调。 | -| ( **RegDisplayRefreshCallback** )(uint32_t devId, RefreshCallback callback, void \*data) | 刷新请求回调。 | -| ( **GetDisplayCapability** )(uint32_t devId, [DisplayCapability](_display_capability.md) \*info) | 获取显示设备能力集。 | -| ( **GetDisplaySupportedModes** )(uint32_t devId, uint32_t \*num, [DisplayModeInfo](_display_mode_info.md) \*modes) | 获取显示设备支持的显示模式信息。 | -| ( **GetDisplayMode** )(uint32_t devId, uint32_t \*modeId) | 获取显示设备当前的显示模式。 | -| ( **SetDisplayMode** )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模式。 | -| ( **GetDisplayPowerStatus** )(uint32_t devId, [DispPowerStatus](_display.md#disppowerstatus) \*status) | 获取显示设备当前的电源状态。 | -| ( **SetDisplayPowerStatus** )(uint32_t devId, [DispPowerStatus](_display.md#disppowerstatus) status) | 设置显示设备当前的电源状态。 | -| ( **GetDisplayBacklight** )(uint32_t devId, uint32_t \*level) | 获取显示设备当前的背光值。 | -| ( **SetDisplayBacklight** )(uint32_t devId, uint32_t level) | 设置显示设备当前的背光值。 | -| ( **GetDisplayProperty** )(uint32_t devId, uint32_t id, uint64_t \*value) | 获取显示设备属性值。 | -| ( **SetDisplayProperty** )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 | -| ( **PrepareDisplayLayers** )(uint32_t devId, bool \*needFlushFb) | 显示设备合成前准备 | -| ( **GetDisplayCompChange** )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获取显示设备合成类型有变化的layer | -| ( **SetDisplayClientCrop** )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的裁剪区域。 | -| ( **SetDisplayClientDestRect** )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示区域。 | -| ( **SetDisplayClientBuffer** )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓存。 | -| ( **SetDisplayClientDamage** )(uint32_t devId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示脏区 | -| ( **SetDisplayVsyncEnabled** )(uint32_t devId, bool enabled) | 使能垂直同步信号。 | -| ( **GetDisplayReleaseFence** )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获取显示图层fence。 | -| ( **GetDisplaySupportedColorGamuts** )(uint32_t devId, uint32_t \*num, [ColorGamut](_display.md#colorgamut) \*gamuts) | 获取显示设备支持的色域信息。 | -| ( **GetDisplayColorGamut** )(uint32_t devId, [ColorGamut](_display.md#colorgamut) \*gamut) | 获取显示设备当前的色域模式。 | -| ( **SetDisplayColorGamut** )(uint32_t devId, [ColorGamut](_display.md#colorgamut) gamut) | 设置显示设备当前的色域模式。 | -| ( **GetDisplayGamutMap** )(uint32_t devId, [GamutMap](_display.md#gamutmap) \*gamutMap) | 获取显示设备当前的色域映射模式。 | -| ( **SetDisplayGamutMap** )(uint32_t devId, [GamutMap](_display.md#gamutmap) gamutMap) | 设置显示设备当前的色域映射模式。 | -| ( **SetDisplayColorTransform** )(uint32_t devId, const float \*matrix) | 设置显示设备当前的4x4的颜色转换矩阵。 | -| ( **GetHDRCapabilityInfos** )(uint32_t devId, [HDRCapability](_h_d_r_capability.md) \*info) | 获取显示设备支持的HDR属性信息。 | -| ( **GetSupportedMetadataKey** )(uint32_t devId, uint32_t \*num, [HDRMetadataKey](_display.md#hdrmetadatakey) \*keys) | 获取显示设备支持的 HDRMetadataKey。 | -| ( **Commit** )(uint32_t devId, int32_t \*fence) | 提交合成送显请求。 | -| ( **InvokeDisplayCmd** )(uint32_t devId,...) | 调用显示设备命令。 | -| ( **CreateVirtualDisplay** )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 | -| ( **DestroyVirtualDisplay** )(uint32_t devId) | 销毁虚拟显示设备。 | -| ( **SetVirtualDisplayBuffer** )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟屏的输出缓存。 | -| ( **GetWriteBackFrame** )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获取显示设备的回写帧。 | -| ( **CreateWriteBack** )(uint32_t \*devId, uint32_t width, uint32_t height, int32_t \*format) | 对指定显示设备创建回写点。 | -| ( **DestroyWriteBack** )(uint32_t devId) | 销毁指定显示设备的回写点。 | - - -## **详细描述** +| ([DeviceFuncs::RegHotPlugCallback](_display.md#reghotplugcallback) )(HotPlugCallback callback, void \*data) | 注册热插拔事件回调。 | +| ([DeviceFuncs::RegDisplayVBlankCallback](_display.md#regdisplayvblankcallback) )(uint32_t devId, VBlankCallback callback, void \*data) | 注册VBlank事件回调。 | +| ([DeviceFuncs::RegDisplayRefreshCallback](_display.md#regdisplayrefreshcallback) )(uint32_t devId, RefreshCallback callback, void \*data) | 刷新请求回调。 | +| ([DeviceFuncs::GetDisplayCapability](_display.md#getdisplaycapability) )(uint32_t devId, DisplayCapability \*info) | 获取显示设备能力集。 | +| ([DeviceFuncs::GetDisplaySupportedModes](_display.md#getdisplaysupportedmodes) )(uint32_t devId, uint32_t \*num, DisplayModeInfo \*modes) | 获取显示设备支持的显示模式信息。 | +| ([DeviceFuncs::GetDisplayMode](_display.md#getdisplaymode) )(uint32_t devId, uint32_t \*modeId) | 获取显示设备当前的显示模式。 | +| ([DeviceFuncs::SetDisplayMode](_display.md#setdisplaymode) )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模式。 | +| ([DeviceFuncs::GetDisplayPowerStatus](_display.md#getdisplaypowerstatus) )(uint32_t devId, DispPowerStatus \*status) | 获取显示设备当前的电源状态。 | +| ([DeviceFuncs::SetDisplayPowerStatus](_display.md#setdisplaypowerstatus) )(uint32_t devId, DispPowerStatus status) | 设置显示设备当前的电源状态。 | +| ([DeviceFuncs::GetDisplayBacklight](_display.md#getdisplaybacklight) )(uint32_t devId, uint32_t \*level) | 获取显示设备当前的背光值。 | +| ([DeviceFuncs::SetDisplayBacklight](_display.md#setdisplaybacklight) )(uint32_t devId, uint32_t level) | 设置显示设备当前的背光值。 | +| ([DeviceFuncs::GetDisplayProperty](_display.md#getdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t \*value) | 获取显示设备属性值。 | +| ([DeviceFuncs::SetDisplayProperty](_display.md#setdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 | +| ([DeviceFuncs::PrepareDisplayLayers](_display.md#preparedisplaylayers) )(uint32_t devId, bool \*needFlushFb) | 显示设备合成前准备。 | +| ([DeviceFuncs::GetDisplayCompChange](_display.md#getdisplaycompchange) )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获取显示设备合成类型有变化的layer。 | +| ([DeviceFuncs::SetDisplayClientCrop](_display.md#setdisplayclientcrop) )(uint32_t devId, IRect \*rect) | 设置显示设备的裁剪区域。 | +| ([DeviceFuncs::SetDisplayClientDestRect](_display.md#setdisplayclientdestrect) )(uint32_t devId, IRect \*rect) | 设置显示设备的显示区域。 | +| ([DeviceFuncs::SetDisplayClientBuffer](_display.md#setdisplayclientbuffer) )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓存。 | +| ([DeviceFuncs::SetDisplayClientDamage](_display.md#setdisplayclientdamage) )(uint32_t devId, uint32_t num, IRect \*rect) | 设置显示设备的显示脏区。 | +| ([DeviceFuncs::SetDisplayVsyncEnabled](_display.md#setdisplayvsyncenabled) )(uint32_t devId, bool enabled) | 使能垂直同步信号。 | +| ([DeviceFuncs::GetDisplayReleaseFence](_display.md#getdisplayreleasefence) )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获取显示图层fence。 | +| ([DeviceFuncs::GetDisplaySupportedColorGamuts](_display.md#getdisplaysupportedcolorgamuts) )(uint32_t devId, uint32_t \*num, ColorGamut \*gamuts) | 获取显示设备支持的色域信息。 | +| ([DeviceFuncs::GetDisplayColorGamut](_display.md#getdisplaycolorgamut) )(uint32_t devId, ColorGamut \*gamut) | 获取显示设备当前的色域模式。 | +| ([DeviceFuncs::SetDisplayColorGamut](_display.md#setdisplaycolorgamut) )(uint32_t devId, ColorGamut gamut) | 设置显示设备当前的色域模式。 | +| ([DeviceFuncs::GetDisplayGamutMap](_display.md#getdisplaygamutmap) )(uint32_t devId, GamutMap \*gamutMap) | 获取显示设备当前的色域映射模式。 | +| ([DeviceFuncs::SetDisplayGamutMap](_display.md#setdisplaygamutmap) )(uint32_t devId, GamutMap gamutMap) | 设置显示设备当前的色域映射模式。 | +| ([DeviceFuncs::SetDisplayColorTransform](_display.md#setdisplaycolortransform) )(uint32_t devId, const float \*matrix) | 设置显示设备当前的4x4的颜色转换矩阵。 | +| ([DeviceFuncs::GetHDRCapabilityInfos](_display.md#gethdrcapabilityinfos) )(uint32_t devId, HDRCapability \*info) | 获取显示设备支持的HDR属性信息。 | +| ([DeviceFuncs::GetSupportedMetadataKey](_display.md#getsupportedmetadatakey) )(uint32_t devId, uint32_t \*num, DisplayInfo::widthHDRMetadataKey \*keys) | 获取显示设备支持的 HDRMetadataKey。 | +| ([DeviceFuncs::Commit](_display.md#commit) )(uint32_t devId, int32_t \*fence) | 提交合成送显请求。 | +| ([DeviceFuncs::InvokeDisplayCmd](_display.md#invokedisplaycmd) )(uint32_t devId,...) | 调用显示设备命令。 | +| ([DeviceFuncs::CreateVirtualDisplay](_display.md#createvirtualdisplay) )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 | +| ([DeviceFuncs::DestroyVirtualDisplay](_display.md#destroyvirtualdisplay) )(uint32_t devId) | 销毁虚拟显示设备。 | +| ([DeviceFuncs::SetVirtualDisplayBuffer](_display.md#setvirtualdisplaybuffer) )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟屏的输出缓存。 | +| ([DeviceFuncs::GetWriteBackFrame](_display.md#getwritebackframe) )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获取显示设备的回写帧。 | +| ([DeviceFuncs::CreateWriteBack](#createwriteback)DeviceFuncs::CreateWriteBack)(uint32_t \*devId, uint32_t width, uint32_t height, int32_t \*format) | PixelFormat, 接口实现层可以根据硬件需求,修改format并返回给图形服务。 | +| ([DeviceFuncs::DestroyWriteBack](#destroywriteback) )(uint32_t devId) | 销毁指定显示设备的回写点。 | -显示设备控制接口结构体,定义显示设备控制接口函数指针。 + +## **类成员变量说明** + + +### CreateWriteBack + + +``` +int32_t(* DeviceFuncs::CreateWriteBack) (uint32_t *devId, uint32_t width, uint32_t height, int32_t *format) +``` + +**描述:** + +PixelFormat, 接口实现层可以根据硬件需求,修改format并返回给图形服务。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID,接口实现层在创建完回写点后将回写点设备ID存放在该参数中返回给图形服务。 | +| width | 输入参数,回写像素宽度。 | +| height | 输入参数,回写像素高度。 | +| format | 输入参数,回写点数据格式,详情参考[PixelFormat](_display.md#pixelformat),接口实现层可以根据硬件需求,修改format并返回给图形服务。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 + + +### DestroyWriteBack + + +``` +int32_t(* DeviceFuncs::DestroyWriteBack) (uint32_t devId) +``` + +**描述:** + +销毁指定显示设备的回写点。 + +该接口用來销毁指定的回写点。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_display.md b/zh-cn/device-dev/reference/hdi-apis/_display.md index 6141341af4fda33a02465682073c09b812a63141..ec7e8d4bb789a1542ebe49aaadbbd2371f01d053 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_display.md +++ b/zh-cn/device-dev/reference/hdi-apis/_display.md @@ -4,266 +4,464 @@ ## **汇总** +## **概述** + +显示模块驱动接口定义。 + +提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + +**Since**: + +1.0 + +**Version**:。 + +2.0 + + ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [display_device.h](display__device_8h.md) | 显示设备控制接口声明。 | | [display_gfx.h](display__gfx_8h.md) | 显示硬件加速驱动接口声明。 | | [display_gralloc.h](display__gralloc_8h.md) | 显示内存驱动接口声明。 | | [display_layer.h](display__layer_8h.md) | 显示图层驱动接口声明。 | | [display_type.h](display__type_8h.md) | 显示类型定义,定义显示驱动接口所使用的数据类型。 | +| [display_vgu.h](display__vgu_8h.md) | 该文件定义2D矢量硬件加速模块相关驱动函数。 | ### 类 - | 类 | 描述 | -| -------- | -------- | -| [DeviceFuncs](_device_funcs.md) | 显示设备控制接口结构体,定义显示设备控制接口函数指针。 [更多...](_device_funcs.md) | -| [GfxFuncs](_gfx_funcs.md) | 显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 [更多...](_gfx_funcs.md) | -| [GrallocFuncs](_gralloc_funcs.md) | 显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 [更多...](_gralloc_funcs.md) | -| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 [更多...](_layer_funcs.md) | -| [DisplayInfo](_display_info.md) | 定义显示信息结构体 [更多...](_display_info.md) | -| [LayerInfo](_layer_info.md) | 定义图层信息结构体 [更多...](_layer_info.md) | -| [LayerAlpha](_layer_alpha.md) | 定义图层Alpha信息的结构体 [更多...](_layer_alpha.md) | -| [BufferData](_buffer_data.md) | 定义一层的缓冲区数据,包括虚拟和物理内存地址。 [更多...](_buffer_data.md) | -| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于存放图层数据。 [更多...](_layer_buffer.md) | -| [IRect](_i_rect.md) | 定义矩形信息 [更多...](_i_rect.md) | -| [ISurface](_i_surface.md) | 用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 [更多...](_i_surface.md) | -| [ILine](_i_line.md) | 线条描述结构体定义,用于硬件加速绘制直线。 [更多...](_i_line.md) | -| [ICircle](_i_circle.md) | 圆形描述结构体定义,用于硬件加速绘制圆形。 [更多...](_i_circle.md) | -| [Rectangle](_rectangle.md) | 矩形描述结构体定义,用于硬件加速绘制矩形, [更多...](_rectangle.md) | -| [GfxOpt](_gfx_opt.md) | 图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 [更多...](_gfx_opt.md) | -| [PropertyObject](_property_object.md) | 定义包含名称、属性ID和值的属性对象。 [更多...](_property_object.md) | -| [DisplayCapability](_display_capability.md) | 定义输出性能。 [更多...](_display_capability.md) | -| [DisplayModeInfo](_display_mode_info.md) | 定义输出模式信息。 [更多...](_display_mode_info.md) | -| [AllocInfo](_alloc_info.md) | 定义关于要分配的内存的信息。 [更多...](_alloc_info.md) | -| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义 [更多...](_h_d_r_capability.md) | -| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数据结构体定义 [更多...](_h_d_r_meta_data.md) | -| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验证内存分配信息的结构体定义 [更多...](_verify_alloc_info.md) | -| [PresentTimestamp](_present_timestamp.md) | 上屏时间戳结构体定义 [更多...](_present_timestamp.md) | -| [__attribute__](____attribute____.md) | 扩展数据句柄结构体定义 [更多...](____attribute____.md) | + | 名称 | 描述 | +| -------- | -------- | +| [DeviceFuncs](_device_funcs.md) | 显示设备控制接口结构体,定义显示设备控制接口函数指针。 | +| [GfxFuncs](_gfx_funcs.md) | 显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 | +| [GrallocFuncs](_gralloc_funcs.md) | 显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 | +| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 | +| [DisplayInfo](_display_info.md) | 定义显示信息结构体 | +| [LayerInfo](_layer_info.md) | 定义图层信息结构体 | +| [LayerAlpha](_layer_alpha.md) | 定义图层Alpha信息的结构体 | +| [BufferData](_buffer_data.md) | 定义一层的缓冲区数据,包括虚拟和物理内存地址。 | +| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于存放图层数据。 | +| [IRect](_i_rect.md) | 定义矩形信息。 | +| [ISurface](_i_surface.md) | 用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 | +| [ILine](_i_line.md) | 线条描述结构体定义,用于硬件加速绘制直线。 | +| [ICircle](_i_circle.md) | 圆形描述结构体定义,用于硬件加速绘制圆形。 | +| [Rectangle](_rectangle.md) | 矩形描述结构体定义,用于硬件加速绘制矩形。 | +| [GfxOpt](_gfx_opt.md) | 图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 | +| [PropertyObject](_property_object.md) | 定义包含名称、属性ID和值的属性对象。 | +| [DisplayCapability](_display_capability.md) | 定义输出性能。 | +| [DisplayModeInfo](_display_mode_info.md) | 定义输出模式信息。 | +| [AllocInfo](_alloc_info.md) | 定义关于要分配的内存的信息。 | +| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义。 | +| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数据结构体定义。 | +| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验证内存分配信息的结构体定义。 | +| [PresentTimestamp](_present_timestamp.md) | 上屏时间戳结构体定义。 | +| [ExtDataHandle](_ext_data_handle.md) | 扩展数据句柄结构体定义。 | +| [YUVDescInfo](_yun_desc_info_.md) | YUV描述信息结构体定义。 | +| [VGUPoint](_v_g_u_point.md) | 坐标点对象。 | +| [VGURect](_v_g_u_rect.md) | 矩形对象。 | +| [VGUPath](_v_g_u_path.md) | 路径对象,存放路径命令和坐标数据。 | +| [VGUMatrix3](_v_g_u_matrix3.md) | 变换矩阵。 | +| [VGUBuffer](_v_g_u_buffer.md) | 硬件加速渲染位图缓存。 | +| [VGUMaskLayer](_v_g_u_mask_layer.md) | 定义蒙版图层。 | +| [VGUSurface](_v_g_u_surface.md) | 2D硬件加速绘制目标表面。 | +| [VGUColorStop](_v_g_u_color_stop.md) | 渐变颜色分布位置。 | +| [VGULinear](_v_g_u_linear.md) | 线性渐变。 | +| [VGURadial](_v_g_u_radial.md) | 辐射渐变。 | +| [VGUConic](_v_g_u_conic.md) | 圆锥渐变。 | +| [VGUImage](_v_g_u_image.md) | 图像对象。 | +| [VGUPattern](_v_g_u_pattern.md) | 图片模式对象。 | +| [VGUGradient](_v_g_u_gradient.md) | 渐变对象。 | +| [VGUSolid](_v_g_u_solid.md) | 颜色对象。 | +| [VGUPaintStyle](_v_g_u_paint_style.md) | 填充或描边路径的渲染风格。 | +| [VGUFillAttr](_v_g_u_fill_attr.md) | 填充路径的属性。 | +| [VGUStrokeAttr](_v_g_u_stroke_attr.md) | 描边路径的属性。 | +| [VGUFuncs](_v_g_u_funcs.md) | 定义2D硬件加速驱动函数。 | ### 宏定义 - | 宏定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| **PROPERTY_NAME_LEN**   50 | 属性名字长度。 | +| [PROPERTY_NAME_LEN](#property_name_len)   50 | 属性名字长度。 | +| [HDI_VGU_SCALAR_IS_FLOAT](#hdi_vgu_scalar_is_float)   1 | VGU标量是否为浮点型 | ### 类型定义 - | 类型定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ([HotPlugCallback](#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | 热插拔事件回调。[更多...](#hotplugcallback) | -| ([VBlankCallback](#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 [更多...](#vblankcallback) | -| ([RefreshCallback](#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调。[更多...](#refreshcallback) | +| ([HotPlugCallback](#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | 热插拔事件回调 。 | +| ([VBlankCallback](#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 | +| ([RefreshCallback](#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调 。 | +| [VGUScalar](#vguscalar) | VGU标量。 | +| [VGUPixelFormat](#vgupixelformat) | 像素格式。 | +| [VGUBlendType](#vgublendtype) | 混合操作类型。 | ### 枚举 - | 枚举 | 描述 | -| -------- | -------- | -| [DispErrCode](#disperrcode) { DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3,   DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7,   DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 [更多...](#disperrcode) | -| [LayerType](#layertype) { LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SIDEBAND, LAYER_TYPE_CURSOR,   LAYER_TYPE_BUTT } | 图层类型定义。 [更多...](#layertype) | -| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3),   HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } | 缓冲区定义。[更多...](#anonymous-enum) | -| [PixelFormat](#pixelformat) { PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565,   PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444,   PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888,   PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444,   PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888,   PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP,   PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P,   PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG,   PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDOR_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | 像素格式类型定义。 [更多...](#pixelformat) | -| [TransformType](#transformtype) { ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270,   ROTATE_BUTT } | 图层变换类型定义。 [更多...](#transformtype) | -| [BlendType](#blendtype) { BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER,   BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT,   BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD,   BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD,   BLEND_BUTT } | 显示内存类型定义。 [更多...](#blendtype) | -| [RopType](#roptype) { ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN,   ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN,   ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN,   ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE,   ROP_BUTT } | 硬件加速支持的ROP操作类型。 [更多...](#roptype) | -| [ColorKey](#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color key操作类型定义,即硬件加速支持的Color key操作类型。 [更多...](#colorkey) | -| [MirrorType](#mirrortype) { MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | 硬件加速支持的镜像操作类型定义 [更多...](#mirrortype) | -| [Connection](#connection) { CON_INVALID = 0, CONNECTED, DISCONNECTED } | 热插拔连接类型定义 [更多...](#connection) | -| [InterfaceType](#interfacetype) { DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656,   DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO,   DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接口类型。 [更多...](#interfacetype) | -| [DispPowerStatus](#disppowerstatus) { POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF,   POWER_STATUS_BUTT } | 枚举显示状态 [更多...](#disppowerstatus) | -| [CompositionType](#compositiontype) { COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO,   COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组合类型。 [更多...](#compositiontype) | -| [ColorGamut](#colorgamut) { COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_STANDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2,   COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6,   COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值 [更多...](#colorgamut) | -| [GamutMap](#gamutmap) { GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | 枚举色域的映射类型 [更多...](#gamutmap) | -| [ColorDataSpace](#colordataspace) {   COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003,   GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007,   GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100,   TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500,   TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900,   PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000,   BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED,   BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL,   DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL,   BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL,   BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型 [更多...](#colordataspace) | -| [HDRFormat](#hdrformat) { NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3,   HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDR格式 [更多...](#hdrformat) | -| [HDRMetadataKey](#hdrmetadatakey) { MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3,   MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7,   MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,   MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字 [更多...](#hdrmetadatakey) | -| [PresentTimestampType](#presenttimestamptype) { HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上屏时间戳类型枚举值 [更多...](#presenttimestamptype) | + | 名称 | 描述 | +| -------- | -------- | +| [DispErrCode](#disperrcode){ DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3,   DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7,   DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 | +| [LayerType](#layertype){ LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SDIEBAND, LAYER_TYPE_CURSOR,   LAYER_TYPE_BUTT } | 图层类型定义。 | +| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3),   HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } | 定义缓冲区使用。 | +| [PixelFormat](#pixelformat){ PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565,   PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444,   PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888,   PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444,   PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888,   PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP,   PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P,   PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG,   PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDER_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | 像素格式类型定义。 | +| [TransformType](#transformtype){ ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270,   ROTATE_BUTT } | 图层变换类型定义。 | +| [BlendType](#blendtype){ BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER,   BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT,   BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD,   BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD,   BLEND_BUTT } | 支持的图像混合类型。 | +| [RopType](#roptype){ ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN,   ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN,   ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN,   ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE,   ROP_BUTT } | 硬件加速支持的ROP操作类型。 | +| [ColorKey](#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color key操作类型定义,即硬件加速支持的Color key操作类型。 | +| [MirrorType](#mirrortype){ MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | 硬件加速支持的镜像操作类型定义。 | +| [Connection](#connection){ CON_INVALID = 0, CONNECTED, DISCONNECTED } | 热插拔连接类型定义。 | +| [InterfaceType](#interfacetype){ DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656,   DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO,   DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接口类型。 | +| [DispPowerStatus](#disppowerstatus){ POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF,   POWER_STATUS_BUTT } | 枚举显示状态。 | +| [CompositionType](#compositiontype){ COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO,   COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组合类型。 | +| [ColorGamut](#colorgamut){ COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_SATNDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2,   COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6,   COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值。 | +| [GamutMap](#gamutmap){ GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | 枚举色域的映射类型。 | +| [ColorDataSpace](#colordataspace){  COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003,   GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007,   GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100,   TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500,   TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900,   PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000,   BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED,   BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL,   DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL,   BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL,   BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型。 | +| [HDRFormat](#hdrformat){ NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3,   HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDR格式。 | +| [HDRMetadataKey](#hdrmetadatakey){  MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3,   MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7,   MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,   MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字。 | +| [PresentTimestampType](#presenttimestamptype){ HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上屏时间戳类型枚举值。 | +| [VGUPathDataType](#vgupathdatatype){ VGU_DATA_TYPE_S16 = 0, VGU_DATA_TYPE_S32, VGU_DATA_TYPE_F32 } | 路径坐标数据类型。 | +| [VGUCapability](#vgucapability){ VGU_CAP_BLIT = (1 << 0), VGU_CAP_BLIT_NUM = (1 << 1), VGU_CAP_PATH = (1 << 2), VGU_CAP_FILTER_BLUR = (1 << 3) } | 硬件加速能力。 | +| [VGUResult](#vguresult){   VGU_SUCCESS = 0, VGU_NO_SUPPORT = -1, VGU_OPERATION_FAILED = -2, VGU_OUT_OF_MEMORY = -3,   VGU_TIMEOUT = -4, VGU_INVALID_PARAMETER = -5, VGU_BUSY = -6, VGU_NO_CONTEXT = -7 } | 错误码定义。 | +| [VGULineCap](#vgulinecap){ VGU_LINECAP_BUTT = 0, VGU_LINECAP_ROUND, VGU_LINECAP_SQUARE } | 线帽。 | +| [VGUJointType](#vgujointtype){ VGU_LINE_JOIN_MITER = 0, VGU_LINE_JOIN_ROUND, VGU_LINE_JOIN_BEVEL, VGU_LINE_JOIN_BUTT } | 联接类型。 | +| [VGUFilter](#vgufilter){ VGU_FILTER_BILINEAR = 0, VGU_FILTER_NEAREST, VGU_FILTER_LINEAR, VGU_FILTER_BUTT } | 图像滤波类型。 | +| [VGUFillRule](#vgufillrule){ VGU_RULE_WINDING = 0, VGU_RULE_EVEN_ODD, VGU_RULE_BUTT } | 填充规则定义。 | +| [VGUFillSpread](#vgufillspread){ VGU_SPREAD_PAD = 0, VGU_SPREAD_REFLECT, VGU_SPREAD_REPEAT, VGU_SPREAD_BUTT } | 渐变填充区域外的延展类型。 | +| [VGUWrapType](#vguwraptype){ VGU_WRAP_REFLECT = 0, VGU_WRAP_REPEAT, VGU_WRAP_BUTT } | 图像模式填充延展类型。 | +| [VGUPathCmd](#vgupathcmd){   VGU_PATH_CMD_CLOSE = 0, VGU_PATH_CMD_MOVE, VGU_PATH_CMD_LINE, VGU_PATH_CMD_HLINE,   VGU_PATH_CMD_VLINE, VGU_PATH_CMD_QUAD, VGU_PATH_CMD_CUBIC, VGU_PATH_CMD_SQUAD,   VGU_PATH_CMD_SCUBIC, VGU_PATH_CMD_BUTT } | 路径绘制指令类型。 | +| [VGUTransformType](#vgutransformtype){ VGU_TRANSFORM_TRANSLATE = (1 << 0), VGU_TRANSFORM_SCALE = (1 << 1), VGU_TRANSFORM_ROTATE_90 = (1 << 2), VGU_TRANSFORM_ROTATE_180 = (1 << 3),   VGU_TRANSFORM_ROTATE_270 = (1 << 4), VGU_TRANSFORM_OTHER = (1 << 16) } | 变换类型。 | +| [VGUClipType](#vgucliptype){ VGU_CLIP_RECT = 0, VGU_CLIP_PATH, VGU_CLIP_BUTT } | 绘制表面剪切类型。 | +| [VGUGradientType](#vgugradienttype){ VGU_GRADIENT_LINEAR = 0, VGU_GRADIENT_RADIAL, VGU_GRADIENT_CONIC, VGU_GRADIENT_BUTT } | 渐变类型。 | +| [VGUPaintType](#vgupainttype){ VGU_PAINT_SOLID = 0, VGU_PAINT_GRADIENT, VGU_PAINT_PATTERN, VGU_PAINT_BUTT } | 渲染对象。 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [DeviceInitialize](#deviceinitialize) ([DeviceFuncs](_device_funcs.md) \*\*funcs) | 实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 [更多...](#deviceinitialize) | -| [DeviceUninitialize](#deviceuninitialize) ([DeviceFuncs](_device_funcs.md) \*funcs) | 取消显示设备控制接口的初始化,释放控制接口使用到的资源。 [更多...](#deviceuninitialize) | -| [GfxInitialize](#gfxinitialize) ([GfxFuncs](_gfx_funcs.md) \*\*funcs) | 获取硬件加速相关的操作接口指针。 [更多...](#gfxinitialize) | -| [GfxUninitialize](#gfxuninitialize) ([GfxFuncs](_gfx_funcs.md) \*funcs) | 释放硬件加速相关的操作接口指针。 [更多...](#gfxuninitialize) | -| [GrallocInitialize](#grallocinitialize) ([GrallocFuncs](_gralloc_funcs.md) \*\*funcs) | 初始化内存模块,并获取内存提供的操作接口。 [更多...](#grallocinitialize) | -| [GrallocUninitialize](#grallocuninitialize) ([GrallocFuncs](_gralloc_funcs.md) \*funcs) | 取消初始化内存模块,并释放内存操作接口指针。 [更多...](#grallocuninitialize) | -| [LayerInitialize](#layerinitialize) ([LayerFuncs](_layer_funcs.md) \*\*funcs) | 实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 [更多...](#layerinitialize) | -| [LayerUninitialize](#layeruninitialize) ([LayerFuncs](_layer_funcs.md) \*funcs) | 取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 [更多...](#layeruninitialize) | +| [DeviceInitialize](#deviceinitialize)(DeviceFuncs \*\*funcs) | 实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 | +| [DeviceUninitialize](#deviceuninitialize)(DeviceFuncs \*funcs) | 取消显示设备控制接口的初始化,释放控制接口使用到的资源。 | +| [GfxInitialize](#gfxinitialize)(GfxFuncs \*\*funcs) | 获取硬件加速相关的操作接口指针。 | +| [GfxUninitialize](#gfxuninitialize)(GfxFuncs \*funcs) | 释放硬件加速相关的操作接口指针。 | +| [GrallocInitialize](#grallocinitialize)(GrallocFuncs \*\*funcs) | 初始化内存模块,并获取内存提供的操作接口。 | +| [GrallocUninitialize](#grallocuninitialize)(GrallocFuncs \*funcs) | 取消初始化内存模块,并释放内存操作接口指针。 | +| [LayerInitialize](#layerinitialize)(LayerFuncs \*\*funcs) | 实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 | +| [LayerUninitialize](#layeruninitialize)(LayerFuncs \*funcs) | 取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 | +| [VGUPathInit](#vgupathinit)(VGUPath \*path, VGUPathDataType type, const uint8_t \*segments, int numSegments, const uint8_t \*data, bool enAlias, VGURect boundBox) | 初始化路径对象。 | +| [VGUPathAppend](#vgupathappend)(VGUPath \*path, const VGUPath \*subpath) | 添加子路径到当前路径中。 | +| [VGUPathClear](#vgupathclear)(VGUPath \*path) | 清除路径对象内存。 | +| [VGUMatrixIdentity](#vgumatrixidentity)(VGUMatrix3 \*matrix) | 初始化矩阵对象为单位矩阵。 | +| [VGUMatrixScale](#vgumatrixscale)(VGUMatrix3 \*matrix, float xScale, float yScale) | 矩阵变换缩放。 | +| [VGUMatrixRotate](#vgumatrixrotate)(VGUMatrix3 \*matrix, float degree) | 矩阵变换旋转。 | +| [VGUMatrixTranslate](#vgumatrixtranslate)(VGUMatrix3 \*matrix, float x, float y) | 矩阵变换平移。 | +| [VGUGradientColorStop](#vgugradientcolorstop)(VGUGradient \*gradient, const VGUColorStop \*colorStop, uint32_t count) | 对渐变添加ColorStop。 | +| [VGUGradientClearStop](#vgugradientclearstop)(VGUGradient \*gradient) | 清除ColorStop。 | +| [VGUGradientMatrix](#vgugradientmatrix)(VGUGradient \*gradient, const VGUMatrix3 \*matrix) | 设置渐变对象的变换矩阵。 | +| [VGUGradientLinear](#vgugradientlinear)(VGUGradient \*gradient, const VGUPoint \*p1, const VGUPoint \*p2) | 创建线性渐变对象。 | +| [VGUGradientRadial](#vgugradientradial)(VGUGradient \*gradient, const VGUPoint \*p1, VGUScalar r1, const VGUPoint \*p2, VGUScalar r2) | 创建辐射渐变对象 | +| [VGUGradientConic](#vgugradientconic)(VGUGradient \*gradient, VGUScalar cx, VGUScalar cy) | 创建圆锥渐变对象。 | +| [VGUInitialize](#vguinitialize)(VGUFuncs \*\*funcs) | 获取硬件加速相关的操作接口指针。 | +| [VGUUninitialize](#vguuninitialize)(VGUFuncs \*funcs) | 去初始化硬件加速模块,同时释放硬件加速模块操作函数指针。 | ### 变量 -| 变量 | 描述 | -| -------- | -------- | -| ( [DeviceFuncs::RegHotPlugCallback](#reghotplugcallback) )([HotPlugCallback](#hotplugcallback) callback, void \*data) | 注册热插拔事件回调。 [更多...](#reghotplugcallback) | -| ( [DeviceFuncs::RegDisplayVBlankCallback](#regdisplayvblankcallback) )(uint32_t devId, [VBlankCallback](#vblankcallback) callback, void \*data) | 注册VBlank事件回调。 [更多...](#regdisplayvblankcallback) | -| ( [DeviceFuncs::RegDisplayRefreshCallback](#regdisplayrefreshcallback) )(uint32_t devId, [RefreshCallback](#refreshcallback) callback, void \*data) | 刷新请求回调。 [更多...](#regdisplayrefreshcallback) | -| ( [DeviceFuncs::GetDisplayCapability](#getdisplaycapability) )(uint32_t devId, [DisplayCapability](_display_capability.md) \*info) | 获取显示设备能力集。 [更多...](#getdisplaycapability) | -| ( [DeviceFuncs::GetDisplaySupportedModes](#getdisplaysupportedmodes) )(uint32_t devId, uint32_t \*num, [DisplayModeInfo](_display_mode_info.md) \*modes) | 获取显示设备支持的显示模式信息。 [更多...](#getdisplaysupportedmodes) | -| ( [DeviceFuncs::GetDisplayMode](#getdisplaymode) )(uint32_t devId, uint32_t \*modeId) | 获取显示设备当前的显示模式。 [更多...](#getdisplaymode) | -| ( [DeviceFuncs::SetDisplayMode](#setdisplaymode) )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模式。 [更多...](#setdisplaymode) | -| ( [DeviceFuncs::GetDisplayPowerStatus](#getdisplaypowerstatus) )(uint32_t devId, [DispPowerStatus](#disppowerstatus) \*status) | 获取显示设备当前的电源状态。 [更多...](#getdisplaypowerstatus) | -| ([ DeviceFuncs::SetDisplayPowerStatus](#setdisplaypowerstatus) )(uint32_t devId, [DispPowerStatus](#disppowerstatus) status) | 设置显示设备当前的电源状态。 [更多...](#setdisplaypowerstatus) | -| ( [DeviceFuncs::GetDisplayBacklight](#getdisplaybacklight) )(uint32_t devId, uint32_t \*level) | 获取显示设备当前的背光值。 [更多...](#getdisplaybacklight) | -| ( [DeviceFuncs::SetDisplayBacklight](#setdisplaybacklight) )(uint32_t devId, uint32_t level) | 设置显示设备当前的背光值。 [更多...](#setdisplaybacklight) | -| ( [DeviceFuncs::GetDisplayProperty](#getdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t \*value) | 获得显示设备属性值。 [更多...](#getdisplayproperty) | -| ( [DeviceFuncs::SetDisplayProperty](#setdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 [更多...](#setdisplayproperty) | -| ( [DeviceFuncs::PrepareDisplayLayers](#preparedisplaylayers) )(uint32_t devId, bool \*needFlushFb) | 显示设备合成前准备。 [更多...](#preparedisplaylayers) | -| ( [DeviceFuncs::GetDisplayCompChange](#getdisplaycompchange) )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获取显示设备合成类型有变化的layer。 [更多...](#getdisplaycompchange) | -| ( [DeviceFuncs::SetDisplayClientCrop](#setdisplayclientcrop) )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的裁剪区域。 [更多...](#setdisplayclientcrop) | -| ( [DeviceFuncs::SetDisplayClientDestRect](#setdisplayclientdestrect) )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示区域。 [更多...](#setdisplayclientdestrect) | -| ( [DeviceFuncs::SetDisplayClientBuffer](#setdisplayclientbuffer) )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓存。 [更多...](#setdisplayclientbuffer) | -| ( [DeviceFuncs::SetDisplayClientDamage](#setdisplayclientdamage) )(uint32_t devId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示脏区。 [更多...](#setdisplayclientdamage) | -| ( [DeviceFuncs::SetDisplayVsyncEnabled](#setdisplayvsyncenabled) )(uint32_t devId, bool enabled) | 使能垂直同步信号。 [更多...](#setdisplayvsyncenabled) | -| ( [DeviceFuncs::GetDisplayReleaseFence](#getdisplayreleasefence) )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获取显示图层fence。 [更多...](#getdisplayreleasefence) | -| ( [DeviceFuncs::GetDisplaySupportedColorGamuts](#getdisplaysupportedcolorgamuts) )(uint32_t devId, uint32_t \*num, [ColorGamut](#colorgamut) \*gamuts) | 获取显示设备支持的色域信息。 [更多...](#getdisplaysupportedcolorgamuts) | -| ( [DeviceFuncs::GetDisplayColorGamut](#getdisplaycolorgamut) )(uint32_t devId, [ColorGamut](#colorgamut) \*gamut) | 获取显示设备当前的色域模式。 [更多...](#getdisplaycolorgamut) | -| ( [DeviceFuncs::SetDisplayColorGamut](#setdisplaycolorgamut) )(uint32_t devId, [ColorGamut](#colorgamut) gamut) | 设置显示设备当前的色域模式。 [更多...](#setdisplaycolorgamut) | -| ( [DeviceFuncs::GetDisplayGamutMap](#getdisplaygamutmap) )(uint32_t devId, [ColorGamut](#colorgamut) \*gamutMap) | 获取显示设备当前的色域映射模式。 [更多...](#getdisplaygamutmap) | -| ( [DeviceFuncs::SetDisplayGamutMap](#setdisplaygamutmap) )(uint32_t devId, [ColorGamut](#colorgamut) gamutMap) | 设置显示设备当前的色域映射模式。 [更多...](#setdisplaygamutmap) | -| ( [DeviceFuncs::SetDisplayColorTransform](#setdisplaycolortransform) )(uint32_t devId, const float \*matrix) | 设置显示设备当前的4x4的颜色转换矩阵。 [更多...](#setdisplaycolortransform) | -| ( [DeviceFuncs::GetHDRCapabilityInfos](#gethdrcapabilityinfos) )(uint32_t devId, [HDRCapability](_h_d_r_capability.md) \*info) | 获取显示设备支持的HDR属性信息。 [更多...](#gethdrcapabilityinfos) | -| ( [DeviceFuncs::GetSupportedMetadataKey](#getsupportedmetadatakey) )(uint32_t devId, uint32_t \*num, [HDRMetadataKey](#hdrmetadatakey) \*keys) | 获取显示设备支持的 HDRMetadataKey。 [更多...](#getsupportedmetadatakey) | -| ( [DeviceFuncs::Commit](#commit) )(uint32_t devId, int32_t \*fence) | 提交合成送显请求。 [更多...](#commit) | -| ( [DeviceFuncs::InvokeDisplayCmd](#invokedisplaycmd) )(uint32_t devId,...) | 调用显示设备命令。 [更多...](#invokedisplaycmd) | -| ([ DeviceFuncs::CreateVirtualDisplay](#createvirtualdisplay) )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 [更多...](#createvirtualdisplay) | -| ( [DeviceFuncs::DestroyVirtualDisplay](#destroyvirtualdisplay) )(uint32_t devId) | 销毁虚拟显示设备。 [更多...](#destroyvirtualdisplay) | -| ( [DeviceFuncs::SetVirtualDisplayBuffer](#setvirtualdisplaybuffer) )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟屏的输出缓存。 [更多...](#setvirtualdisplaybuffer) | -| ( [DeviceFuncs::GetWriteBackFrame](#getwritebackframe) )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获取显示设备的回写帧。 [更多...](#getwritebackframe) | -| ( [DeviceFuncs::CreateWriteBack](#createwriteback) )(uint32_t \*devId, uint32_t width, uint32_t height, int32_t \*format) | 对指定显示设备创建回写点。 [更多...](#createwriteback) | -| ( [DeviceFuncs::DestroyWriteBack](#destroywriteback) )(uint32_t devId) | 销毁指定显示设备的回写点。 [更多...](#destroywriteback) | -| [DisplayInfo::width](#width-17) | 显示屏宽度 | -| [DisplayInfo::height](#height-17) | 显示屏高度 | -| [DisplayInfo::rotAngle](#rotangle) | 显示屏旋转角度 | -| [LayerInfo::width](#width-27) | 图层宽度 | -| [LayerInfo::height](#height-27) | 图层高度 | -| [LayerInfo::type](#type-13) | 图层类型,包括图形层、视频层和媒体播放模式 | -| [LayerInfo::bpp](#bpp) | 每像素所占bit数 | -| [LayerInfo::pixFormat](#pixformat-12) | 图层像素格式 | -| [LayerAlpha::enGlobalAlpha](#englobalalpha-12) | 全局Alpha使能标志 | -| [LayerAlpha::enPixelAlpha](#enpixelalpha-12) | 像素Alpha使能标志 | -| [LayerAlpha::alpha0](#alpha0-12) | Alpha0值,取值范围:[0, 255] | -| [LayerAlpha::alpha1](#alpha1-12) | Alpha1值,取值范围:[0, 255] | -| [LayerAlpha::gAlpha](#galpha) | 全局Alpha值,取值范围:[0, 255] | -| [BufferData::phyAddr](#phyaddr-12) | 物理内存地址 | -| [BufferData::virAddr](#viraddr) | 虚拟内存地址 | -| [LayerBuffer::fenceId](#fenceid) | buffer 的fence号r | -| [LayerBuffer::width](#width-37) | buffer宽度 | -| [LayerBuffer::height](#height-37) | buffer高度 | -| [LayerBuffer::pitch](#pitch) | 一行数据所占字节数 | -| [LayerBuffer::pixFormat](#pixformat-22) | buffer像素格式r | -| [LayerBuffer::data](#data) | 图层buffer数据 | -| [LayerBuffer::hdl](#hdl) | 图层buffer句柄 | -| [IRect::x](#x-12) | 矩形框起始x坐标 | -| [IRect::y](#y-12) | 矩形框起始y坐标 | -| [IRect::w](#w) | 矩形框宽度 | -| [IRect::h](#h) | 矩形框高度 | -| [ISurface::phyAddr](#phyaddr-22) | 图像首地址 | -| [ISurface::height](#height-47) | 图像高度 | -| [ISurface::width](#width-47) | 图像宽度 | -| [ISurface::stride](#stride) | 图像跨度 | -| [ISurface::enColorFmt](#encolorfmt) | 图像格式 | -| [ISurface::bYCbCrClut](#bycbcrclut) | CLUT表是否位于YCbCr 空间 | -| [ISurface::bAlphaMax255](#balphamax255) | 图像Alpha最大值为255还是128 | -| [ISurface::bAlphaExt1555](#balphaext1555) | 是否使能1555的Alpha扩展 | -| [ISurface::alpha0](#alpha0-22) | Alpha0值,取值范围:[0,255] | -| [ISurface::alpha1](#alpha1-22) | Alpha1值,取值范围:[0,255] | -| [ISurface::cbcrPhyAddr](#cbcrphyaddr) | CbCr分量地址 | -| [ISurface::cbcrStride](#cbcrstride) | CbCr分量跨度 | -| [ISurface::clutPhyAddr](#clutphyaddr) | CLUT表首地址,用作颜色扩展或颜色校正 | -| [ILine::x0](#x0) | 线条起点的x坐标 | -| [ILine::y0](#y0) | 线条起点的y坐标 | -| [ILine::x1](#x1) | 线条终点的x坐标 | -| [ILine::y1](#y1) | 线条终点的y坐标 | -| [ILine::color](#color-13) | 线条颜色 | -| [ICircle::x](#x-22) | 圆心x坐标 | -| [ICircle::y](#y-22) | 圆心y坐标r | -| [ICircle::r](#r) | 圆的半径 | -| [ICircle::color](#color-23) | 圆的颜色 | -| [Rectangle::rect](#rect) | 矩形区域 | -| [Rectangle::color](#color-33) | 矩形颜色 | -| [GfxOpt::enGlobalAlpha](#englobalalpha-22) | 全局Alpha使能位 | -| [GfxOpt::globalAlpha](#globalalpha) | 全局Alpha的值 | -| [GfxOpt::enPixelAlpha](#enpixelalpha-22) | 像素Alpha使能位 | -| [GfxOpt::blendType](#blendtype) | 混合方式 | -| [GfxOpt::colorKeyFrom](#colorkeyfrom) | 色键模式 | -| [GfxOpt::enableRop](#enablerop) | Rop功能使能位 | -| [GfxOpt::colorRopType](#colorroptype) | 颜色的Rop类型 | -| [GfxOpt::alphaRopType](#alpharoptype) | Alpha的Rop类型 | -| [GfxOpt::enableScale](#enablescale) | 缩放功能使能位 | -| [GfxOpt::rotateType](#rotatetype) | 旋转类型 | -| [GfxOpt::mirrorType](#mirrortype) | 镜像类型 | -| [PropertyObject::name](#name-12) [PROPERTY_NAME_LEN] | 属性名称 | -| [PropertyObject::propId](#propid) | 属性ID | -| [PropertyObject::value](#value-12) | 属性值 | -| [DisplayCapability::name](#name-22) [PROPERTY_NAME_LEN] | 显示设备名称 | -| [DisplayCapability::type](#type-23) | 显示屏接口类型 | -| [DisplayCapability::phyWidth](#phywidth) | 物理宽度 | -| [DisplayCapability::phyHeight](#phyheight) | 物理高度 | -| [DisplayCapability::supportLayers](#supportlayers) | 支持的图层数 | -| [DisplayCapability::virtualDispCount](#virtualdispcount) | 支持的虚拟屏数 | -| [DisplayCapability::supportWriteBack](#supportwriteback) | 是否支持回写 | -| [DisplayCapability::propertyCount](#propertycount) | 属性数组大小 | -| [DisplayCapability::props](#props) | 属性数组 | -| [DisplayModeInfo::width](#width-57) | 像素宽度 | -| [DisplayModeInfo::height](#height-57) | 像素高度 | -| [DisplayModeInfo::freshRate](#freshrate) | 刷新速率 | -| [DisplayModeInfo::id](#id) | 模式ID | -| [AllocInfo::width](#width-67) | 申请内存宽度 | -| [AllocInfo::height](#height-67) | 申请内存高度 | -| [AllocInfo::usage](#usage-12) | 申请内存的使用场景 | -| [AllocInfo::format](#format-12) | 申请内存格式 | -| [AllocInfo::expectedSize](#expectedsize) | 申请内存大小 | -| [HDRCapability::formatCount](#formatcount) | 支持的HDR格式的数量 | -| [HDRCapability::formats](#formats) | 支持的HDR格式的数组首地址 | -| [HDRCapability::maxLum](#maxlum) | 最大的光亮度luminance值 | -| [HDRCapability::maxAverageLum](#maxaveragelum) | 最大的平均光亮度luminance值 | -| [HDRCapability::minLum](#minlum) | 最小的光亮度luminance值 | -| [HDRMetaData::key](#key) | HDR元数据关键字 | -| [HDRMetaData::value](#value-22) | 关键字对应的值 | -| [VerifyAllocInfo::width](#width-77) | 分配内存的宽度 | -| [VerifyAllocInfo::height](#height-77) | 分配内存的高度 | -| [VerifyAllocInfo::usage](#usage-22) | 内存的用处 | -| [VerifyAllocInfo::format](#format-22) | 分配内存的像素格式 | -| [PresentTimestamp::type](#type-33) | 上屏时间戳类型 | -| [PresentTimestamp::time](#time) | 类型对应的值 | -| [__attribute__::fd](#fd) | 句柄 fd,-1代表不支持 | -| [__attribute__::reserveInts](#reserveints) | reserve数组的个数 | -| [__attribute__::reserve](#reserve) [0] | reserve数组 | -| [__attribute__::baseAddr](#baseaddr) | 内存的初始地址 | -| [__attribute__::yOffset](#yoffset) | Y的偏移量 | -| [__attribute__::uOffset](#uoffset) | U的偏移量 | -| [__attribute__::vOffset](#voffset) | V的偏移量 | -| [__attribute__::yStride](#ystride) | Y的stride信息 | -| [__attribute__::uvStride](#uvstride) | UV的stride信息 | -| [__attribute__::uvStep](#uvstep) | UV的step信息 | - - -## **详细描述** + | 名称 | 描述 | +| -------- | -------- | +| ([DeviceFuncs::RegHotPlugCallback](#reghotplugcallback) )(HotPlugCallback callback, void \*data) | 注册热插拔事件回调。 | +| ([DeviceFuncs::RegDisplayVBlankCallback](#regdisplayvblankcallback) )(uint32_t devId, VBlankCallback callback, void \*data) | 注册VBlank事件回调。 | +| ([DeviceFuncs::RegDisplayRefreshCallback](#regdisplayrefreshcallback) )(uint32_t devId, RefreshCallback callback, void \*data) | 刷新请求回调。 | +| ([DeviceFuncs::GetDisplayCapability](#getdisplaycapability) )(uint32_t devId, DisplayCapability \*info) | 获取显示设备能力集。 | +| ([DeviceFuncs::GetDisplaySupportedModes](#getdisplaysupportedmodes) )(uint32_t devId, uint32_t \*num, DisplayModeInfo \*modes) | 获取显示设备支持的显示模式信息。 | +| ([DeviceFuncs::GetDisplayMode](#getdisplaymode) )(uint32_t devId, uint32_t \*modeId) | 获取显示设备当前的显示模式。 | +| ([DeviceFuncs::SetDisplayMode](#setdisplaymode) )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模式。 | +| ([DeviceFuncs::GetDisplayPowerStatus](#getdisplaypowerstatus) )(uint32_t devId, DispPowerStatus \*status) | 获取显示设备当前的电源状态。 | +| ([DeviceFuncs::SetDisplayPowerStatus](#setdisplaypowerstatus) )(uint32_t devId, DispPowerStatus status) | 设置显示设备当前的电源状态。 | +| ([DeviceFuncs::GetDisplayBacklight](#getdisplaybacklight) )(uint32_t devId, uint32_t \*level) | 获取显示设备当前的背光值。 | +| ([DeviceFuncs::SetDisplayBacklight](#setdisplaybacklight) )(uint32_t devId, uint32_t level) | 设置显示设备当前的背光值。 | +| ([DeviceFuncs::GetDisplayProperty](#getdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t \*value) | 获取显示设备属性值。 | +| ([DeviceFuncs::SetDisplayProperty](#setdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 | +| ([DeviceFuncs::PrepareDisplayLayers](#preparedisplaylayers) )(uint32_t devId, bool \*needFlushFb) | 显示设备合成前准备。 | +| ([DeviceFuncs::GetDisplayCompChange](#getdisplaycompchange) )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获取显示设备合成类型有变化的layer。 | +| ([DeviceFuncs::SetDisplayClientCrop](#setdisplayclientcrop) )(uint32_t devId, IRect \*rect) | 设置显示设备的裁剪区域。 | +| ([DeviceFuncs::SetDisplayClientDestRect](#setdisplayclientdestrect) )(uint32_t devId, IRect \*rect) | 设置显示设备的显示区域。 | +| ([DeviceFuncs::SetDisplayClientBuffer](#setdisplayclientbuffer) )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓存。 | +| ([DeviceFuncs::SetDisplayClientDamage](#setdisplayclientdamage) )(uint32_t devId, uint32_t num, IRect \*rect) | 设置显示设备的显示脏区。 | +| ([DeviceFuncs::SetDisplayVsyncEnabled](#setdisplayvsyncenabled) )(uint32_t devId, bool enabled) | 使能垂直同步信号。 | +| ([DeviceFuncs::GetDisplayReleaseFence](#getdisplayreleasefence) )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获取显示图层fence。 | +| ([DeviceFuncs::GetDisplaySupportedColorGamuts](#getdisplaysupportedcolorgamuts) )(uint32_t devId, uint32_t \*num, ColorGamut \*gamuts) | 获取显示设备支持的色域信息。 | +| ([DeviceFuncs::GetDisplayColorGamut](#getdisplaycolorgamut) )(uint32_t devId, ColorGamut \*gamut) | 获取显示设备当前的色域模式。 | +| ([DeviceFuncs::SetDisplayColorGamut](#setdisplaycolorgamut) )(uint32_t devId, ColorGamut gamut) | 设置显示设备当前的色域模式。 | +| ([DeviceFuncs::GetDisplayGamutMap](#getdisplaygamutmap) )(uint32_t devId, GamutMap \*gamutMap) | 获取显示设备当前的色域映射模式。 | +| ([DeviceFuncs::SetDisplayGamutMap](#setdisplaygamutmap) )(uint32_t devId, GamutMap gamutMap) | 设置显示设备当前的色域映射模式。 | +| ([DeviceFuncs::SetDisplayColorTransform](#setdisplaycolortransform) )(uint32_t devId, const float \*matrix) | 设置显示设备当前的4x4的颜色转换矩阵。 | +| ([DeviceFuncs::GetHDRCapabilityInfos](#gethdrcapabilityinfos) )(uint32_t devId, HDRCapability \*info) | 获取显示设备支持的HDR属性信息。 | +| ([DeviceFuncs::GetSupportedMetadataKey](#getsupportedmetadatakey) )(uint32_t devId, uint32_t \*num, DisplayInfo::widthHDRMetadataKey \*keys) | 获取显示设备支持的 HDRMetadataKey。 | +| ([DeviceFuncs::Commit](#commit) )(uint32_t devId, int32_t \*fence) | 提交合成送显请求。 | +| ([DeviceFuncs::InvokeDisplayCmd](#invokedisplaycmd) )(uint32_t devId,...) | 调用显示设备命令。 | +| ([DeviceFuncs::CreateVirtualDisplay](#createvirtualdisplay) )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 | +| ([DeviceFuncs::DestroyVirtualDisplay](#destroyvirtualdisplay) )(uint32_t devId) | 销毁虚拟显示设备。 | +| ([DeviceFuncs::SetVirtualDisplayBuffer](#setvirtualdisplaybuffer) )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟屏的输出缓存。 | +| ([DeviceFuncs::GetWriteBackFrame](#getwritebackframe) )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获取显示设备的回写帧。 | +| [DisplayInfo::width](#width-19) | 显示屏宽度 | +| [DisplayInfo::height](#height-18) | 显示屏高度 | +| [DisplayInfo::rotAngle](#rotangle) | 显示屏旋转角度 | +| [LayerInfo::width](#width-29) | 图层宽度 | +| [LayerInfo::height](#height-28) | 图层高度 | +| [LayerInfo::type](#type-17) | 图层类型,包括图形层、视频层和媒体播放模式。 | +| [LayerInfo::bpp](#bpp) | 每像素所占bit数 | +| [LayerInfo::pixFormat](#pixformat-12) | 图层像素格式 | +| [LayerAlpha::enGlobalAlpha](#englobalalpha-12) | 全局Alpha使能标志 | +| [LayerAlpha::enPixelAlpha](#enpixelalpha-12) | 像素Alpha使能标志 | +| [LayerAlpha::alpha0](#alpha0-12) | Alpha0值,取值范围:[0, 255] | +| [LayerAlpha::alpha1](#alpha1-12) | Alpha1值,取值范围:[0, 255] | +| [LayerAlpha::gAlpha](#galpha) | 全局alpha值,取值范围:[0, 255] | +| [BufferData::phyAddr](#phyaddr-13) | 物理内存地址 | +| [BufferData::virAddr](#viraddr-12) | 虚拟内存地址 | +| [LayerBuffer::fenceId](#fenceid) | buffer 的fence号 | +| [LayerBuffer::width](#width-39) | buffer宽度 | +| [LayerBuffer::height](#height-38) | buffer高度 | +| [LayerBuffer::pitch](#pitch) | 一行数据所占字节数 | +| [LayerBuffer::pixFormat](#pixformat-22) | buffer像素格式 | +| [LayerBuffer::data](#data-12) | 图层buffer数据 | +| [LayerBuffer::hdl](#hdl) | 图层buffer句柄 | +| [IRect::x](#x-14) | 矩形框起始x坐标 | +| [IRect::y](#y-14) | 矩形框起始y坐标 | +| [IRect::w](#w-12) | 矩形框宽度 | +| [IRect::h](#h-12) | 矩形框高度 | +| [ISurface::phyAddr](#phyaddr-23) | 图像首地址 | +| [ISurface::height](#height-48) | 图像高度 | +| [ISurface::width](#width-49) | 图像宽度 | +| [ISurface::stride](#stride-12) | 图像跨度 | +| [ISurface::enColorFmt](#encolorfmt) | 图像格式 | +| [ISurface::bYCbCrClut](#bycbcrclut) | CLUT表是否位于YCbCr 空间 | +| [ISurface::bAlphaMax255](#balphamax255) | 图像Alpha最大值为255还是128 | +| [ISurface::bAlphaExt1555](#balphaext1555) | 是否使能1555的Alpha扩展 | +| [ISurface::alpha0](#alpha0-22) | Alpha0值,取值范围:[0,255] | +| [ISurface::alpha1](#alpha1-22) | Alpha1值,取值范围:[0,255] | +| [ISurface::cbcrPhyAddr](#clutphyaddr) | CbCr分量地址 | +| [ISurface::cbcrStride](#cbcrstride) | CbCr分量跨度 | +| [ISurface::clutPhyAddr](#clutphyaddr) | CLUT表首地址,用作颜色扩展或颜色校正。 | +| [ILine::x0](#x0-12) | 线条起点的x坐标 | +| [ILine::y0](#y0-12) | 线条起点的y坐标 | +| [ILine::x1](#x1-13) | 线条终点的x坐标 | +| [ILine::y1](#y1-13) | 线条终点的y坐标 | +| [ILine::color](#color-15) | 线条颜色 | +| [ICircle::x](#x-24) | 圆心x坐标 | +| [ICircle::y](#y-24) | 圆心y坐标r | +| [ICircle::r](#r) | 圆的半径 | +| [ICircle::color](#color-25) | 圆的颜色 | +| [Rectangle::rect](#rect-13) | 矩形区域 | +| [Rectangle::color](#color-35) | 矩形颜色 | +| [GfxOpt::enGlobalAlpha](#englobalalpha-22) | 全局Alpha使能位 | +| [GfxOpt::globalAlpha](#globalalpha) | 全局Alpha的值 | +| [GfxOpt::enPixelAlpha](#enpixelalpha-22) | 像素Alpha使能位 | +| [GfxOpt::blendType](#blendtype) | 混合方式 | +| [GfxOpt::colorKeyFrom](#colorkeyfrom) | 色键模式 | +| [GfxOpt::enableRop](#enablerop) | Rop功能使能位 | +| [GfxOpt::colorRopType](#colorroptype) | 颜色的Rop类型 | +| [GfxOpt::alphaRopType](#alpharoptype) | Alpha的Rop类型 | +| [GfxOpt::enableScale](#enablescale) | 缩放功能使能位 | +| [GfxOpt::rotateType](#rotatetype) | 旋转类型 | +| [GfxOpt::mirrorType](#mirrortype) | 镜像类型 | +| [PropertyObject::name](#name-12) | 属性名称 | +| [PropertyObject::propId](#propid) | 属性ID | +| [PropertyObject::value](#value-12) | 属性值 | +| [DisplayCapability::name](#name-22) | 显示设备名称 | +| [DisplayCapability::type](#type-27) | 显示屏接口类型 | +| [DisplayCapability::phyWidth](#phywidth) | 物理宽度 | +| [DisplayCapability::phyHeight](#phyheight) | 物理高度 | +| [DisplayCapability::supportLayers](#supportlayers) | 支持的图层数 | +| [DisplayCapability::virtualDispCount](#virtualdispcount) | 支持的虚拟屏数 | +| [DisplayCapability::supportWriteBack](#supportwriteback) | 是否支持回写 | +| [DisplayCapability::propertyCount](#propertycount) | 属性数组大小 | +| [DisplayCapability::props](#props) | 属性数组 | +| [DisplayModeInfo::width](#width-59) | 像素宽度 | +| [DisplayModeInfo::height](#height-58) | 像素高度 | +| [DisplayModeInfo::freshRate](#freshrate) | 刷新速率 | +| [DisplayModeInfo::id](#id) | 模式ID | +| [AllocInfo::width](#width-69) | 申请内存宽度 | +| [AllocInfo::height](#height-68) | 申请内存高度 | +| [AllocInfo::usage](#usage-12) | 申请内存的使用场景 | +| [AllocInfo::format](#format-12) | 申请内存格式 | +| [AllocInfo::expectedSize](#expectedsize) | 申请内存大小 | +| [HDRCapability::formatCount](#formatcount) | 支持的HDR格式的数量 | +| [HDRCapability::formats](#formats) | 支持的HDR格式的数组首地址 | +| [HDRCapability::maxLum](#maxlum) | 最大的光亮度luminance值 | +| [HDRCapability::maxAverageLum](#maxaveragelum) | 最大的平均光亮度luminance值 | +| [HDRCapability::minLum](#minlum) | 最小的光亮度luminance值 | +| [HDRMetaData::key](#key) | HDR元数据关键字 | +| [HDRMetaData::value](#value-22) | 关键字对应的值 | +| [VerifyAllocInfo::width](#width-79) | 分配内存的宽度 | +| [VerifyAllocInfo::height](#height-78) | 分配内存的高度 | +| [VerifyAllocInfo::usage](#usage-22) | 内存的用处 | +| [VerifyAllocInfo::format](#format-22) | 分配内存的像素格式 | +| [PresentTimestamp::type](#type-37) | 上屏时间戳类型 | +| [PresentTimestamp::time](#time) | 类型对应的值 | +| [ExtDataHandle::fd](#fd) | 句柄 fd,-1代表不支持 | +| [ExtDataHandle::reserveInts](#reserveints) | reserve数组的个数 | +| [ExtDataHandle::reserve](#reserve) [0] | reserve数组 | +| [YUVDescInfo::baseAddr](#baseaddr) | 内存的初始地址 | +| [YUVDescInfo::yOffset](#yoffset) | Y的偏移量 | +| [YUVDescInfo::uOffset](#uoffset) | U的偏移量 | +| [YUVDescInfo::vOffset](#voffset) | V的偏移量 | +| [YUVDescInfo::yStride](#ystride) | Y的stride信息 | +| [YUVDescInfo::uvStride](#uvstride) | UV的stride信息 | +| [YUVDescInfo::uvStep](#uvstep) | UV的step信息 | +| [VGUPoint::x](#x-34) | 点水平坐标 | +| [VGUPoint::y](#y-34) | 点垂直坐标 | +| [VGURect::x](#x-44) | 矩形水平起始坐标 | +| [VGURect::y](#y-44) | 矩形垂直起始坐标 | +| [VGURect::w](#w-22) | 矩形宽度 | +| [VGURect::h](#h-22) | 矩形高度 | +| [VGUPath::segment](#segment) | 存放路径命令数据 | +| [VGUPath::numSegments](#numsegments) | 路径命令总数 | +| [VGUPath::data](#data-22) | 存放路径命令对应坐标数据 | +| [VGUPath::type](#type-47) | 路径数据存储类型 | +| [VGUPath::enAlias](#enalias) | 抗锯齿开关 | +| [VGUPath::boundBox](#boundbox) | 路径最大边界 | +| [VGUMatrix3::m](#m) [3][3] | 3x3变换矩阵 | +| [VGUMatrix3::type](#type-57) | 矩阵变换类型,简单变换为缩放,平移,90度倍数旋转。 | +| [VGUBuffer::pixelFormat](#pixelformat) | 像素格式 | +| [VGUBuffer::width](#width-89) | 位图宽度 | +| [VGUBuffer::height](#height-88) | 位图高度 | +| [VGUBuffer::stride](#stride-22) | 位图stride | +| [VGUBuffer::virAddr](#viraddr-22) | 位图缓存的虚拟地址 | +| [VGUBuffer::phyAddr](#phyaddr-33) | 位图缓存的物理地址 | +| [VGUMaskLayer::buffer](#buffer-13) | 蒙版缓存 | +| [VGUMaskLayer::rect](#rect-23) | 蒙版矩形 | +| [VGUSurface::buffer](#buffer-23) | 位图缓存 | +| [VGUSurface::clipRect](#cliprect) | 矩形剪切域,如果为空,整个表面直接渲染。 | +| [VGUSurface::clipPath](#clippath) | 路径剪切域,如果为空,整个表面直接渲染。 | +| [VGUSurface::clipType](#cliptype) | 表面剪切类型 | +| [VGUSurface::mask](#mask) | 蒙版图层, 可以为空。 | +| [VGUSurface::blend](#blend) | 混合叠加模式 | +| [VGUSurface::filter](#filter) | 图像滤波类型 | +| [VGUColorStop::stop](#stop) | 颜色偏移位置, 值范围是 0.0 ~ 1.0。 | +| [VGUColorStop::color](#color-45) | 偏移位置对应颜色 | +| [VGULinear::x1](#x1-23) | 线性渐变起点水平坐标 | +| [VGULinear::y1](#y1-23) | 线性渐变起点垂直坐标 | +| [VGULinear::x2](#x2) | 线性渐变终点水平坐标 | +| [VGULinear::y2](#y2) | 线性渐变起点垂直坐标 | +| [VGURadial::x0](#x0-22) | 内圈圆心水平坐标 | +| [VGURadial::y0](#y0-22) | 内圈圆心垂直坐标 | +| [VGURadial::r0](#r0) | 内圈圆半径 | +| [VGURadial::x1](#x1-33) | 外圈圆心水平坐标 | +| [VGURadial::y1](#y1-33) | 外圈圆心垂直坐标 | +| [VGURadial::r1](#r1) | 外圈圆半径 | +| [VGUConic::cx](#cx) | 圆弧中心x坐标 | +| [VGUConic::cy](#cy) | 圆弧中心y坐标 | +| [VGUImage::buffer](#buffer-33) | 图像存储缓存 | +| [VGUImage::matrix](#matrix-12) | 图像矩阵变换,该参数为空,则内部使用单位变换矩阵。 | +| [VGUImage::rect](#rect-33) | 图像截取矩形,该参数为空,则截取整个图像。 | +| [VGUImage::opacity](#opacity-13) | 透明度,范围0~255。 | +| [VGUPattern::image](#image) | 图像对象 | +| [VGUPattern::wrapx](#wrapx) | 图像水平方向平铺类型 | +| [VGUPattern::wrapy](#wrapy) | 图像垂直方向平铺类型 | +| [VGUGradient::matrix](#matrix-22) | 针对渐变对象的变换矩阵 | +| [VGUGradient::colorStops](#colorstops) | 渐变停止颜色数组指针 | +| [VGUGradient::stopCount](#stopcount) | 渐变停止颜色个数 | +| [VGUGradient::linear](#linear) | 线性渐变对象 | +| [VGUGradient::radial](#radial) | 辐射渐变对象 | +| [VGUGradient::conic](#conic) | 圆锥渐变对象 | +| [VGUGradient::type](#type-67) | 渐变类型 | +| [VGUGradient::spread](#spread) | 渐变延伸模式 | +| [VGUGradient::opacity](#opacity-23) | 透明度,范围0~255。 | +| [VGUSolid::color](#color-55) | 颜色值 | +| [VGUSolid::opacity](#opacity-33) | 透明度. 值范围 0 ~ 255。 | +| [VGUPaintStyle::gradient](#gradient) | 渐变对象 | +| [VGUPaintStyle::pattern](#pattern) | 图片模式对象 | +| [VGUPaintStyle::solid](#solid) | 颜色对象 | +| [VGUPaintStyle::type](#type-77) | 渲染类型 | +| [VGUFillAttr::rule](#rule) | 填充规格 | +| [VGUStrokeAttr::cap](#cap) | 线帽类型 | +| [VGUStrokeAttr::join](#join) | 联结类型 | +| [VGUStrokeAttr::miterLimit](#miterlimit) | 最大斜切长度 | +| [VGUStrokeAttr::width](#width-99) | 线宽 | +| ([VGUFuncs::InitVgu](#initvgu) )(void) | 初始化硬件加速。 | +| ([VGUFuncs::DeinitVgu](#deinitvgu) )(void) | 去初始化硬件加速。 | +| ([VGUFuncs::QueryCapability](#querycapability))(uint32_t cap) | 查询硬件能力集。 | +| ([VGUFuncs::RenderFill](#renderfill))(VGUSurface \*target, const VGUPath \*path, const VGUMatrix3 \*matrix, const VGUFillAttr \*attr, const VGUPaintStyle \*style) | 使用指定的渲染对象来填充路径。 | +| ([VGUFuncs::RenderStroke](#renderstroke) )(VGUSurface \*target, const VGUPath \*path, const VGUMatrix3 \*matrix, const VGUStrokeAttr \*attr, const VGUPaintStyle \*style) | 使用指定的渲染对象来描边路径。 | +| ([VGUFuncs::RenderBlur](#renderblur) )(VGUSurface \*target, uint16_t blur) | 对目标表面进行模糊处理。 | +| ([VGUFuncs::RenderBlit](#renderblit) )(VGUSurface \*target, const VGUImage \*src, uint32_t color) | 对图像进行搬移操作。 | +| ([VGUFuncs::RenderBlitN](#renderblitn) )(VGUSurface \*target, const VGUImage \*src, uint16_t count, uint32_t color) | 对多个源图像进行叠加操作。 | +| ([VGUFuncs::RenderClearRect](#renderclearrect) )(VGUSurface \*target, const VGURect \*rect, uint32_t color, uint8_t opacity) | 对指定矩形进行颜色清除操作。 | +| ([VGUFuncs::RenderCancel](#rendercancel) )() | 取消硬件加速渲染。 | +| ([VGUFuncs::RenderSync](#rendersync) )(int32_t timeOut) | 同步硬件加速模块绘制或搬移操作。 | + + +## **宏定义说明** + + +### PROPERTY_NAME_LEN + + +``` +#define PROPERTY_NAME_LEN 50 +``` + +**描述:** + +属性名称长度 + +### HDI_VGU_SCALAR_IS_FLOAT + + +``` +#define HDI_VGU_SCALAR_IS_FLOAT 1 +``` + +**描述:** + +VGU标量是否为浮点型 -显示模块驱动接口定义。 -提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 +## **类型定义说明** -**Since:** -1.0 +### VGUPixelFormat -**Version:** -2.0 +``` +typedef PixelFormat VGUPixelFormat; +``` + +**描述:** +像素格式 -## **类型定义说明** + +### VGUBlendType + + +``` +typedef BlendType VGUBlendType; +``` + +**描述:** + +混合操作类型 + +### VGUScalar + + +``` +#ifdef HDI_VGU_SCALAR_IS_FLOAT +typedef float VGUScalar; +#else +typedef int32_t VGUScalar; +#endif +``` + +**描述:** + +VGU标量 ### HotPlugCallback @@ -277,15 +475,15 @@ typedef void(* HotPlugCallback) (uint32_t devId, bool connected, void *data) 热插拔事件回调。 -当有热插拔事件发生时,会回调该接口,需要通过RegHotPlugCallback注册该回调接口。 +当有热插拔事件发生时,会回调该接口,需要通过[RegHotPlugCallback](#reghotplugcallback)注册该回调接口。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,此ID由HDI实现层生成,并通过当前回调接口传递给图形服务使用,用以标记当前连接的显示设备。 | | connected | 输入参数,指明设备的连接状态,true代表连接,false代表断开。 | -| data | 输出参数,图形服务携带的私有数据,该参数携带的是RegHotPlugCallback接口注册时传递的私有数据地址,详情参考 RegHotPlugCallback 接口注册时传递的地址。 | +| data | 输出参数,图形服务携带的私有数据,该参数携带的是[RegHotPlugCallback](#reghotplugcallback)接口注册时传递的私有数据地址。 | ### RefreshCallback @@ -299,14 +497,14 @@ typedef void(* RefreshCallback) (uint32_t devId, void *data) 刷新请求回调。 -刷新请求回调,当接口实现层需要图形服务刷新数据帧时会回调该接口,需要通过RegDisplayRefreshCallback注册该回调接口。 +当接口实现层需要图形服务刷新数据帧时会回调该接口,需要通过[RegDisplayRefreshCallback](#regdisplayrefreshcallback)注册该回调接口。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID。 | -| data | 输出参数,图形服务携带的私有数据,该参数携带的是RegDisplayRefreshCallback接口注册时传递的地址。 | +| data | 输出参数,图形服务携带的私有数据,该参数携带的是[RegDisplayRefreshCallback](#regdisplayrefreshcallback)接口注册时传递的地址。 | ### VBlankCallback @@ -320,15 +518,15 @@ typedef void(* VBlankCallback) (unsigned int sequence, uint64_t ns, void *data) VBlank 事件回调。 -垂直同步事件回调接口,需要通过RegDisplayVBlankCallback注册该回调接口。 +垂直同步事件回调接口,需要通过[RegDisplayVBlankCallback](#regdisplayvblankcallback)注册该回调接口。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | sequence | 输入参数,指明VBlank序列,是一个累加值。 | | ns | 输入参数,该次VBlank事件的时间戳,以纳秒为单位。 | -| data | 输出参数,图形服务携带的私有数据,该参数携带的是RegDisplayVBlankCallback接口注册时传递的地址。 | +| data | 输出参数,图形服务携带的私有数据,该参数携带的是[RegDisplayVBlankCallback](#regdisplayvblankcallback)接口注册时传递的地址。 | ## **枚举类型说明** @@ -343,7 +541,7 @@ anonymous enum **描述:** -缓冲区定义。 +定义缓冲区使用。 | 枚举值 | 描述 | | -------- | -------- | @@ -366,9 +564,9 @@ enum BlendType **描述:** -显示内存类型定义。 +支持的图像混合类型。 -根据图形系统指定的类型进行分配,包括带cache或者不带cache的内存。 +系统在硬件加速期间基于指定的混合类型合成图像。 | 枚举值 | 描述 | | -------- | -------- | @@ -457,7 +655,7 @@ enum ColorGamut **描述:** -色域类型枚举值。 +色域类型枚举值 | 枚举值 | 描述 | | -------- | -------- | @@ -507,14 +705,14 @@ enum CompositionType | 枚举值 | 描述 | | -------- | -------- | -| COMPOSITION_CLIENT | Client 合成类型,使用CPU或者GPU合成。 | -| COMPOSITION_DEVICE | Device 合成类型,使用Device合成。 | -| COMPOSITION_CURSOR | Cursor合成类型,用于光标合成。 | -| COMPOSITION_VIDEO | Video合成类型,用于视频层合成。 | -| COMPOSITION_DEVICE_CLEAR | Device clear 合成类型,device会清除目标区域。 | -| COMPOSITION_CLIENT_CLEAR | Client clear 合成类型,service会清除目标区域。 | -| COMPOSITION_TUNNEL | Tunnel 合成类型,用于tunnel。 | -| COMPOSITION_BUTT | 合成类型,一个不可用类型,用于默认初始化。 | +| COMPOSITION_CLIENT | Client 合成类型,使用CPU或者GPU合成 | +| COMPOSITION_DEVICE | Device 合成类型,使用Device合成 | +| COMPOSITION_CURSOR | Cursor合成类型,用于光标合成 | +| COMPOSITION_VIDEO | Video合成类型,用于视频层合成 | +| COMPOSITION_DEVICE_CLEAR | Device clear 合成类型,device会清除目标区域 | +| COMPOSITION_CLIENT_CLEAR | Client clear 合成类型,service会清除目标区域 | +| COMPOSITION_TUNNEL | Tunnel 合成类型,用于tunnel | +| COMPOSITION_BUTT | 合成类型,一个不可用类型,用于默认初始化 | ### Connection @@ -672,7 +870,7 @@ enum InterfaceType | DISP_INTF_VGA | VGA 接口 | | DISP_INTF_MIPI | MIPI 接口 | | DISP_INTF_PANEL | PANEL 接口 | -| DISP_INTF_BUTT | BUTT接口,一个不可用类型,用于默认初始化。 | +| DISP_INTF_BUTT | BUTT 接口,一个不可用类型,用于默认初始化。 | ### LayerType @@ -761,7 +959,7 @@ enum PixelFormat | PIXEL_FMT_UYVY_422_PKG | UYVY422 打包格式t | | PIXEL_FMT_YVYU_422_PKG | YVYU422 打包格式 | | PIXEL_FMT_VYUY_422_PKG | VYUY422 打包格式 | -| PIXEL_FMT_VENDOR_MASK | vendor mask 格式 | +| PIXEL_FMT_VENDER_MASK | vendor mask 格式 | | PIXEL_FMT_BUTT | Invalid 像素格式 | @@ -774,7 +972,7 @@ enum PresentTimestampType **描述:** -上屏时间戳类型枚举值。 +上屏时间戳类型枚举值 | 枚举值 | 描述 | | -------- | -------- | @@ -794,7 +992,7 @@ enum RopType 硬件加速支持的ROP操作类型。 -硬件加速支持的ROP操作类型,在将前景位图的RGB颜色分量和Alpha分量值与背景位图的RGB颜色 分量值和Alpha分量值进行按位的布尔运算(包括按位与,按位或等),将结果输出。 +硬件加速支持的ROP操作类型,在将前景位图的RGB颜色分量和Alpha分量值与背景位图的RGB颜色分量值和Alpha分量值进行按位的布尔运算(包括按位与,按位或等),将结果输出。 | 枚举值 | 描述 | | -------- | -------- | @@ -837,1152 +1035,1261 @@ enum TransformType | ROTATE_BUTT | 无效操作 | -## **函数说明** - - -### DeviceInitialize() +### VGUCapability ``` -int32_t DeviceInitialize (DeviceFuncs **funcs) +enum VGUCapability ``` **描述:** -实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 - -**参数:** +硬件加速能力。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,显示设备控制接口指针,初始化时分配内存,调用者不需要分配内存,调用者获取该指针用于操作显示设备。 | +| VGU_CAP_BLIT | 支持Blit能力 | +| VGU_CAP_BLIT_NUM | 搬移支持图片叠加最大数目 | +| VGU_CAP_PATH | 支持路径的fill和stroke能力 | +| VGU_CAP_FILTER_BLUR | 支持模糊能力 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUClipType -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGUClipType +``` -1.0 +**描述:** -**Version:** +绘制表面剪切类型。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_CLIP_RECT | 矩形剪切(默认) | +| VGU_CLIP_PATH | 路径剪切 | +| VGU_CLIP_BUTT | 无效定义 | -### DeviceUninitialize() +### VGUFillRule ``` -int32_t DeviceUninitialize (DeviceFuncs * funcs) +enum VGUFillRule ``` **描述:** -取消显示设备控制接口的初始化,释放控制接口使用到的资源。 - -**参数:** +填充规则定义。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,显示设备控制接口指针,用于释放初始化函数中分配的操作指针内存。 | +| VGU_RULE_WINDING | 非0填充(默认) | +| VGU_RULE_EVEN_ODD | 奇偶填充 | +| VGU_RULE_BUTT | 无效定义 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUFillSpread -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGUFillSpread +``` -1.0 +**描述:** -**Version:** +渐变填充区域外的延展类型。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_SPREAD_PAD | Pad类型(默认) | +| VGU_SPREAD_REFLECT | Reflect类型 | +| VGU_SPREAD_REPEAT | Repeat类型 | +| VGU_SPREAD_BUTT | 无效定义 | -### GfxInitialize() +### VGUFilter ``` -int32_t GfxInitialize (GfxFuncs **funcs) +enum VGUFilter ``` **描述:** -获取硬件加速相关的操作接口指针。 - -**参数:** +图像滤波类型。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,硬件加速模块操作接口指针,调用者不需要分配内存,调用者获取该指针操作硬件加速。 | +| VGU_FILTER_BILINEAR | 双线性插值(默认) | +| VGU_FILTER_NEAREST | 无插值 | +| VGU_FILTER_LINEAR | 线性插值 | +| VGU_FILTER_BUTT | 无效定义 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUGradientType -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGUGradientType +``` -1.0 +**描述:** -**Version:** +渐变类型。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_GRADIENT_LINEAR | 线性渐变 | +| VGU_GRADIENT_RADIAL | 辐射渐变 | +| VGU_GRADIENT_CONIC | 圆锥渐变 | +| VGU_GRADIENT_BUTT | 无效定义 | -### GfxUninitialize() +### VGUJointType ``` -int32_t GfxUninitialize (GfxFuncs * funcs) +enum VGUJointType ``` **描述:** -释放硬件加速相关的操作接口指针。 - -**参数:** +联接类型。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,硬件加速操作接口指针。 | +| VGU_LINE_JOIN_MITER | 尖角(默认) | +| VGU_LINE_JOIN_ROUND | 圆角 | +| VGU_LINE_JOIN_BEVEL | 斜角 | +| VGU_LINE_JOIN_BUTT | 无效定义 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGULineCap -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGULineCap +``` -1.0 +**描述:** -**Version:** +线帽。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_LINECAP_BUTT | 线条末端为平直线帽(默认) | +| VGU_LINECAP_ROUND | 线条末端为圆形线帽 | +| VGU_LINECAP_SQUARE | 线条末端为正方向形线帽 | -### GrallocInitialize() +### VGUPaintType ``` -int32_t GrallocInitialize (GrallocFuncs **funcs) +enum VGUPaintType ``` **描述:** -初始化内存模块,并获取内存提供的操作接口。 - -**参数:** +渲染对象 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,内存模块操作接口指针,初始化内存模块时分配内存,调用者不需要分配内存,调用者获取该指针操作内存。 | +| VGU_PAINT_SOLID | 填充颜色 | +| VGU_PAINT_GRADIENT | 渲染渐变对象 | +| VGU_PAINT_PATTERN | 渲染图片模式 | +| VGU_PAINT_BUTT | 无效操作 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUPathCmd -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGUPathCmd +``` -1.0 +**描述:** -**Version:** +路径绘制指令类型。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_PATH_CMD_CLOSE | 线段关闭,坐标数据:none | +| VGU_PATH_CMD_MOVE | 移动到指定位置,坐标数据:x0, y0 | +| VGU_PATH_CMD_LINE | 线条,坐标数据:x0, y0 | +| VGU_PATH_CMD_HLINE | 水平线,坐标数据:x0 | +| VGU_PATH_CMD_VLINE | 垂直线,坐标数据:y0 | +| VGU_PATH_CMD_QUAD | 二次贝塞尔曲线,坐标数据:x0, y0, x1, y1 | +| VGU_PATH_CMD_CUBIC | 三次贝塞尔曲线,坐标数据:x0, y0, x1, y1, x2, y2 | +| VGU_PATH_CMD_SQUAD | 平滑二次贝塞尔曲线,坐标数据:x1, y1 | +| VGU_PATH_CMD_SCUBIC | 平滑三次贝塞尔曲线,坐标数据:x1, y1, x2, y2 | +| VGU_PATH_CMD_BUTT | 无效定义 | -### GrallocUninitialize() +### VGUPathDataType ``` -int32_t GrallocUninitialize (GrallocFuncs * funcs) +enum VGUPathDataType ``` **描述:** -取消初始化内存模块,并释放内存操作接口指针。 - -**参数:** +路径坐标数据类型。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,内存操作接口指针,用于释放内存初始化函数中分配的操作指针内存。 | +| VGU_DATA_TYPE_S16 | 整型(2 bytes) | +| VGU_DATA_TYPE_S32 | 整型(4 bytes) | +| VGU_DATA_TYPE_F32 | 浮点(4 bytes) | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUResult -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**Since:** +``` +enum VGUResult +``` -1.0 +**描述:** -**Version:** +错误码定义。 -1.0 + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_SUCCESS | 成功 | +| VGU_NO_SUPPORT | 不支持 | +| VGU_OPERATION_FAILED | 操作失败 | +| VGU_OUT_OF_MEMORY | 内存溢出 | +| VGU_TIMEOUT | 超时 | +| VGU_INVALID_PARAMETER | 无效参数, | +| VGU_BUSY | 设备忙 | +| VGU_NO_CONTEXT | 无上下文 | -### LayerInitialize() +### VGUTransformType ``` -int32_t LayerInitialize (LayerFuncs **funcs) +enum VGUTransformType ``` **描述:** -实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 - -**参数:** +变换类型。 - | 名称 | 描述 | + | 枚举值 | 描述 | | -------- | -------- | -| funcs | 输出参数,图层操作接口指针,初始化图层时分配内存,调用者不需要分配内存,调用者获取该指针操作图层。 | +| VGU_TRANSFORM_TRANSLATE | 平移变换 | +| VGU_TRANSFORM_SCALE | 缩放变换 | +| VGU_TRANSFORM_ROTATE_90 | 旋转90度 | +| VGU_TRANSFORM_ROTATE_180 | 旋转180度 | +| VGU_TRANSFORM_ROTATE_270 | 旋转270度 | +| VGU_TRANSFORM_OTHER | 其他变换 | -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +### VGUWrapType -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**参见:** +``` +enum VGUWrapType +``` -[LayerUninitialize](#layeruninitialize) +**描述:** +图像模式填充延展类型。 -### LayerUninitialize() + | 枚举值 | 描述 | +| -------- | -------- | +| VGU_WRAP_REFLECT | 反射类型 | +| VGU_WRAP_REPEAT | 重复类型 | +| VGU_WRAP_BUTT | 无效定义 | + + +## **函数说明** + + +### DeviceInitialize() ``` -int32_t LayerUninitialize (LayerFuncs * funcs) +int32_t DeviceInitialize (DeviceFuncs ** funcs) ``` **描述:** -取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 +实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| funcs | 输出参数,图层操作接口指针,用于释放图层初始化函数中分配的操作指针内存。 | +| funcs | 输出参数,显示设备控制接口指针,初始化时分配内存,调用者不需要分配内存,调用者获取该指针用于操作显示设备。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**参见:** -[LayerInitialize](#layerinitialize) +### DeviceUninitialize() -**Since:** -1.0 +``` +int32_t DeviceUninitialize (DeviceFuncs * funcs) +``` -**Version:** +**描述:** -1.0 +取消显示设备控制接口的初始化,释放控制接口使用到的资源。 +**参数:** -## **变量说明** + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,显示设备控制接口指针,用于释放初始化函数中分配的操作指针内存。 | +**返回:** -### alpha0 [1/2] +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GfxInitialize() ``` -uint8_t LayerAlpha::alpha0 +int32_t GfxInitialize (GfxFuncs ** funcs) ``` **描述:** -Alpha0值,取值范围:[0, 255] - +获取硬件加速相关的操作接口指针。 -### alpha0 [2/2] +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,硬件加速模块操作接口指针,调用者不需要分配内存,调用者获取该指针操作硬件加速。 | -``` -uint8_t ISurface::alpha0 -``` +**返回:** -**描述:** +DISPLAY_SUCCESS 表示执行成功。 -Alpha0值,取值范围:[0,255] +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### alpha1 [1/2] +### GfxUninitialize() ``` -uint8_t LayerAlpha::alpha1 +int32_t GfxUninitialize (GfxFuncs * funcs) ``` **描述:** -Alpha1值,取值范围:[0, 255] - +释放硬件加速相关的操作接口指针。 -### alpha1 [2/2] +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,硬件加速操作接口指针。 | -``` -uint8_t ISurface::alpha1 -``` +**返回:** -**描述:** +DISPLAY_SUCCESS 表示执行成功。 -Alpha1值,取值范围:[0,255] +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### alphaRopType +### GrallocInitialize() ``` -RopType GfxOpt::alphaRopType +int32_t GrallocInitialize (GrallocFuncs ** funcs) ``` **描述:** -Alpha的Rop类型 - +初始化内存模块,并获取内存提供的操作接口。 -### bAlphaExt1555 +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,内存模块操作接口指针,初始化内存模块时分配内存,调用者不需要分配内存,调用者获取该指针操作内存。 | -``` -bool ISurface::bAlphaExt1555 -``` +**返回:** -**描述:** +DISPLAY_SUCCESS 表示执行成功。 -是否使能1555的Alpha扩展 +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### bAlphaMax255 +### GrallocUninitialize() ``` -bool ISurface::bAlphaMax255 +int32_t GrallocUninitialize (GrallocFuncs * funcs) ``` **描述:** -图像Alpha最大值为255还是128 +取消初始化内存模块,并释放内存操作接口指针。 +**参数:** -### baseAddr - + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,内存操作接口指针,用于释放内存初始化函数中分配的操作指针内存。 | -``` -void* __attribute__::baseAddr -``` +**返回:** -**描述:** +DISPLAY_SUCCESS 表示执行成功。 -内存的初始地址 +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### blendType +### LayerInitialize() ``` -BlendType GfxOpt::blendType +int32_t LayerInitialize (LayerFuncs ** funcs) ``` **描述:** -混合方式 +实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 +**参数:** -### bpp + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,图层操作接口指针,初始化图层时分配内存,调用者不需要分配内存,调用者获取该指针操作图层。 | + +**返回:** +DISPLAY_SUCCESS 表示执行成功。 -``` -int32_t LayerInfo::bpp -``` +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -**描述:** +**参见:** -每像素所占bit数 +[LayerUninitialize](#layeruninitialize) -### bYCbCrClut +### LayerUninitialize() ``` -bool ISurface::bYCbCrClut +int32_t LayerUninitialize (LayerFuncs * funcs) ``` **描述:** -CLUT表是否位于YCbCr空间 +取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 +**参数:** -### cbcrPhyAddr + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,图层操作接口指针,用于释放图层初始化函数中分配的操作指针内存。 | +**返回:** -``` -uint64_t ISurface::cbcrPhyAddr -``` +DISPLAY_SUCCESS 表示执行成功。 -**描述:** +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -CbCr分量地址 +**参见:** + +[LayerInitialize](#layerinitialize) -### cbcrStride +### VGUGradientClearStop() ``` -int32_t ISurface::cbcrStride +VGUResult VGUGradientClearStop (VGUGradient * gradient) ``` **描述:** -CbCr分量跨度 - +清除ColorStop。 -### clutPhyAddr +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| gradient | 输入参数,渐变对象。 | -``` -uint64_t ISurface::clutPhyAddr -``` +**返回:** -**描述:** +VGU_SUCCESS 表示执行成功。 -CLUT表首地址,用作颜色扩展或颜色校正 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### color [1/3] +### VGUGradientColorStop() ``` -uint32_t ILine::color +VGUResult VGUGradientColorStop (VGUGradient * gradient, const VGUColorStop * colorStop, uint32_t count ) ``` **描述:** -线条颜色 - +对渐变添加ColorStop。 -### color [2/3] +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| gradient | 输入参数,渐变对象。 | +| colorStop | 输入参数,ColorStop数组指针。 | +| count | 输入参数,colorStops总数。 | -``` -uint32_t ICircle::color -``` +**返回:** -**描述:** +VGU_SUCCESS 表示执行成功。 -圆的颜色 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### color [3/3] +### VGUGradientConic() ``` -uint32_t Rectangle::color +VGUResult VGUGradientConic (VGUGradient * gradient, VGUScalar cx, VGUScalar cy ) ``` **描述:** -矩形颜色 - +创建圆锥渐变对象。 -### colorKeyFrom +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| gradient | 输入参数,渐变对象。 | +| cx | 输入参数,渐变中心水平坐标。 | +| cy | 输入参数,渐变中心垂直坐标。 | -``` -ColorKey GfxOpt::colorKeyFrom -``` +**返回:** -**描述:** +VGU_SUCCESS 表示执行成功。 -色键模式 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### colorRopType +### VGUGradientLinear() ``` -RopType GfxOpt::colorRopType +VGUResult VGUGradientLinear (VGUGradient * gradient, const VGUPoint * p1, const VGUPoint * p2 ) ``` **描述:** -颜色的Rop类型 +创建线性渐变对象。 +**参数:** -### Commit + | 名称 | 描述 | +| -------- | -------- | +| gradient | 输入参数,渐变对象。 | +| p1 | 输入参数,起点坐标。 | +| p2 | 输入参数,终点坐标。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### VGUGradientMatrix() ``` -int32_t(* DeviceFuncs::Commit) (uint32_t devId, int32_t *fence) +VGUResult VGUGradientMatrix (VGUGradient * gradient, const VGUMatrix3 * matrix ) ``` **描述:** -提交合成送显请求。 - -图形服务通过该接口向接口实现层提交合成送显请求,如果有硬件合成层,接口实现层需要在这时进行合成,并且把最终合成的数据送到硬件进行显示。 +设置渐变对象的变换矩阵。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| fences | 输出参数,fence首地址,指向fence数组的首地址。 | +| gradient | 输入参数,渐变对象。 | +| matrix | 输入参数,渐变对象变换矩阵。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### CreateVirtualDisplay +### VGUGradientRadial() ``` -int32_t(* DeviceFuncs::CreateVirtualDisplay) (uint32_t width, uint32_t height, int32_t *format, uint32_t *devId) +VGUResult VGUGradientRadial (VGUGradient * gradient, const VGUPoint * p1, VGUScalar r1, const VGUPoint * p2, VGUScalar r2 ) ``` **描述:** -创建虚拟显示设备。 - -该接口用于创建一个虚拟显示设备。 +创建辐射渐变对象 **参数:** -| 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| width | 输入参数,指定显示设备的像素宽度。 | -| height | 输入参数,指定显示设备的像素高度。 | -| format | 输出参数,指定显示设备的像素格式。详情参考[PixelFormat](#pixelformat),接口实现层可以根据硬件需求,修改format并返回给图形服务。 | -| devId | 输出参数,用于接口层返回创建的设备ID。 | +| gradient | 输入参数,渐变对象。 | +| p1 | 输入参数,内圆圆心坐标。 | +| r1 | 输入参数,内圆半径。 | +| p2 | 输入参数,外圆圆心坐标。 | +| r2 | 输入参数,外圆半径。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### CreateWriteBack +### VGUInitialize() ``` -int32_t(* DeviceFuncs::CreateWriteBack) (uint32_t *devId, uint32_t width, uint32_t height, int32_t *format) +VGUResult VGUInitialize (VGUFuncs ** funcs) ``` **描述:** -对指定显示设备创建回写点。 - -该接口用来对指定的设备创建一个回写点,如果回写点数量超过了限制,接口实现层将会返回失败。 +获取硬件加速相关的操作接口指针。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID,接口实现层在创建完回写点后将回写点设备ID存放在该参数中返回给图形服务。 | -| width | 输入参数,回写像素宽度。 | -| height | 输入参数,回写像素高度。 | -| format | 输入参数,回写点数据格式,详情参考[PixelFormat](#pixelformat),接口实现层可以根据硬件需求,修改format并返回给图形服务。 | +| funcs | 输出参数,硬件加速模块操作接口指针,调用者不需要分配内存,调用者获取该指针操作硬件加速。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### data +### VGUMatrixIdentity() ``` -BufferData LayerBuffer::data +VGUResult VGUMatrixIdentity (VGUMatrix3 * matrix) ``` **描述:** -图层buffer数据 +初始化矩阵对象为单位矩阵。 + +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| matrix | 输入参数,变换矩阵对象。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### DestroyVirtualDisplay + +### VGUMatrixRotate() ``` -int32_t(* DeviceFuncs::DestroyVirtualDisplay) (uint32_t devId) +VGUResult VGUMatrixRotate (VGUMatrix3 * matrix, float degree ) ``` **描述:** -销毁虚拟显示设备。 - -该接口用于销毁指定的虚拟显示设备。 +矩阵变换旋转。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | +| matrix | 输入参数,变换矩阵对象。 | +| degree | 输入参数,旋转度数。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### DestroyWriteBack +### VGUMatrixScale() ``` -int32_t(* DeviceFuncs::DestroyWriteBack) (uint32_t devId) +VGUResult VGUMatrixScale (VGUMatrix3 * matrix, float xScale, float yScale ) ``` **描述:** -销毁指定显示设备的回写点。 - -该接口用來销毁指定的回写点。 +矩阵变换缩放。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | +| matrix | 输入参数,变换矩阵对象。 | +| xScale | 输入参数,水平方向缩放倍数。 | +| yScale | 输入参数,垂直方向缩放倍数。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### enableRop +### VGUMatrixTranslate() ``` -bool GfxOpt::enableRop +VGUResult VGUMatrixTranslate (VGUMatrix3 * matrix, float x, float y ) ``` **描述:** -Rop功能使能位 - +矩阵变换平移。 -### enableScale +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| matrix | 输入参数,变换矩阵对象。 | +| x | 输入参数,水平方向位置。 | +| y | 输入参数,垂直方向位置。 | -``` -bool GfxOpt::enableScale -``` +**返回:** -**描述:** +VGU_SUCCESS 表示执行成功。 -缩放功能使能位 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### enColorFmt +### VGUPathAppend() ``` -PixelFormat ISurface::enColorFmt +VGUResult VGUPathAppend (VGUPath * path, const VGUPath * subpath ) ``` **描述:** -图像格式 - +添加子路径到当前路径中。 -### enGlobalAlpha [1/2] +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| path | 输入参数,路径对象。 | +| subpath | 输入参数,存放子路径对象。 | -``` -bool LayerAlpha::enGlobalAlpha -``` +**返回:** -**描述:** +VGU_SUCCESS 表示执行成功。 -全局Alpha使能标志 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### enGlobalAlpha [2/2] +### VGUPathClear() ``` -bool GfxOpt::enGlobalAlpha +VGUResult VGUPathClear (VGUPath * path) ``` **描述:** -全局Alpha使能位 +清除路径对象内存。 +**参数:** -### enPixelAlpha [1/2] + | 名称 | 描述 | +| -------- | -------- | +| path | 输入参数,路径对象。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### VGUPathInit() ``` -bool LayerAlpha::enPixelAlpha +VGUResult VGUPathInit (VGUPath * path, VGUPathDataType type, const uint8_t * segments, int numSegments, const uint8_t * data, bool enAlias, VGURect boundBox ) ``` **描述:** -像素Alpha使能标志 +初始化路径对象。 +**参数:** -### enPixelAlpha [2/2] + | 名称 | 描述 | +| -------- | -------- | +| path | 输入参数,路径对象。 | +| type | 输入参数,存储路径的数据类型。 | +| segments | 输入参数,路径的命令缓存。 | +| numSegments | 输入参数,路径命令总数。 | +| data | 输入参数,路径命令对应的坐标缓存。 | +| enAlias | 输入参数,使能抗锯齿。 | +| boundBox | 输入参数,路径的边界范围。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### VGUUninitialize() ``` -bool GfxOpt::enPixelAlpha +VGUResult VGUUninitialize (VGUFuncs * funcs) ``` **描述:** -像素Alpha使能位 +去初始化硬件加速模块,同时释放硬件加速模块操作函数指针。 +**参数:** -### expectedSize + | 名称 | 描述 | +| -------- | -------- | +| funcs | 输出参数,硬件加速操作接口指针。 | +**返回:** -``` -uint32_t AllocInfo::expectedSize -``` +VGU_SUCCESS 表示执行成功。 -**描述:** +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -申请内存大小 +## **变量说明** -### fd + +### alpha0 [1/2] ``` -int32_t __attribute__::fd +uint8_t LayerAlpha::alpha0 ``` **描述:** -句柄 fd,-1代表不支持。 +alpha0值,取值范围:[0, 255] -### fenceId +### alpha0 [2/2] ``` -int32_t LayerBuffer::fenceId +uint8_t ISurface::alpha0 ``` **描述:** -buffer 的fence号 +Alpha0值,取值范围:[0,255] -### format [1/2] +### alpha1 [1/2] ``` -PixelFormat AllocInfo::format +uint8_t LayerAlpha::alpha1 ``` **描述:** -申请内存格式 +alpha1值,取值范围:[0, 255] -### format [2/2] +### alpha1 [2/2] ``` -PixelFormat VerifyAllocInfo::format +uint8_t ISurface::alpha1 ``` **描述:** -分配内存的像素格式 +Alpha1值,取值范围:[0,255] -### formatCount +### alphaRopType ``` -uint32_t HDRCapability::formatCount +RopType GfxOpt::alphaRopType ``` **描述:** -支持的HDR格式的数量 +Alpha的Rop类型 -### formats +### bAlphaExt1555 ``` -HDRFormat* HDRCapability::formats +bool ISurface::bAlphaExt1555 ``` **描述:** -支持的HDR格式的数组首地址 +是否使能1555的Alpha扩展 -### freshRate +### bAlphaMax255 ``` -uint32_t DisplayModeInfo::freshRate +bool ISurface::bAlphaMax255 ``` **描述:** -刷新速率 +图像alpha最大值为255还是128 -### gAlpha +### baseAddr ``` -uint8_t LayerAlpha::gAlpha +void* YUVDescInfo::baseAddr ``` **描述:** -全局Alpha值,取值范围:[0, 255] +内存的初始地址 -### GetDisplayBacklight +### blend ``` -int32_t(* DeviceFuncs::GetDisplayBacklight) (uint32_t devId, uint32_t *level) +VGUBlendType VGUSurface::blend ``` **描述:** -获取显示设备当前的背光值。 +混合叠加模式 -图形服务可以通过该接口获取设置显示设备的背光值。 -**参数:** +### blendType - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| level | 输出参数,保存对应设备的背光值,由接口实现层进行写入。 | -**返回:** +``` +BlendType GfxOpt::blendType +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +混合方式 -### GetDisplayCapability +### boundBox ``` -int32_t(* DeviceFuncs::GetDisplayCapability) (uint32_t devId, DisplayCapability *info) +VGURect VGUPath::boundBox ``` **描述:** -获取显示设备能力集。 +路径最大边界 -图形服务可以通过该接口获取显示设备具备哪些显示能力。 -**参数:** +### bpp - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| info | 输出参数,设备支持的能力级信息,详情参考 {\@DisplayCapability}。 | -**返回:** +``` +int32_t LayerInfo::bpp +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +每像素所占bit数 -### GetDisplayColorGamut +### buffer [1/3] ``` -int32_t(* DeviceFuncs::GetDisplayColorGamut) (uint32_t devId, ColorGamut *gamut) +VGUBuffer* VGUMaskLayer::buffer ``` **描述:** -获取显示设备当前的色域模式。 +蒙版缓存 -**参数:** - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| gamut | 输出参数,保存对应设备的色域模式,由接口实现层进行写入。 | +### buffer [2/3] -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +``` +VGUBuffer* VGUSurface::buffer +``` -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +**描述:** +位图缓存 -### GetDisplayCompChange +VGUSurface::clipRect + + +### buffer [3/3] ``` -int32_t(* DeviceFuncs::GetDisplayCompChange) (uint32_t devId, uint32_t *num, uint32_t *Layers, int32_t *type) +VGUBuffer* VGUImage::buffer ``` **描述:** -获取显示设备合成类型有变化的layer。 +图像存储缓存 -在合成准备阶段,显示设备会根据设备的合成能力修改图层的合成类型,该接口会返回哪些图层合成类型发生了变化。 -**参数:** +### bYCbCrClut - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| num | 输出参数,表示合成类型发生了变化的图层数量。 | -| Layers | 输出参数,指向图层数组首地址。 | -| type | 输出参数,指向合成类型数组首地址。 | -**返回:** +``` +bool ISurface::bYCbCrClut +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +CLUT表是否位于 YCbCr 空间 -### GetDisplayGamutMap +### cap ``` -int32_t(* DeviceFuncs::GetDisplayGamutMap) (uint32_t devId, GamutMap *gamutMap) +VGULineCap VGUStrokeAttr::cap ``` **描述:** -获取显示设备当前的色域映射模式。 +线帽类型 -**参数:** - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| gamutMap | 输出参数,保存对应设备的色域映射模式,由接口实现层进行写入。 | +### cbcrPhyAddr -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +``` +uint64_t ISurface::cbcrPhyAddr +``` -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +**描述:** +CbCr分量地址 -### GetDisplayMode + +### cbcrStride ``` -int32_t(* DeviceFuncs::GetDisplayMode) (uint32_t devId, uint32_t *modeId) +int32_t ISurface::cbcrStride ``` **描述:** -获取显示设备当前的显示模式。 +CbCr分量跨度 -图形服务可以通过该接口获取显示设备当前的显示模式。 -**参数:** +### clipPath - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| modeId | 输出参数,存放当前设备的显示模式ID, 由接口实现层进行数据的写入。 | -**返回:** +``` +VGUPath* VGUSurface::clipPath +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +路径剪切域,如果为空,整个表面直接渲染 -### GetDisplayPowerStatus +### clipRect ``` -int32_t(* DeviceFuncs::GetDisplayPowerStatus) (uint32_t devId, DispPowerStatus *status) +VGURect* VGUSurface::clipRect ``` **描述:** -获取显示设备当前的电源状态。 +矩形剪切域,如果为空,整个表面直接渲染 -图形服务可以通过该接口获设置显示设备的电源状态。 -**参数:** +### clipType - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| status | 输出参数,保存对应设备的电源状态,由接口实现层进行状态的写入。 | -**返回:** +``` +VGUClipType VGUSurface::clipType +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +表面剪切类型 -### GetDisplayProperty +### clutPhyAddr ``` -int32_t(* DeviceFuncs::GetDisplayProperty) (uint32_t devId, uint32_t id, uint64_t *value) +uint64_t ISurface::clutPhyAddr ``` **描述:** -获得显示设备属性值。 +Clut表首地址,用作颜色扩展或颜色校正 -图形服务可以通过该接口获取显示设备具体的属性值。 -**参数:** +### color [1/5] - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| id | 输入参数,由接口GetDisplayCapability返回属性ID。 | -| level | 输出参数,属性ID对应的属性值,由接口实现层写入。 | -**返回:** +``` +uint32_t ILine::color +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +线条颜色 -### GetDisplayReleaseFence +### color [2/5] ``` -int32_t(* DeviceFuncs::GetDisplayReleaseFence) (uint32_t devId, uint32_t *num, uint32_t *layers, int32_t *fences) +uint32_t ICircle::color ``` **描述:** -获取显示图层fence。 +圆的颜色 -图形服务在调用接口Commit后,需要通过该接口获取图层的fence信息。 -**参数:** +### color [3/5] - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| num | 输出参数,图层个数。 | -| layers | 输出参数,图层首地址,指向图层数组的首地址。 | -| fences | 输出参数,fence首地址,指向fence数组的首地址。 | -**返回:** +``` +uint32_t Rectangle::color +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +矩形颜色 -### GetDisplaySupportedColorGamuts +### color [4/5] ``` -int32_t(* DeviceFuncs::GetDisplaySupportedColorGamuts) (uint32_t devId, uint32_t *num, ColorGamut *gamuts) +uint32_t VGUColorStop::color ``` **描述:** -获取显示设备支持的色域信息。 +偏移位置对应颜色 -**参数:** - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| num | 输出参数,设备支持的色域数组个数。 | -| gamuts | 输出参数,色域首地址,指向色域数组首地址。 | +### color [5/5] -**返回:** -DISPLAY_SUCCESS 表示执行成功。 +``` +uint32_t VGUSolid::color +``` -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +**描述:** +颜色值 -### GetDisplaySupportedModes + +### colorKeyFrom ``` -int32_t(* DeviceFuncs::GetDisplaySupportedModes) (uint32_t devId, uint32_t *num, DisplayModeInfo *modes) +ColorKey GfxOpt::colorKeyFrom ``` **描述:** -获取显示设备支持的显示模式信息。 +色键模式 -图形服务可以通过该接口获取到显示设备支持哪些显示模式。 -**参数:** +### colorRopType - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| num | 输出参数,设备支持的模式数量。 | -| modes | 输出参数,设备支持的所有模式信息,包括所有能支持的分辨率和刷新率,每一个模式实现层都有一个Id与之对应,在获取当前模式 和设置当前模式时都会使用到,详情参考 {\@DisplayModeInfo}。 | -**返回:** +``` +RopType GfxOpt::colorRopType +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +颜色的Rop类型 -### GetHDRCapabilityInfos +### colorStops ``` -int32_t(* DeviceFuncs::GetHDRCapabilityInfos) (uint32_t devId, HDRCapability *info) +VGUColorStop* VGUGradient::colorStops ``` **描述:** -获取显示设备支持的HDR属性信息。 +渐变停止颜色数组指针 + + +### Commit + + +``` +int32_t(* DeviceFuncs::Commit) (uint32_t devId, int32_t *fence) +``` + +**描述:** + +提交合成送显请求。 + +图形服务通过该接口向接口实现层提交合成送显请求,如果有硬件合成层,接口实现层需要在这时进行合成,并且把最终合成的数据送到硬件进行显示。 **参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,指示需要操作的设备ID。 | -| info | 输出参数,保存对应设备的HDR属性信息,由接口实现层进行写入。 | +| fences | 输出参数,fence首地址,指向fence数组的首地址。 | **返回:** @@ -1991,24 +2298,39 @@ DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### GetSupportedMetadataKey +### conic ``` -int32_t(* DeviceFuncs::GetSupportedMetadataKey) (uint32_t devId, uint32_t *num, HDRMetadataKey *keys) +VGUConic VGUGradient::conic ``` **描述:** -获取显示设备支持的 HDRMetadataKey。 +圆锥渐变对象 + + +### CreateVirtualDisplay + + +``` +int32_t(* DeviceFuncs::CreateVirtualDisplay) (uint32_t width, uint32_t height, int32_t *format, uint32_t *devId) +``` + +**描述:** + +创建虚拟显示设备。 + +该接口用于创建一个虚拟显示设备。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| num | 输出参数,设备支持的HDRMetadataKey数组个数。 | -| keys | 输出参数,HDRMetadataKey首地址,指向HDRMetadataKey数组首地址。 | +| width | 输入参数,指定显示设备的像素宽度。 | +| height | 输入参数,指定显示设备的像素高度。 | +| format | 输出参数,指定显示设备的像素格式。 详情参考[PixelFormat](#pixelformat),接口实现层可以根据硬件需求,修改format并返回给图形服务。 | +| devId | 输出参数,用于接口层返回创建的设备ID。 | **返回:** @@ -2017,63 +2339,748 @@ DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### GetWriteBackFrame +### cx ``` -int32_t(* DeviceFuncs::GetWriteBackFrame) (uint32_t devId, BufferHandle *buffer, int32_t *fence) +VGUScalar VGUConic::cx ``` **描述:** -获取显示设备的回写帧。 +圆弧中心x坐标 -该接口用来获取devId指定的回写点数据,接口实现层将显示设备回写点的数据写入到设置的缓存中。 -**参数:** +### cy - | 名称 | 描述 | -| -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| buffer | 输出参数,回写点数据缓存。 | -| fence | 输出参数,同步栅栏,图形服务在调用该接口时,需要将Buffer的release fence 传入,标记该缓存是否可以被写入,接口实现层在接口返回前需要将buffer的acquirce fence 写入回传给图形服务,用来标记回写数据是否已经写入缓存。 | -**返回:** +``` +VGUScalar VGUConic::cy +``` -DISPLAY_SUCCESS 表示执行成功。 +**描述:** -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +圆弧中心y坐标 -### globalAlpha +### data [1/2] ``` -uint32_t GfxOpt::globalAlpha +BufferData LayerBuffer::data ``` **描述:** -全局Alpha的值 +图层buffer数据 -### h +### data [2/2] ``` -int32_t IRect::h +uint8_t* VGUPath::data ``` **描述:** -矩形框高度 +存放路径命令对应坐标数据 -### hdl +### DeinitVgu ``` -BufferHandle* LayerBuffer::hdl +VGUResult(* VGUFuncs::DeinitVgu) (void) +``` + +**描述:** + +去初始化硬件加速。 + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + +**参见:** + +[InitVgu](#initvgu) + + +### DestroyVirtualDisplay + + +``` +int32_t(* DeviceFuncs::DestroyVirtualDisplay) (uint32_t devId) +``` + +**描述:** + +销毁虚拟显示设备。 + +该接口用于销毁指定的虚拟显示设备。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### enableRop + + +``` +bool GfxOpt::enableRop +``` + +**描述:** + +Rop功能使能位 + + +### enableScale + + +``` +bool GfxOpt::enableScale +``` + +**描述:** + +缩放功能使能位 + + +### enAlias + + +``` +bool VGUPath::enAlias +``` + +**描述:** + +抗锯齿开关 + + +### enColorFmt + + +``` +PixelFormat ISurface::enColorFmt +``` + +**描述:** + +图像格式 + + +### enGlobalAlpha [1/2] + + +``` +bool LayerAlpha::enGlobalAlpha +``` + +**描述:** + +全局alpha使能标志 + + +### enGlobalAlpha [2/2] + + +``` +bool GfxOpt::enGlobalAlpha +``` + +**描述:** + +全局alpha使能位 + + +### enPixelAlpha [1/2] + + +``` +bool LayerAlpha::enPixelAlpha +``` + +**描述:** + +像素alpha使能标志 + + +### enPixelAlpha [2/2] + + +``` +bool GfxOpt::enPixelAlpha +``` + +**描述:** + +像素alpha使能位 + + +### expectedSize + + +``` +uint32_t AllocInfo::expectedSize +``` + +**描述:** + +申请内存大小 + + +### fd + + +``` +int32_t ExtDataHandle::fd +``` + +**描述:** + +句柄 fd, -1代表不支持 + + +### fenceId + + +``` +int32_t LayerBuffer::fenceId +``` + +**描述:** + +buffer 的fence号r + + +### filter + + +``` +VGUFilter VGUSurface::filter +``` + +**描述:** + +图像滤波类型 + + +### format [1/2] + + +``` +PixelFormat AllocInfo::format +``` + +**描述:** + +申请内存格式 + + +### format [2/2] + + +``` +PixelFormat VerifyAllocInfo::format +``` + +**描述:** + +分配内存的像素格式 + + +### formatCount + + +``` +uint32_t HDRCapability::formatCount +``` + +**描述:** + +支持的HDR格式的数量 + + +### formats + + +``` +HDRFormat* HDRCapability::formats +``` + +**描述:** + +支持的HDR格式的数组首地址 + + +### freshRate + + +``` +uint32_t DisplayModeInfo::freshRate +``` + +**描述:** + +刷新速率 + + +### gAlpha + + +``` +uint8_t LayerAlpha::gAlpha +``` + +**描述:** + +全局alpha值,取值范围:[0, 255] + + +### GetDisplayBacklight + + +``` +int32_t(* DeviceFuncs::GetDisplayBacklight) (uint32_t devId, uint32_t *level) +``` + +**描述:** + +获取显示设备当前的背光值。 + +图形服务可以通过该接口获取设置显示设备的背光值。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| level | 输出参数,保存对应设备的背光值,由接口实现层进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayCapability + + +``` +int32_t(* DeviceFuncs::GetDisplayCapability) (uint32_t devId, DisplayCapability *info) +``` + +**描述:** + +获取显示设备能力集。 + +图形服务可以通过该接口获取显示设备具备哪些显示能力。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| info | 输出参数,设备支持的能力级信息,详情参考[DisplayCapability](_display_capability.md)。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayColorGamut + + +``` +int32_t(* DeviceFuncs::GetDisplayColorGamut) (uint32_t devId, ColorGamut *gamut) +``` + +**描述:** + +获取显示设备当前的色域模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| gamut | 输出参数,保存对应设备的色域模式,由接口实现层进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayCompChange + + +``` +int32_t(* DeviceFuncs::GetDisplayCompChange) (uint32_t devId, uint32_t *num, uint32_t *Layers, int32_t *type) +``` + +**描述:** + +获取显示设备合成类型有变化的layer。 + +在合成准备阶段,显示设备会根据设备的合成能力修改图层的合成类型,该接口会返回哪些图层合成类型发生了变化。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| num | 输出参数,表示合成类型发生了变化的图层数量。 | +| Layers | 输出参数,指向图层数组首地址。 | +| type | 输出参数,指向合成类型数组首地址。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayGamutMap + + +``` +int32_t(* DeviceFuncs::GetDisplayGamutMap) (uint32_t devId, GamutMap *gamutMap) +``` + +**描述:** + +获取显示设备当前的色域映射模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| gamutMap | 输出参数,保存对应设备的色域映射模式,由接口实现层进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayMode + + +``` +int32_t(* DeviceFuncs::GetDisplayMode) (uint32_t devId, uint32_t *modeId) +``` + +**描述:** + +获取显示设备当前的显示模式。 + +图形服务可以通过该接口获取显示设备当前的显示模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| modeId | 输出参数,存放当前设备的显示模式ID, 由接口实现层进行数据的写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayPowerStatus + + +``` +int32_t(* DeviceFuncs::GetDisplayPowerStatus) (uint32_t devId, DispPowerStatus *status) +``` + +**描述:** + +获取显示设备当前的电源状态。 + +图形服务可以通过该接口获设置显示设备的电源状态。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| status | 输出参数,保存对应设备的电源状态,由接口实现层进行状态的写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayProperty + + +``` +int32_t(* DeviceFuncs::GetDisplayProperty) (uint32_t devId, uint32_t id, uint64_t *value) +``` + +**描述:** + +获取显示设备属性值。 + +图形服务可以通过该接口获取显示设备具体的属性值。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| id | 输入参数,由接口GetDisplayCapability返回属性ID。 | +| level | 输出参数,属性ID对应的属性值,由接口实现层写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplayReleaseFence + + +``` +int32_t(* DeviceFuncs::GetDisplayReleaseFence) (uint32_t devId, uint32_t *num, uint32_t *layers, int32_t *fences) +``` + +**描述:** + +获取显示图层fence。 + +图形服务在调用接口Commit后,需要通过该接口获取图层的fence信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| num | 输出参数,图层个数。 | +| layers | 输出参数,图层首地址,指向图层数组的首地址。 | +| fences | 输出参数,fence首地址,指向fence数组的首地址。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplaySupportedColorGamuts + + +``` +int32_t(* DeviceFuncs::GetDisplaySupportedColorGamuts) (uint32_t devId, uint32_t *num, ColorGamut *gamuts) +``` + +**描述:** + +获取显示设备支持的色域信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| num | 输出参数,设备支持的色域数组个数。 | +| gamuts | 输出参数,色域首地址,指向色域数组首地址。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetDisplaySupportedModes + + +``` +int32_t(* DeviceFuncs::GetDisplaySupportedModes) (uint32_t devId, uint32_t *num, DisplayModeInfo *modes) +``` + +**描述:** + +获取显示设备支持的显示模式信息。 + +图形服务可以通过该接口获取到显示设备支持哪些显示模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| num | 输出参数,设备支持的模式数量。 | +| modes | 输出参数,设备支持的所有模式信息,包括所有能支持的分辨率和刷新率,每一个模式实现层都有一个Id与之对应,在获取当前模式 和设置当前模式时都会使用到,详情参考 [DisplayModeInfo](_display_mode_info.md)。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetHDRCapabilityInfos + + +``` +int32_t(* DeviceFuncs::GetHDRCapabilityInfos) (uint32_t devId, HDRCapability *info) +``` + +**描述:** + +获取显示设备支持的HDR属性信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| info | 输出参数,保存对应设备的HDR属性信息,由接口实现层进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetSupportedMetadataKey + + +``` +int32_t(* DeviceFuncs::GetSupportedMetadataKey) (uint32_t devId, uint32_t *num, HDRMetadataKey *keys) +``` + +**描述:** + +获取显示设备支持的 HDRMetadataKey。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| num | 输出参数,设备支持的HDRMetadataKey数组个数。 | +| keys | 输出参数,HDRMetadataKey首地址, 指向HDRMetadataKey数组首地址。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### GetWriteBackFrame + + +``` +int32_t(* DeviceFuncs::GetWriteBackFrame) (uint32_t devId, BufferHandle *buffer, int32_t *fence) +``` + +**描述:** + +获取显示设备的回写帧。 + +该接口用来获取devId指定的回写点数据,接口实现层将显示设备回写点的数据写入到设置的缓存中。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| buffer | 输出参数,回写点数据缓存。 | +| fence | 输出参数,同步栅栏,图形服务在调用该接口时,需要将Buffer的release fence 传入,标记该缓存是否可以被写入,接口实现层在接口返回前需要将buffer的acquirce fence 写入回传给图形服务,用来标记回写数据是否已经写入缓存。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### globalAlpha + + +``` +uint32_t GfxOpt::globalAlpha +``` + +**描述:** + +全局alpha的值 + + +### gradient + + +``` +VGUGradient* VGUPaintStyle::gradient +``` + +**描述:** + +渐变对象 + + +### h [1/2] + + +``` +int32_t IRect::h +``` + +**描述:** + +矩形框高度 + + +### h [2/2] + + +``` +VGUScalar VGURect::h +``` + +**描述:** + +矩形高度 + + +### hdl + + +``` +BufferHandle* LayerBuffer::hdl ``` **描述:** @@ -2081,120 +3088,529 @@ BufferHandle* LayerBuffer::hdl 图层buffer句柄 -### height [1/7] +### height [1/8] + + +``` +uint32_t DisplayInfo::height +``` + +**描述:** + +显示屏高度 + + +### height [2/8] + + +``` +int32_t LayerInfo::height +``` + +**描述:** + +图层高度 + + +### height [3/8] + + +``` +int32_t LayerBuffer::height +``` + +**描述:** + +buffer高度 + + +### height [4/8] + + +``` +int32_t ISurface::height +``` + +**描述:** + +图像高度 + + +### height [5/8] + + +``` +int32_t DisplayModeInfo::height +``` + +**描述:** + +像素高度 + + +### height [6/8] + + +``` +uint32_t AllocInfo::height +``` + +**描述:** + +申请内存高度 + + +### height [7/8] + + +``` +uint32_t VerifyAllocInfo::height +``` + +**描述:** + +分配内存的高度 + + +### height [8/8] + + +``` +uint32_t VGUBuffer::height +``` + +**描述:** + +位图高度 + + +### id + + +``` +int32_t DisplayModeInfo::id +``` + +**描述:** + +模式ID + + +### image + + +``` +VGUImage* VGUPattern::image +``` + +**描述:** + +图像对象 + + +### InitVgu + + +``` +VGUResult(* VGUFuncs::InitVgu) (void) +``` + +**描述:** + +初始化硬件加速。 + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + +**参见:** + +[DeinitVgu](#deinitvgu) + + +### InvokeDisplayCmd + + +``` +int32_t(* DeviceFuncs::InvokeDisplayCmd) (uint32_t devId,...) +``` + +**描述:** + +调用显示设备命令。 + +该接口用于图形服务和接口实现层之间的接口扩展,如果由临时接口新增可以通过该接口进行扩展,不用增加新的接口定义。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### join + + +``` +VGUJointType VGUStrokeAttr::join +``` + +**描述:** + +联结类型 + + +### key + + +``` +HDRMetadataKey HDRMetaData::key +``` + +**描述:** + +HDR元数据关键字 + + +### linear + + +``` +VGULinear VGUGradient::linear +``` + +**描述:** + +线性渐变对象 + + +### m + + +``` +float VGUMatrix3::m[3][3] +``` + +**描述:** + +3x3变换矩阵 + + +### mask + + +``` +VGUMaskLayer* VGUSurface::mask +``` + +**描述:** + +蒙版图层,可以为空 + + +### matrix [1/2] + + +``` +VGUMatrix3* VGUImage::matrix +``` + +**描述:** + +图像矩阵变换,该参数为空,则内部使用单位变换矩阵 + + +### matrix [2/2] + + +``` +VGUMatrix3* VGUGradient::matrix +``` + +**描述:** + +针对渐变对象的变换矩阵 + + +### maxAverageLum + + +``` +float HDRCapability::maxAverageLum +``` + +**描述:** + +最大的平均光亮度luminance值 + + +### maxLum + + +``` +float HDRCapability::maxLum +``` + +**描述:** + +最大的光亮度luminance值 + + +### minLum + + +``` +float HDRCapability::minLum +``` + +**描述:** + +最小的光亮度luminance值 + + +### mirrorType + + +``` +MirrorType GfxOpt::mirrorType +``` + +**描述:** + +镜像类型 + + +### miterLimit + + +``` +float VGUStrokeAttr::miterLimit +``` + +**描述:** + +最大斜切长度 + + +### name [1/2] + + +``` +char PropertyObject::name[PROPERTY_NAME_LEN] +``` + +**描述:** + +属性名称 + + +### name [2/2] + + +``` +char DisplayCapability::name[PROPERTY_NAME_LEN] +``` + +**描述:** + +显示设备名称 + + +### numSegments + + +``` +int32_t VGUPath::numSegments +``` + +**描述:** + +路径命令总数 + + +### opacity [1/3] + + +``` +uint8_t VGUImage::opacity +``` + +**描述:** + +透明度,范围0~255 + + +### opacity [2/3] + + +``` +uint8_t VGUGradient::opacity +``` + +**描述:** + +透明度,范围0~255 + + +### opacity [3/3] + + +``` +uint8_t VGUSolid::opacity +``` + +**描述:** + +透明度,取值范围 0 ~ 255。 + + +### pattern + + +``` +VGUPattern* VGUPaintStyle::pattern +``` + +**描述:** + +图片模式对象 + + +### phyAddr [1/3] + + +``` +uint64_t BufferData::phyAddr +``` + +**描述:** + +物理内存地址 + + +### phyAddr [2/3] ``` -uint32_t DisplayInfo::height +uint64_t ISurface::phyAddr ``` **描述:** -显示屏高度 +图像首地址 -### height [2/7] +### phyAddr [3/3] ``` -int32_t LayerInfo::height +uint64_t VGUBuffer::phyAddr ``` **描述:** -图层高度 +位图缓存的物理地址 -### height [3/7] +### phyHeight ``` -int32_t LayerBuffer::height +uint32_t DisplayCapability::phyHeight ``` **描述:** -buffer高度 +物理高度 -### height [4/7] +### phyWidth ``` -int32_t ISurface::height +uint32_t DisplayCapability::phyWidth ``` **描述:** -图像高度 +物理宽度 -### height [5/7] +### pitch ``` -int32_t DisplayModeInfo::height +int32_t LayerBuffer::pitch ``` **描述:** -像素高度 +一行数据所占字节数 -### height [6/7] +### pixelFormat ``` -uint32_t AllocInfo::height +VGUPixelFormat VGUBuffer::pixelFormat ``` **描述:** -申请内存高度 +像素格式 -### height [7/7] +### pixFormat [1/2] ``` -uint32_t VerifyAllocInfo::height +PixelFormat LayerInfo::pixFormat ``` **描述:** -分配内存的高度 +图层像素格式 -### id +### pixFormat [2/2] ``` -int32_t DisplayModeInfo::id +PixelFormat LayerBuffer::pixFormat ``` **描述:** -模式ID +buffer像素格式r -### InvokeDisplayCmd +### PrepareDisplayLayers ``` -int32_t(* DeviceFuncs::InvokeDisplayCmd) (uint32_t devId,...) +int32_t(* DeviceFuncs::PrepareDisplayLayers) (uint32_t devId, bool *needFlushFb) ``` **描述:** -调用显示设备命令。 +显示设备合成前准备。 -该接口用于图形服务和接口实现层之间的接口扩展,如果由临时接口新增可以通过该接口进行扩展,不用增加新的接口定义。 +图形服务在合成前需要通过该接口通知显示设备进行合成前的准备工作。 **参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,指示需要操作的设备ID。 | +| needFlushFb | 输出参数,接口实现层通过该参数指示图形服务在commit前是否需要通过[SetDisplayClientBuffer](#setdisplayclientbuffer)重新设置显示帧存。 true表示需要设置显示帧存,false表示不需要。 | **返回:** @@ -2203,193 +3619,225 @@ DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### key +### propertyCount ``` -HDRMetadataKey HDRMetaData::key +uint32_t DisplayCapability::propertyCount ``` **描述:** -HDR元数据关键字 +属性数组大小 -### maxAverageLum +### propId ``` -float HDRCapability::maxAverageLum +uint32_t PropertyObject::propId ``` **描述:** -最大的平均光亮度luminance值 +属性ID -### maxLum +### props ``` -float HDRCapability::maxLum +PropertyObject* DisplayCapability::props ``` **描述:** -最大的光亮度luminance值 +属性数组 -### minLum +### QueryCapability ``` -float HDRCapability::minLum +int32_t(* VGUFuncs::QueryCapability) (uint32_t cap) ``` **描述:** -最小的光亮度luminance值 +查询硬件能力集。 +**参数:** -### mirrorType + | 名称 | 描述 | +| -------- | -------- | +| cap | 输入参数,待查询能力。该参数类型定义参考 [VGUCapability](#vgucapability)。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### r ``` -MirrorType GfxOpt::mirrorType +int32_t ICircle::r ``` **描述:** -镜像类型 +圆的半径 -### name [1/2] +### r0 ``` -char PropertyObject::name[PROPERTY_NAME_LEN] +VGUScalar VGURadial::r0 ``` **描述:** -属性名称 +内圈圆半径 -### name [2/2] +### r1 ``` -char DisplayCapability::name[PROPERTY_NAME_LEN] +VGUScalar VGURadial::r1 ``` **描述:** -显示设备名称 +外圈圆半径 -### phyAddr [1/2] +### radial ``` -uint64_t BufferData::phyAddr +VGURadial VGUGradient::radial ``` **描述:** -物理内存地址 +辐射渐变对象 -### phyAddr [2/2] +### rect [1/3] ``` -uint64_t ISurface::phyAddr +IRect Rectangle::rect ``` **描述:** -图像首地址 +矩形区域 -### phyHeight +### rect [2/3] ``` -uint32_t DisplayCapability::phyHeight +VGURect* VGUMaskLayer::rect ``` **描述:** -物理高度 +蒙版矩形 -### phyWidth +### rect [3/3] ``` -uint32_t DisplayCapability::phyWidth +VGURect* VGUImage::rect ``` **描述:** -物理宽度 +图像截取矩形,该参数为空,则截取整个图像 -### pitch +### RegDisplayRefreshCallback ``` -int32_t LayerBuffer::pitch +int32_t(* DeviceFuncs::RegDisplayRefreshCallback) (uint32_t devId, RefreshCallback callback, void *data) ``` **描述:** -一行数据所占字节数 +刷新请求回调。 +注册刷新请求事件回调,当实现层有刷新需求时,实现层通过回调注册的接口通知图形服务。 -### pixFormat [1/2] +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| callback | 输入参数,刷新请求事件回调实例,当有接口实现层有刷新请求时,需要通过该实例通知图形服务。 | +| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | -``` -PixelFormat LayerInfo::pixFormat -``` +**返回:** -**描述:** +DISPLAY_SUCCESS 表示执行成功。 -图层像素格式 +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### pixFormat [2/2] +### RegDisplayVBlankCallback ``` -PixelFormat LayerBuffer::pixFormat +int32_t(* DeviceFuncs::RegDisplayVBlankCallback) (uint32_t devId, VBlankCallback callback, void *data) ``` **描述:** -buffer像素格式 +注册VBlank事件回调。 +注册VBlank事件回调,当有VBlank事件发生时接口实现层需要回调注册的接口。 -### PrepareDisplayLayers +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| devId | 输入参数,指示需要操作的设备ID。 | +| callback | 输入参数,VBlank事件回调实例,当有VBlank事件发生时并且DisplayVsync处于Enable状态,接口实现层需要通过该实例通知图形服务。 | +| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 + + +### RegHotPlugCallback ``` -int32_t(* DeviceFuncs::PrepareDisplayLayers) (uint32_t devId, bool *needFlushFb) +int32_t(* DeviceFuncs::RegHotPlugCallback) (HotPlugCallback callback, void *data) ``` **描述:** -显示设备合成前准备。 +注册热插拔事件回调。 -图形服务在合成前需要通过该接口通知显示设备进行合成前的准备工作。 +注册热插拔事件回调,当有热插拔事件发生时接口实现层需要回调注册的接口。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| needFlushFb | 输出参数,接口实现层通过该参数指示图形服务在commit前是否需要通过SetDisplayClientBuffer重新设置显示帧存。 true表示需要设置显示帧存,false表示不需要。 | +| callback | 输入参数,热插拔事件回调实例,当有热插拔事件发生时,接口实现层需要通过该实例通知图形服务。 | +| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | **返回:** @@ -2398,195 +3846,289 @@ DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### propertyCount +### RenderBlit ``` -uint32_t DisplayCapability::propertyCount +VGUResult(* VGUFuncs::RenderBlit) (VGUSurface *target, const VGUImage *src, uint32_t color) ``` **描述:** -属性数组大小 +对图像进行搬移操作。 +搬移过程中同时进行颜色空间转换,矩阵变换操作。 -### propId +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| target | 输入参数,渲染目标表面。 | +| src | 输入参数,待叠加源图像。 | +| color | 输入参数,参与混合的颜色值。如果颜色值为0,则不参与混合操作。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### RenderBlitN ``` -uint32_t PropertyObject::propId +VGUResult(* VGUFuncs::RenderBlitN) (VGUSurface *target, const VGUImage *src, uint16_t count, uint32_t color) ``` **描述:** -属性ID +对多个源图像进行叠加操作。 +搬移过程中同时进行颜色空间转换,矩阵变换操作。该接口支持多个源图形同时叠加到目标表面, 对于硬件支持源图像数目可以通过[QueryCapability](#querycapability)接口查询**。** + +**参数**: + + + | 名称 | 描述 | +| -------- | -------- | +| target | 输入参数,渲染目标表面。 | +| src | 输入参数,待叠加源图像数组。 | +| count | 输入参数,待叠加源图像个数。 | +| color | 输入参数,参与混合的颜色值。如果颜色值为0,则不参与混合操作。 | + + +**返回**: + + +VGU_SUCCESS 表示执行成功。 + + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### props + +### RenderBlur ``` -PropertyObject* DisplayCapability::props +VGUResult(* VGUFuncs::RenderBlur) (VGUSurface *target, uint16_t blur) ``` **描述:** -属性数组 +对目标表面进行模糊处理。 + +**参数:** + | 名称 | 描述 | +| -------- | -------- | +| target | 输入参数,渲染目标表面。 | +| blur | 输入参数,模糊半径。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### r + +### RenderCancel ``` -int32_t ICircle::r +VGUResult(* VGUFuncs::RenderCancel) () ``` **描述:** -圆的半径 +取消硬件加速渲染。 + +**返回:** + +VGU_SUCCESS 表示执行成功。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### rect + +### RenderClearRect ``` -IRect Rectangle::rect +VGUResult(* VGUFuncs::RenderClearRect) (VGUSurface *target, const VGURect *rect, uint32_t color, uint8_t opacity) ``` **描述:** -矩形区域 +对指定矩形进行颜色清除操作。 +**参数:** -### RegDisplayRefreshCallback + | 名称 | 描述 | +| -------- | -------- | +| target | 输入参数,渲染目标表面。 | +| rect | 输入参数,待填充矩形大小,如果该参数为空,则整个表面清除。 | +| color | 输入参数,填充颜色。 | +| opacity | 输入参数,填充透明度。 | + +**返回:** + +VGU_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 + + +### RenderFill ``` -int32_t(* DeviceFuncs::RegDisplayRefreshCallback) (uint32_t devId, RefreshCallback callback, void *data) +VGUResult(* VGUFuncs::RenderFill) (VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, const VGUFillAttr *attr, const VGUPaintStyle *style) ``` **描述:** -刷新请求回调。 - -注册刷新请求事件回调,当实现层有刷新需求时,实现层通过回调注册的接口通知图形服务。 +使用指定的渲染对象来填充路径。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| callback | 输入参数,刷新请求事件回调实例,当有接口实现层有刷新请求时,需要通过该实例通知图形服务。 | -| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | +| target | 输入参数,渲染目标表面。 | +| path | 输入参数,路径对象。 | +| matrix | 输入参数,变换矩阵对象。 如果该参数为空,默认为单位矩阵。 | +| attr | 输入参数,填充属性。 | +| style | 输入参数,绘制对象。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### RegDisplayVBlankCallback +### RenderStroke ``` -int32_t(* DeviceFuncs::RegDisplayVBlankCallback) (uint32_t devId, VBlankCallback callback, void *data) +VGUResult(* VGUFuncs::RenderStroke) (VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, const VGUStrokeAttr *attr, const VGUPaintStyle *style) ``` **描述:** -注册VBlank事件回调。 - -注册VBlank事件回调,当有VBlank事件发生时接口实现层需要回调注册的接口。 +使用指定的渲染对象来描边路径。 **参数:** | 名称 | 描述 | | -------- | -------- | -| devId | 输入参数,指示需要操作的设备ID。 | -| callback | 输入参数,VBlank事件回调实例,当有VBlank事件发生时并且DisplayVsync处于Enable状态,接口实现层需要通过该实例通知图形服务。 | -| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | +| target | 输入参数,渲染目标表面。 | +| path | 输入参数,路径对象。 | +| matrix | 输入参数,变换矩阵对象。 如果该参数为空,默认为单位矩阵。 | +| attr | 输入参数,描边属性。 | +| style | 输入参数,绘制对象。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 -### RegHotPlugCallback +### RenderSync ``` -int32_t(* DeviceFuncs::RegHotPlugCallback) ((HotPlugCallback callback, void *data) +VGUResult(* VGUFuncs::RenderSync) (int32_t timeOut) ``` **描述:** -注册热插拔事件回调。 +同步硬件加速模块绘制或搬移操作。 -注册热插拔事件回调,当有热插拔事件发生时接口实现层需要回调注册的接口。 +该函数将阻塞等待硬件绘制完成后继续运行。 **参数:** | 名称 | 描述 | | -------- | -------- | -| callback | 输入参数,热插拔事件回调实例,当有热插拔事件发生时,接口实现层需要通过该实例通知图形服务。 | -| data | 输出参数,图形服务携带的私有数据,在事件回调接口中需要返回给图形服务。 | +| timeOut | 输入参数,该参数表示硬件加速同步等待超时时间。 值为**0**表示没有等待时间。 | **返回:** -DISPLAY_SUCCESS 表示执行成功。 +VGU_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 +其他值表示执行失败,具体错误码查看[VGUResult](#vguresult)。 ### reserve ``` -int32_t __attribute__::reserve[0] +int32_t ExtDataHandle::reserve[0] +``` + +**描述:** + +reserve数组 + + +### reserveInts + + +``` +uint32_t ExtDataHandle::reserveInts +``` + +**描述:** + +reserve数组的个数 + + +### rotAngle + + +``` +int32_t DisplayInfo::rotAngle ``` **描述:** -reserve数组 +显示屏旋转角度 -### reserveInts +### rotateType ``` -uint32_t __attribute__::reserveInts +TransformType GfxOpt::rotateType ``` **描述:** -reserve数组的个数 +旋转类型 -### rotAngle +### rule ``` -int32_t DisplayInfo::rotAngle +VGUFillRule VGUFillAttr::rule ``` **描述:** -显示屏旋转角度 +填充规格 -### rotateType +### segment ``` -TransformType GfxOpt::rotateType +uint8_t* VGUPath::segment ``` **描述:** -旋转类型 +存放路径命令数据 ### SetDisplayBacklight @@ -2938,7 +4480,55 @@ DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](#disperrcode)。 -### stride +### solid + + +``` +VGUSolid* VGUPaintStyle::solid +``` + +**描述:** + +颜色对象 + + +### spread + + +``` +VGUFillSpread VGUGradient::spread +``` + +**描述:** + +渐变延伸模式 + + +### stop + + +``` +float VGUColorStop::stop +``` + +**描述:** + +颜色偏移位置,取值范围是 0.0 ~ 1.0。 + + +### stopCount + + +``` +uint16_t VGUGradient::stopCount +``` + +**描述:** + +渐变停止颜色个数 + + +### stride [1/2] ``` @@ -2950,6 +4540,18 @@ int32_t ISurface::stride 图像跨度 +### stride [2/2] + + +``` +uint32_t VGUBuffer::stride +``` + +**描述:** + +位图stride + + ### supportLayers @@ -2986,7 +4588,7 @@ int64_t PresentTimestamp::time 类型对应的值 -### type [1/3] +### type [1/7] ``` @@ -2998,7 +4600,7 @@ LayerType LayerInfo::type 图层类型,包括图形层、视频层和媒体播放模式 -### type [2/3] +### type [2/7] ``` @@ -3010,7 +4612,7 @@ InterfaceType DisplayCapability::type 显示屏接口类型 -### type [3/3] +### type [3/7] ``` @@ -3022,11 +4624,59 @@ PresentTimestampType PresentTimestamp::type 上屏时间戳类型 +### type [4/7] + + +``` +VGUPathDataType VGUPath::type +``` + +**描述:** + +路径数据存储类型 + + +### type [5/7] + + +``` +uint32_t VGUMatrix3::type +``` + +**描述:** + +矩阵变换类型,简单变换为缩放,平移,90度倍数旋转 + + +### type [6/7] + + +``` +VGUGradientType VGUGradient::type +``` + +**描述:** + +渐变类型 + + +### type [7/7] + + +``` +VGUPaintType VGUPaintStyle::type +``` + +**描述:** + +渲染类型 + + ### uOffset ``` -size_t __attribute__::uOffset +size_t YUVDescInfo::uOffset ``` **描述:** @@ -3062,7 +4712,7 @@ uint64_t VerifyAllocInfo::usage ``` -size_t __attribute__::uvStep +size_t YUVDescInfo::uvStep ``` **描述:** @@ -3106,7 +4756,7 @@ float HDRMetaData::value 关键字对应的值 -### virAddr +### virAddr [1/2] ``` @@ -3118,6 +4768,18 @@ void* BufferData::virAddr 虚拟内存地址 +### virAddr [2/2] + + +``` +void* VGUBuffer::virAddr +``` + +**描述:** + +位图缓存的虚拟地址 + + ### virtualDispCount @@ -3134,7 +4796,7 @@ uint32_t DisplayCapability::virtualDispCount ``` -size_t __attribute__::vOffset +size_t YUVDescInfo::vOffset ``` **描述:** @@ -3142,7 +4804,7 @@ size_t __attribute__::vOffset V的偏移量 -### w +### w [1/2] ``` @@ -3154,7 +4816,19 @@ int32_t IRect::w 矩形框宽度 -### width [1/7] +### w [2/2] + + +``` +VGUScalar VGURect::w +``` + +**描述:** + +矩形宽度 + + +### width [1/9] ``` @@ -3166,7 +4840,7 @@ uint32_t DisplayInfo::width 显示屏宽度 -### width [2/7] +### width [2/9] ``` @@ -3178,7 +4852,7 @@ int32_t LayerInfo::width 图层宽度 -### width [3/7] +### width [3/9] ``` @@ -3190,7 +4864,7 @@ int32_t LayerBuffer::width buffer宽度 -### width [4/7] +### width [4/9] ``` @@ -3202,7 +4876,7 @@ int32_t ISurface::width 图像宽度 -### width [5/7] +### width [5/9] ``` @@ -3214,7 +4888,7 @@ int32_t DisplayModeInfo::width 像素宽度 -### width [6/7] +### width [6/9] ``` @@ -3226,7 +4900,7 @@ uint32_t AllocInfo::width 申请内存宽度 -### width [7/7] +### width [7/9] ``` @@ -3238,7 +4912,55 @@ uint32_t VerifyAllocInfo::width 分配内存的宽度 -### x [1/2] +### width [8/9] + + +``` +uint32_t VGUBuffer::width +``` + +**描述:** + +位图宽度 + + +### width [9/9] + + +``` +float VGUStrokeAttr::width +``` + +**描述:** + +线宽 + + +### wrapx + + +``` +VGUWrapType VGUPattern::wrapx +``` + +**描述:** + +图像水平方向平铺类型 + + +### wrapy + + +``` +VGUWrapType VGUPattern::wrapy +``` + +**描述:** + +图像垂直方向平铺类型 + + +### x [1/4] ``` @@ -3250,7 +4972,7 @@ int32_t IRect::x 矩形框起始x坐标 -### x [2/2] +### x [2/4] ``` @@ -3262,7 +4984,31 @@ int32_t ICircle::x 圆心x坐标 -### x0 +### x [3/4] + + +``` +VGUScalar VGUPoint::x +``` + +**描述:** + +点水平坐标 + + +### x [4/4] + + +``` +VGUScalar VGURect::x +``` + +**描述:** + +矩形水平起始坐标 + + +### x0 [1/2] ``` @@ -3274,7 +5020,19 @@ int32_t ILine::x0 线条起点的x坐标 -### x1 +### x0 [2/2] + + +``` +VGUScalar VGURadial::x0 +``` + +**描述:** + +内圈圆心水平坐标 + + +### x1 [1/3] ``` @@ -3286,7 +5044,43 @@ int32_t ILine::x1 线条终点的x坐标 -### y [1/2] +### x1 [2/3] + + +``` +VGUScalar VGULinear::x1 +``` + +**描述:** + +线性渐变起点水平坐标 + + +### x1 [3/3] + + +``` +VGUScalar VGURadial::x1 +``` + +**描述:** + +外圈圆心水平坐标 + + +### x2 + + +``` +VGUScalar VGULinear::x2 +``` + +**描述:** + +线性渐变终点水平坐标 + + +### y [1/4] ``` @@ -3298,7 +5092,7 @@ int32_t IRect::y 矩形框起始y坐标 -### y [2/2] +### y [2/4] ``` @@ -3310,7 +5104,31 @@ int32_t ICircle::y 圆心y坐标r -### y0 +### y [3/4] + + +``` +VGUScalar VGUPoint::y +``` + +**描述:** + +点垂直坐标 + + +### y [4/4] + + +``` +VGUScalar VGURect::y +``` + +**描述:** + +矩形垂直起始坐标 + + +### y0 [1/2] ``` @@ -3322,7 +5140,19 @@ int32_t ILine::y0 线条起点的y坐标 -### y1 +### y0 [2/2] + + +``` +VGUScalar VGURadial::y0 +``` + +**描述:** + +内圈圆心垂直坐标 + + +### y1 [1/3] ``` @@ -3334,11 +5164,47 @@ int32_t ILine::y1 线条终点的y坐标 +### y1 [2/3] + + +``` +VGUScalar VGULinear::y1 +``` + +**描述:** + +线性渐变起点垂直坐标 + + +### y1 [3/3] + + +``` +VGUScalar VGURadial::y1 +``` + +**描述:** + +外圈圆心垂直坐标 + + +### y2 + + +``` +VGUScalar VGULinear::y2 +``` + +**描述:** + +线性渐变终点垂直坐标 + + ### yOffset ``` -size_t __attribute__::yOffset +size_t YUVDescInfo::yOffset ``` **描述:** @@ -3350,7 +5216,7 @@ Y的偏移量 ``` -size_t __attribute__::yStride +size_t YUVDescInfo::yStride ``` **描述:** diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_capability.md b/zh-cn/device-dev/reference/hdi-apis/_display_capability.md index a4a43e5cb58d12934ab7589b6e901c97b5a4c3c7..dc9fb8e076741b999ee98f403c7c5e563d2e7ffc 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_display_capability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_display_capability.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义输出性能。 + +**相关模块:** [Display](_display.md) @@ -13,10 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [name](_display.md#name-22) [PROPERTY_NAME_LEN] | 显示设备名称 | -| [type](_display.md#type-23) | 显示屏接口类型 | +| [name [PROPERTY_NAME_LEN]](_display.md#name-22) | 显示设备名称 | +| [type](_display.md#type-27) | 显示屏接口类型 | | [phyWidth](_display.md#phywidth) | 物理宽度 | | [phyHeight](_display.md#phyheight) | 物理高度 | | [supportLayers](_display.md#supportlayers) | 支持的图层数 | @@ -24,8 +26,3 @@ | [supportWriteBack](_display.md#supportwriteback) | 是否支持回写 | | [propertyCount](_display.md#propertycount) | 属性数组大小 | | [props](_display.md#props) | 属性数组 | - - -## **详细描述** - -定义输出性能。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_info.md b/zh-cn/device-dev/reference/hdi-apis/_display_info.md index b67997b6de13b855cdea17de0987e37d70b233be..daaa760ad656a45a7877199274a37ddf1b369f11 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_display_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_display_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义显示信息结构体。 + +**相关模块:** [Display](_display.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](_display.md#width-17) | 显示屏宽度 | -| [height](_display.md#height-17) | 显示屏高度 | +| [width](_display.md#width-19) | 显示屏宽度 | +| [height](_display.md#height-18) | 显示屏高度 | | [rotAngle](_display.md#rotangle) | 显示屏旋转角度 | - - -## **详细描述** - -定义显示信息结构体。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md b/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md index eafd58d19e35fad8b0a08e5389bd1ca9e34b1209..a89c6e0ff77a5b9bf8d183a17539c9ea4f651919 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义输出模式信息。 + +**相关模块:** [Display](_display.md) @@ -13,14 +15,9 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](_display.md#width-57) | 像素宽度 | -| [height](_display.md#height-57) | 像素高度 | +| [width](_display.md#width-59) | 像素宽度 | +| [height](_display.md#height-58) | 像素高度 | | [freshRate](_display.md#freshrate) | 刷新速率 | | [id](_display.md#id) | 模式ID | - - -## **详细描述** - -定义输出模式信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md b/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md index cc322e8336343a6499543a67f7ca6565cf3f29b3..df3fc98fbc8e6a2a2938fc0d6435ac6459b38677 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md +++ b/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md @@ -3,6 +3,16 @@ ## **概述** +录入结果信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,24 +23,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [authType](#authtype) | 用户认证凭据类型。 | | [executorType](#executortype) | 执行器类型。 | -| [executorId](#executorsensorhint) | 既定用户认证凭据类型的执行器传感器提示,用于找到对应认证方式的传感器。 | - - -## **详细描述** - -录入结果信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 +| [executorSensorHint](#executorsensorhint) | 既定用户认证凭据类型的执行器传感器提示,用于找到对应认证方式的传感器。 | ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md b/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md index a1213411c37768ce085514a640f8d89adc301a63..c16294b124fd10052766e2eec171eefcc2c388d8 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md +++ b/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md @@ -3,6 +3,16 @@ ## **概述** +注册认证凭据参数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,26 +23,13 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [credentialId](#credentialid) | 认证凭据ID。 | | [oldInfo](#oldinfo) | 旧凭据信息。 | | [rootSecret](#rootsecret) | 保护文件加密密钥的密钥。 | -## **详细描述** - -注册认证凭据参数。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** @@ -57,7 +54,7 @@ struct CredentialInfo EnrollParam::oldInfo **描述:** -旧凭据信息{\@link CredentialInfo}。 +旧凭据信息[CredentialInfo](_credential_info.md)。 ### rootSecret diff --git a/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md b/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md index 36c6ffd6e1e8e66e645074fd4fb3b81388059e14..63fe13082c82824a84d862b0c6ce7acd0798553f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md @@ -3,6 +3,16 @@ ## **概述** +注册信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,25 +23,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [enrolledId](#enrolledid) | 注册ID,用户注册新的认证凭据时会更新注册ID。 | | [authType](#authtype) | 用户认证凭据类型。 | -## **详细描述** - -注册信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** @@ -44,7 +41,7 @@ enum AuthType EnrolledInfo::authType **描述:** -用户认证凭据类型AuthType}。 +用户认证凭据类型[AuthType](_hdf_user_auth.md#authtype)。 ### enrolledId diff --git a/zh-cn/device-dev/reference/hdi-apis/_event_info.md b/zh-cn/device-dev/reference/hdi-apis/_event_info.md index 02b70dc552b5ced6c3ed1b8f1cc995cce92fab1d..93032444d007f364a50ec8e287d948efa8702e38 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_event_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_event_info.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义事件上报信息。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [appData](#appdata) | 设置回调时给入的上层实例。 | | [appDataLen](#appdatalen) | appData字节数。 | @@ -23,11 +25,6 @@ | [eventDataLen](#eventdatalen) | eventData字节数。 | -## **详细描述** - -定义事件上报信息。 - - ## **类成员变量说明** @@ -40,7 +37,7 @@ int8_t* EventInfo::appData **描述:** -设置回调时给入的上层实例 +设置回调时给入的上层实例。 ### appDataLen @@ -52,7 +49,7 @@ uint32_t EventInfo::appDataLen **描述:** -appData字节数 +appData字节数。 ### data1 @@ -64,7 +61,7 @@ uint32_t EventInfo::data1 **描述:** -事件上报携带的数据1 +事件上报携带的数据1。 ### data2 @@ -76,7 +73,7 @@ uint32_t EventInfo::data2 **描述:** -事件上报携带的数据2 +事件上报携带的数据2。 ### eventData @@ -88,7 +85,7 @@ int8_t* EventInfo::eventData **描述:** -事件上报携带的数据信息 +事件上报携带的数据信息。 ### eventDataLen @@ -100,4 +97,4 @@ uint32_t EventInfo::eventDataLen **描述:** -eventData字节数 +eventData字节数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_info.md b/zh-cn/device-dev/reference/hdi-apis/_executor_info.md index 29f4d116ca581180a4a07be6ffccddbc250ee365..c67700a04747ebc6a061cf7cb6cab70699090524 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_executor_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_info.md @@ -3,6 +3,16 @@ ## **概述** +执行器信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) | [HdfPinAuth](_hdf_pin_auth.md) @@ -13,7 +23,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [sensorId](#sensorid) | 传感器ID,不同传感器在人脸/口令认证驱动内的唯一标识。 | | [executorType](#executortype) | 执行器类型,根据执行器支持的能力/算法类型进行分类。 | @@ -26,19 +36,6 @@ | [info](#info) | 执行器注册信息。 | -## **详细描述** - -执行器信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** @@ -63,7 +60,7 @@ enum ExecutorSecureLevel ExecutorInfo::esl **描述:** -执行器安全等级[ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel)。 +执行器安全等级[ExecutorSecureLevel](_hdf_face_auth.md#executorsecurelevel)。 ### executorRole @@ -75,7 +72,7 @@ enum ExecutorRole ExecutorInfo::executorRole **描述:** -执行器角色[ExecutorRole](_hdf_user_auth.md#executorrole)。 +执行器角色[ExecutorRole](_hdf_face_auth.md#executorrole)。 ### executorType @@ -147,6 +144,4 @@ unsigned short ExecutorInfo::sensorId **描述:** -传感器ID,不同传感器在人脸认证驱动内的唯一标识。 - -传感器ID,不同传感器在口令认证驱动内的唯一标识。 +传感器ID,不同传感器在人脸认证驱动、口令认证驱动内的唯一标识。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md b/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md index ff242ae7d76d8749b458eac663519c3ca30fbb12..a0ee3deb5f7e7e0ae97a1c5f3ce6db95bd42bc88 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md @@ -3,6 +3,16 @@ ## **概述** +执行器注册信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,7 +23,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [authType](#authtype) | 用户认证凭据类型。 | | [executorRole](#executorrole) | 执行器角色。 | @@ -23,19 +33,6 @@ | [publicKey](#publickey) | 执行器公钥,用于校验该执行器私钥签名的信息。 | -## **详细描述** - -执行器注册信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md b/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md index 90ed9fcc8933fe089cf35c374839e4168bf83f8c..ba9ea1bf58db81a19ebdff5a34eb0a5e0031563f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md @@ -3,6 +3,16 @@ ## **概述** +执行器发送的消息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,24 +23,13 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [executorIndex](#executorindex) | 用户认证框架的执行器索引。 | | [commandId](#commandid) | 消息命令ID。 | | [msg](#msg) | 执行器发送的消息。 | -## **详细描述** - -执行器发送的消息。 - -**Since:** - -3.2 - -**Version:** - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_ext_data_handle.md b/zh-cn/device-dev/reference/hdi-apis/_ext_data_handle.md new file mode 100644 index 0000000000000000000000000000000000000000..eb120bcd201dd27759e96c7dd73872c7f004b28e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_ext_data_handle.md @@ -0,0 +1,22 @@ +# ExtDataHandle + + +## **概述** + +扩展数据句柄结构体定义。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [fd](_display.md#fd) | 句柄fd,-1代表不支持。 | +| [reserveInts](_display.md#reserveints) | reserve数组的个数。 | +| [reserve](_display.md#reserve) [0] | reserve数组。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md index b9c9e4ad7876f5796cd736e15b1ec3ae429eb4c1..580e403779f4246547b52d2e90534a6c230ad0ae 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义人脸认证驱动的枚举类和数据结构。 + +**Since:** + +3.2 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) @@ -13,34 +19,25 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [ExecutorInfo](_executor_info.md) | 执行器信息。 [更多...](_executor_info.md) | -| [TemplateInfo](_template_info.md) | 凭据模版信息。 [更多...](_template_info.md) | +| [ExecutorInfo](_executor_info.md) | 执行器信息。 | +| [TemplateInfo](_template_info.md) | 凭据模版信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](_hdf_face_auth.md#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 [更多...](_hdf_face_auth.md#authtype) | -| [ExecutorRole](_hdf_face_auth.md#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_face_auth.md#executorrole) | -| [ExecutorSecureLevel](_hdf_face_auth.md#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](_hdf_face_auth.md#executorsecurelevel) | -| [CommandId](_hdf_face_auth.md#commandid) : int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认证功能相关操作命令。 [更多...](_hdf_face_auth.md#commandid) | -| [FaceTipsCode](_hdf_face_auth.md#facetipscode) : int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4,   FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8,   FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举提示信息编码。 [更多...](_hdf_face_auth.md#facetipscode) | +| [AuthType](_hdf_face_auth.md#authtype): int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](_hdf_face_auth.md#executorrole): int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](_hdf_face_auth.md#executorsecurelevel): int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [CommandId](_hdf_face_auth.md#commandid): int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认证功能相关操作命令。 | +| [FaceTipsCode](_hdf_face_auth.md#facetipscode): int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4,   FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8,   FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举提示信息编码。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.face_auth.v1_0 | 人脸认证接口的包路径 | - - -## **详细描述** - -定义人脸认证驱动的枚举类和数据结构。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md b/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md index 2f5936c9d16e2800eb9fd6718d7f18f552e99685..da5ba0c838ea4dd4d13bf64034bddf6e2697a401 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md +++ b/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +BufferHandleUsage类型定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [size](#size) | 结构体大小 | -| [version](#version) | 组件版本信息 | -| [portIndex](#portindex) | 端口索引 | -| [usage](#usage) | 使用率 | - - -## **详细描述** - -BufferHandleUsage类型定义。 +| [size](#size) | 结构体大小。 | +| [version](#version) | 组件版本信息。 | +| [portIndex](#portindex) | 端口索引。 | +| [usage](#usage) | 申请内存的使用场景。 | ## **类成员变量说明** @@ -38,7 +35,7 @@ uint32_t GetBufferHandleUsageParams::portIndex **描述:** -端口索引 +端口索引。 ### size @@ -50,7 +47,7 @@ uint32_t GetBufferHandleUsageParams::size **描述:** -结构体大小 +结构体大小。 ### usage @@ -62,7 +59,7 @@ uint32_t GetBufferHandleUsageParams::usage **描述:** -usage +申请内存的使用场景。 ### version @@ -74,4 +71,4 @@ union OMX_VERSIONTYPE GetBufferHandleUsageParams::version **描述:** -组件版本信息 +组件版本信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md index 76ed3097f7da3a13a35b00d4f791bfcf2ffa2ccf..fcc1c2a22e5cb89102134fe227a7c38a29c82ac2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md +++ b/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 + +**相关模块:** [Display](_display.md) @@ -13,21 +15,16 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [InitGfx](#initgfx) )(void) | 初始化硬件加速。 [更多...](#initgfx) | -| ( [DeinitGfx](#deinitgfx) )(void) | 去初始化硬件加速。 [更多...](#deinitgfx) | -| ( [FillRect](#fillrect) )([ISurface](_i_surface.md) \*surface, [IRect](_i_rect.md) \*rect, uint32_t color, [GfxOpt](_gfx_opt.md) \*opt) | 填充矩形,用一种颜色填充画布上指定矩形区域的矩形框。 [更多...](#fillrect) | -| ( [DrawRectangle](#drawrectangle) )([ISurface](_i_surface.md) \*surface, [Rectangle](_rectangle.md) \*rect, uint32_t color, [GfxOpt](_gfx_opt.md) \*opt) | 绘制矩形框,用一种颜色在画布上绘制指定区域的矩形框。 [更多...](#drawrectangle) | -| ( [DrawLine](#drawline) )([ISurface](_i_surface.md) \*surface, [ILine](_i_line.md) \*line, [GfxOpt](_gfx_opt.md) \*opt) | 绘制直线,使用一种颜色在画布上绘制一条直线。 [更多...](#drawline) | -| ( [DrawCircle](#drawcircle) )([ISurface](_i_surface.md) \*surface, [ICircle](_i_circle.md) \*circle, [GfxOpt](_gfx_opt.md) \*opt) | 绘制圆形,使用一种颜色在画布上绘制指定圆心和半径的圆。 [更多...](#drawcircle) | -| ( [Blit](#blit) )([ISurface](_i_surface.md) \*srcSurface, [IRect](_i_rect.md) \*srcRect, [ISurface](_i_surface.md) \*dstSurface, [IRect](_i_rect.md) \*dstRect, [GfxOpt](_gfx_opt.md) \*opt) | 位图搬移 [更多...](#blit) | -| ( [Sync](#sync) )(int32_t timeOut) | 硬件加速同步。 [更多...](#sync) | - - -## **详细描述** - -显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 +| ([InitGfx](#initgfx))(void) | 初始化硬件加速。 | +| ([DeinitGfx](#deinitgfx))(void) | 去初始化硬件加速。 | +| ([FillRect](#fillrect))(ISurface \*surface, IRect \*rect, uint32_t color, GfxOpt \*opt) | 填充矩形,用一种颜色填充画布上指定矩形区域的矩形框。 | +| ([DrawRectangle](#drawrectangle))(ISurface \*surface, Rectangle \*rect, uint32_t color, GfxOpt \*opt) | 绘制矩形框,用一种颜色在画布上绘制指定区域的矩形框。 | +| ([DrawLine](#drawline))(ISurface \*surface, ILine \*line, GfxOpt \*opt) | 绘制直线,使用一种颜色在画布上绘制一条直线。 | +| ([DrawCircle](#drawcircle))(ISurface \*surface, ICircle \*circle, GfxOpt \*opt) | 绘制圆形,使用一种颜色在画布上绘制指定圆心和半径的圆。 | +| ([Blit](#blit))(ISurface \*srcSurface, IRect \*srcRect, ISurface \*dstSurface, IRect \*dstRect, GfxOpt \*opt) | 位图搬移 | +| ([Sync](#sync))(int32_t timeOut) | 硬件加速同步。 | ## **类成员变量说明** @@ -42,11 +39,11 @@ int32_t(* GfxFuncs::Blit) (ISurface *srcSurface, IRect *srcRect, ISurface *dstSu **描述:** -位图搬移 +位图搬移。 在位图搬移过程中,可以实现色彩空间转换、缩放、旋转等功能。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -56,7 +53,7 @@ int32_t(* GfxFuncs::Blit) (ISurface *srcSurface, IRect *srcRect, ISurface *dstSu | dstRect | 输出参数,目标位图区域。 | | opt | 输入参数,硬件加速选项。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -74,13 +71,13 @@ int32_t(* GfxFuncs::DeinitGfx) (void) 去初始化硬件加速。 -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [InitGfx](#initgfx) @@ -96,7 +93,7 @@ int32_t(* GfxFuncs::DrawCircle) (ISurface *surface, ICircle *circle, GfxOpt *opt 绘制圆形,使用一种颜色在画布上绘制指定圆心和半径的圆。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -104,7 +101,7 @@ int32_t(* GfxFuncs::DrawCircle) (ISurface *surface, ICircle *circle, GfxOpt *opt | circle | 输入参数,圆形结构。 | | opt | 输入参数,硬件加速选项。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -122,7 +119,7 @@ int32_t(* GfxFuncs::DrawLine) (ISurface *surface, ILine *line, GfxOpt *opt) 绘制直线,使用一种颜色在画布上绘制一条直线。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -130,7 +127,7 @@ int32_t(* GfxFuncs::DrawLine) (ISurface *surface, ILine *line, GfxOpt *opt) | line | 输入参数,直线结构。 | | opt | 输入参数,硬件加速选项。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -148,7 +145,7 @@ int32_t(* GfxFuncs::DrawRectangle) (ISurface *surface, Rectangle *rect, uint32_t 绘制矩形框,用一种颜色在画布上绘制指定区域的矩形框。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -157,7 +154,7 @@ int32_t(* GfxFuncs::DrawRectangle) (ISurface *surface, Rectangle *rect, uint32_t | color | 输入参数,绘制的颜色。 | | opt | 输入参数,硬件加速选项。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -175,7 +172,7 @@ int32_t(* GfxFuncs::FillRect) (ISurface *surface, IRect *rect, uint32_t color, G 填充矩形,用一种颜色填充画布上指定矩形区域的矩形框。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -184,7 +181,7 @@ int32_t(* GfxFuncs::FillRect) (ISurface *surface, IRect *rect, uint32_t color, G | color | 输入参数,填充的颜色。 | | opt | 输入参数,硬件加速选项。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -202,13 +199,13 @@ int32_t(* GfxFuncs::InitGfx) (void) 初始化硬件加速。 -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [DeinitGfx](#deinitgfx) @@ -226,13 +223,13 @@ int32_t(* GfxFuncs::Sync) (int32_t timeOut) 在使用硬件加速模块进行图像绘制、图像叠加、图像搬移时,通过调用该接口进行硬件同步,该接口会等待硬件加速完成。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | timeOut | 输入参数,硬件加速同步超时设置,设置为0表示无超时,等待直到硬件加速完成。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md b/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md index 00fdaa09fd517f09213a136e8ab126a907c73b02..a278028b82892474e27285b6f08fcfc9a72c3cd4 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md +++ b/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 + +**相关模块:** [Display](_display.md) @@ -13,11 +15,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [enGlobalAlpha](_display.md#englobalalpha-22) | 全局alpha使能标志 | -| [globalAlpha](_display.md#globalalpha) | 全局alpha的值 | -| [enPixelAlpha](_display.md#enpixelalpha-22) | 像素alpha使能标志 | +| [enGlobalAlpha](_display.md#englobalalpha-22) | 全局Alpha使能标志 | +| [globalAlpha](_display.md#globalalpha) | 全局Alpha的值 | +| [enPixelAlpha](_display.md#enpixelalpha-22) | 像素Alpha使能标志 | | [blendType](_display.md#blendtype) | 混合方式 | | [colorKeyFrom](_display.md#colorkeyfrom) | 色键模式 | | [enableRop](_display.md#enablerop) | Rop功能使能位 | @@ -26,8 +28,3 @@ | [enableScale](_display.md#enablescale) | 缩放功能使能位 | | [rotateType](_display.md#rotatetype) | 旋转类型 | | [mirrorType](_display.md#mirrortype) | 镜像类型 | - - -## **详细描述** - -图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md index d67c99a3dd81c1e4afa35a157c5b43538d65f4c1..db86f4424e237c419c2860fd1e64b4f50feeb2b1 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md +++ b/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 + +**相关模块:** [Display](_display.md) @@ -13,23 +15,18 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [AllocMem](#allocmem) )(const [AllocInfo](_alloc_info.md) \*info, BufferHandle \*\*handle) | 显示内存分配。 [更多...](#allocmem) | -| ( [FreeMem](#freemem) )(BufferHandle \*handle) | 显示内存释放。 [更多...](#freemem) | -| ( [Mmap](#mmap) )(BufferHandle \*handle) | 显示内存映射,将内存映射到对应的进程地址空间中。 [更多...](#mmap) | -| ( [MmapYUV](#mmapyuv) )(BufferHandle \*handle, YUVDescInfo \*info) | YUV 内存映射。 [更多...](#mmapyuv) | -| ( [MmapCache](#mmapcache) )(BufferHandle \*handle) | 显示内存映射,将内存映射为 cache 内存到对应的进程地址空间中。 [更多...](#mmapcache) | -| ( [Unmap](#unmap) )(BufferHandle \*handle) | 内存反映射,将内存进行反映射。 [更多...](#unmap) | -| ( [FlushCache](#flushcache) )(BufferHandle \*handle) | 刷新cache,刷新cache里的内容到内存并且使cache里的内容无效。 [更多...](#flushcache) | -| ( [FlushMCache](#flushmcache) )(BufferHandle \*handle) | 刷新Mmap映射的cache,刷新Mmap映射的cache里的内容到内存并且使cache里的内容无效。 [更多...](#flushmcache) | -| ( [InvalidateCache](#invalidatecache) )(BufferHandle \*handle) | 使cache中的内容无效用以存储更新内存内容。 [更多...](#invalidatecache) | -| ( [IsSupportedAlloc](#issupportedalloc) )(uint32_t num, const [VerifyAllocInfo](_verify_alloc_info.md) \*infos, bool \*supporteds) | 检测给定的VerifyAllocInfo数组信息能否申请内存成功。 [更多...](#issupportedalloc) | - - -## **详细描述** - -显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 +| ([AllocMem](#allocmem))(const AllocInfo \*info, BufferHandle \*\*handle) | 显示内存分配。 | +| ([FreeMem](#freemem))(BufferHandle \*handle) | 显示内存释放。 | +| ([Mmap](#mmap))(BufferHandle \*handle) | 显示内存映射,将内存映射到对应的进程地址空间中。 | +| ([MmapYUV](#mmapyuv))(BufferHandle \*handle, YUVDescInfo \*info) | YUV 内存映射。 | +| ([MmapCache](#mmapcache))(BufferHandle \*handle) | 显示内存映射,将内映射为cache内存到对应的进程地址空间中。 | +| ([Unmap](#unmap))(BufferHandle \*handle) | 内存反映射,将内存进行反映射。 | +| ([FlushCache](#flushcache))(BufferHandle \*handle) | 刷新cache,刷新cache里的内容到内存并且使cache里的内容无效。 | +| ([FlushMCache](#flushmcache))(BufferHandle \*handle) | 刷新Mmap映射的cache,刷新Mmap映射的cache里的内容到内存并且使cache里的内容无效。 | +| ([InvalidateCache](#invalidatecache))(BufferHandle \*handle) | 使cache中的内容无效用以存储更新内存内容。 | +| ([IsSupportedAlloc](#issupportedalloc))(uint32_t num, const VerifyAllocInfo \*infos, bool \*supporteds) | 检测给定的VerifyAllocInfo数组信息能否申请内存成功。 | ## **类成员变量说明** @@ -48,14 +45,14 @@ int32_t(* GrallocFuncs::AllocMem) (const AllocInfo *info, BufferHandle **handle) 根据GUI图形系统传递的参数分配内存,分配的内存根据类型可分为共享内存、cache内存和非cache内存等。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | info | 输入参数,指示申请内存AllocInfo信息. | | handle | 输入参数,指向申请的内存handle指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -73,13 +70,13 @@ int32_t(* GrallocFuncs::FlushCache) (BufferHandle *handle) 刷新cache,刷新cache里的内容到内存并且使cache里的内容无效。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,待刷新cache的handle指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -97,13 +94,13 @@ int32_t(* GrallocFuncs::FlushMCache) (BufferHandle *handle) 刷新Mmap映射的cache,刷新Mmap映射的cache里的内容到内存并且使cache里的内容无效。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,待刷新cache的handle指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -121,13 +118,13 @@ void(* GrallocFuncs::FreeMem) (BufferHandle *handle) 显示内存释放。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输入参数,待释放的内存handle指针。 | -**返回:** +**返回:** 成功返回有效地址,失败返回NULL。 @@ -143,13 +140,13 @@ int32_t(* GrallocFuncs::InvalidateCache) (BufferHandle *handle) 使cache中的内容无效用以存储更新内存内容。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,待无效cache的handle指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -167,15 +164,15 @@ int32_t(* GrallocFuncs::IsSupportedAlloc) (uint32_t num, const VerifyAllocInfo * 检测给定的VerifyAllocInfo数组信息能否申请内存成功。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| num | 输入参数,VerifyAllocInfo数组个数。 | -| infos | 输出参数,VerifyAllocInfo数组首地址。 | +| num | 输入参数,[VerifyAllocInfo](_verify_alloc_info.md)数组个数。 | +| infos | 输出参数,[VerifyAllocInfo](_verify_alloc_info.md)数组首地址。 | | supporteds | 输出参数,supporteds数组首地址, 表示能否申请成功。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -193,13 +190,13 @@ void*(* GrallocFuncs::Mmap) (BufferHandle *handle) 显示内存映射,将内存映射到对应的进程地址空间中。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输入参数,待映射内存handle指针。 | -**返回:** +**返回:** 成功返回有效地址,失败返回NULL。 @@ -215,13 +212,13 @@ void*(* GrallocFuncs::MmapCache) (BufferHandle *handle) 显示内存映射,将内存映射为 cache 内存到对应的进程地址空间中。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,待映射内存 handle 指针。 | -**返回:** +**返回:** 成功返回有效地址,失败返回 NULL。 @@ -237,14 +234,14 @@ void*(* GrallocFuncs::MmapYUV) (BufferHandle *handle, YUVDescInfo *info) YUV 内存映射。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,指示内存映射的输出缓存。 | -| info | 输出参数,指示内存映射的YUVDescInfo信息。 | +| info | 输出参数,指示内存映射的[YUVDescInfo](_yun_desc_info_.md)信息。 | -**返回:** +**返回:** 成功返回有效地址,失败返回 NULL。 @@ -260,13 +257,13 @@ int32_t(* GrallocFuncs::Unmap) (BufferHandle *handle) 内存反映射,将内存进行反映射。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | handle | 输出参数,待反映射内存handle指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md index 08d19bbbbfe355000de3b0421183a4a8f1eb73da..a82e3058421ea0160df98b4cfcadb2c127dbf3ea 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +HDR属性结构体定义。 + +**相关模块:** [Display](_display.md) @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [formatCount](_display.md#formatcount) | 支持的HDR格式的数量 | | [formats](_display.md#formats) | 支持的HDR格式的数组首地址 | | [maxLum](_display.md#maxlum) | 最大的光亮度luminance值 | | [maxAverageLum](_display.md#maxaveragelum) | 最大的平均光亮度luminance值 | | [minLum](_display.md#minlum) | 最小的光亮度luminance值 | - - -## **详细描述** - -HDR属性结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md index d20665318f9555957e07bac0617c2f65e6f5586f..44610a551845f6df58cf94c74cf994c9dcd40e27 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md +++ b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +HDR元数据结构体定义。 + +**相关模块:** [Display](_display.md) @@ -13,12 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [key](_display.md#key) | HDR元数据关键字。 | | [value](_display.md#value-22) | 关键字对应的值。 | - - -## **详细描述** - -HDR元数据结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md index 742e19ca1cb15f5562d8a22f65651c69e2250123..7ef609b97adf64a1cc7546e0e84012a6a6ce0f0b 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md @@ -1,12 +1,23 @@ # HdfFaceAuth +## **概述** + +提供人脸认证驱动的标准API接口。 + +人脸认证驱动为人脸认证服务提供统一的访问接口。获取人脸认证驱动代理后,人脸认证服务可以调用相关接口获取执行器,获取人脸认证执行器后, 人脸认证服务可以调用相关接口获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 + +**Since:** + +3.2 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [FaceAuthTypes.idl](_face_auth_types_8idl.md) | 定义人脸认证驱动的枚举类和数据结构。 | | [IExecutor.idl](face__auth_2_i_executor_8idl.md) | 定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 | @@ -16,44 +27,33 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [ExecutorInfo](_executor_info.md) | 执行器信息。 [更多...](_executor_info.md) | -| [TemplateInfo](_template_info.md) | 凭据模版信息。 [更多...](_template_info.md) | -| [IExecutor](interface_i_executor.md) | 定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 [更多...](interface_i_executor.md) | -| [IExecutorCallback](interface_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_i_executor.md)。 [更多...](interface_i_executor_callback.md) | -| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获取人脸认证驱动的执行器列表接口。 [更多...](interface_i_face_auth_interface.md) | +| [ExecutorInfo](_executor_info.md) | 执行器信息。 | +| [TemplateInfo](_template_info.md) | 凭据模版信息。 | +| [IExecutor](interface_i_executor.md) | 定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 | +| [IExecutorCallback](interface_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_i_executor.md)。 | +| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获取人脸认证驱动的执行器列表接口。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 [更多...](#authtype) | -| [ExecutorRole](#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | -| [ExecutorSecureLevel](#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](#executorsecurelevel) | -| [CommandId](#commandid) : int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认证功能相关操作命令。 [更多...](#commandid) | -| [FaceTipsCode](#facetipscode) : int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4,   FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8,   FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举提示信息编码。 [更多...](#facetipscode) | +| [AuthType](#authtype): int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](#executorrole): int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](#executorsecurelevel): int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [CommandId](#commandid): int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认证功能相关操作命令。 | +| [FaceTipsCode](#facetipscode): int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4,   FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8,   FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举提示信息编码。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.face_auth.v1_0 | 人脸认证接口的包路径 | -## **详细描述** - -提供人脸认证驱动的标准API接口。 - -人脸认证驱动为人脸认证服务提供统一的访问接口。获取人脸认证驱动代理后,人脸认证服务可以调用相关接口获取执行器,获取人脸认证执行器后, 人脸认证服务可以调用相关接口获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 - -**Since:** - -3.2 - - ## **枚举类型说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_feature_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_feature_info.md new file mode 100644 index 0000000000000000000000000000000000000000..a70f0222d87c4633abcb243913540b3fd9b6fb97 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_feature_info.md @@ -0,0 +1,48 @@ +# HdfFeatureInfo + + +## **概述** + +feature对象信息。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [ifName](#ifname) | feature对象的网卡名称。 | +| [type](#type) | feature对象的类型。 | + + +## **类成员变量说明** + + +### ifName + + +``` +String HdfFeatureInfo::ifName +``` + +**描述:** + +feature对象的网卡名称。 + + +### type + + +``` +int HdfFeatureInfo::type +``` + +**描述:** + +feature对象的类型。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_light_color.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_color.md new file mode 100644 index 0000000000000000000000000000000000000000..6dc7205e01de6bb66bf73bb9eebbf8c8737a0efc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_color.md @@ -0,0 +1,37 @@ +# HdfLightColor + + +## **概述** + +定义亮灯参数。 + +参数包括灯的模式设置。 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [colorValue](#colorvalue) | 设置灯的模式 | + + +## **类成员变量说明** + + +### colorValue + + +``` +union ColorValue HdfLightColor::colorValue +``` + +**描述:** + +设置灯的模式, 详见[ColorValue](union_color_value.md)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_light_effect.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_effect.md new file mode 100644 index 0000000000000000000000000000000000000000..341b2fb7f29860c5bd48a843f233b9b22516cf16 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_effect.md @@ -0,0 +1,50 @@ +# HdfLightEffect + + +## **概述** + +定义灯的效果参数。 + +参数包括设置灯的亮度、闪烁模式。 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [lightBrightness](#lightbrightness) | 亮度值。 | +| [flashEffect](#flasheffect) | 闪烁模式。 | + + +## **类成员变量说明** + + +### flashEffect + + +``` +struct HdfLightFlashEffect HdfLightEffect::flashEffect +``` + +**描述:** + +闪烁模式。详见**[HdfLightFlashEffect](_hdf_light_flash_effect.md)**。 + + +### lightBrightness + + +``` +int HdfLightEffect::lightBrightness +``` + +**描述:** + +亮度值:Bits 24–31为扩展位,Bits 16–23为红色,Bits 8–15为绿色,Bits 0–7为蓝色。 如果字节段等于0时,灯的亮度根据HCS配置的默认亮度进行设置。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_light_flash_effect.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_flash_effect.md new file mode 100644 index 0000000000000000000000000000000000000000..2d853ebaab83a9eed7c4fe87c32e706da4c0b38a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_flash_effect.md @@ -0,0 +1,63 @@ +# HdfLightFlashEffect + + +## **概述** + +定义灯的闪烁参数。 + +这些参数包括闪烁模式以及闪烁期间指示灯的打开和关闭时间。 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [flashMode](#flashmode) | 闪烁模式。 | +| [onTime](#ontime) | 表示在一个闪烁周期内灯持续点亮的时间,单位毫秒。 | +| [offTime](#offtime) | 表示在一个闪烁周期内灯持续熄灭的时间,单位毫秒。 | + + +## **类成员变量说明** + + +### flashMode + + +``` +int HdfLightFlashEffect::flashMode +``` + +**描述:** + +闪烁模式。详见[HdfLightFlashMode](light.md#hdflightflashmode)。 + + +### offTime + + +``` +int HdfLightFlashEffect::offTime +``` + +**描述:** + +表示在一个闪烁周期内灯持续熄灭的时间,单位毫秒。 + + +### onTime + + +``` +int HdfLightFlashEffect::onTime +``` + +**描述:** + +表示在一个闪烁周期内灯持续点亮的时间,单位毫秒。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_light_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_info.md new file mode 100644 index 0000000000000000000000000000000000000000..8674b13b2368719c859becac7cc845613fbfc560 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_light_info.md @@ -0,0 +1,76 @@ +# HdfLightInfo + + +## **概述** + +定义灯的基本信息。 + +参数包括灯类型ID、逻辑灯的名称、逻辑控制器中物理灯的数量和自定义扩展信息。 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [lightName](#lightname) | 逻辑灯的名称。 | +| [lightId](#lightid) | 灯类型ID。 | +| [lightNumber](#lightnumber) | 逻辑控制器中物理灯的数量。 | +| [reserved](#reserved) | 自定义扩展信息。 | + + +## **类成员变量说明** + + +### lightId + + +``` +int HdfLightInfo::lightId +``` + +**描述:** + +灯类型ID。详见[HdfLightId](light.md#hdflightid)。 + + +### lightName + + +``` +String HdfLightInfo::lightName +``` + +**描述:** + +逻辑灯的名称。 + + +### lightNumber + + +``` +int HdfLightInfo::lightNumber +``` + +**描述:** + +逻辑控制器中物理灯的数量。 + + +### reserved + + +``` +int HdfLightInfo::reserved +``` + +**描述:** + +自定义扩展信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_motion_event.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_motion_event.md new file mode 100644 index 0000000000000000000000000000000000000000..cdf6b6de73a224d141a63e61054f03cb318f0c1c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_motion_event.md @@ -0,0 +1,89 @@ +# HdfMotionEvent + + +## **概述** + +上报手势识别数据结构。 + +上报手势识别数据事件信息包括手势识别类型、手势识别结果、手势识别状态、手势识别数据长度、手势识别数据。 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [motion](#motion) | 手势识别类型。 | +| [result](#result) | 手势识别结果。 | +| [status](#status) | 手势识别状态。 | +| [datalen](#datalen) | 手势识别数据长度。 | +| [data](#data) | 手势识别数据。 | + + +## **类成员变量说明** + + +### data + + +``` +int [] HdfMotionEvent::data +``` + +**描述:** + +手势识别数据。 + + +### datalen + + +``` +int HdfMotionEvent::datalen +``` + +**描述:** + +手势识别数据长度。 + + +### motion + + +``` +int HdfMotionEvent::motion +``` + +**描述:** + +手势识别类型。 + + +### result + + +``` +int HdfMotionEvent::result +``` + +**描述:** + +手势识别结果。 + + +### status + + +``` +int HdfMotionEvent::status +``` + +**描述:** + +手势识别状态。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..c865bc30d915523c671a2979d1f10d2b1417c9b5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info.md @@ -0,0 +1,87 @@ +# HdfNetDeviceInfo + + +## **概述** + +网络设备信息。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [index](#index) | 网络设备索引。 | +| [ifName](#ifname) | 网卡名称。 | +| [ifNameLen](#ifnamelen) | 网卡名称长度。 | +| [iftype](#iftype) | 网卡类型。 | +| [mac](#mac) | 网络设备MAC地址。 | + + +## **类成员变量说明** + + +### ifName + + +``` +String HdfNetDeviceInfo::ifName +``` + +**描述:** + +网卡名称。 + + +### ifNameLen + + +``` +unsigned int HdfNetDeviceInfo::ifNameLen +``` + +**描述:** + +网卡名称长度。 + + +### iftype + + +``` +unsigned char HdfNetDeviceInfo::iftype +``` + +**描述:** + +网卡类型。 + + +### index + + +``` +unsigned int HdfNetDeviceInfo::index +``` + +**描述:** + +网络设备索引。 + + +### mac + + +``` +unsigned char [] HdfNetDeviceInfo::mac +``` + +**描述:** + +网络设备MAC地址。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info_result.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info_result.md new file mode 100644 index 0000000000000000000000000000000000000000..d48f209f60a14cc68c2e966173192a5018b49d5a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_net_device_info_result.md @@ -0,0 +1,35 @@ +# HdfNetDeviceInfoResult + + +## **概述** + +网络设备信息集合。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [deviceInfos](#deviceinfos) | 网络设备信息集合。 | + + +## **类成员变量说明** + + +### deviceInfos + + +``` +struct HdfNetDeviceInfo [] HdfNetDeviceInfoResult::deviceInfos +``` + +**描述:** + +网络设备信息集合。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md index 10de6c4064d9b27e522693a9d859d5a097d1e85f..b5a0a2ce3457fe5f5a1208b51d0cf9d3933efa5f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md @@ -1,12 +1,23 @@ # HdfPinAuth +## **概述** + +提供口令认证驱动的标准API接口。 + +口令认证驱动为口令认证服务提供统一的访问接口。获取口令认证驱动代理后,口令认证服务可以调用相关接口获取执行器,获取口令认证执行器后, 口令认证服务可以调用相关接口获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 + +**Since:** + +3.2 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [IExecutor.idl](pin__auth_2_i_executor_8idl.md) | 定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 | | [IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。 | @@ -16,43 +27,32 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IExecutor](interface_pin_i_executor.md) | 定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。[更多...](interface_pin_i_executor.md) | -| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 [更多...](interface_pin_i_executor_callback.md) | -| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获取口令认证驱动的执行器列表接口。 [更多...](interface_i_pin_auth_interface.md) | -| [ExecutorInfo](_executor_info.md) | 执行器信息。 [更多...](_executor_info.md) | -| [TemplateInfo](_template_info.md) | 凭据模版信息。 [更多...](_template_info.md) | +| [IExecutor](interface_pin_i_executor.md) | 定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 | +| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 | +| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获取口令认证驱动的执行器列表接口。 | +| [ExecutorInfo](_executor_info.md) | 执行器信息。 | +| [TemplateInfo](_template_info.md) | 凭据模版信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](#authtype) : int {   PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 [更多...](#authtype) | -| [ExecutorRole](#executorrole) : int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | -| [ExecutorSecureLevel](#executorsecurelevel) : int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](#executorsecurelevel) | -| [CommandId](#commandid) : int { DEFAULT = 0 } | 枚举口令认证相关功能操作命令。 [更多...](#commandid) | +| [AuthType](#authtype): int {   PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](#executorrole): int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](#executorsecurelevel): int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [CommandId](#commandid): int { DEFAULT = 0 } | 枚举口令认证相关功能操作命令。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.pin_auth.v1_0 | 口令认证接口的包路径 | -## **详细描述** - -提供口令认证驱动的标准API接口。 - -口令认证驱动为口令认证服务提供统一的访问接口。获取口令认证驱动代理后,口令认证服务可以调用相关接口获取执行器,获取口令认证执行器后, 口令认证服务可以调用相关接口获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 - -**Since:** - -3.2 - - ## **枚举类型说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_events.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_events.md new file mode 100644 index 0000000000000000000000000000000000000000..e736441a261b43df836741365219889894a43d75 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_events.md @@ -0,0 +1,115 @@ +# HdfSensorEvents + + +## **概述** + +定义传感器上报的数据。 + +上报的传感器数据包括传感器ID、传感器算法版本号、数据生成时间、传感器类型ID、 数据选项(如测量范围和精度)、数据上报模式、数据地址、数据长度。 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [sensorId](#sensorid) | 传感器ID。 | +| [version](#version) | 传感器算法版本号。 | +| [timestamp](#timestamp) | 传感器数据生成时间。 | +| [option](#option) | 传感器数据选项,包括测量范围和精度。 | +| [mode](#mode) | 传感器数据上报模式。 | +| [data](#data) | 传感器数据地址。 | +| [dataLen](#datalen) | 传感器数据长度。 | + + +## **类成员变量说明** + + +### data + + +``` +unsigned char [] HdfSensorEvents::data +``` + +**描述:** + +传感器数据地址。 + + +### dataLen + + +``` +unsigned int HdfSensorEvents::dataLen +``` + +**描述:** + +传感器数据长度。 + + +### mode + + +``` +int HdfSensorEvents::mode +``` + +**描述:** + +传感器数据上报模式。 + + +### option + + +``` +unsigned int HdfSensorEvents::option +``` + +**描述:** + +传感器数据选项,包括测量范围和精度。 + + +### sensorId + + +``` +int HdfSensorEvents::sensorId +``` + +**描述:** + +传感器ID。 + + +### timestamp + + +``` +long HdfSensorEvents::timestamp +``` + +**描述:** + +传感器数据生成时间。 + + +### version + + +``` +int HdfSensorEvents::version +``` + +**描述:** + +传感器算法版本号。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_information.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_information.md new file mode 100644 index 0000000000000000000000000000000000000000..ae9c37c451081576d74ad35cd807c07f9f82c80a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_sensor_information.md @@ -0,0 +1,141 @@ +# HdfSensorInformation + + +## **概述** + +定义传感器的基本信息。 + +传感器的信息包括传感器名称、供应商、固件版本、硬件版本、传感器类型ID、传感器ID、最大测量范围、精度和功率。 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [sensorName](#sensorname) | 传感器名称。 | +| [vendorName](#vendorname) | 传感器供应商。 | +| [firmwareVersion](#firmwareversion) | 传感器固件版本。 | +| [hardwareVersion](#hardwareversion) | 传感器硬件版本。 | +| [sensorTypeId](#sensortypeid) | 传感器类型ID。 | +| [sensorId](#sensorid) | 传感器ID,由传感器驱动程序开发人员定义。 | +| [maxRange](#maxrange) | 传感器的最大测量范围。 | +| [accuracy](#accuracy) | 传感器精度。 | +| [power](#power) | 传感器功率。 | + + +## **类成员变量说明** + + +### accuracy + + +``` +float HdfSensorInformation::accuracy +``` + +**描述:** + +传感器精度。 + + +### firmwareVersion + + +``` +String HdfSensorInformation::firmwareVersion +``` + +**描述:** + +传感器固件版本。 + + +### hardwareVersion + + +``` +String HdfSensorInformation::hardwareVersion +``` + +**描述:** + +传感器硬件版本。 + + +### maxRange + + +``` +float HdfSensorInformation::maxRange +``` + +**描述:** + +传感器的最大测量范围。 + + +### power + + +``` +float HdfSensorInformation::power +``` + +**描述:** + +传感器功率。 + + +### sensorId + + +``` +int HdfSensorInformation::sensorId +``` + +**描述:** + +传感器ID,由传感器驱动程序开发人员定义。 + + +### sensorName + + +``` +String HdfSensorInformation::sensorName +``` + +**描述:** + +传感器名称。 + + +### sensorTypeId + + +``` +int HdfSensorInformation::sensorTypeId +``` + +**描述:** + +传感器类型ID(在[HdfSensorTypeTag](sensor.md#hdfsensortypetag)中描述)**。** + + +### vendorName + + +``` +String HdfSensorInformation::vendorName +``` + +**描述:** + +传感器供应商。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_sta_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_sta_info.md new file mode 100644 index 0000000000000000000000000000000000000000..05d24dd843d57a33be7655c3d921bd681b4a36e9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_sta_info.md @@ -0,0 +1,35 @@ +# HdfStaInfo + + +## **概述** + +STA的信息。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [mac](#mac) | STA的MAC地址。 | + + +## **类成员变量说明** + + +### mac + + +``` +unsigned char [] HdfStaInfo::mac +``` + +**描述:** + +STA的MAC地址。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md index 5652e991ce997a3b1c53d18467dc185f278e806d..ba1f6fd2b244795392c49f9bd994bc27fb3298c2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +设备发热的信息列表。 + +**相关模块:** [Thermal](thermal.md) @@ -13,16 +15,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [info](#info) | 设备发热的信息列表。 | -## **详细描述** - -设备发热的信息列表。 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md index abdbc3ced7dfeafaf2c4892d213017fd87642005..2fbbca3bfa3acb1cfe8f629664d9347ab8386d2e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md @@ -1,12 +1,23 @@ # HdfUserAuth +## **概述** + +提供用户认证驱动的标准API接口。 + +用户认证驱动为用户认证服务提供统一的访问接口。获取用户认证驱动代理后,用户认证服务可以调用相关接口注册执行器,管理用户认证凭据, 完成PIN码和生物特征。 + +**Since:** + +3.2 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [IUserAuthInterface.idl](_i_user_auth_interface_8idl.md) | 声明用户认证驱动的API接口。接口可用于注册执行器,管理用户认证凭据,完成PIN码和生物特征认证。 | | [UserAuthTypes.idl](_user_auth_types_8idl.md) | 定义用户认证驱动的枚举类和数据结构。 | @@ -14,49 +25,39 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认证驱动的API接口。 [更多...](interface_i_user_auth_interface.md) | -| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信息。 [更多...](_executor_register_info.md) | -| [ExecutorInfo](_user_executor_info.md) | 执行器信息。 [更多...](_user_executor_info.md) | -| [ScheduleInfo](_schedule_info.md) | 调度信息。 [更多...](_schedule_info.md) | -| [AuthSolution](_auth_solution.md) | 认证方案。 [更多...](_auth_solution.md) | -| [ExecutorSendMsg](_executor_send_msg.md) | 执行器发送的消息。 [更多...](_executor_send_msg.md) | -| [AuthResultInfo](_auth_result_info.md) | 用户身份认证结果信息。 [更多...](_auth_result_info.md) | -| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信息。 [更多...](_identify_result_info.md) | -| [EnrollParam](_enroll_param.md) | 注册认证凭据参数。 [更多...](_enroll_param.md) | -| [CredentialInfo](_credential_info.md) | 认证凭据信息。 [更多...](_credential_info.md) | -| [EnrolledInfo](_enrolled_info.md) | 注册信息。 [更多...](_enrolled_info.md) | +| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认证驱动的API接口。 | +| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信息。 | +| [ExecutorInfo](_user_executor_info.md) | 执行器信息。 | +| [ScheduleInfo](_schedule_info.md) | 调度信息。 | +| [AuthSolution](_auth_solution.md) | 认证方案。 | +| [ExecutorSendMsg](_executor_send_msg.md) | 执行器发送的消息。 | +| [AuthResultInfo](_auth_result_info.md) | 用户身份认证结果信息。 | +| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信息。 | +| [EnrollParam](_enroll_param.md) | 注册认证凭据参数。 | +| [CredentialInfo](_credential_info.md) | 认证凭据信息。 | +| [EnrolledInfo](_enrolled_info.md) | 注册信息。 | +| [EnrollResultInfo](_enroll_resultinfo.md) | 录入结果信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](#authtype) : int {   PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认证凭据类型。 [更多...](#authtype) | -| [ExecutorRole](#executorrole) : int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | -| [ExecutorSecureLevel](#executorsecurelevel) : int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](#executorsecurelevel) | -| [PinSubType](#pinsubtype) : int {   PIN\_SIX = 10000, PIN\_NUMBER = 10001, PIN\_MIX = 10002 } | 口令认证子类型。 [更多...](#pinsubtype) | +| [AuthType](#authtype): int { PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](#executorrole): int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](#executorsecurelevel): int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [PinSubType](#pinsubtype) : int { PIN_SIX = 10000, PIN_NUMBER = 10001, PIN_MIX = 10002 } | 口令认证子类型。 | -### 变量 +### 关键字 - | 变量 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.user_auth.v1_0 | 用户认证接口的包路径 | -## **详细描述** - -提供用户认证驱动的标准API接口。 - -用户认证驱动为用户认证服务提供统一的访问接口。获取用户认证驱动代理后,用户认证服务可以调用相关接口注册执行器,管理用户认证凭据, 完成PIN码和生物特征。 - -**Since:** - -3.2 - - ## **枚举类型说明** @@ -130,5 +131,5 @@ enum PinSubType : int | 枚举值 | 描述 | | -------- | -------- | | PIN_SIX | 六位口令密码。 | -| PIN_NUMBER| 数字口令密码。 | +| PIN_NUMBER | 数字口令密码。 | | PIN_MIX | 混合密码。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_vibrator_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_vibrator_info.md new file mode 100644 index 0000000000000000000000000000000000000000..f176936bc9025a917b58ec1c130041f4ad96026a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_vibrator_info.md @@ -0,0 +1,102 @@ +# HdfVibratorInfo + + +## **概述** + +定义马达参数。 + +参数包括设置马达振幅和频率以及振幅和频率的范围。 + +**相关模块:** + +[Vibrator](vibrator.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [isSupportIntensity](#issupportintensity) | 设置马达振幅。1表示支持,0表示不支持。 | +| [isSupportFrequency](#issupportfrequency) | 设置马达频率。1表示支持,0表示不支持。 | +| [intensityMaxValue](#intensitymaxvalue) | 最大振幅。 | +| [intensityMinValue](#intensityminvalue) | 最小振幅。 | +| [frequencyMaxValue](#frequencymaxvalue) | 最大频率。 | +| [frequencyMinValue](#frequencyminvalue) | 最小频率。 | + + +## **类成员变量说明** + + +### frequencyMaxValue + + +``` +int HdfVibratorInfo::frequencyMaxValue +``` + +**描述:** + +最大频率。 + + +### frequencyMinValue + + +``` +int HdfVibratorInfo::frequencyMinValue +``` + +**描述:** + +最小频率。 + + +### intensityMaxValue + + +``` +int HdfVibratorInfo::intensityMaxValue +``` + +**描述:** + +最大振幅。 + + +### intensityMinValue + + +``` +int HdfVibratorInfo::intensityMinValue +``` + +**描述:** + +最小振幅。 + + +### isSupportFrequency + + +``` +int HdfVibratorInfo::isSupportFrequency +``` + +**描述:** + +设置马达频率。1表示支持,0表示不支持。 + + +### isSupportIntensity + + +``` +int HdfVibratorInfo::isSupportIntensity +``` + +**描述:** + +设置马达振幅。1表示支持,0表示不支持。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_driver_scan_ssid.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_driver_scan_ssid.md new file mode 100644 index 0000000000000000000000000000000000000000..7fb2e4b79eb9895f1dcba5b2ee8be56b94294721 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_driver_scan_ssid.md @@ -0,0 +1,48 @@ +# HdfWifiDriverScanSsid + + +## **概述** + +WiFi扫描参数SSID信息。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [ssid](#ssid) | WiFi扫描的SSID。 | +| [ssidLen](#ssidlen) | WiFi扫描的SSID长度。 | + + +## **类成员变量说明** + + +### ssid + + +``` +String HdfWifiDriverScanSsid::ssid +``` + +**描述:** + +WiFi扫描的SSID。 + + +### ssidLen + + +``` +int HdfWifiDriverScanSsid::ssidLen +``` + +**描述:** + +WiFi扫描的SSID长度。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_info.md new file mode 100644 index 0000000000000000000000000000000000000000..9adcd49e7bfdfaded903d9535971b586d944b3ca --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_info.md @@ -0,0 +1,48 @@ +# HdfWifiInfo + + +## **概述** + +WiFi频段信息。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [band](#band) | WiFi频段。 | +| [size](#size) | WiFi频段下支持的频率个数。 | + + +## **类成员变量说明** + + +### band + + +``` +int HdfWifiInfo::band +``` + +**描述:** + +WiFi频段。 + + +### size + + +``` +unsigned int HdfWifiInfo::size +``` + +**描述:** + +WiFi频段下支持的频率个数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan.md new file mode 100644 index 0000000000000000000000000000000000000000..8f86e02e5da124f5a357b345a7705d5ba83222d1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan.md @@ -0,0 +1,100 @@ +# HdfWifiScan + + +## **概述** + +WiFi扫描参数。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [ssids](#ssids) | WiFi扫描的SSID集合。 | +| [freqs](#freqs) | WiFi扫描的频率集合。 | +| [extraIes](#extraies) | WiFi扫描请求中携带的扩展IE。 | +| [bssid](#bssid) | WiFi扫描的BSSID。 | +| [prefixSsidScanFlag](#prefixssidscanflag) | SSID扫描的前缀标志。 | +| [fastConnectFlag](#fastconnectflag) | 快速连接标志。 | + + +## **类成员变量说明** + + +### bssid + + +``` +unsigned char [] HdfWifiScan::bssid +``` + +**描述:** + +WiFi扫描的BSSID。 + + +### extraIes + + +``` +unsigned char [] HdfWifiScan::extraIes +``` + +**描述:** + +WiFi扫描请求中携带的扩展IE。 + + +### fastConnectFlag + + +``` +unsigned char HdfWifiScan::fastConnectFlag +``` + +**描述:** + +快速连接标志。 + + +### freqs + + +``` +int [] HdfWifiScan::freqs +``` + +**描述:** + +WiFi扫描的频率集合。 + + +### prefixSsidScanFlag + + +``` +unsigned char HdfWifiScan::prefixSsidScanFlag +``` + +**描述:** + +SSID扫描的前缀标志。 + + +### ssids + + +``` +struct HdfWifiDriverScanSsid [] HdfWifiScan::ssids +``` + +**描述:** + +WiFi扫描的SSID集合。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan_result.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan_result.md new file mode 100644 index 0000000000000000000000000000000000000000..3c752f70abebab38485fe2885322b0644b05fad3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_wifi_scan_result.md @@ -0,0 +1,165 @@ +# HdfWifiScanResult + + +## **概述** + +WiFi扫描结果。 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [flags](#flags) | BSS/IBSS的标志位。 | +| [bssid](#bssid) | BSSID信息。 | +| [caps](#caps) | Capability信息字段(主机字节序排列)。 | +| [freq](#freq) | 信道频率。 | +| [beaconInt](#beaconint) | Beacon帧间隔。 | +| [qual](#qual) | 信号质量。 | +| [level](#level) | 信号强度。 | +| [age](#age) | 收到最新的Beacon或者探测响应帧数据的时间长度,单位为毫秒。 | +| [variable](#variable) | 扫描结果中的变量值。 | +| [ie](#ie) | 紧跟的Probe Response中IE字段。 | +| [beaconIe](#beaconie) | 紧跟的Beacon中IE字段。 | + + +## **类成员变量说明** + + +### age + + +``` +unsigned int HdfWifiScanResult::age +``` + +**描述:** + +收到最新的Beacon或者探测响应帧数据的时间长度,单位为毫秒。 + + +### beaconIe + + +``` +unsigned char [] HdfWifiScanResult::beaconIe +``` + +**描述:** + +紧跟的Beacon中IE字段。 + + +### beaconInt + + +``` +short HdfWifiScanResult::beaconInt +``` + +**描述:** + +Beacon帧间隔。 + + +### bssid + + +``` +unsigned char [] HdfWifiScanResult::bssid +``` + +**描述:** + +BSSID信息。 + + +### caps + + +``` +short HdfWifiScanResult::caps +``` + +**描述:** + +Capability信息字段(主机字节序排列)。 + + +### flags + + +``` +int HdfWifiScanResult::flags +``` + +**描述:** + +BSS/IBSS的标志位。 + + +### freq + + +``` +int HdfWifiScanResult::freq +``` + +**描述:** + +信道频率。 + + +### ie + + +``` +unsigned char [] HdfWifiScanResult::ie +``` + +**描述:** + +紧跟的Probe Response中IE字段。 + + +### level + + +``` +int HdfWifiScanResult::level +``` + +**描述:** + +信号强度。 + + +### qual + + +``` +int HdfWifiScanResult::qual +``` + +**描述:** + +信号质量。 + + +### variable + + +``` +unsigned char [] HdfWifiScanResult::variable +``` + +**描述:** + +扫描结果中的变量值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_activity_changed_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_activity_changed_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..512c1de4667f228022002ae3532680b03b471cb2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_activity_changed_callback_8idl.md @@ -0,0 +1,37 @@ +# IActivityChangedCallback.idl + + +## **概述** + +定义行为识别数据上报回调函数接口。 + +在行为识别用户订阅行为识别数据时需要注册这个回调函数接口的实例。 + +**Since**: + +3.2 + +**Version**: + +1.0 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IActivityChangedCallback](interface_i_activity_changed_callback.md) | 定义上报行为事件的回调函数 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.activity_recognition.v1_0 | 行为识别模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_activity_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_activity_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..1115b0560274f44133152ce9dacc3ca6910f019b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_activity_interface_8idl.md @@ -0,0 +1,35 @@ +# IActivityInterface.idl + + +## **概述** + +声明行为识别模块提供的API,用于获取设备支持的行为类型,订阅或取消订阅不同的行为事件,获取当前的行为事件,以及获取设备缓存的行为事件。 + +**Since**: + +3.2 + +**Version**: + +1.0 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IActivityInterface](interface_i_activity_interface.md) | 定义对行为识别进行基本操作的接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.activity_recognition.v1_0 | 行为识别模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md index 96897505990ce8d3b82c7a6d27b6f0f21cfb6cb5..7b87b968efd6452fef859f9392e44af4e1ff2797 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md @@ -3,38 +3,35 @@ ## **概述** -**所属模块:** - -[Battery](battery.md) - +电池信息的回调。 -## **汇总** +电池模块为电池服务提供的订阅电池信息变化的回调。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [IBatteryCallback](interface_i_battery_callback.md) | 电池信息的回调。 [更多...](interface_i_battery_callback.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.battery.v1_0 | 电池信息接口的包路径 | +[Battery](battery.md) -## **详细描述** +## **汇总** -电池信息的回调。 -电池模块为电池服务提供的订阅电池信息变化的回调。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [IBatteryCallback](interface_i_battery_callback.md) | 电池信息的回调。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | 电池模块接口的包路径 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md index 7a4a80ad0cd4c4d46a7afd72724c1fc404b56903..662cabfcd0b933eb19f6919c278e149ffd712b34 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md @@ -3,34 +3,35 @@ ## **概述** -**所属模块:** +获取、订阅电池信息的接口。 -[Battery](battery.md) +服务获取此模块的对象或代理后,可以调用相关的接口获取、订阅电池信息。 +**Since:** -## **汇总** +3.1 +**Version:** -### 类 +1.0 - | 类 | 描述 | -| -------- | -------- | -| [IBatteryInterface](interface_i_battery_interface.md) | 获取、订阅电池信息的接口。 [更多...](interface_i_battery_interface.md) | +**相关模块:** +[Battery](battery.md) -### 变量 - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.battery.v1_0 | 电池信息接口的包路径 | +## **汇总** -## **详细描述** +### 类 -获取、订阅电池信息的接口。 + | 名称 | 描述 | +| -------- | -------- | +| [IBatteryInterface](interface_i_battery_interface.md) | 获取、订阅电池信息的接口。 | -服务获取此对象后,可以调用相关的接口获取、订阅电池信息。 -**Since:** +### 关键字 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | 电池模块接口的包路径 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..0c641e4aeb1d2785a18aeaa78ab38c30e4c49b54 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_8idl.md @@ -0,0 +1,35 @@ +# ICameraDevice.idl + + +## **概述** + +Camera设备操作接口。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraDevice](interface_i_camera_device.md) | 定义Camera设备基本的操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..944d0a957e8a806e67b2eb1a7c3bd7dc10d40a91 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_camera_device_callback_8idl.md @@ -0,0 +1,35 @@ +# ICameraDeviceCallback.idl + + +## **概述** + +Camera设备的回调接口,主要包含Camera设备发生错误时和上报metadata的回调函数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraDeviceCallback](interface_i_camera_device_callback.md) | 定义Camera设备回调操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..8a2434a865bed0af4cd3ab98ca7cbc91ee15b333 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_8idl.md @@ -0,0 +1,35 @@ +# ICameraHost.idl + + +## **概述** + +Camera服务的管理类,对上层提供HDI接口。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraHost](interface_i_camera_host.md) | 定义Camera设备功能操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..c77ad0f79b94cd58cf9c658b89bbb1b8a9343616 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_camera_host_callback_8idl.md @@ -0,0 +1,35 @@ +# ICameraHostCallback.idl + + +## **概述** + +ICameraHost的回调接口,提供Camera设备和闪关灯状态变化的回调函数,回调函数由调用者实现。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraHostCallback](interface_i_camera_host_callback.md) | 定义Camera设备功能回调操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_circle.md b/zh-cn/device-dev/reference/hdi-apis/_i_circle.md index 1bc7edaa14025dad5c55d757af5ac06dbeb04bc4..2293ef4912ae0d72e8cf9aa7ecea55cf098cde01 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_circle.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_circle.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +圆形描述结构体定义,用于硬件加速绘制圆形。 + +**相关模块:** [Display](_display.md) @@ -13,14 +15,9 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [x](_display.md#x-22) | 矩形框起始X坐标。 | -| [y](_display.md#y-22) | 矩形框起始Y坐标。 | +| [x](_display.md#x-24) | 矩形框起始X坐标。 | +| [y](_display.md#y-24) | 矩形框起始Y坐标。 | | [r](_display.md#r) | 圆的半径。 | -| [color](_display.md#color-23) | 圆的颜色。 | - - -## **详细描述** - -圆形描述结构体定义,用于硬件加速绘制圆形。 +| [color](_display.md#color-25) | 圆的颜色。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md index 3776682000f467549f40f0f7bfb4d606a56ccb9c..9a2f845c20dafdb59bbdc5f7bba0550e9691c864 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义获取人脸认证驱动的执行器列表接口,用于从人脸认证驱动获取执行器对象列表。 + +**Since:** + +3.2 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获取人脸认证驱动的执行器列表接口。 [更多...](interface_i_face_auth_interface.md) | +| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获取人脸认证驱动的执行器列表接口。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.face_auth.v1_0 | 人脸认证接口的包路径 | - - -## **详细描述** - -定义获取人脸认证驱动的执行器列表接口,用于从人脸认证驱动获取执行器对象列表。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md b/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md index cf3f527b4fe26462524e33a0bc2e87b7a294d5e4..8c20b1df852f9663f11f9810664778f527c65541 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义用于提供Input设备驱动程序功能的接口。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,16 +15,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [iInputManager](#iinputmanager) | Input设备的设备管理接口。 | -| [iInputController](#iinputcontroller) | Input设备的业务控制接口。 | -| [iInputReporter](#iinputreporter) | Input设备的数据上报接口。 | - - -## **详细描述** - -定义用于提供Input设备驱动程序功能的接口。 +| [iInputManager](#iinputmanager) | Input设备的设备管理接口 | +| [iInputController](#iinputcontroller) | Input设备的业务控制接口 | +| [iInputReporter](#iinputreporter) | Input设备的数据上报接口 | ## **类成员变量说明** @@ -37,7 +34,7 @@ InputController* IInputInterface::iInputController **描述:** -Input设备的业务控制接口。 +Input设备的业务控制接口 ### iInputManager @@ -49,7 +46,7 @@ InputManager* IInputInterface::iInputManager **描述:** -Input设备的设备管理接口。 +Input设备的设备管理接口 ### iInputReporter @@ -61,4 +58,4 @@ InputReporter* IInputInterface::iInputReporter **描述:** -Input设备的数据上报接口。 +Input设备的数据上报接口 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_light_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_light_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..aca373cfa7d9f8ce752380cdec2ec7e0466188ee --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_light_interface_8idl.md @@ -0,0 +1,35 @@ +# ILightInterface.idl + + +## **概述** + +定义灯模块的通用接口能力,包括获取灯类型ID、打开或关闭灯光、设置灯的亮度和闪烁模式。 + +**Since:** + +3.1 + +**Version:** + +1.0 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ILightInterface](interface_i_light_interface.md) | 提供灯模块基本操作接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.light.v1_0 | 灯模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_line.md b/zh-cn/device-dev/reference/hdi-apis/_i_line.md index ee33cb7f530956d58f511b68858c0770d7530ce6..5862171b3cf32ca39b0a60adf34cf1f13729464d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_line.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_line.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +线条描述结构体定义,用于硬件加速绘制直线。 + +**相关模块:** [Display](_display.md) @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [x0](_display.md#x0) | 线条起点的X坐标。 | -| [y0](_display.md#y0) | 线条起点的Y坐标。 | -| [x1](_display.md#x1) | 线条终点的X坐标。 | -| [y1](_display.md#y1) | 线条终点的Y坐标。 | -| [color](_display.md#color-13) | 线条颜色。 | - - -## **详细描述** - -线条描述结构体定义,用于硬件加速绘制直线。 +| [x0](_display.md#x0-12) | 线条起点的X坐标。 | +| [y0](_display.md#y0-12) | 线条起点的Y坐标。 | +| [x1](_display.md#x1-13) | 线条终点的X坐标。 | +| [y1](_display.md#y1-13) | 线条终点的Y坐标。 | +| [color](_display.md#color-15) | 线条颜色。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_motion_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_motion_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..08483942ca8df59eb0513ecef2444a4cab4337d0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_motion_callback_8idl.md @@ -0,0 +1,37 @@ +# IMotionCallback.idl + + +## **概述** + +定义上报手势识别数据回调函数接口。 + +在手势识别用户订阅手势识别数据时需要注册这个回调函数接口的实例。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IMotionCallback](interface_i_motion_callback.md) | 定义上报手势识别数据回调函数。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.motion.v1_0 | 手势识别模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_motion_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_motion_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..92fd912be4c749fd3e0af1668131c13ccc2c8729 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_motion_interface_8idl.md @@ -0,0 +1,37 @@ +# IMotionInterface.idl + + +## **概述** + +定义使能/去使能手势识别、订阅/取消订阅手势识别数据的接口。 + +在实现拿起、翻转、摇一摇、旋转屏等手势识别功能时,需要调用此处定义的接口。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IMotionInterface](interface_i_motion_interface.md) | 提供Motion设备基本控制操作接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.motion.v1_0 | 手势识别模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_offline_stream_operator_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_offline_stream_operator_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..4328c264226967bd3e8853dd2b5f9e084dea7b55 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_offline_stream_operator_8idl.md @@ -0,0 +1,35 @@ +# IOfflineStreamOperator.idl + + +## **概述** + +离线流的操作接口。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IOfflineStreamOperator](interface_i_offline_stream_operator.md) | 定义Camera设备离线流操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md index 75007400f13eb9b00a91b8954caf233be2906ad9..4a1362ac9401a1f682c0f0ef0e61fb6cac9ecfe2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义获取口令认证驱动的执行器列表接口,用于从口令认证驱动获取执行器对象列表。 + +**Since:** + +3.2 + **所属模块:** [HdfPinAuth](_hdf_pin_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获取口令认证驱动的执行器列表接口。 [更多...](interface_i_pin_auth_interface.md) | +| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获取口令认证驱动的执行器列表接口。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.pin_auth.v1_0 | 口令认证接口的包路径 | - - -## **详细描述** - -定义获取口令认证驱动的执行器列表接口,用于从口令认证驱动获取执行器对象列表。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md index 58b85115424fd410feff222b777c099e50a88746..3336fcba06cf6ec28189e14c35300c7d6b3eedd2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md @@ -3,38 +3,35 @@ ## **概述** -**所属模块:** - -[Power](power.md) - +休眠/唤醒状态的回调。 -## **汇总** +电源模块为电源服务提供的订阅休眠/唤醒状态的回调。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | 休眠/唤醒状态的回调。 [更多...](interface_i_power_hdi_callback.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.power.v1_0 | 电源接口的包路径 | +[Power](power.md) -## **详细描述** +## **汇总** -休眠/唤醒状态的回调。 -电源模块为电源服务提供的订阅休眠/唤醒状态的回调。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | 休眠/唤醒状态的回调。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电源模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md index b6899c701f1f7919e937b3f9e7e86e7693e13fe2..dc9da2e90b44e572eece17d102853495bb91e7a2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md @@ -3,38 +3,35 @@ ## **概述** -**所属模块:** - -[Power](power.md) - +休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 -## **汇总** +电源模块为电源服务提供休眠/唤醒操作、订阅休眠/唤醒状态和运行锁管理的接口。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [IPowerInterface](interface_i_power_interface.md) | 休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 [更多...](interface_i_power_interface.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.power.v1_0 | 电源接口的包路径 | +[Power](power.md) -## **详细描述** +## **汇总** -休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 -电源模块为电源服务提供休眠/唤醒操作、订阅休眠/唤醒状态和运行锁管理的接口。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [IPowerInterface](interface_i_power_interface.md) | 休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电源模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_rect.md b/zh-cn/device-dev/reference/hdi-apis/_i_rect.md index f2b8f481e4ebb1800008d7ccf84bf9da98e0ef96..f9085f24e11c14e4ef55d9b4c02f27e8bd7e4b97 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_rect.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_rect.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义矩形信息。 + +**相关模块:** [Display](_display.md) @@ -13,14 +15,9 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [x](_display.md#x-12) | 矩形框起始X坐标。 | -| [y](_display.md#y-12) | 矩形框起始Y坐标。 | -| [w](_display.md#w) | 矩形框宽度。 | -| [h](_display.md#h) | 矩形框高度。 | - - -## **详细描述** - -定义矩形信息。 +| [x](_display.md#x-14) | 矩形框起始X坐标。 | +| [y](_display.md#y-14) | 矩形框起始Y坐标。 | +| [w](_display.md#w-12) | 矩形框宽度。 | +| [h](_display.md#h-12) | 矩形框高度。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_sensor_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_sensor_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..90176ba6c0d139069118cc31184af63e7d5c8158 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_sensor_callback_8idl.md @@ -0,0 +1,35 @@ +# ISensorCallback.idl + + +## **概述** + +Sensor模块为Sensor服务提供数据上报的回调函数。 + +**Since:** + +2.2 + +**Version:** + +1.0 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ISensorCallback](interface_i_sensor_callback.md) | 定义用于上报传感器数据的回调函数。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.sensor.v1_0 | Sensor模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_sensor_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_sensor_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..9b93aadd9a598ef7f112ba15e6d775a9b074ced5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_sensor_interface_8idl.md @@ -0,0 +1,35 @@ +# ISensorInterface.idl + + +## **概述** + +Sensor模块对外通用的接口声明文件,提供获取传感器设备信息、订阅/取消订阅传感器数据、 使能/去使能传感器、设置传感器模式、设置传感器精度,量程等可选配置接口定义。 + +**Since:** + +2.2 + +**Version:** + +1.0 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ISensorInterface](interface_i_sensor_interface.md) | 提供Sensor设备基本控制操作接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.sensor.v1_0 | Sensor模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..1ee2bebbcae25ee741c7f52362cfc1cd8a3e3a57 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_8idl.md @@ -0,0 +1,36 @@ +# IStreamOperator.idl + + +## **概述** + +流的操作接口。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IStreamOperator](interface_i_stream_operator.md) | 定义Camera设备流操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | +| sequenceable ohos.hdi.camera.v1_0.BufferProducerSequenceable | ohos.hdi.camera.v1_0序列,可用缓冲区生成器。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..f349924e485b58083362b1641a013ba2252ede13 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_stream_operator_callback_8idl.md @@ -0,0 +1,35 @@ +# IStreamOperatorCallback.idl + + +## **概述** + +[IStreamOperator](interface_i_stream_operator.md)相关的回调,这些回调均由调用者实现。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IStreamOperatorCallback](interface_i_stream_operator_callback.md) | 定义Camera设备流回调操作。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_surface.md b/zh-cn/device-dev/reference/hdi-apis/_i_surface.md index 26873d781962dcbe7d81d890889fdf29afa8a396..8006305430c09c9e3f97b5731cf0b882e3ee9f4c 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_surface.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_surface.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 + +**相关模块:** [Display](_display.md) @@ -13,23 +15,18 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [phyAddr](_display.md#phyaddr-22) | 图像首地址 | -| [height](_display.md#height-47) | 图像高度 | -| [width](_display.md#width-47) | 图像宽度 | -| [stride](_display.md#stride) | 图像跨度 | +| [phyAddr](_display.md#phyaddr-23) | 图像首地址 | +| [height](_display.md#height-48) | 图像高度 | +| [width](_display.md#width-49) | 图像宽度 | +| [stride](_display.md#stride-12) | 图像跨度 | | [enColorFmt](_display.md#encolorfmt) | 图像格式 | -| [bYCbCrClut](_display.md#bycbcrclut) | CLUT表是否位于YCbCr空间 | +| [bYCbCrClut](_display.md#bycbcrclut) | CLUT表是否位于 YCbCr 空间 | | [bAlphaMax255](_display.md#balphamax255) | 图像Alpha最大值为255还是128 | | [bAlphaExt1555](_display.md#balphaext1555) | 是否使能1555的Alpha扩展 | | [alpha0](_display.md#alpha0-22) | Alpha0值,取值范围:[0,255] | | [alpha1](_display.md#alpha1-22) | Alpha1值,取值范围:[0,255] | -| [cbcrPhyAddr](_display.md#cbcrphyaddr) | CbCr分量地址 | +| [clutPhyAddr](_display.md#clutphyaddr) | CbCr分量地址 | | [cbcrStride](_display.md#cbcrstride) | CbCr分量跨度 | -| [clutPhyAddr](_display.md#clutphyaddr) | CLUT表首地址,用作颜色扩展或颜色校正。| - - -## **详细描述** - -用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 +| [clutPhyAddr](_display.md#clutphyaddr) | CLUT表首地址,用作颜色扩展或颜色校正 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md index 5a4758d6b98696af3f30cdea9973526aa0dc68e4..67ec77493039b8de2a3a97be1063c2945c4c968a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md @@ -3,38 +3,35 @@ ## **概述** -**所属模块:** - -[Thermal](thermal.md) - +设备发热状态的回调。 -## **汇总** +热模块为热服务提供的设备发热状态的回调。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备发热状态的回调。 [更多...](interface_i_thermal_callback.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.thermal.v1_0 | 设备温度管理接口的包路径 | +[Thermal](thermal.md) -## **详细描述** +## **汇总** -设备发热状态的回调。 -热模块为热服务提供的设备发热状态的回调。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备发热状态的回调。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | Thermal模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md index 06a92364867540b188c6d3cec54e94ff968d74ca..94f01ad5540cbeb24513fed7cab2573ee21ac077 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md @@ -3,38 +3,35 @@ ## **概述** -**所属模块:** - -[Thermal](thermal.md) - +设备温度管理、控制及订阅接口。 -## **汇总** +热模块为热服务提供的设备温度管理、控制及订阅接口。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管理、控制及订阅接口。 [更多...](interface_i_thermal_interface.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.thermal.v1_0 | 设备温度管理接口的包路径 | +[Thermal](thermal.md) -## **详细描述** +## **汇总** -设备温度管理、控制及订阅接口。 -热模块为热服务提供的设备温度管理、控制及订阅接口。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管理、控制及订阅接口。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | Thermal模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_usb_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_usb_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b7dad51734962b8a92cdac7544341552bb0c51c6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_usb_interface_8idl.md @@ -0,0 +1,35 @@ +# IUsbInterface.idl + + +## **概述** + +声明标准的USB驱动接口函数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IUsbInterface](interface_i_usb_interface.md) | 定义USB驱动基本的操作功能。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.usb.v1_0 | USB驱动接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_usbd_bulk_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_usbd_bulk_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..0c86dd008f370412921b5187ee2498c4c62b529a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_usbd_bulk_callback_8idl.md @@ -0,0 +1,35 @@ +# IUsbdBulkCallback.idl + + +## **概述** + +USB驱动批量传输读/写数据的回调。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IUsbdBulkCallback](interface_i_usbd_bulk_callback.md) | USB驱动的回调函数。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.usb.v1_0 | USB驱动接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_usbd_subscriber_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_usbd_subscriber_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..6a7bdfc81009ef635e3bf85ea770726963a073fc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_usbd_subscriber_8idl.md @@ -0,0 +1,35 @@ +# IUsbdSubscriber.idl + + +## **概述** + +USB驱动的订阅函数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IUsbdSubscriber](interface_i_usbd_subscriber.md) | 定义USB驱动的订阅类相关函数。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.usb.v1_0 | USB驱动接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md index 7f3c5bd0151a021922e2030f7c66bd5bd19aa98f..65a42d5ab47817d5f689becba8a863a3595d9667 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md @@ -3,6 +3,12 @@ ## **概述** +声明用户认证驱动的API接口。接口可用于注册执行器,管理用户认证凭据,完成PIN码和生物特征认证。 + +**Since:** + +3.2 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认证驱动的API接口。 [更多...](interface_i_user_auth_interface.md) | +| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认证驱动的API接口。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.user_auth.v1_0 | 用户认证接口的包路径 | - - -## **详细描述** - -声明用户认证驱动的API接口。接口可用于注册执行器,管理用户认证凭据,完成PIN码和生物特征认证。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_vibrator_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_vibrator_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..bd1f6b90c2b08b8e9b58193eafea768589d6836e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_vibrator_interface_8idl.md @@ -0,0 +1,35 @@ +# IVibratorInterface.idl + + +## **概述** + +定义马达的通用API,可用于控制马达执行单次或周期性振动、设置马达振幅与频率。 + +**Since:** + +3.2 + +**Version:** + +1.1 + +**相关模块:** + +[Vibrator](vibrator.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IVibratorInterface](interface_i_vibrator_interface.md) | Vibrator模块向上层服务提供统一的接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.vibrator.v1_1 | 马达模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md deleted file mode 100644 index 4010893f082cb29cf18a9f8aaeeff6c7ea0bbec6..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md +++ /dev/null @@ -1,369 +0,0 @@ -# IWiFi - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| ( [start](#start) )(struct IWiFi \*iwifi) | 创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 [更多...](#start) | -| ( [stop](#stop) )(struct IWiFi \*iwifi) | 销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 [更多...](#stop) | -| ( [getSupportFeature](#getsupportfeature) )(uint8_t \*supType, uint32_t size) | 获取该设备支持的WLAN特性(不考虑当前的使用状态)。 [更多...](#getsupportfeature) | -| ( [getSupportCombo](#getsupportcombo) )(uint64_t \*combo, uint32_t size) | 获取多网卡共存情况。 [更多...](#getsupportcombo) | -| ( [createFeature](#createfeature) )(int32_t type, struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*ifeature) | 根据输入类型创建对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 [更多...](#createfeature) | -| ( [getFeatureByIfName](#getfeaturebyifname) )(const char \*ifName, struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*ifeature) | 通过网络接口名字获取对应的特性。 [更多...](#getfeaturebyifname) | -| ( [registerEventCallback](#registereventcallback) )([CallbackFunc](_w_l_a_n.md#callbackfunc) cbFunc, const char \*ifName) | 注册IWiFi的回调函数,监听异步事件。 [更多...](#registereventcallback) | -| ( [unregisterEventCallback](#unregistereventcallback) )([CallbackFunc](_w_l_a_n.md#callbackfunc) cbFunc, const char \*ifName) | 去注册IWiFi的回调函数。 [更多...](#unregistereventcallback) | -| ( [destroyFeature](#destroyfeature) )(struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*ifeature) | 根据输入类型销毁对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 [更多...](#destroyfeature) | -| ( [resetDriver](#resetdriver) )(const uint8_t chipId, const char \*ifName) | 重置具有指定芯片ID的WLAN驱动程序。 [更多...](#resetdriver) | -| ( [getNetDevInfo](#getnetdevinfo) )(struct NetDeviceInfoResult \*netDeviceInfoResult) | 获取网络设备信息(设备索引、网卡名字、MAC等信息)。 [更多...](#getnetdevinfo) | -| ( [getPowerMode](#getpowermode) )(const char \*ifName, uint8_t \*mode) | 获取正在使用的功率模式。 [更多...](#getpowermode) | -| ( [setPowerMode](#setpowermode) )(const char \*ifName, uint8_t mode) | 设置功率模式 [更多...](#setpowermode) | - - -## **详细描述** - -HAL对WLAN服务提供的基本能力。 - -用于创建HAL与驱动的通道,创建/获取/销毁WLAN特性等。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类成员变量说明** - - -### createFeature - - -``` -int32_t(* IWiFi::createFeature) (int32_t type, struct IWiFiBaseFeature **ifeature) -``` - -**描述:** - -根据输入类型创建对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| type | 输入参数,创建的feature类型。 | -| ifeature | 输出参数,获取创建的feature对象。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### destroyFeature - - -``` -int32_t(* IWiFi::destroyFeature) (struct IWiFiBaseFeature *ifeature) -``` - -**描述:** - -根据输入类型销毁对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| ifeature | 输入参数,销毁的feature对象。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getFeatureByIfName - - -``` -int32_t(* IWiFi::getFeatureByIfName) (const char *ifName, struct IWiFiBaseFeature **ifeature) -``` - -**描述:** - -通过网络接口名字获取对应的特性。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| ifName | 输入参数,网卡名称。 | -| ifeature | 输出参数,获取该网络接口名字的feature对象。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getNetDevInfo - - -``` -int32_t(* IWiFi::getNetDevInfo) (struct NetDeviceInfoResult *netDeviceInfoResult) -``` - -**描述:** - -获取网络设备信息(设备索引、网卡名字、MAC等信息)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| netDeviceInfoResult | 输出参数,得到的网络设备信息。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getPowerMode - - -``` -int32_t(* IWiFi::getPowerMode) (const char *ifName, uint8_t *mode) -``` - -**描述:** - -获取正在使用的功率模式。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| ifName | 输入参数,网卡名称。 | -| mode | 输出参数,功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getSupportCombo - - -``` -int32_t(* IWiFi::getSupportCombo) (uint64_t *combo, uint32_t size) -``` - -**描述:** - -获取多网卡共存情况。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| combo | 输出参数,基于芯片的能力保存当前所有支持的多网卡共存情况(比如支持AP,STA,P2P等不同组合的共存)。 | -| size | 输入参数,combo数组的长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getSupportFeature - - -``` -int32_t(* IWiFi::getSupportFeature) (uint8_t *supType, uint32_t size) -``` - -**描述:** - -获取该设备支持的WLAN特性(不考虑当前的使用状态)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| supType | 输出参数,保存当前设备支持的特性。 | -| size | 输入参数,supType数组的长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### registerEventCallback - - -``` -int32_t(* IWiFi::registerEventCallback) (CallbackFunc cbFunc, const char *ifName) -``` - -**描述:** - -注册IWiFi的回调函数,监听异步事件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| cbFunc | 输入参数,注册的回调函数。 | -| ifName | 输入参数,网卡名称。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### resetDriver - - -``` -int32_t(* IWiFi::resetDriver) (const uint8_t chipId, const char *ifName) -``` - -**描述:** - -重置具有指定芯片ID的WLAN驱动程序。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| chipId | 输入参数,需要进行重置驱动的对应芯片ID。 | -| ifName | 输入参数,网卡名称。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### setPowerMode - - -``` -int32_t(* IWiFi::setPowerMode) (const char *ifName, uint8_t mode) -``` - -**描述:** - -设置功率模式 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| ifName | 输入参数,网卡名称。 | -| mode | 输入参数,功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### start - - -``` -int32_t(* IWiFi::start) (struct IWiFi *iwifi) -``` - -**描述:** - -创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| iwifi | 输入参数,IWiFi对象。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### stop - - -``` -int32_t(* IWiFi::stop) (struct IWiFi *iwifi) -``` - -**描述:** - -销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| iwifi | 输入参数,IWiFi对象。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### unregisterEventCallback - - -``` -int32_t(* IWiFi::unregisterEventCallback) (CallbackFunc cbFunc, const char *ifName) -``` - -**描述:** - -去注册IWiFi的回调函数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| cbFunc | 输入参数,去注册的回调函数。 | -| ifName | 输入参数,网卡名称。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md deleted file mode 100644 index 2b291fba5e1a5852eee597b9d401ea72884f5b70..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md +++ /dev/null @@ -1,101 +0,0 @@ -# IWiFiAp - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [baseFeature](#basefeature) | 基本特性。 | -| ( [getAsscociatedStas](#getasscociatedstas) )(const struct IWiFiAp \*apFeature, struct [StaInfo](_sta_info.md) \*staInfo, uint32_t count, uint32_t \*num) | 获取连接上的所有STA的信息(目前只包含MAC地址)。 [更多...](#getasscociatedstas) | -| ( [setCountryCode](#setcountrycode) )(const struct IWiFiAp \*apFeature, const char \*code, uint32_t len) | 设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 [更多...](#setcountrycode) | - - -## **详细描述** - -继承了IWiFiBaseFeature基本特性,并包含AP模式下获取连接STA的信息和设置国家码的功能。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类成员变量说明** - - -### baseFeature - - -``` -struct IWiFiBaseFeature IWiFiAp::baseFeature -``` - -**描述:** - -基本特性。 - - -### getAsscociatedStas - - -``` -int32_t(* IWiFiAp::getAsscociatedStas) (const struct IWiFiAp *apFeature, struct StaInfo *staInfo, uint32_t count, uint32_t *num) -``` - -**描述:** - -获取连接上的所有STA的信息(目前只包含MAC地址)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| apFeature | 输入参数,AP特性。 | -| staInfo | 输出参数,保存与AP连接的STA的基本信息。 | -| count | 输入参数,staInfo结构体数组的元素个数。 | -| num | 输出参数,实际连接的STA的个数。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### setCountryCode - - -``` -int32_t(* IWiFiAp::setCountryCode) (const struct IWiFiAp *apFeature, const char *code, uint32_t len) -``` - -**描述:** - -设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| apFeature | 输入参数,AP特性。 | -| code | 输入参数,设置的国家码。 | -| len | 输入参数,国家码长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md deleted file mode 100644 index 0f440188c6e2ce31ffc78229a6d82c8e53a3702a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md +++ /dev/null @@ -1,259 +0,0 @@ -# IWiFiBaseFeature - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [ifName](#ifname) [[IFNAME_MAX_LEN](_w_l_a_n.md#ga63637ece87095ff8d153f650434ecf97)] | 网卡名称。 | -| **type** | 特性的类型,参考[FeatureType](_w_l_a_n.md#featuretype)。 | -| ( [getNetworkIfaceName](#getnetworkifacename) )(const struct IWiFiBaseFeature \*baseFeature) | 根据基本特性获取网卡名称。 [更多...](#getnetworkifacename) | -| ( [getFeatureType](#getfeaturetype) )(const struct IWiFiBaseFeature \*baseFeature) | 获取基本特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 [更多...](#getfeaturetype) | -| ( [setMacAddress](#setmacaddress) )(const struct IWiFiBaseFeature \*baseFeature, unsigned char \*mac, uint8_t len) | 根据传入参数设置对应网卡的MAC地址。 [更多...](#setmacaddress) | -| ( [getDeviceMacAddress](#getdevicemacaddress) )(const struct IWiFiBaseFeature \*baseFeature, unsigned char \*mac, uint8_t len) | 获取设备的MAC地址。 [更多...](#getdevicemacaddress) | -| ( [getValidFreqsWithBand](#getvalidfreqswithband) )(const struct IWiFiBaseFeature \*baseFeature, int32_t band, int32_t \*freqs, uint32_t count, uint32_t \*num) | 获取指定频段(2.4G或者5G)下支持的频率。 [更多...](#getvalidfreqswithband) | -| ( [setTxPower](#settxpower) )(const struct IWiFiBaseFeature \*baseFeature, int32_t power) | 设置发射功率。 [更多...](#settxpower) | -| ( [getChipId](#getchipid) )(const struct IWiFiBaseFeature \*baseFeature, uint8_t \*chipId) | 获得当前驱动的芯片ID。 [更多...](#getchipid) | -| ( [getIfNamesByChipId](#getifnamesbychipid) )(const uint8_t chipId, char \*\*ifNames, uint32_t \*num) | 通过芯片ID获得当前芯片所有的网卡名称。 [更多...](#getifnamesbychipid) | - - -## **详细描述** - -WLAN基本特性操作接口,包括获取网卡名称,设置MAC地址,设置发射功率等公共能力接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类成员变量说明** - - -### getChipId - - -``` -int32_t(* IWiFiBaseFeature::getChipId) (const struct IWiFiBaseFeature *baseFeature, uint8_t *chipId) -``` - -**描述:** - -获得当前驱动的芯片ID。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | -| chipId | 输出参数,获得的芯片ID。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getDeviceMacAddress - - -``` -int32_t(* IWiFiBaseFeature::getDeviceMacAddress) (const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len) -``` - -**描述:** - -获取设备的MAC地址。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | -| mac | 输出参数,获得的MAC地址。 | -| len | 输入参数,获得的MAC地址长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getFeatureType - - -``` -int32_t(*IWiFiBaseFeature::getFeatureType) (const struct IWiFiBaseFeature *baseFeature) -``` - -**描述:** - -获取基本特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | - -**返回:** - -如果操作成功,则返回特性类型。 - -如果操作失败,则返回负值。 - - -### getIfNamesByChipId - - -``` -int32_t(* IWiFiBaseFeature::getIfNamesByChipId) (const uint8_t chipId, char **ifNames, uint32_t *num) -``` - -**描述:** - -通过芯片ID获得当前芯片所有的网卡名称。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| chipId | 输入参数,需要获取网卡名称的芯片ID。 | -| ifNames | 输出参数,网卡名称。 | -| num | 输出参数,网卡的数量。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### getNetworkIfaceName - - -``` -const char*(* IWiFiBaseFeature::getNetworkIfaceName) (const struct IWiFiBaseFeature *baseFeature) -``` - -**描述:** - -根据基本特性获取网卡名称。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | - -**返回:** - -如果操作成功,则返回网卡名称。 - -如果操作失败,则返回NULL。 - - -### getValidFreqsWithBand - - -``` -int32_t(* IWiFiBaseFeature::getValidFreqsWithBand) (const struct IWiFiBaseFeature *baseFeature, int32_t band, int32_t *freqs, uint32_t count, uint32_t *num) -``` - -**描述:** - -获取指定频段(2.4G或者5G)下支持的频率。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | -| band | 输入参数,指定的一个频段。 | -| freqs | 输出参数,保存支持的频率。 | -| count | 输入参数,频率数组的元素个数。 | -| num | 输出参数,实际支持的频率个数。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### ifName - - -``` -char IWiFiBaseFeature::ifName[IFNAME_MAX_LEN] -``` - -**描述:** - -网卡名称。 - - -### setMacAddress - - -``` -int32_t(* IWiFiBaseFeature::setMacAddress) (const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len) -``` - -**描述:** - -根据传入参数设置对应网卡的MAC地址。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | -| mac | 输入参数,设置的MAC地址。 | -| len | 输入参数,设置的MAC地址长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### setTxPower - - -``` -int32_t(* IWiFiBaseFeature::setTxPower) (const struct IWiFiBaseFeature *baseFeature, int32_t power) -``` - -**描述:** - -设置发射功率。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| baseFeature | 输入参数,基本特性。 | -| power | 输入参数,设置的发射功率。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md deleted file mode 100644 index aff3e568d7d0cae1422620565645673dbcb5508e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md +++ /dev/null @@ -1,99 +0,0 @@ -# IWiFiSta - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [baseFeature](#basefeature) | 基本特性。 | -| ( [setScanningMacAddress](#setscanningmacaddress) )(const struct IWiFiSta \*staFeature, unsigned char \*scanMac, uint8_t len) | 设置扫描单个MAC地址。 [更多...](#setscanningmacaddress) | -| ( [startScan](#startscan) )(const char \*ifName, WifiScan \*scan) | 启动扫描。 [更多...](#startscan) | - - -## **详细描述** - -继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,额外包含设置扫描单个MAC地址功能。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类成员变量说明** - - -### baseFeature - - -``` -struct IWiFiBaseFeature IWiFiSta::baseFeature -``` - -**描述:** - -基本特性。 - - -### setScanningMacAddress - - -``` -int32_t(* IWiFiSta::setScanningMacAddress) (const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len) -``` - -**描述:** - -设置扫描单个MAC地址。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| staFeature | 输入参数,STA特性。 | -| scanMac | 输入参数,设置STA扫描的MAC地址。 | -| len | 输入参数,MAC地址的长度。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### startScan - - -``` -int32_t(* IWiFiSta::startScan) (const char *ifName, WifiScan *scan) -``` - -**描述:** - -启动扫描。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| ifName | 输入参数,网卡名称。 | -| scan | 输入参数,扫描参数。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wlan_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_wlan_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..beb6dbd85a0accf901c36f1212d4e1a5747c95f6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wlan_callback_8idl.md @@ -0,0 +1,35 @@ +# IWlanCallback.idl + + +## **概述** + +WLAN模块为WLAN服务提供的重启驱动、扫描结果、Netlink消息处理的回调。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IWlanCallback](interface_i_wlan_callback.md) | 定义WLAN模块的回调函数。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.wlan.v1_0 | WLAN模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wlan_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_wlan_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..adaa08cb01c1d4e01d58f984623fd0d762a7a56e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wlan_interface_8idl.md @@ -0,0 +1,35 @@ +# IWlanInterface.idl + + +## **概述** + +WLAN模块操作接口,上层服务调用相关的接口可实现:建立/关闭WLAN热点,扫描/关联/去关联WLAN热点,设置国家码,管理网络设备等功能。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IWlanInterface](interface_i_wlan_interface.md) | WLAN模块向上层WLAN服务提供了统一接口。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.wlan.v1_0 | WLAN模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md b/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md index f990a2d18bffdca9b2404f92e1c56f191bc93676..7de20781d4853dcc55f0a24b127939d5abc0c241 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md @@ -3,6 +3,16 @@ ## **概述** +用户身份识别结果信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,26 +23,13 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [result](#result) | 用户身份识别结果。 | | [userId](#userid) | 用户ID。 | | [token](#token) | 用户身份识别令牌。 | -## **详细描述** - -用户身份识别结果信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_input.md b/zh-cn/device-dev/reference/hdi-apis/_input.md deleted file mode 100644 index dbd838eafb69a6c12d443de9271c1ff24ddd14cf..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_input.md +++ /dev/null @@ -1,238 +0,0 @@ -# Input - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [input_controller.h](input__controller_8h.md) | 描述Input设备业务控制相关的接口声明。 | -| [input_manager.h](input__manager_8h.md) | 描述Input设备管理相关的接口声明。 | -| [input_reporter.h](input__reporter_8h.md) | 描述Input设备数据上报相关的接口声明。 | -| [input_type.h](input__type_8h.md) | Input设备相关的类型定义,定义了Input设备驱动接口所使用的结构体及枚举类型。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [InputController](_input_controller.md) | 提供Input设备业务控制相关的接口。 [更多...](_input_controller.md) | -| [InputManager](_input_manager.md) | 提供Input设备管理相关的接口。 [更多...](_input_manager.md) | -| [IInputInterface](_i_input_interface.md) | 定义用于提供输入设备驱动能力的接口。[更多...](_i_input_interface.md) | -| [InputReporter](_input_reporter.md) | 提供Input设备数据上报相关的接口。 [更多...](_input_reporter.md) | -| [InputEventPackage](_event_package.md) | Input事件数据包结构。 [更多...](_event_package.md) | -| [InputHotPlugEvent](_input_hotplug_event.md) | 热插拔事件数据包结构。 [更多...](_input_hotplug_event.md) | -| [InputDevDesc](_input_dev_desc.md) | Input设备描述信息。 [更多...](_input_dev_desc.md) | -| [InputEventCb](_input_report_event_cb.md) | 此结构体定义了输入事件回调函数并提供给Input服务使用。 [更多...](_input_report_event_cb.md) | -| [InputHostCb](_input_host_cb.md) | 此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 [更多...](_input_host_cb.md) | -| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,存储支持事件的位图。 [更多...](_input_dev_ability.md) | -| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信息。 [更多...](_input_dimension_info.md) | -| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信息。 [更多...](_input_dev_identify.md) | -| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 [更多...](_input_dev_attr.md) | -| [InputDeviceInfo](_device_info.md) | Input设备基础设备信息。 [更多...](_device_info.md) | -| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数据结构。 [更多...](_input_extra_cmd.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| **MAX_INPUT_DEV_NUM**   32 | Input设备最大数量。 | -| **DEV_NAME_LEN**   64 | Input设备名称长度。 | -| **CHIP_INFO_LEN**   10 | 芯片信息长度。 | -| **CHIP_NAME_LEN**   10 | 芯片名称长度。 | -| **VENDOR_NAME_LEN**   10 | 厂商名称长度。 | -| **SELF_TEST_RESULT_LEN**   20 | 自测结果长度。 | -| **DEV_MANAGER_SERVICE_NAME**   "hdf_input_host" | Input设备节点服务名称。 | -| **DIV_ROUND_UP(nr, d)**  (((nr) + (d) - 1) / (d)) | 向上取整计算公式。| -| **BYTE_HAS_BITS**  8 | 一个字节所包含的比特数。 | -| **BITS_TO_UINT64(count)**  DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(uint64_t)) | 比特与64位无符号整数的转换公式。 | -| **HDF_FF_CNT**  (0x7f + 1) | Input设备发送力反馈命令的数量最大值。| - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [RetStatus](#retstatus) { INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3,   INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 [更多...](#retstatus) | -| [InputDevType](#inputdevtype) { INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE,   INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 [更多...](#inputdevtype) | -| [PowerStatus](#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN } | 定义电源状态。 [更多...](#powerstatus) | -| [CapacitanceTest](#capacitancetest) { BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST,   TEST_TYPE_UNKNOWN } | 定义容值测试类型。 [更多...](#capacitancetest) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [GetInputInterface](#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | Input服务通过调用此接口获取操作Input设备的所有接口。 [更多...](#getinputinterface) | -| [ReleaseInputInterface](#releaseinputinterface) ([IInputInterface](_i_input_interface.md) \*\*inputInterface) | Input服务通过调用此接口释放操作Input设备的所有接口。 [更多...](#releaseinputinterface) | - - -## **详细描述** - -Input模块驱动接口声明。 - -本模块为Input服务提供相关驱动接口,包括Input设备的打开和关闭、Input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **枚举类型说明** - - -### CapacitanceTest - - -``` -enum CapacitanceTest -``` - -**描述:** - -定义容值测试类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| BASE_TEST | 基础容值测试 | -| FULL_TEST | 全量容值自检测试 | -| MMI_TEST | MMI容值测试 | -| RUNNING_TEST | 老化容值测试 | -| TEST_TYPE_UNKNOWN | 未知的测试类型 | - - -### InputDevType - - -``` -enum InputDevType -``` - -**描述:** - -定义Input设备类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| INDEV_TYPE_TOUCH | 触摸屏。 | -| INDEV_TYPE_KEY | 物理按键。 | -| INDEV_TYPE_KEYBOARD | 键盘。 | -| INDEV_TYPE_MOUSE | 鼠标。 | -| INDEV_TYPE_BUTTON | 虚拟按键。 | -| INDEV_TYPE_CROWN | 表冠。 | -| INDEV_TYPE_ENCODER | 自定义编码的特定功能或者事件。 | -| INDEV_TYPE_UNKNOWN | 未知输入设备类型。 | - - -### PowerStatus - - -``` -enum PowerStatus -``` - -**描述:** - -定义电源状态。 - - | 枚举值 | 描述 | -| -------- | -------- | -| INPUT_RESUME | 正常唤醒。 | -| INPUT_SUSPEND | 休眠下电模式。 | -| INPUT_LOW_POWER | 休眠低功耗模式。 | -| INPUT_POWER_STATUS_UNKNOWN | 未知电源状态。 | - - -### RetStatus - - -``` -enum RetStatus -``` - -**描述:** - -定义返回值类型。 - - | 枚举值 | 描述 | -| -------- | -------- | -| INPUT_SUCCESS | 成功。 | -| INPUT_FAILURE | 失败。 | -| INPUT_INVALID_PARAM | 无效参数。 | -| INPUT_NOMEM | 内存不足。 | -| INPUT_NULL_PTR | 空指针。 | -| INPUT_TIMEOUT | 执行超时。 | -| INPUT_UNSUPPORTED | 特性不支持。 | - - -## **函数说明** - - -### GetInputInterface() - - -``` -int32_t GetInputInterface (IInputInterface **interface) -``` - -**描述:** - -Input服务通过调用此接口获取操作Input设备的所有接口。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| interface | 对Input设备进行接口操作的指针,通常在Input服务启动后,通过调用此函数获取Input设备操作接口。 | - -**返回:** - -INPUT_SUCCESS 表示执行成功。 - -其他值表示执行失败,具体错误码查看[RetStatus](#retstatus)。 - -**Since:** - -1.0 - -**Version:** - -1.0 - -### ReleaseInputInterface() - - -``` -int32_t ReleaseInputInterface (IInputInterface *inputInterface) -``` - -**描述:** - -Input服务通过调用此接口释放操作Input设备的所有接口。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| inputInterface| 对Input设备进行接口操作的指针。 | - -**返回:** - -INPUT_SUCCESS 表示执行成功。 - -其他值表示执行失败,具体错误码查看[RetStatus](#retstatus)。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_controller.md b/zh-cn/device-dev/reference/hdi-apis/_input_controller.md index 2f3d3e0c4394801375698db6f2393d5d85de169b..34ed01cf05b1a3ccbf1c59fe78ea25dd1a2d19bb 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_controller.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_controller.md @@ -3,9 +3,13 @@ ## **概述** -**所属模块:** +提供Input设备业务控制相关的接口。 + +此类接口包含电源状态的设置、特性的使能、器件信息的获取,以及产线相关的测试功能接口。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,24 +17,17 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [SetPowerStatus](#setpowerstatus) )(uint32_t devIndex, uint32_t status) | 设置电源状态 [更多...](#setpowerstatus) | -| ( [GetPowerStatus](#getpowerstatus) )(uint32_t devIndex, uint32_t \*status) | 获取电源状态 [更多...](#getpowerstatus) | -| ( [GetDeviceType](#getdevicetype) )(uint32_t devIndex, uint32_t \*deviceType) | 获取devIndex对应的Input设备的类型 [更多...](#getdevicetype) | -| ( [GetChipInfo](#getchipinfo) )(uint32_t devIndex, char \*chipInfo, uint32_t length) | 获取器件对应的编码信息 [更多...](#getchipinfo) | -| ( [GetVendorName](#getvendorname) )(uint32_t devIndex, char \*vendorName, uint32_t length) | 获取devIndex对应的模组厂商名 [更多...](#getvendorname) | -| ( [GetChipName](#getchipname) )(uint32_t devIndex, char \*chipName, uint32_t length) | 获取devIndex对应的驱动芯片名 [更多...](#getchipname) | -| ( [SetGestureMode](#setgesturemode) )(uint32_t devIndex, uint32_t gestureMode) | 设置手势模式 [更多...](#setgesturemode) | -| ( [RunCapacitanceTest](#runcapacitancetest) )(uint32_t devIndex, uint32_t testType, char \*result, uint32_t length) | 执行容值自检测试 [更多...](#runcapacitancetest) | -| ( [RunExtraCommand](#runextracommand) )(uint32_t devIndex, [InputExtraCmd](_input_extra_cmd.md) \*cmd) | 执行拓展指令 [更多...](#runextracommand) | - - -## **详细描述** - -提供Input设备业务控制相关的接口。 - -此类接口包含电源状态的设置、特性的使能、器件信息的获取,以及产线相关的测试功能接口。 +| ([SetPowerStatus](#setpowerstatus) )(uint32_t devIndex, uint32_t status) | 设置电源状态。 | +| ([GetPowerStatus](#getpowerstatus) )(uint32_t devIndex, uint32_t \*status) | 获取电源状态。 | +| ([GetDeviceType](#getdevicetype) )(uint32_t devIndex, uint32_t \*deviceType) | 获取devIndex对应的Input设备的类型。 | +| ([GetChipInfo](#getchipinfo) )(uint32_t devIndex, char \*chipInfo, uint32_t length) | 获取器件对应的编码信息。 | +| ([GetVendorName](#getvendorname) )(uint32_t devIndex, char \*vendorName, uint32_t length) | 获取devIndex对应的模组厂商名。 | +| ([GetChipName](#getchipname) )(uint32_t devIndex, char \*chipName, uint32_t length) | 获取devIndex对应的驱动芯片名。 | +| ([SetGestureMode](#setgesturemode) )(uint32_t devIndex, uint32_t gestureMode) | 设置手势模式。 | +| ([RunCapacitanceTest](#runcapacitancetest) )(uint32_t devIndex, uint32_t testType, char \*result, uint32_t length) | 执行容值自检测试。 | +| ([RunExtraCommand](#runextracommand) )(uint32_t devIndex, [InputExtraCmd](_input_extra_cmd.md) \*cmd) | 执行拓展指令。 | ## **类成员变量说明** @@ -49,7 +46,7 @@ int32_t(* InputController::GetChipInfo) (uint32_t devIndex, char *chipInfo, uint 一款产品通常会有多家模组和Driver IC,上层应用如果关注具体器件型号,则通过此接口来获取。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -57,11 +54,11 @@ int32_t(* InputController::GetChipInfo) (uint32_t devIndex, char *chipInfo, uint | chipInfo | 输出参数,获取的对应设备索引的器件编码信息。 | | length | 输入参数,保存器件芯片信息的内存长度。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetChipName @@ -75,7 +72,7 @@ int32_t(* InputController::GetChipName) (uint32_t devIndex, char *chipName, uint 获取devIndex对应的驱动芯片名。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -83,11 +80,11 @@ int32_t(* InputController::GetChipName) (uint32_t devIndex, char *chipName, uint | chipName | 输出参数,获取的对应设备索引的驱动芯片名。 | | length | 输入参数,保存驱动芯片名的内存长度。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetDeviceType @@ -101,18 +98,18 @@ int32_t(* InputController::GetDeviceType) (uint32_t devIndex, uint32_t *deviceTy 获取devIndex对应的Input设备的类型。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| deviceType | 输出参数,获取的对应设备索引的设备类型,具体参考[InputDevType](_input.md#inputdevtype)。 | +| deviceType | 输出参数,获取的对应设备索引的设备类型,具体参考[InputDevType](input.md#inputdevtype)。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetPowerStatus @@ -128,18 +125,18 @@ int32_t(* InputController::GetPowerStatus) (uint32_t devIndex, uint32_t *status) 在系统休眠或者唤醒时,Input服务或电源管理模块获取电源状态,以便驱动IC能正常进入对应的休眠模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| status | 输出参数,获取的对应设备索引的电源状态,具体参考[PowerStatus](_input.md#powerstatus)。 | +| status | 输出参数,获取的对应设备索引的电源状态,具体参考[PowerStatus](input.md#powerstatus)。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetVendorName @@ -153,19 +150,19 @@ int32_t(* InputController::GetVendorName) (uint32_t devIndex, char *vendorName, 获取devIndex对应的模组厂商名。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| devIndex | Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| vendorName | 获取的对应设备索引的模组厂商名。 | -| length | 保存模组厂商名的内存长度。 | +| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | +| vendorName | 输出参数,获取的对应设备索引的模组厂商名。 | +| length | 输入参数,保存模组厂商名的内存长度。 | -**返回:** +**返回:** -Returns INPUT_SUCCESS 表示执行成功。 +INPUT_SUCCESS 表示执行成功。 -Returns 其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### RunCapacitanceTest @@ -179,22 +176,22 @@ int32_t(* InputController::RunCapacitanceTest) (uint32_t devIndex, uint32_t test 执行容值自检测试。 -启动不同检测场景下的容值自检测试,并获取测试结果,容值自检项由器件厂商自定义, 一般包括RawData测试、短路检测、开路检测、干扰检测、行列差检测等测试项。 +启动不同检测场景下的容值自检测试,并获取测试结果,容值自检项由器件厂商自定义, 一般包括RawData测试、 \* 短路检测、开路检测、干扰检测、行列差检测等测试项。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| testType | 输入参数,容值测试的测试类型,具体参考[CapacitanceTest](_input.md#capacitancetest)。 | +| testType | 输入参数,容值测试的测试类型,具体参考[CapacitanceTest](input.md#capacitancetest)。 | | result | 输出参数,容值测试的结果,成功则输出“SUCC”,失败则返回对应的错误提示。 | | length | 输入参数,保存容值测试结果的内存长度。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### RunExtraCommand @@ -208,18 +205,18 @@ int32_t(* InputController::RunExtraCommand) (uint32_t devIndex, InputExtraCmd *c 执行拓展指令。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | | cmd | 输入参数,拓展指令数据包,包括指令编码及参数,具体参考[InputExtraCmd](_input_extra_cmd.md)。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### SetGestureMode @@ -235,18 +232,18 @@ int32_t(* InputController::SetGestureMode) (uint32_t devIndex, uint32_t gestureM 上层应用开关手势模式,即设置手势模式的对应使能bit。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | | gestureMode | 输入参数,手势模式的开关状态。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### SetPowerStatus @@ -262,15 +259,15 @@ int32_t(* InputController::SetPowerStatus) (uint32_t devIndex, uint32_t status) 在系统休眠或者唤醒时,Input服务或电源管理模块设置电源状态,以使驱动IC能正常进入对应的休眠模式。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| status | 输入参数,设置的电源状态,Input服务控制Input设备进入resume或者suspend等状态[PowerStatus](_input.md#powerstatus)。 | +| status | 输入参数,设置的电源状态,Input服务控制Input设备进入resume或者suspend等状态[PowerStatus](input.md#powerstatus)。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md index d7ec4c6686ae6b2f80a83c11b74685a1bdfcb128..09a32f7c4d89e3e74b1a3a232a213e1b5be07899 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备的能力属性,存储支持事件的位图。用位的方式来表示该Input设备能够上报的事件类型。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,184 +15,190 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [devProp](#devprop) | 设备属性 | -| [eventType](#eventtype) | 记录支持的事件类型的位图 | -| [absCode](#abscode) | 记录支持的绝对坐标的位图 | -| [relCode](#relcode) | 记录支持的相对坐标的位图 | -| [keyCode](#keycode) | 记录支持的按键值的位图 | -| [ledCode](#ledcode) | 记录设备支持的指示灯的位图 | -| [miscCode](misccode#) |记录设备支持的其他功能的位图 | -| [soundCode](#soundcode) | 记录设备支持的声音或警报的位图 | -| [forceCode](#forcecode) | 记录设备支持的作用力功能的位图 | -| [switchCode](#switchcode) | 记录设备支持的开关功能的位图 | -| [keyType](#keytype) | 按键状态的位图 | -| [ledType](#ledtype) | LED状态的位图 | -| [soundType](#soundtype) | 声音状态的位图 | -| [switchType](#switchtype) | 开关状态的位图 | - -## **详细描述** - -Input设备的能力属性,存储支持事件的位图。用位的方式来表示该Input设备能够上报的事件类型。 +| [devProp](#devprop) [[BITS_TO_UINT64](input.md#bitstouint64)(INPUT_PROP_CNT)] | 设备属性 | +| [eventType](#eventtype) [[BITS_TO_UINT64](input.md#bitstouint64)(EV_CNT)] | 记录支持的事件类型的位图 | +| [absCode](#abscode) [[BITS_TO_UINT64](input.md#bitstouint64)(ABS_CNT)] | 记录支持的绝对坐标的位图 | +| [relCode](#relcode) [[BITS_TO_UINT64](input.md#bitstouint64)(REL_CNT)] | 记录支持的相对坐标的位图 | +| [keyCode](#keycode) [[BITS_TO_UINT64](input.md#bitstouint64)(KEY_CNT)] | 记录支持的按键值的位图 | +| [ledCode](#ledcode) [[BITS_TO_UINT64](input.md#bitstouint64)(LED_CNT)] | 记录设备支持的指示灯的位图 | +| [miscCode](#misccode) [[BITS_TO_UINT64](input.md#bitstouint64)(MSC_CNT)] | 记录设备支持的其他功能的位图 | +| [soundCode](#soundcode) [[BITS_TO_UINT64](input.md#bitstouint64)(SND_CNT)] | 记录设备支持的声音或警报的位图 | +| [forceCode](#forcecode) [[BITS_TO_UINT64](input.md#bitstouint64)([HDF_FF_CNT](input.md#hdfffcnt))] | 记录设备支持的作用力功能的位图 | +| [switchCode](#switchcode) [[BITS_TO_UINT64](input.md#bitstouint64)(SW_CNT)] | 记录设备支持的开关功能的位图 | +| [keyType](#keytype) [[BITS_TO_UINT64](input.md#bitstouint64)(KEY_CNT)] | 按键状态的位图 | +| [ledType](#ledtype) [[BITS_TO_UINT64](input.md#bitstouint64)(LED_CNT)] | LED状态的位图 | +| [soundType](#soundtype) [[BITS_TO_UINT64](input.md#bitstouint64)(SND_CNT)] | 声音状态的位图 | +| [switchType](#switchtype) [[BITS_TO_UINT64](input.md#bitstouint64)(SW_CNT)] | 开关状态的位图 | ## **类成员变量说明** -### devProp - +### absCode + ``` -uint64_t InputDevAbility::devProp[BITS_TO_UINT64(INPUT_PROP_CNT)] +uint64_t InputDevAbility::absCode[BITS_TO_UINT64(ABS_CNT)] ``` **描述:** -设备属性。 - +记录支持的绝对坐标的位图 -### eventType +### devProp + ``` -uint64_t InputDevAbility::eventType[BITS_TO_UINT64(EV_CNT)] +uint64_t InputDevAbility::devProp[BITS_TO_UINT64(INPUT_PROP_CNT)] ``` **描述:** -用于记录支持的事件类型的位图。 +设备属性 -### absCode +### eventType + ``` -uint64_t InputDevAbility::absCode[BITS_TO_UINT64(ABS_CNT)] +uint64_t InputDevAbility::eventType[BITS_TO_UINT64(EV_CNT)] ``` **描述:** -记录支持的绝对坐标的位图。 +用于记录支持的事件类型的位图 -### relCode +### forceCode + ``` -uint64_t InputDevAbility::relCode[BITS_TO_UINT64(REL_CNT)] +uint64_t InputDevAbility::forceCode[BITS_TO_UINT64(HDF_FF_CNT)] ``` **描述:** -记录支持的相对坐标的位图。 +记录设备支持的作用力功能的位图 -### keyCode +### keyCode + ``` uint64_t InputDevAbility::keyCode[BITS_TO_UINT64(KEY_CNT)] ``` **描述:** -记录支持的按键值的位图。 +记录支持的按键值的位图 -### ledCode - +### keyType + ``` -uint64_t InputDevAbility::ledCode[BITS_TO_UINT64(LED_CNT)] +uint64_t InputDevAbility::keyType[BITS_TO_UINT64(KEY_CNT)] ``` **描述:** -记录设备支持的指示灯的位图。 - +按键状态的位图 -### miscCode +### ledCode + ``` -uint64_t InputDevAbility::miscCode[BITS_TO_UINT64(MSC_CNT)] +uint64_t InputDevAbility::ledCode[BITS_TO_UINT64(LED_CNT)] ``` **描述:** -记录设备支持的其他功能的位图。 - +记录设备支持的指示灯的位图 -### soundCode +### ledType + ``` -uint64_t InputDevAbility::soundCode[BITS_TO_UINT64(SND_CNT)] +uint64_t InputDevAbility::ledType[BITS_TO_UINT64(LED_CNT)] ``` **描述:** -记录设备支持的声音或警报的位图。 +led状态的位图 -### forceCode +### miscCode + ``` -uint64_t InputDevAbility::forceCode[BITS_TO_UINT64(HDF_FF_CNT)] +uint64_t InputDevAbility::miscCode[BITS_TO_UINT64(MSC_CNT)] ``` **描述:** -记录设备支持的作用力功能的位图。 +记录设备支持的其他功能的位图 -### switchCode +### relCode + ``` -uint64_t InputDevAbility::switchCode[BITS_TO_UINT64(SW_CNT)] +uint64_t InputDevAbility::relCode[BITS_TO_UINT64(REL_CNT)] ``` **描述:** -记录设备支持的开关功能的位图。 +记录支持的相对坐标的位图 -### keyType +### soundCode + ``` -uint64_t InputDevAbility::keyType[BITS_TO_UINT64(KEY_CNT)] +uint64_t InputDevAbility::soundCode[BITS_TO_UINT64(SND_CNT)] ``` **描述:** -按键状态的位图。 +记录设备支持的声音或警报的位图 -### ledType +### soundType + ``` -uint64_t InputDevAbility::ledType[BITS_TO_UINT64(LED_CNT)] +uint64_t InputDevAbility::soundType[BITS_TO_UINT64(SND_CNT)] ``` **描述:** -LED状态的位图。 +声音状态的位图 -### soundType +### switchCode + + ``` -uint64_t InputDevAbility::soundType[BITS_TO_UINT64(SND_CNT)] +uint64_t InputDevAbility::switchCode[BITS_TO_UINT64(SW_CNT)] ``` **描述:** -声音状态的位图。 +记录设备支持的开关功能的位图 + ### switchType + ``` uint64_t InputDevAbility::switchType[BITS_TO_UINT64(SW_CNT)] ``` **描述:** -开关状态的位图。 - +开关状态的位图 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md index d6dcb2b37936249aeae66af38131a56c27019797..27ffb8c84c6882fdecde230d24023d0ead5bade6 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备属性。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,46 +15,47 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [devName](#devname) | 设备名 | +| [devName](#devname) [DEV_NAME_LEN] | 设备名 | | [id](#id) | 设备识别信息 | -| [axisInfo](#axisinfo) | 设备维度信息 | - -## **详细描述** - -Input设备属性。 +| [axisInfo](#axisinfo) [ABS_CNT] | 设备维度信息 | ## **类成员变量说明** -### devName +### axisInfo + ``` -char InputDevAttr::devName[DEV_NAME_LEN] +InputDimensionInfo InputDevAttr::axisInfo[ABS_CNT] ``` **描述:** -设备名。 +设备维度信息 -### id +### devName + + ``` -InputDevIdentify InputDevAttr::id +char InputDevAttr::devName[DEV_NAME_LEN] ``` **描述:** -设备识别信息。 +设备名 -### axisInfo +### id + + ``` -InputDimensionInfo InputDevAttr::axisInfo[ABS_CNT]; +InputDevIdentify InputDevAttr::id ``` **描述:** -设备维度信息。 \ No newline at end of file +设备识别信息 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md index e2fbf7cf662776f9017cf4f4d17ae6114251b435..89b51c3c3dde76f178fcee194062fde0dea4d740 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备描述信息。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [devIndex](#devindex) | 设备索引 | -| [devType](#devtype) | 设备类型 | - - -## **详细描述** - -Input设备描述信息。 +| [devIndex](#devindex) | 设备索引。 | +| [devType](#devtype) | 设备类型。 | ## **类成员变量说明** @@ -29,23 +26,23 @@ Input设备描述信息。 ### devIndex - -```cpp + +``` uint32_t InputDevDesc::devIndex ``` **描述:** -设备索引。 +设备索引 ### devType - -```cpp + +``` uint32_t InputDevDesc::devType ``` **描述:** -设备类型。 +设备类型 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md index 76839b56e7950a86e5232ea388b0e92fe7e3b142..1470ec653c305b4fc2d1fe79aba276a557ea4c30 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备的识别信息。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,16 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [busType](#bustype) | 总线类型 | | [vendor](#vendor) | 生产商编号 | -| [product](#product) | 产品编号 | -| [version](#version) | 版本号 | - -## **详细描述** - -Input设备的识别信息。 +| [product](#product) | 产品编号 | +| [version](#version) | 版本号 | ## **类成员变量说明** @@ -30,40 +28,47 @@ Input设备的识别信息。 ### busType -```cpp + +``` uint16_t InputDevIdentify::busType ``` **描述:** -总线类型。 +总线类型 -### vendor -```cpp -uint16_t InputDevIdentify::vendor +### product + + +``` +uint16_t InputDevIdentify::product ``` **描述:** -生产商编号。 +产品编号 -### product -```cpp -uint16_t InputDevIdentify::product +### vendor + + +``` +uint16_t InputDevIdentify::vendor ``` **描述:** -产品编号。 +生产商编号 + ### version -```cpp + +``` uint16_t InputDevIdentify::version ``` **描述:** -版本号。 +版本号 diff --git a/zh-cn/device-dev/reference/hdi-apis/_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_input_device_info.md similarity index 68% rename from zh-cn/device-dev/reference/hdi-apis/_device_info.md rename to zh-cn/device-dev/reference/hdi-apis/_input_device_info.md index d70dedd1806bb2b2c392c58f0ed8e4bca5deaed2..46d0ccbb683ebbeff26b184da4525c295562f601 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_device_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_device_info.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备基础设备信息。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,106 +15,99 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [devIndex](#devindex) | 设备索引 | -| [devType](#devtype) | 设备类型 | +| [devIndex](#devindex) | 设备索引 | +| [devType](#devtype) | 设备类型 | | [chipInfo](#chipinfo) [CHIP_INFO_LEN] | 驱动芯片编码信息 | -| [vendorName](#vendorname) [VENDOR_NAME_LEN] | 模组厂商名 | +| [vendorName](#vendorname) [VENDOR_NAME_LEN] | 模组厂商名 | | [chipName](#chipname) [CHIP_NAME_LEN] | 驱动芯片型号 | -| [attrSet](#attrset)| 设备属性。 | -| [abilitySet](#abilityset)| 设备能力属性。| - - - -## **详细描述** - -Input设备基础设备信息。 +| [attrSet](#attrset) | 设备属性 | +| [abilitySet](#abilityset) | 设备能力属性 | ## **类成员变量说明** -### chipInfo +### abilitySet ``` -char InputDeviceInfo::chipInfo[CHIP_INFO_LEN] +InputDevAbility InputDeviceInfo::abilitySet ``` **描述:** -驱动芯片编码信息。 +设备能力属性 -### chipName +### attrSet ``` -char InputDeviceInfo::chipName[CHIP_NAME_LEN] +InputDevAttr InputDeviceInfo::attrSet ``` **描述:** -驱动芯片型号。 +设备属性 -### devIndex +### chipInfo ``` -uint32_t InputDeviceInfo::devIndex +char InputDeviceInfo::chipInfo[CHIP_INFO_LEN] ``` **描述:** -设备索引。 - +驱动芯片编码信息 -### devType +### chipName ``` -uint32_t InputDeviceInfo::devType +char InputDeviceInfo::chipName[CHIP_NAME_LEN] ``` **描述:** -设备类型。 +驱动芯片型号 -### vendorName +### devIndex ``` -char InputDeviceInfo::vendorName[VENDOR_NAME_LEN] +uint32_t InputDeviceInfo::devIndex ``` **描述:** -模组厂商名。 +设备索引 -### attrSet +### devType ``` -InputDevAttr InputDeviceInfo::attrSet +uint32_t InputDeviceInfo::devType ``` **描述:** -设备属性。 +设备类型 -### abilitySet +### vendorName ``` -InputDevAbility InputDeviceInfo::abilitySet +char InputDeviceInfo::vendorName[VENDOR_NAME_LEN] ``` **描述:** -设备能力属性。 \ No newline at end of file +模组厂商名 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md b/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md index bdbbdbd5d33b9886691cbedfa742fa432c43f34e..16919c614433d3d3781a4618a1aafb2d04a49272 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input设备的维度信息。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,18 +15,14 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [axis](#axis) | 坐标轴 | | [min](#min) | 记录各个坐标的最小值 | -| [max](#max) | 记录各个坐标的最大值 | -| [fuzz](#fuzz) | 记录各个坐标的分辨率 | -| [flat](#flat) | 记录各个坐标的基准值 | -| [range](#range) | 范围 | - -## **详细描述** - -Input设备的维度信息。 +| [max](#max) | 记录各个坐标的最大值 | +| [fuzz](#fuzz) | 记录各个坐标的分辨率 | +| [flat](#flat) | 记录各个坐标的基准值 | +| [range](#range) | 范围 | ## **类成员变量说明** @@ -32,60 +30,71 @@ Input设备的维度信息。 ### axis + ``` int32_t InputDimensionInfo::axis ``` **描述:** -坐标轴。 +坐标轴 -### min +### flat + + ``` -int32_t InputDimensionInfo::min +int32_t InputDimensionInfo::flat ``` **描述:** -记录各个坐标的最小值。 +记录各个坐标的基准值 -### max +### fuzz + + ``` -int32_t InputDimensionInfo::max +int32_t InputDimensionInfo::fuzz ``` **描述:** -记录各个坐标的最大值。 +记录各个坐标的分辨率 -### fuzz +### max + + ``` -int32_t InputDimensionInfo::fuzz +int32_t InputDimensionInfo::max ``` **描述:** -记录各个坐标的分辨率。 +记录各个坐标的最大值 -### flat +### min + + ``` -int32_t InputDimensionInfo::flat +int32_t InputDimensionInfo::min ``` **描述:** -记录各个坐标的基准值。 +记录各个坐标的最小值 + ### range + ``` int32_t InputDimensionInfo::range ``` **描述:** -范围。 \ No newline at end of file +范围 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_event_cb.md b/zh-cn/device-dev/reference/hdi-apis/_input_event_cb.md new file mode 100644 index 0000000000000000000000000000000000000000..b91f20bfafd8c53c43ce9a481a9d368572730044 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_event_cb.md @@ -0,0 +1,43 @@ +# InputEventCb + + +## **概述** + +此结构体定义了输入事件回调函数并提供给Input服务使用。 + +**相关模块:** + +[Input](input.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| ([EventPkgCallback](#eventpkgcallback) )(const [InputEventPackage](_input_event_package.md) \*\*pkgs, uint32_t count, uint32_t devIndex) | 输入事件数据上报的回调函数。 | + + +## **类成员变量说明** + + +### EventPkgCallback + + +``` +void(* InputEventCb::EventPkgCallback) (const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex) +``` + +**描述:** + +输入事件数据上报的回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| eventData | 输入参数,驱动上报的Input事件数据。 | +| count | 输入参数,Input事件数据包的个数。 | +| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_event_package.md b/zh-cn/device-dev/reference/hdi-apis/_input_event_package.md similarity index 75% rename from zh-cn/device-dev/reference/hdi-apis/_event_package.md rename to zh-cn/device-dev/reference/hdi-apis/_input_event_package.md index d044d04799d0a1a4c8c726025cbb3624db1a7bf5..402db456d3bfe64396d9441dc458292e260e9a18 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_event_package.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_event_package.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Input事件数据包结构。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [type](#type) | 输入事件的属性 | | [code](#code) | 输入事件的特定编码项 | @@ -21,11 +23,6 @@ | [timestamp](#timestamp) | 输入事件对应的时间戳 | -## **详细描述** - -Input事件数据包结构。 - - ## **类成员变量说明** @@ -33,7 +30,7 @@ Input事件数据包结构。 ``` -uint32_t EventPackage::code +uint32_t InputEventPackage::code ``` **描述:** @@ -45,7 +42,7 @@ uint32_t EventPackage::code ``` -uint64_t EventPackage::timestamp +uint64_t InputEventPackage::timestamp ``` **描述:** @@ -57,7 +54,7 @@ uint64_t EventPackage::timestamp ``` -uint32_t EventPackage::type +uint32_t InputEventPackage::type ``` **描述:** @@ -69,7 +66,7 @@ uint32_t EventPackage::type ``` -int32_t EventPackage::value +int32_t InputEventPackage::value ``` **描述:** diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md b/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md index 56083e65b9a4c823d7c5fc42cc29ddbd3b910228..15f6265f62ba0cbecfe9168947ea9d38d228de6d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +扩展指令的数据结构。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [cmdCode](#cmdcode) | 指令对应的编码。 | | [cmdValue](#cmdvalue) | 指令传输的数据。 | -## **详细描述** - -扩展指令的数据结构。 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md b/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md index 372d6d7847b87f3d69a034e382093462d778e26e..9fa62eb2d7cb0ddf78799b6be36ac01ec01ec69d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,32 +15,24 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [HotPlugCallback](#hotplugcallback) ) (const [InputHotPlugEvent](_input_hotplug_event.md) \*event) | 热插拔事件上报的回调函数。 [更多...](#hotplugcallback) | - - -## **详细描述** - -此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 - - -## **类成员变量说明** +| ([HotPlugCallback](#hotplugcallback) )(const [InputHotPlugEvent](_input_hot_plug_event.md) \*event) | 热插拔事件上报的回调函数。 | ### HotPlugCallback - + ``` -void (* InputHostCb::HotPlugCallback) (const InputHotPlugEvent* event); +void(* InputHostCb::HotPlugCallback) (const InputHotPlugEvent *event) ``` **描述:** 热插拔事件上报的回调函数。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| event | 输入参数,上报的热插拔事件数据。 | \ No newline at end of file +| event | 输入参数,上报的热插拔事件数据。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md b/zh-cn/device-dev/reference/hdi-apis/_input_hot_plug_event.md similarity index 59% rename from zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md rename to zh-cn/device-dev/reference/hdi-apis/_input_hot_plug_event.md index 1bfe63ea8dbf62d5577191ab8c18ca4fa4af7096..120da873657221d2f2301b1f9caa4d8e7ec76543 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_hot_plug_event.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +热插拔事件数据包结构。 + +**相关模块:** -[Input](_input.md) +[Input](input.md) ## **汇总** @@ -13,16 +15,11 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [devIndex](#devindex) | 设备索引 | -| [devType](#devtype) | 设备类型 | -| [status](#status) | 设备状态| - - -## **详细描述** - -热插拔事件数据包结构。 +| [devIndex](#devindex) | 设备索引。 | +| [devType](#devtype) | 设备类型。 | +| [status](#status) | 设备状态。 | ## **类成员变量说明** @@ -30,31 +27,31 @@ ### devIndex - + ``` uint32_t InputHotPlugEvent::devIndex ``` **描述:** -设备索引。 +设备索引 ### devType - + ``` uint32_t InputHotPlugEvent::devType ``` **描述:** -设备类型。 +设备类型 ### status - + ``` uint32_t InputHotPlugEvent::status ``` @@ -62,5 +59,5 @@ uint32_t InputHotPlugEvent::status **描述:** 设备状态。 -- 1:离线 -- 0:在线。 + +1: 离线。 0: 在线。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_manager.md b/zh-cn/device-dev/reference/hdi-apis/_input_manager.md index 6f9a062e8fc5bec538ce8dcb044c1d0eb5fd0859..f3ba8b6b97959e9cc7cde4292f23be594c589155 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_manager.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_manager.md @@ -3,9 +3,13 @@ ## **概述** -**所属模块:** +提供Input设备管理相关的接口。 + +此类接口包含Input设备的扫描、打开和关闭、特定设备信息查询,以及所有设备列表信息获取等接口。 -[Input](_input.md) +**相关模块:** + +[Input](input.md) ## **汇总** @@ -13,20 +17,13 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [ScanInputDevice](#scaninputdevice) )(DevDesc \*staArr, uint32_t arrLen) | Input服务用于扫描所有在线设备。 [更多...](#scaninputdevice) | -| ( [OpenInputDevice](#openinputdevice) )(uint32_t devIndex) | Input服务打开对应设备的设备文件 [更多...](#openinputdevice) | -| ( [CloseInputDevice](#closeinputdevice) )(uint32_t devIndex) | Input服务关闭对应设备的设备文件 [更多...](#closeinputdevice) | -| ( [GetInputDevice](#getinputdevice) )(uint32_t devIndex, [InputDeviceInfo](_device_info.md) \*\*devInfo) | Input服务获取对应ID的设备信息 [更多...](#getinputdevice) | -| ( [GetInputDeviceList](#getinputdevicelist) )(uint32_t \*devNum, [InputDeviceInfo](_device_info.md) \*\*devList, uint32_t size) | Input服务获取所有Input设备列表的设备信息 [更多...](#getinputdevicelist) | - - -## **详细描述** - -提供Input设备管理相关的接口。 - -此类接口包含Input设备的扫描、打开和关闭、特定设备信息查询,以及所有设备列表信息获取等。 +| ([ScanInputDevice](#scaninputdevice) )([InputDevDesc](_input_dev_desc.md) \*staArr, uint32_t arrLen) | Input服务用于扫描所有在线设备。 | +| ([OpenInputDevice](#openinputdevice) )(uint32_t devIndex) | Input服务打开对应设备的设备文件。 | +| ([CloseInputDevice](#closeinputdevice) )(uint32_t devIndex) | Input服务关闭对应设备的设备文件。 | +| ([GetInputDevice](#getinputdevice) )(uint32_t devIndex, [InputDeviceInfo](_input_device_info.md) \*\*devInfo) | Input服务获取对应ID的设备信息。 | +| ([GetInputDeviceList](#getinputdevicelist) )(uint32_t \*devNum, [InputDeviceInfo](_input_device_info.md) \*\*devList, uint32_t size) | Input服务获取所有Input设备列表的设备信息。 | ## **类成员变量说明** @@ -35,7 +32,7 @@ ### CloseInputDevice -```cpp +``` int32_t(* InputManager::CloseInputDevice) (uint32_t devIndex) ``` @@ -43,23 +40,23 @@ int32_t(* InputManager::CloseInputDevice) (uint32_t devIndex) Input服务关闭对应设备的设备文件。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。| +| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetInputDevice -```cpp +``` int32_t(* InputManager::GetInputDevice) (uint32_t devIndex, InputDeviceInfo **devInfo) ``` @@ -67,24 +64,24 @@ int32_t(* InputManager::GetInputDevice) (uint32_t devIndex, InputDeviceInfo **de Input服务获取对应ID的设备信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -| devInfo | 输出参数,即devIndex对应的设备的设备信息,具体参考[InputDeviceInfo](_device_info.md)。 | +| devInfo | 输出参数,即devIndex对应的设备的设备信息,具体参考[InputDeviceInfo](_input_device_info.md)。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### GetInputDeviceList -```cpp +``` int32_t(* InputManager::GetInputDeviceList) (uint32_t *devNum, InputDeviceInfo **devList, uint32_t size) ``` @@ -92,25 +89,25 @@ int32_t(* InputManager::GetInputDeviceList) (uint32_t *devNum, InputDeviceInfo * Input服务获取所有Input设备列表的设备信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devNum | 输出参数,当前已经注册过的所有Input设备的总数。 | -| devList | 输出参数,Input设备列表所对应的设备信息,具体参考[InputDeviceInfo](_device_info.md)。 | -| size | 输入参数,即指定deviceList数组对应的元素个数。| +| devList | 输出参数,Input设备列表所对应的设备信息,具体参考[InputDeviceInfo](_input_device_info.md)。 | +| size | 输入参数,即指定deviceList数组对应的元素个数。 | -返回: +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### OpenInputDevice -```cpp +``` int32_t(* InputManager::OpenInputDevice) (uint32_t devIndex) ``` @@ -118,23 +115,23 @@ int32_t(* InputManager::OpenInputDevice) (uint32_t devIndex) Input服务打开对应设备的设备文件。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### ScanInputDevice -```cpp +``` int32_t(* InputManager::ScanInputDevice) (InputDevDesc *staArr, uint32_t arrLen) ``` @@ -142,15 +139,15 @@ int32_t(* InputManager::ScanInputDevice) (InputDevDesc *staArr, uint32_t arrLen) Input服务用于扫描所有在线设备。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | staArr | 输出参数,存放Input设备扫描信息的数组,信息包含设备索引以及设备类型。 | | arrLen | 输入参数,staArr数组的长度信息。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md b/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md deleted file mode 100644 index b6dd9371652a5af31acba24509d9bc040d8fe6c7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md +++ /dev/null @@ -1,47 +0,0 @@ -# InputEventCb - - -## **概述** - -**所属模块:** - -[Input](_input.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| ( [EventPkgCallback](#eventpkgcallback) )(const [InputEventPackage](_event_package.md) \*\*pkgs, uint32_t count, uint32_t devIndex) | 输入事件数据上报的回调函数。 [更多...](#eventpkgcallback) | - - -## **详细描述** - -此结构体定义了输入事件回调函数并提供给Input服务使用。 - - -## **类成员变量说明** - - -### EventPkgCallback - - -``` -void (* InputEventCb::EventPkgCallback)(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex); -``` - -**描述:** - -输入事件数据上报的回调函数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| pkgs| 驱动上报的Input事件数据。 | -| count | Input事件数据包的个数。 | -| devIndex | Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | - diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md b/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md index c940b505e9afd0e810da168a011514479fc285d6..05a265bcd9663ff490143df88032c8cc19bf972a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md +++ b/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md @@ -3,9 +3,13 @@ ## **概述** -**所属模块:** +提供Input设备数据上报相关的接口。 + +此类接口包含input设备的数据上报回调函数的注册和注销。 -[Input](_input.md) +**相关模块:** + +[Input](input.md) ## **汇总** @@ -13,19 +17,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [RegisterReportCallback](#registerreportcallback) )(uint32_t devIndex, [InputEventCb](_input_report_event_cb.md) \*callback) | 注册对应设备的回调函数。 [更多...](#registerreportcallback) | -| ( [UnregisterReportCallback](#unregisterreportcallback) )(uint32_t devIndex) | 注销对应设备的回调函数。 [更多...](#unregisterreportcallback) | -| ( [RegisterHotPlugCallback](#registerhotplugcallback) )([InputHostCb](_input_host_cb.md) \*callback) | 注册Input设备的热插拔回调函数。 [更多...](#registerhotplugcallback) | -| ( [UnregisterHotPlugCallback](#unregisterhotplugcallback) )(void) | 注销Input设备的热插拔回调函数。 [更多...](#unregisterhotplugcallback) | - - -## **详细描述** - -提供Input设备数据上报相关的接口。 - -此类接口包含Input设备的数据上报回调函数的注册和注销。 +| ([RegisterReportCallback](#registerreportcallback) )(uint32_t devIndex, [InputEventCb](_input_event_cb.md) \*callback) | 注册对应设备的回调函数。 | +| ([UnregisterReportCallback](#unregisterreportcallback) )(uint32_t devIndex) | 注销对应设备的回调函数。 | +| ([RegisterHotPlugCallback](#registerhotplugcallback) )([InputHostCb](_input_host_cb.md) \*callback) | 注册Input设备的热插拔回调函数。 | +| ([UnregisterHotPlugCallback](#unregisterhotplugcallback) )(void) | 注销Input设备的热插拔回调函数。 | ## **类成员变量说明** @@ -34,7 +31,7 @@ ### RegisterHotPlugCallback -```cpp +``` int32_t(* InputReporter::RegisterHotPlugCallback) (InputHostCb *callback) ``` @@ -44,23 +41,23 @@ int32_t(* InputReporter::RegisterHotPlugCallback) (InputHostCb *callback) Input服务通过此接口注册回调函数到hdi中,所有Input设备由此函数进行热插拔事件上报。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | callback | 输入参数,回调函数的函数指针。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### RegisterReportCallback -```cpp +``` int32_t(* InputReporter::RegisterReportCallback) (uint32_t devIndex, InputEventCb *callback) ``` @@ -70,24 +67,24 @@ int32_t(* InputReporter::RegisterReportCallback) (uint32_t devIndex, InputEventC Input服务通过此接口注册数据回调函数到hdi中,hdi通过此回调函数上报Input事件。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | | callback | 输入参数,回调函数的函数指针。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### UnregisterHotPlugCallback -```cpp +``` int32_t(* InputReporter::UnregisterHotPlugCallback) (void) ``` @@ -95,17 +92,17 @@ int32_t(* InputReporter::UnregisterHotPlugCallback) (void) 注销Input设备的热插拔回调函数。 -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 ### UnregisterReportCallback -```cpp +``` int32_t(* InputReporter::UnregisterReportCallback) (uint32_t devIndex) ``` @@ -113,14 +110,14 @@ int32_t(* InputReporter::UnregisterReportCallback) (uint32_t devIndex) 注销对应设备的回调函数。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。| +| devIndex | 输入参数,Input设备索引,用于标志多个Input设备,取值从0开始,最多支持32个设备。 | -**返回:** +**返回:** INPUT_SUCCESS 表示执行成功。 -其他值表示执行失败,具体错误码查看[RetStatus](_input.md#retstatus)。 +其他值表示执行失败,具体错误码查看[RetStatus](input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md b/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md index 9dc52678aecefe62852b3c53f430b051c1f39bb0..2e941168a2d4917bc64becf9fea5d23769db931e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义图层Alpha信息的结构体。 + +**相关模块:** [Display](_display.md) @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [enGlobalAlpha](_display.md#englobalalpha-12) | 全局alpha使能标志 | -| [enPixelAlpha](_display.md#enpixelalpha-12) | 像素alpha使能标志 | -| [alpha0](_display.md#alpha0-12) | alpha0值,取值范围:[0, 255] | -| [alpha1](_display.md#alpha1-12) | alpha1值,取值范围:[0, 255] | -| [gAlpha](_display.md#galpha) | 全局alpha值,取值范围:[0, 255] | - - -## **详细描述** - -定义图层Alpha信息的结构体。 +| [enGlobalAlpha](_display.md#englobalalpha-12) | 全局Alpha使能标志 | +| [enPixelAlpha](_display.md#enpixelalpha-12) | 像素Alpha使能标志 | +| [alpha0](_display.md#alpha0-12) | Alpha0值,取值范围:[0, 255] | +| [alpha1](_display.md#alpha1-12) | Alpha1值,取值范围:[0, 255] | +| [gAlpha](_display.md#galpha) | 全局Alpha值,取值范围:[0, 255] | diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md b/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md index 179aa36a396027e7cbae879faf591dcbfc977550..6f19f9bbb6d40719f9c9725735b455b0577bb6fe 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +图层Buffer,用于存放图层数据。 + +**相关模块:** [Display](_display.md) @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [fenceId](_display.md#fenceid) | buffer的fence号 | -| [width](_display.md#width-37) | buffer宽度 | -| [height](_display.md#height-37) | buffer高度 | +| [width](_display.md#width-39) | buffer宽度 | +| [height](_display.md#height-38) | buffer高度 | | [pitch](_display.md#pitch) | 一行数据所占字节数 | | [pixFormat](_display.md#pixformat-22) | 图层像素格式 | -| [data](_display.md#data) | 图层buffer数据 | +| [data](_display.md#data-12) | 图层buffer数据 | | [hdl](_display.md#hdl) | 图层buffer句柄 | - - -## **详细描述** - -图层Buffer,用于存放图层数据。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md index 6868d6a8388fc43ef53e245a960504741a1ebf6c..95fb4bf8040f3a5fac4b3ba9eab25ce0b900d31d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 + +**相关模块:** [Display](_display.md) @@ -13,55 +15,50 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ( [InitDisplay](#initdisplay) )(uint32_t devId) | 初始化显示设备。 [更多...](#initdisplay) | -| ( [DeinitDisplay](#deinitdisplay) )(uint32_t devId) | 取消初始化显示设备。 [更多...](#deinitdisplay) | -| ( [GetDisplayInfo](#getdisplayinfo) )(uint32_t devId, [DisplayInfo](_display_info.md) \*dispInfo) | 获取显示设备相关信息。 [更多...](#getdisplayinfo) | -| ( [CreateLayer](#createlayer) )(uint32_t devId, const [LayerInfo](_layer_info.md) \*layerInfo, uint32_t \*layerId) | 打开图层。 [更多...](#createlayer) | -| ( [CloseLayer](#closelayer) )(uint32_t devId, uint32_t layerId) | 关闭图层。 [更多...](#closelayer) | -| ( [SetLayerVisible](#setlayervisible) )(uint32_t devId, uint32_t layerId, bool visible) | 设置图层是否可见。 [更多...](#setlayervisible) | -| ( [GetLayerVisibleState](#getlayervisiblestate) )(uint32_t devId, uint32_t layerId, bool \*visible) | 获取图层是否可见状态。 [更多...](#getlayervisiblestate) | -| ( [SetLayerSize](#setlayersize) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 设置图层大小。 [更多...](#setlayersize) | -| ( [GetLayerSize](#getlayersize) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 获取图层大小。 [更多...](#getlayersize) | -| ( [SetLayerCrop](#setlayercrop) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 设置图层裁剪区域。 [更多...](#setlayercrop) | -| ( [SetLayerZorder](#setlayerzorder) )(uint32_t devId, uint32_t layerId, uint32_t zorder) | 设置图层Z轴次序。 [更多...](#setlayerzorder) | -| ( [GetLayerZorder](#getlayerzorder) )(uint32_t devId, uint32_t layerId, uint32_t \*zorder) | 获取图层Z轴次序。 [更多...](#getlayerzorder) | -| ( [SetLayerPreMulti](#setlayerpremulti) )(uint32_t devId, uint32_t layerId, bool preMul) | 设置图层预乘。 [更多...](#setlayerpremulti) | -| ( [GetLayerPreMulti](#getlayerpremulti) )(uint32_t devId, uint32_t layerId, bool \*preMul) | 获取图层预乘标识。 [更多...](#getlayerpremulti) | -| ( [SetLayerAlpha](#setlayeralpha) )(uint32_t devId, uint32_t layerId, [LayerAlpha](_layer_alpha.md) \*alpha) | 设置图层alpha值。 [更多...](#setlayeralpha) | -| ( [GetLayerAlpha](#getlayeralpha) )(uint32_t devId, uint32_t layerId, [LayerAlpha](_layer_alpha.md) \*alpha) | 获取图层alpha值。 [更多...](#getlayeralpha) | -| ( [SetLayerColorKey](#setlayercolorkey) )(uint32_t devId, uint32_t layerId, bool enable, uint32_t key) | 设置图层colorkey属性,在图层叠加时使用。 [更多...](#setlayercolorkey) | -| ( [GetLayerColorKey](#getlayercolorkey) )(uint32_t devId, uint32_t layerId, bool \*enable, uint32_t \*key) | 获取图层colorkey。 [更多...](#getlayercolorkey) | -| ( [SetLayerPalette](#setlayerpalette) )(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 设置图层调色板。 [更多...](#setlayerpalette) | -| ( [GetLayerPalette](#getlayerpalette) )(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 获取图层调色板。 [更多...](#getlayerpalette) | -| ( [SetTransformMode](#settransformmode) )(uint32_t devId, uint32_t layerId, [TransformType](_display.md#transformtype) type) | 设置图层变换模式,根据不同的场景设置图层的旋转、缩放、移位等。 [更多...](#settransformmode) | -| ( [SetLayerCompression](#setlayercompression) )(uint32_t devId, uint32_t layerId, int32_t compType) | 设置图层压缩功能 [更多...](#setlayercompression) | -| ( [GetLayerCompression](#getlayercompression) )(uint32_t devId, uint32_t layerId, int32_t \*compType) | 获取图层压缩功能是否打开。 [更多...](#getlayercompression) | -| ( [SetLayerDirtyRegion](#setlayerdirtyregion) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*region) | 设置图层刷新区域。 [更多...](#setlayerdirtyregion) | -| ( [GetLayerBuffer](#getlayerbuffer) )(uint32_t devId, uint32_t layerId, [LayerBuffer](_layer_buffer.md) \*buffer) | 获取图层的buffer。 [更多...](#getlayerbuffer) | -| ( [Flush](#flush) )(uint32_t devId, uint32_t layerId, [LayerBuffer](_layer_buffer.md) \*buffer) | 刷新图层。 [更多...](#flush) | -| ( [WaitForVBlank](#waitforvblank) )(uint32_t devId, uint32_t layerId, int32_t timeOut) | 实现等待帧消隐期到来功能。 [更多...](#waitforvblank) | -| ( [SnapShot](#snapshot) )(uint32_t devId, [LayerBuffer](_layer_buffer.md) \*buffer) | 实现抓图功能。 [更多...](#snapshot) | -| ( [SetLayerVisibleRegion](#setlayervisibleregion) )(uint32_t devId, uint32_t layerId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置一个图层的可见区域 [更多...](#setlayervisibleregion) | -| ( [SetLayerBuffer](#setlayerbuffer) )(uint32_t devId, uint32_t layerId, const BufferHandle \*buffer, int32_t fence) | 设置一个层的缓冲区。 [更多...](#setlayerbuffer) | -| ( [InvokeLayerCmd](#invokelayercmd) )(uint32_t devId, uint32_t layerId, uint32_t cmd,...) | 扩展接口 [更多...](#invokelayercmd) | -| ( [SetLayerCompositionType](#setlayercompositiontype) )(uint32_t devId, uint32_t layerId, [CompositionType](_display.md#compositiontype) type) | 设置客户端期望的组合类型 [更多...](#setlayercompositiontype) | -| ( [SetLayerBlendType](#setlayerblendtype) )(uint32_t devId, uint32_t layerId, [BlendType](_display.md#blendtype) type) | 设置混合类型 [更多...](#setlayerblendtype) | -| ( [SetLayerColorTransform](#setlayercolortransform) )(uint32_t devId, uint32_t layerId, const float \*matrix) | 设置图层当前的颜色转换矩阵。 [更多...](#setlayercolortransform) | -| ( [SetLayerColorDataSpace](#setlayercolordataspace) )(uint32_t devId, uint32_t layerId, [ColorDataSpace](_display.md#colordataspace) colorSpace) | 设置图层的颜色数据空间。 [更多...](#setlayercolordataspace) | -| ( [GetLayerColorDataSpace](#getlayercolordataspace) )(uint32_t devId, uint32_t layerId, [ColorDataSpace](_display.md#colordataspace) \*colorSpace) | 获取图层当前的颜色数据空间。 [更多...](#getlayercolordataspace) | -| ( [SetLayerMetaData](#setlayermetadata) )(uint32_t devId, uint32_t layerId, uint32_t num, const [HDRMetaData](_h_d_r_meta_data.md) \*metaData) | 设置图层的HDRmetaData。 [更多...](#setlayermetadata) | -| ( [SetLayerMetaDataSet](#setlayermetadataset) )(uint32_t devId, uint32_t layerId, [HDRMetadataKey](_display.md#hdrmetadatakey) key, uint32_t num, const uint8_t \*metaData) | 设置图层的metaData set。 [更多...](#setlayermetadataset) | -| ( [GetSupportedPresentTimestamp](#getsupportedpresenttimestamp) )(uint32_t devId, uint32_t layerId, [PresentTimestampType](_display.md#presenttimestamptype) \*type) | 获取图层支持的上屏时间戳类型。 [更多...](#getsupportedpresenttimestamp) | -| ( [GetHwPresentTimestamp](#gethwpresenttimestamp) )(uint32_t devId, uint32_t layerId, [PresentTimestamp](_present_timestamp.md) \*pts) | 获取图层的上屏时间戳信息。 [更多...](#gethwpresenttimestamp) | -| ( [SetLayerTunnelHandle](#setlayertunnelhandle) )(uint32_t devId, uint32_t layerId, ExtDataHandle \*handle) | 设置图层的tunnel句柄。 [更多...](#setlayertunnelhandle) | -| ( [GetLayerReleaseFence](#getlayerreleasefence) )(uint32_t devId, uint32_t layerId, int32_t \*fence) | 获取图层的同步栅栏。 [更多...](#getlayerreleasefence) | - - -## **详细描述** - -显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 +| ([InitDisplay](#initdisplay))(uint32_t devId) | 初始化显示设备。 | +| ([DeinitDisplay](#deinitdisplay))(uint32_t devId) | 取消初始化显示设备。 | +| ([GetDisplayInfo](#getdisplayinfo))(uint32_t devId, DisplayInfo \*dispInfo) | 获取显示设备相关信息。 | +| ([CreateLayer](#createlayer))(uint32_t devId, const LayerInfo \*layerInfo, uint32_t \*layerId) | 打开图层。 | +| ([CloseLayer](#closelayer))(uint32_t devId, uint32_t layerId) | 关闭图层。 | +| ([SetLayerVisible](#setlayervisible))(uint32_t devId, uint32_t layerId, bool visible) | 设置图层是否可见。 | +| ([GetLayerVisibleState](#getlayervisiblestate))(uint32_t devId, uint32_t layerId, bool \*visible) | 获取图层是否可见状态。 | +| ([SetLayerSize](#setlayersize))(uint32_t devId, uint32_t layerId, IRect \*rect) | 设置图层大小。 | +| ([GetLayerSize](#getlayersize))(uint32_t devId, uint32_t layerId, IRect \*rect) | 获取图层大小。 | +| ([SetLayerCrop](#setlayercrop))(uint32_t devId, uint32_t layerId, IRect \*rect) | 设置图层裁剪区域。 | +| ([SetLayerZorder](#setlayerzorder))(uint32_t devId, uint32_t layerId, uint32_t zorder) | 设置图层Z轴次序。 | +| ([GetLayerZorder](#getlayerzorder))(uint32_t devId, uint32_t layerId, uint32_t \*zorder) | 获取图层Z轴次序。 | +| ([SetLayerPreMulti](#setlayerpremulti))(uint32_t devId, uint32_t layerId, bool preMul) | 设置图层预乘。 | +| ([GetLayerPreMulti](#getlayerpremulti))(uint32_t devId, uint32_t layerId, bool \*preMul) | 获取图层预乘标识。 | +| ([SetLayerAlpha](#setlayeralpha))(uint32_t devId, uint32_t layerId, LayerAlpha \*alpha) | 设置图层Alpha值。 | +| ([GetLayerAlpha](#getlayeralpha))(uint32_t devId, uint32_t layerId, LayerAlpha \*alpha) | 获取图层Alpha值。 | +| ([SetLayerColorKey](#setlayercolorkey))(uint32_t devId, uint32_t layerId, bool enable, uint32_t key) | 设置图层colorkey属性,在图层叠加时使用。 | +| ([GetLayerColorKey](#getlayercolorkey))(uint32_t devId, uint32_t layerId, bool \*enable, uint32_t \*key) | 获取图层colorkey。 | +| ([SetLayerPalette](#setlayerpalette))(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 设置图层调色板。 | +| ([GetLayerPalette](#getlayerpalette))(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 获取图层调色板。 | +| ([SetTransformMode](#settransformmode))(uint32_t devId, uint32_t layerId, TransformType type) | 设置图层变换模式,根据不同的场景设置图层的旋转、缩放、移位等。 | +| ([SetLayerCompression](#setlayercompression))(uint32_t devId, uint32_t layerId, int32_t compType) | 设置图层压缩功能。 | +| ([GetLayerCompression](#getlayercompression))(uint32_t devId, uint32_t layerId, int32_t \*compType) | 获取图层压缩功能是否打开。 | +| ([SetLayerDirtyRegion](#setlayerdirtyregion))(uint32_t devId, uint32_t layerId, IRect \*region) | 设置图层刷新区域。 | +| ([GetLayerBuffer](#getlayerbuffer))(uint32_t devId, uint32_t layerId, LayerBuffer \*buffer) | 获取图层的buffer。 | +| ([Flush](#flush))(uint32_t devId, uint32_t layerId, LayerBuffer \*buffer) | 刷新图层。 | +| ([WaitForVBlank](#waitforvblank))(uint32_t devId, uint32_t layerId, int32_t timeOut) | 实现等待帧消隐期到来功能。 | +| ([SnapShot](#snapshot))(uint32_t devId, LayerBuffer \*buffer) | 实现抓图功能。 | +| ([SetLayerVisibleRegion](#setlayervisibleregion))(uint32_t devId, uint32_t layerId, uint32_t num, IRect \*rect) | 设置一个图层的可见区域。 | +| ([SetLayerBuffer](#setlayerbuffer))(uint32_t devId, uint32_t layerId, const BufferHandle \*buffer, int32_t fence) | 设置一个层的缓冲区。 | +| ([InvokeLayerCmd](#invokelayercmd))(uint32_t devId, uint32_t layerId, uint32_t cmd,...) | 扩展接口。 | +| ([SetLayerCompositionType](#setlayercompositiontype))(uint32_t devId, uint32_t layerId, CompositionType type) | 设置客户端期望的组合类型。 | +| ([SetLayerBlendType](#setlayerblendtype))(uint32_t devId, uint32_t layerId, BlendType type) | 设置混合类型。 | +| ([SetLayerColorTransform](#setlayercolortransform))(uint32_t devId, uint32_t layerId, const float \*matrix) | 设置图层当前的颜色转换矩阵。 | +| ([SetLayerColorDataSpace](#setlayercolordataspace))(uint32_t devId, uint32_t layerId, ColorDataSpace colorSpace) | 设置图层的颜色数据空间。 | +| ([GetLayerColorDataSpace](#getlayercolordataspace))(uint32_t devId, uint32_t layerId, ColorDataSpace \*colorSpace) | 获取图层当前的颜色数据空间。 | +| ([SetLayerMetaData](#setlayermetadata))(uint32_t devId, uint32_t layerId, uint32_t num, const HDRMetaData \*metaData) | 设置图层的HDRmetaData。 | +| ([SetLayerMetaDataSet](#setlayermetadataset))(uint32_t devId, uint32_t layerId, HDRMetadataKey key, uint32_t num, const uint8_t \*metaData) | 设置图层的metaData set。 | +| ([GetSupportedPresentTimestamp](#getsupportedpresenttimestamp))(uint32_t devId, uint32_t layerId, PresentTimestampType \*type) | 获取图层支持的上屏时间戳类型。 | +| ([GetHwPresentTimestamp](#gethwpresenttimestamp))(uint32_t devId, uint32_t layerId, PresentTimestamp \*pts) | 获取图层的上屏时间戳信息。 | +| ([SetLayerTunnelHandle](#setlayertunnelhandle))(uint32_t devId, uint32_t layerId, ExtDataHandle \*handle) | 设置图层的tunnel句柄。 | +| ([GetLayerReleaseFence](#getlayerreleasefence))(uint32_t devId, uint32_t layerId, int32_t \*fence) | 获取图层的同步栅栏。 | ## **类成员变量说明** @@ -80,22 +77,22 @@ int32_t(* LayerFuncs::CloseLayer) (uint32_t devId, uint32_t layerId) 在完成显示后,如果不在需要使用图层,调用关闭图层接口关闭图层。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 | | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** -**OpenLayer** +[CreateLayer](#createlayer) ### CreateLayer @@ -111,7 +108,7 @@ int32_t(* LayerFuncs::CreateLayer) (uint32_t devId, const LayerInfo *layerInfo, GUI在使用图层时,需要先根据图层信息打开图层,打开图层成功可获得图层ID,根据图层ID使用图层各接口。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -119,13 +116,13 @@ GUI在使用图层时,需要先根据图层信息打开图层,打开图层 | layerInfo | 输入参数,图层信息,上层GUI打开图层时需传递图层信息,包括图层类型,图层大小,像素格式等信息。 | | layerId | 输入参数,图层ID,打开图层成功后返回给GUI的图层ID,用于标识唯一的图层。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [CloseLayer](#closelayer) @@ -141,19 +138,19 @@ int32_t(* LayerFuncs::DeinitDisplay) (uint32_t devId) 取消初始化显示设备。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [InitDisplay](#initdisplay) @@ -171,7 +168,7 @@ int32_t(* LayerFuncs::Flush) (uint32_t devId, uint32_t layerId, LayerBuffer *buf 将buffer显示数据刷新到指定的layerId图层上,实现图像数据显示到屏幕上。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -179,7 +176,7 @@ int32_t(* LayerFuncs::Flush) (uint32_t devId, uint32_t layerId, LayerBuffer *buf | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | buffer | 输出参数,待刷新的buffer。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -197,14 +194,14 @@ int32_t(* LayerFuncs::GetDisplayInfo) (uint32_t devId, DisplayInfo *dispInfo) 获取显示设备相关信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 | | dispInfo | 输出参数,显示相关信息。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -222,7 +219,7 @@ int32_t(* LayerFuncs::GetHwPresentTimestamp) (uint32_t devId, uint32_t layerId, 获取图层的上屏时间戳信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -230,7 +227,7 @@ int32_t(* LayerFuncs::GetHwPresentTimestamp) (uint32_t devId, uint32_t layerId, | layerId | 输入参数,指示需要操作的图层ID。 | | pts | 输出参数,保存图层的上屏时间戳信息, 由接口实现层进行写入。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -248,7 +245,7 @@ int32_t(* LayerFuncs::GetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlp 获取图层alpha值。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -256,13 +253,13 @@ int32_t(* LayerFuncs::GetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlp | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | alpha | 输出参数,保存获取的图层alpha值。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerAlpha](#setlayeralpha) @@ -280,7 +277,7 @@ int32_t(* LayerFuncs::GetLayerBuffer) (uint32_t devId, uint32_t layerId, LayerBu 向buffer中绘图后,调用Flush接口显示到屏幕上。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -288,13 +285,13 @@ int32_t(* LayerFuncs::GetLayerBuffer) (uint32_t devId, uint32_t layerId, LayerBu | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | buffer | 输出参数,保存获取的图层buffer。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [Flush](#flush) @@ -310,7 +307,7 @@ int32_t(* LayerFuncs::GetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, 获取图层当前的颜色数据空间。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -318,7 +315,7 @@ int32_t(* LayerFuncs::GetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, | layerId | 输入参数,指示需要操作的图层ID。 | | colorSpace | 输出参数,保存对应图层的颜色数据空间。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -336,7 +333,7 @@ int32_t(* LayerFuncs::GetLayerColorKey) (uint32_t devId, uint32_t layerId, bool 获取图层colorkey。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -345,13 +342,13 @@ int32_t(* LayerFuncs::GetLayerColorKey) (uint32_t devId, uint32_t layerId, bool | enable | 输出参数,保存获取的enable色键使能标识。 | | key | 输出参数,保存获取的色键值,即颜色值。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerColorKey](#setlayercolorkey) @@ -367,7 +364,7 @@ int32_t(* LayerFuncs::GetLayerCompression) (uint32_t devId, uint32_t layerId, in 获取图层压缩功能是否打开。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -375,13 +372,13 @@ int32_t(* LayerFuncs::GetLayerCompression) (uint32_t devId, uint32_t layerId, in | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | compType | 输出参数,保存获取的图层压缩功能状态。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerCompression](#setlayercompression) @@ -397,7 +394,7 @@ int32_t(* LayerFuncs::GetLayerPalette) (uint32_t devId, uint32_t layerId, uint32 获取图层调色板。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -406,13 +403,13 @@ int32_t(* LayerFuncs::GetLayerPalette) (uint32_t devId, uint32_t layerId, uint32 | palette | 输出参数,保存获取的图层调色板。 | | len | 输入参数,调色板长度。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerPalette](#setlayerpalette) @@ -428,7 +425,7 @@ int32_t(* LayerFuncs::GetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool 获取图层预乘标识。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -436,13 +433,13 @@ int32_t(* LayerFuncs::GetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | preMul | 输出参数,保存获取的图层预乘使能标识。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerPreMulti](#setlayerpremulti) @@ -458,7 +455,7 @@ int32_t(* LayerFuncs::GetLayerReleaseFence) (uint32_t devId, uint32_t layerId, i 获取图层的同步栅栏。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -466,7 +463,7 @@ int32_t(* LayerFuncs::GetLayerReleaseFence) (uint32_t devId, uint32_t layerId, i | layerId | 输入参数,指示需要操作的图层ID。 | | fence | 输出参数,保存图层的 release fence, 由接口实现层进行写入。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -484,7 +481,7 @@ int32_t(* LayerFuncs::GetLayerSize) (uint32_t devId, uint32_t layerId, IRect *re 获取图层大小。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -492,13 +489,13 @@ int32_t(* LayerFuncs::GetLayerSize) (uint32_t devId, uint32_t layerId, IRect *re | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | rect | 输出参数,保存获取的图层大小。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerSize](#setlayersize) @@ -514,7 +511,7 @@ int32_t(* LayerFuncs::GetLayerVisibleState) (uint32_t devId, uint32_t layerId, b 获取图层是否可见状态。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -522,13 +519,13 @@ int32_t(* LayerFuncs::GetLayerVisibleState) (uint32_t devId, uint32_t layerId, b | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | visible | 输出参数,保存获取的图层可见状态,true表示图层可见,false表示图层不可见。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerVisible](#setlayervisible) @@ -544,7 +541,7 @@ int32_t(* LayerFuncs::GetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_ 获取图层Z轴次序。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -552,13 +549,13 @@ int32_t(* LayerFuncs::GetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_ | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | zorder | 输出参数,保存获取的图层Z轴次序,为整数值,取值范围为[0, 255],值越大图层越往上排列。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [SetLayerZorder](#setlayerzorder) @@ -574,7 +571,7 @@ int32_t(* LayerFuncs::GetSupportedPresentTimestamp) (uint32_t devId, uint32_t la 获取图层支持的上屏时间戳类型。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -582,7 +579,7 @@ int32_t(* LayerFuncs::GetSupportedPresentTimestamp) (uint32_t devId, uint32_t la | layerId | 输入参数,指示需要操作的图层ID。 | | type | 输出参数,保存图层支持的上屏时间戳类型, 由接口实现层进行写入。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -600,19 +597,19 @@ int32_t(* LayerFuncs::InitDisplay) (uint32_t devId) 初始化显示设备。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [DeinitDisplay](#deinitdisplay) @@ -628,7 +625,7 @@ int32_t(* LayerFuncs::InvokeLayerCmd) (uint32_t devId, uint32_t layerId, uint32_ 扩展接口 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -636,7 +633,7 @@ int32_t(* LayerFuncs::InvokeLayerCmd) (uint32_t devId, uint32_t layerId, uint32_ | layerId | 输入参数,层ID,唯一标识一个层。可以对该层进行操作。 | | cmd | 输入参数,表示扩展cmd,用于识别不同的意图。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -654,7 +651,7 @@ int32_t(* LayerFuncs::SetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlp 设置图层alpha值。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -662,13 +659,13 @@ int32_t(* LayerFuncs::SetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlp | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | alpha | 输入参数,待设置的图层 alpha 值。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerAlpha](#getlayeralpha) @@ -684,7 +681,7 @@ int32_t(* LayerFuncs::SetLayerBlendType) (uint32_t devId, uint32_t layerId, Blen 设置混合类型 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -692,7 +689,7 @@ int32_t(* LayerFuncs::SetLayerBlendType) (uint32_t devId, uint32_t layerId, Blen | layerId | 输入参数,层ID,唯一标识一个层。可以对该层进行操作。 | | type | 输入参数,指示混合类型。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -710,7 +707,7 @@ int32_t(* LayerFuncs::SetLayerBuffer) (uint32_t devId, uint32_t layerId, const B 设置一个层的缓冲区。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -719,7 +716,7 @@ int32_t(* LayerFuncs::SetLayerBuffer) (uint32_t devId, uint32_t layerId, const B | buffer | 输入参数,指示缓冲区句柄的指针,该指针包含所有用于合成的缓冲区的所有信息。 | | fence | 输入参数,同步文件的fd。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -737,7 +734,7 @@ int32_t(* LayerFuncs::SetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, 设置图层的颜色数据空间。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -745,7 +742,7 @@ int32_t(* LayerFuncs::SetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, | layerId | 输入参数,指示需要操作的图层ID。 | | colorSpace | 输入参数,表示需要设置的颜色数据空间。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -763,7 +760,7 @@ int32_t(* LayerFuncs::SetLayerColorKey) (uint32_t devId, uint32_t layerId, bool 设置图层colorkey属性,在图层叠加时使用。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -772,13 +769,13 @@ int32_t(* LayerFuncs::SetLayerColorKey) (uint32_t devId, uint32_t layerId, bool | enable | 输入参数,待设置的色键使能标识。 | | key | 输入参数,待设置的色键值,即颜色值。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerColorKey](#getlayercolorkey) @@ -794,7 +791,7 @@ int32_t(* LayerFuncs::SetLayerColorTransform) (uint32_t devId, uint32_t layerId, 设置图层当前的颜色转换矩阵。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -802,7 +799,7 @@ int32_t(* LayerFuncs::SetLayerColorTransform) (uint32_t devId, uint32_t layerId, | layerId | 输入参数,指示需要操作的图层ID。 | | matrix | 输入参数,表示需要设置的颜色转换模式。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -818,9 +815,9 @@ int32_t(* LayerFuncs::SetLayerCompositionType) (uint32_t devId, uint32_t layerId **描述:** -设置客户端期望的组合类型 +设置客户端期望的组合类型。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -828,7 +825,7 @@ int32_t(* LayerFuncs::SetLayerCompositionType) (uint32_t devId, uint32_t layerId | layerId | 输入参数,层ID,唯一标识一个层。可以对该层进行操作。 | | type | 输入参数,指示客户端期望的组合类型。它可能随实现而变化。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -844,11 +841,11 @@ int32_t(* LayerFuncs::SetLayerCompression) (uint32_t devId, uint32_t layerId, in **描述:** -设置图层压缩功能 +设置图层压缩功能。 在特定场景下,需要对图像数据进行压缩,可设置启动或关闭图层压缩功能。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -856,13 +853,13 @@ int32_t(* LayerFuncs::SetLayerCompression) (uint32_t devId, uint32_t layerId, in | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | compType | 输入参数,图层压缩使能标识。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerCompression](#getlayercompression) @@ -878,7 +875,7 @@ int32_t(* LayerFuncs::SetLayerCrop) (uint32_t devId, uint32_t layerId, IRect *re 设置图层裁剪区域。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -886,7 +883,7 @@ int32_t(* LayerFuncs::SetLayerCrop) (uint32_t devId, uint32_t layerId, IRect *re | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | rect | 输入参数,待设置的裁剪区域。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -906,7 +903,7 @@ int32_t(* LayerFuncs::SetLayerDirtyRegion) (uint32_t devId, uint32_t layerId, IR GUI图形系统绘制好图像数据后,在调用Flush接口刷新屏幕之前需要设置图层刷新区域。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -914,7 +911,7 @@ GUI图形系统绘制好图像数据后,在调用Flush接口刷新屏幕之前 | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | region | 输入参数,待设置的刷新区域。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -932,7 +929,7 @@ int32_t(* LayerFuncs::SetLayerMetaData) (uint32_t devId, uint32_t layerId, uint3 设置图层的HDRmetaData。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -941,7 +938,7 @@ int32_t(* LayerFuncs::SetLayerMetaData) (uint32_t devId, uint32_t layerId, uint3 | num | 输入参数,metadata 数组个数。 | | metaData | 输入参数,表示需要设置的 metadata 数组首地址。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -959,17 +956,17 @@ int32_t(* LayerFuncs::SetLayerMetaDataSet) (uint32_t devId, uint32_t layerId, HD 设置图层的metaData set。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,指示需要操作的设备ID。 | | layerId | 输入参数,指示需要操作的图层ID。 | -| key | 输入参数,表示需要设置的 HDRMetadataKey。 | +| key | 输入参数,表示需要设置的[HDRMetadataKey](_display.md#hdrmetadatakey)。 | | num | 输入参数,metadata 数组个数。 | | metaData | 输入参数,表示需要设置的 metadata 数组首地址, 数据类型为uint8_t。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -987,7 +984,7 @@ int32_t(* LayerFuncs::SetLayerPalette) (uint32_t devId, uint32_t layerId, uint32 设置图层调色板。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -996,13 +993,13 @@ int32_t(* LayerFuncs::SetLayerPalette) (uint32_t devId, uint32_t layerId, uint32 | palette | 输入参数,待设置的图层调色板。 | | len | 输入参数,调色板长度。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerPalette](#getlayerpalette) @@ -1018,7 +1015,7 @@ int32_t(* LayerFuncs::SetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool 设置图层预乘。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1026,13 +1023,13 @@ int32_t(* LayerFuncs::SetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | preMul | 输入参数,待设置的图层预乘使能标识,1表示使能图层预乘,0表示不使能图层预乘。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerPreMulti](#getlayerpremulti) @@ -1048,7 +1045,7 @@ int32_t(* LayerFuncs::SetLayerSize) (uint32_t devId, uint32_t layerId, IRect *re 设置图层大小。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1056,13 +1053,13 @@ int32_t(* LayerFuncs::SetLayerSize) (uint32_t devId, uint32_t layerId, IRect *re | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | rect | 输入参数,待设置的图层大小,单位为像素。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerSize](#getlayersize) @@ -1078,7 +1075,7 @@ int32_t(* LayerFuncs::SetLayerTunnelHandle) (uint32_t devId, uint32_t layerId, E 设置图层的tunnel句柄。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1086,7 +1083,7 @@ int32_t(* LayerFuncs::SetLayerTunnelHandle) (uint32_t devId, uint32_t layerId, E | layerId | 输入参数,指示需要操作的图层ID。 | | handle | 输入参数,表示需要设置的句柄。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -1106,7 +1103,7 @@ int32_t(* LayerFuncs::SetLayerVisible) (uint32_t devId, uint32_t layerId, bool v 不可见情况下图层不显示在屏幕上,可见情况下图层显示在屏幕上。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1114,13 +1111,13 @@ int32_t(* LayerFuncs::SetLayerVisible) (uint32_t devId, uint32_t layerId, bool v | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | visible | 输入参数,待设置的图层可见标识,设置true表示图层可见,设置false表示图层不可见。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerVisibleState](#getlayervisiblestate) @@ -1136,16 +1133,16 @@ int32_t(* LayerFuncs::SetLayerVisibleRegion) (uint32_t devId, uint32_t layerId, 设置一个图层的可见区域 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备的ID。取值范围为0 ~ 4,其中0表示第一个显示设备,4表示最后一个显示设备。 | | layerId | 输入参数,层ID,唯一标识一个层。可以对该层进行操作。 | -| num | 输入参数,指定rect的计数,该区域包含多个 [IRect](_i_rect.md),num表示该区域中有多少个rect区域。 | +| num | 输入参数,指定rect的计数,该区域包含多个[IRect](_i_rect.md),num表示该区域中有多少个rect区域。 | | rect | 输出参数,rectes对象的指针。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -1165,7 +1162,7 @@ int32_t(* LayerFuncs::SetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_ 图层的Z序值越大,图层越靠上显示。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1173,13 +1170,13 @@ int32_t(* LayerFuncs::SetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_ | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | zorder | 输入参数,待设置的图层Z序,为整数值,取值范围为[0, 255],值越大图层越往上排列。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 其他值表示执行失败,具体错误码查看[DispErrCode](_display.md#disperrcode)。 -**参见:** +**参见:** [GetLayerZorder](#getlayerzorder) @@ -1195,7 +1192,7 @@ int32_t(* LayerFuncs::SetTransformMode) (uint32_t devId, uint32_t layerId, Trans 设置图层变换模式,根据不同的场景设置图层的旋转、缩放、移位等。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1203,7 +1200,7 @@ int32_t(* LayerFuncs::SetTransformMode) (uint32_t devId, uint32_t layerId, Trans | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | type | 输入参数,待设置的图层变换模式。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -1225,14 +1222,14 @@ int32_t(* LayerFuncs::SnapShot) (uint32_t devId, LayerBuffer *buffer) otherwise. -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | devId | 输入参数,显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 | | buffer | 输出参数,保存截屏的buffer信息。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 @@ -1252,7 +1249,7 @@ int32_t(* LayerFuncs::WaitForVBlank) (uint32_t devId, uint32_t layerId, int32_t 该函数会让系统等待,直到帧消隐期到来,用于软件和硬件之间的同步。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | @@ -1260,7 +1257,7 @@ int32_t(* LayerFuncs::WaitForVBlank) (uint32_t devId, uint32_t layerId, int32_t | layerId | 输入参数,图层ID,图层的唯一标识,根据图层ID操作图层。 | | timeOut | 输入参数,超时时间,在设置的超时时间后,没有等到帧消隐期到来则超时返回。 | -**返回:** +**返回:** DISPLAY_SUCCESS 表示执行成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_info.md b/zh-cn/device-dev/reference/hdi-apis/_layer_info.md index dec0da93d00b2149b713cc2369472137edc4cb8f..2a37f273707a9af958cdac308f26f6cabf525855 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_layer_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_info.md @@ -3,7 +3,11 @@ ## **概述** -**所属模块:** +定义图层信息结构体。 + +在创建图层时,需要将LayerInfo传递给创建图层接口,创建图层接口根据图层信息创建相应图层。 + +**相关模块:** [Display](_display.md) @@ -13,17 +17,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](_display.md#width-27) | 图层宽度 | -| [height](_display.md#height-27) | 图层高度 | -| [type](_display.md#type-13) | 图层类型,包括图形层、视频层和媒体播放模式。 | +| [width](_display.md#width-29) | 图层宽度 | +| [height](_display.md#height-28) | 图层高度 | +| [type](_display.md#type-17) | 图层类型,包括图形层、视频层和媒体播放模式。 | | [bpp](_display.md#bpp) | 每像素所占bit数 | | [pixFormat](_display.md#pixformat-12) | 图层像素格式 | - - -## **详细描述** - -定义图层信息结构体。 - -在创建图层时,需要将LayerInfo传递给创建图层接口,创建图层接口根据图层信息创建相应图层。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light.md b/zh-cn/device-dev/reference/hdi-apis/_light.md deleted file mode 100644 index 62e49861d2aaad72185e10e690f2b52c59a93309..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_light.md +++ /dev/null @@ -1,159 +0,0 @@ -# Light - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [light_if.h](light__if_8h.md) | 声明light模块的通用API,可用于获取灯ID、打开或关闭灯、并设置灯光亮度和闪烁模式。 | -| [light_type.h](light_8typeh.md) | 定义灯的数据结构,包括灯ID、灯的模式、灯的闪烁模式和持续时间、灯的状态、灯的效果。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [LightFlashEffect](_light_flash_effect.md) | 定义闪烁参数。 [更多...](_light_flash_effect.md) | -| [LightEffect](_light_effect.md) | 定义灯的效果参数。 [更多...](_light_effect.md) | -| [LightInfo](_light_info.md) | 定义灯的基本信息。 [更多...](_light_info.md) | -| [LightInterface](_light_interface.md) | 定义可以在灯上执行的基本操作。 [更多...](_light_interface.md) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [LightStatus](#lightstatus) { LIGHT_SUCCESS = 0, LIGHT_NOT_SUPPORT = -1, LIGHT_NOT_FLASH = -2, LIGHT_NOT_BRIGHTNESS = -3 } | 枚举灯模块的状态值。 [更多...](#lightstatus) | -| [LightId](#lightid) { LIGHT_ID_NONE = 0, LIGHT_ID_BATTERY = 1, LIGHT_ID_NOTIFICATIONS = 2, LIGHT_ID_ATTENTION = 3,   LIGHT_ID_BUTT = 4 } | 枚举灯类型 [更多...](#lightid) | -| [LightFlashMode](#lightflashmode) { LIGHT_FLASH_NONE = 0, LIGHT_FLASH_TIMED = 1, LIGHT_FLASH_BUTT = 2 } | 枚举灯的模式 [更多...](#lightflashmode) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [NewLightInterfaceInstance](#newlightinterfaceinstance) (void) | 创建LightInterface实例。 [更多...](#newlightinterfaceinstance) | -| [FreeLightInterfaceInstance](#freelightinterfaceinstance) (void) | 释放LightInterface实例和相关资源。 [更多...](#freelightinterfaceinstance) | - - -## **详细描述** - -灯模块对灯服务提供通用的接口能力。 - -灯模块为灯服务提供通用的接口去访问灯驱动。 服务获取灯驱动对象或代理后,可以调用相关的APIs接口获取灯信息、打开或关闭灯,并根据灯ID设置灯闪烁模式。 - -**Since:** - -3.1 - - -## **枚举类型说明** - - -### LightFlashMode - - -``` -enum LightFlashMode -``` - -**描述:** - -枚举灯的模式 - - | 枚举值 | 描述 | -| -------- | -------- | -| LIGHT_FLASH_NONE | 常亮。 | -| LIGHT_FLASH_TIMED | 闪烁。 | -| LIGHT_FLASH_BUTT | 无效模式。 | - - -### LightId - - -``` -enum LightId -``` - -**描述:** - -枚举灯类型 - - | 枚举值 | 描述 | -| -------- | -------- | -| LIGHT_ID_NONE | 未知ID。 | -| LIGHT_ID_BATTERY | 电源指示灯。 | -| LIGHT_ID_NOTIFICATIONS | 通知灯。 | -| LIGHT_ID_ATTENTION | 报警灯。 | -| LIGHT_ID_BUTT | 无效ID。 | - - -### LightStatus - - -``` -enum LightStatus -``` - -**描述:** - -枚举灯模块的状态值。 - - | 枚举值 | 描述 | -| -------- | -------- | -| LIGHT_SUCCESS | 操作成功。 | -| LIGHT_NOT_SUPPORT | 灯ID不支持。 | -| LIGHT_NOT_FLASH | 设置闪烁不支持。 | -| LIGHT_NOT_BRIGHTNESS | 设置亮度不支持。 | - - -## **函数说明** - - -### FreeLightInterfaceInstance() - - -``` -int32_t FreeLightInterfaceInstance (void ) -``` - -**描述:** - -释放LightInterface实例和相关资源。 - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -3.1 - - -### NewLightInterfaceInstance() - - -``` -const struct LightInterface* NewLightInterfaceInstance (void ) -``` - -**描述:** - -创建LightInterface实例。 - -创建的LightInterface实例可用于执行相关的灯控制操作。 - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -3.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_effect.md b/zh-cn/device-dev/reference/hdi-apis/_light_effect.md deleted file mode 100644 index 63a331afec767e0ed728758026263075c7cbed70..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_light_effect.md +++ /dev/null @@ -1,57 +0,0 @@ -# LightEffect - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### Public 属性 - -| Public 属性 | 描述 | -| -------- | -------- | -| [lightBrightness](#lightbrightness) | 亮度值。 | -| [flashEffect](#flasheffect) | 闪烁模式。 | - - -## **详细描述** - -定义灯的效果参数。 - -参数包括亮度和闪烁模式。 - -**Since:** - -3.1 - - -## **类成员变量说明** - - -### flashEffect - - -``` -struct LightFlashEffect LightEffect::flashEffect -``` - -**描述:** - -闪烁模式。详见[LightFlashEffect](_light_flash_effect.md)。 - - -### lightBrightness - - -``` -int32_t LightEffect::lightBrightness -``` - -**描述:** - -亮度值:Bits 24–31为扩展位,Bits 16–23为红色,Bits 8–15为绿色,Bits 0–7为蓝色。 如果相对应的字节段不等于0,表示打开相应颜色的灯。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md b/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md deleted file mode 100644 index 9a8a9123a99ee397b85ff88fc9158af0a16d446e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md +++ /dev/null @@ -1,70 +0,0 @@ -# LightFlashEffect - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [flashMode](#flashmode) | 闪烁模式。 | -| [onTime](#ontime) | 表示灯在闪烁期间点亮时持续的时间(毫秒)。 | -| [offTime](#offtime) | 表示灯在闪烁期间熄灭时持续的时间(毫秒)。 | - - -## **详细描述** - -定义闪烁参数。 - -这些参数包括闪烁模式以及闪烁期间指示灯的打开和关闭时间。 - -**Since:** - -3.1 - - -## **类成员变量说明** - - -### flashMode - - -``` -int32_t LightFlashEffect::flashMode -``` - -**描述:** - -闪烁模式,详见[LightFlashMode](_light.md#lightflashmode)。 - - -### offTime - - -``` -int32_t LightFlashEffect::offTime -``` - -**描述:** - -表示灯在闪烁期间熄灭时持续的时间(毫秒)。 - - -### onTime - - -``` -int32_t LightFlashEffect::onTime -``` - -**描述:** - -表示灯在闪烁期间点亮时持续的时间(毫秒)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_info.md b/zh-cn/device-dev/reference/hdi-apis/_light_info.md deleted file mode 100644 index 20d8387e71e256aaefa055c21bd9b66d208379d2..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_light_info.md +++ /dev/null @@ -1,57 +0,0 @@ -# LightInfo - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [lightId](#lightid) | 灯ID | -| [reserved](#reserved) | 自定义扩展信息 | - - -## **详细描述** - -定义灯的基本信息。 - -基本的灯信息包括灯ID和自定义扩展信息。 - -**Since:** - -3.1 - - -## **类成员变量说明** - - -### lightId - - -``` -uint32_t LightInfo::lightId -``` - -**描述:** - -灯ID,详见[LightId](_light.md#lightid)。 - - -### reserved - - -``` -int32_t LightInfo::reserved -``` - -**描述:** - -自定义扩展信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_interface.md b/zh-cn/device-dev/reference/hdi-apis/_light_interface.md deleted file mode 100644 index 9621d96fb11e3d7a3df73214c9aa2d5a45f0b252..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_light_interface.md +++ /dev/null @@ -1,109 +0,0 @@ -# LightInterface - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### Public 属性 - -| Public 属性 | 描述 | -| -------- | -------- | -| ( [GetLightInfo](#getlightinfo) )([out] struct [LightInfo](_light_info.md) \*\*lightInfo, [out] uint32_t \*count) | 获取当前系统中所有类型的灯信息。 [更多...](#getlightinfo) | -| ( [TurnOnLight](#turnonlight) )([in] uint32_t lightId, [in] struct [LightEffect](_light_effect.md) \*effect) | 根据指定的灯ID打开列表中的可用灯。 [更多...](#turnonlight) | -| ( [TurnOffLight](#turnofflight) )([in] uint32_t lightId) | 根据指定的灯ID关闭列表中的可用灯。 [更多...](#turnofflight) | - - -## **详细描述** - -定义可以在灯上执行的基本操作。 - -操作包括获取灯的信息、打开或关闭灯、设置灯的亮度和闪烁模式。 - - -## **类成员变量说明** - - -### GetLightInfo - - -``` -int32_t(* LightInterface::GetLightInfo) ([out] struct LightInfo **lightInfo,[out] uint32_t *count) -``` - -**描述:** - -获取当前系统中所有类型的灯信息。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| lightInfo | 表示指向灯信息的二级指针,详见[LightInfo](_light_info.md)。 | -| count | 表示指向灯数量的指针。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### TurnOffLight - - -``` -int32_t(* LightInterface::TurnOffLight) ([in] uint32_t lightId) -``` - -**描述:** - -根据指定的灯ID关闭列表中的可用灯。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| lightId | 表示灯ID,详见[LightId](_light.md#lightid)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### TurnOnLight - - -``` -int32_t(* LightInterface::TurnOnLight) ([in] uint32_t lightId,[in] struct LightEffect *effect) -``` - -**描述:** - -根据指定的灯ID打开列表中的可用灯。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| lightId | 表示灯ID,详见[LightId](_light.md#lightid)。 | -| effect | 表示指向灯效果的指针,如果lightbrightness字段为0时, 灯的亮度根据HCS配置的默认亮度进行设置,详见[LightEffect](_light_effect.md)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果不支持灯ID,则返回-1。 - -如果不支持闪烁设置,则返回-2。 - -如果不支持亮度设置,则返回-3。 - diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_light_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..14c020c8b3154c2d9296425d9b94edfcba667635 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light_types_8idl.md @@ -0,0 +1,49 @@ +# LightTypes.idl + + +## **概述** + +定义灯的数据结构,包括灯类型ID、灯的基本信息、灯的模式、灯的闪烁参数、灯的颜色模式和灯的效果参数。 + +**Since:** + +3.1 + +**Version:** + +1.0 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfLightInfo](_hdf_light_info.md) | 定义灯的基本信息。 | +| [HdfLightFlashEffect](_hdf_light_flash_effect.md) | 定义灯的闪烁参数。 | +| [RGBColor](_r_g_b_color.md) | 定义灯的RGB模式。 | +| [WRGBColor](_w_r_g_b_color.md) | 定义灯的WRGB模式。 | +| [ColorValue](union_color_value.md) | 定义灯的颜色模式。 | +| [HdfLightColor](_hdf_light_color.md) | 定义亮灯参数。 | +| [HdfLightEffect](_hdf_light_effect.md) | 定义灯的效果参数。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfLightId](light.md#hdflightid) { HDF_LIGHT_ID_BATTERY = 1, HDF_LIGHT_ID_NOTIFICATIONS = 2, HDF_LIGHT_ID_ATTENTION = 3, HDF_LIGHT_ID_BUTT = 4 } | 枚举灯类型。 | +| [HdfLightFlashMode](light.md#hdflightflashmode) { HDF_LIGHT_FLASH_NONE = 0, HDF_LIGHT_FLASH_TIMED = 1, HDF_LIGHT_FLASH_GRADIENT = 2, HDF_LIGHT_FLASH_BUTT = 2 } | 枚举灯的模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.light.v1_0 | 灯模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_meas_channel_param.md b/zh-cn/device-dev/reference/hdi-apis/_meas_channel_param.md new file mode 100644 index 0000000000000000000000000000000000000000..f79fa1a599c8747f62b908285f98f36075bb59b8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_meas_channel_param.md @@ -0,0 +1,56 @@ +# MeasChannelParam + + +## **概述** + +信道测量参数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [channelId](#channelid) | 信道号。 | +| [measTime](#meastime) | 测量时间。 | + + +## **类成员变量说明** + + +### channelId + + +``` +int MeasChannelParam::channelId +``` + +**描述:** + +信道号。 + + +### measTime + + +``` +int MeasChannelParam::measTime +``` + +**描述:** + +测量时间。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_meas_channel_result.md b/zh-cn/device-dev/reference/hdi-apis/_meas_channel_result.md new file mode 100644 index 0000000000000000000000000000000000000000..58c05d98f1424fcd8821a7ac425df7ee2acdbb5d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_meas_channel_result.md @@ -0,0 +1,69 @@ +# MeasChannelResult + + +## **概述** + +信道测量结果。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [channelId](#channelid) | 信道号。 | +| [chload](#chload) | 信道负载。 | +| [noise](#noise) | 信道噪声。 | + + +## **类成员变量说明** + + +### channelId + + +``` +int MeasChannelResult::channelId +``` + +**描述:** + +信道号。 + + +### chload + + +``` +int MeasChannelResult::chload +``` + +**描述:** + +信道负载。 + + +### noise + + +``` +int MeasChannelResult::noise +``` + +**描述:** + +信道噪声。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_motion_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_motion_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..2f1c31dce3a06a64e8cba139bb0ec3235c4b5b06 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_motion_types_8idl.md @@ -0,0 +1,35 @@ +# MotionTypes.idl + + +## **概述** + +定义手势识别模块用到的数据结构,包括手势识别类型、上报的手势识别数据结构。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfMotionEvent](_hdf_motion_event.md) | 上报手势识别数据结构。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfMotionTypeTag](motion.md#hdfmotiontypetag) {   HDF_MOTION_TYPE_PICKUP = 0, HDF_MOTION_TYPE_FLIP, HDF_MOTION_CLOSE_TO_EAR, HDF_MOTION_TYPE_SHAKE,   HDF_MOTION_TYPE_ROTATION, HDF_MOTION_TYPE_POCKET_MODE, HDF_MOTION_TYPE_LEAVE_EAR, HDF_MOTION_TYPE_WRIST_UP,   HDF_MOTION_TYPE_WRIST_DOWN, HDF_MOTION_TYPE_MAX } | 枚举手势识别类型。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md deleted file mode 100644 index 73ab78e3a96dd2462352ba188d74bb550375939d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md +++ /dev/null @@ -1,24 +0,0 @@ -# OHOS::Camera::CaptureEndedInfo - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [streamId_](_camera.md#streamid-34) | 捕获的流ID。 | -| [frameCount_](_camera.md#framecount) | 捕获结束时已经抓取的帧数。 | - - -## **详细描述** - -捕获结束相关信息,用于捕获结束回调[OnCaptureEnded](_camera.md#oncaptureended)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md deleted file mode 100644 index fed70cf0c2f5339c6d17280d30ba324167a08120..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md +++ /dev/null @@ -1,24 +0,0 @@ -# OHOS::Camera::CaptureErrorInfo - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [streamId_](_camera.md#streamid-44) | 流ID。 | -| [error_](_camera.md#error) | 错误类型。 | - - -## **详细描述** - -流错误信息,用于回调[OnCaptureError](_camera.md#oncaptureerror)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md deleted file mode 100644 index ed436019406bf6e0646d37c6a78cc3996d993b0e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md +++ /dev/null @@ -1,25 +0,0 @@ -# OHOS::Camera::CaptureInfo - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [streamIds_](_camera.md#streamids) | 捕获的流ID集合。 | -| [captureSetting_](_camera.md#capturesetting) | 捕获的配置信息。 | -| [enableShutterCallback_](_camera.md#enableshuttercallback) | 使能捕获回调,每一次捕获后都会触发 [OnFrameShutter](_camera.md#onframeshutter)。 | - - -## **详细描述** - -捕获请求的相关信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md deleted file mode 100644 index 7000a726a8d5d1456daafc9e9baff100c162208b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md +++ /dev/null @@ -1,30 +0,0 @@ -# OHOS::Camera::ICameraDevice - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Device") | IPC通信token校验。 | -| [GetStreamOperator](_camera.md#getstreamoperator) (const OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) > &streamOperator)=0 | 获取流操作句柄。 [更多...](_camera.md#getstreamoperator) | -| [UpdateSettings](_camera.md#updatesettings) (const std::shared_ptr< CameraSetting > &settings)=0 | 更新设备控制参数。 [更多...](_camera.md#updatesettings) | -| [SetResultMode](_camera.md#setresultmode) (const [ResultCallbackMode](_camera.md#resultcallbackmode) &mode)=0 | 设置metadata上报模式,逐帧上报还是设备状态变化时上报。 [更多...](_camera.md#setresultmode) | -| [GetEnabledResults](_camera.md#getenabledresults) (std::vector< MetaType > &results)=0 | 查询使能的metadata。 [更多...](_camera.md#getenabledresults) | -| [EnableResult](_camera.md#enableresult) (const std::vector< MetaType > &results)=0 | 打开metadata上报开关。 [更多...](_camera.md#enableresult) | -| [DisableResult](_camera.md#disableresult) (const std::vector< MetaType > &results)=0 | 关闭metadata上报开关。 [更多...](_camera.md#disableresult) | -| [Close](_camera.md#close) ()=0 | 关闭Camera设备。 [更多...](_camera.md#close) | - - -## **详细描述** - -Camera设备操作。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md deleted file mode 100644 index 4a7f16ecc6932bca6fc726e496004236aa3f81ad..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md +++ /dev/null @@ -1,25 +0,0 @@ -# OHOS::Camera::ICameraDeviceCallback - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.DeviceCallback") | IPC通信token校验。 | -| [OnError](_camera.md#onerror) ([ErrorType](_camera.md#errortype) type, int32_t errorCode)=0 | 设备发生错误时调用,由调用者实现,用于返回错误信息给调用者。 [更多...](_camera.md#onerror) | -| [OnResult](_camera.md#onresult) (uint64_t timestamp, const std::shared_ptr< CameraMetadata > &result)=0 | 上报camera设备相关的metadata的回调,上报方式查看 [SetResultMode](_camera.md#setresultmode)。 [更多...](_camera.md#onresult) | - - -## **详细描述** - -Camera设备操作回调。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md deleted file mode 100644 index a77249e55bb64230e8eb8c1d48e59c9623013a3e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md +++ /dev/null @@ -1,35 +0,0 @@ -# OHOS::Camera::ICameraHost - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Host") | IPC通信token校验。 | -| [SetCallback](_camera.md#setcallback) (const OHOS::sptr< [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) > &callback)=0 | 设置ICameraHost回调接口,回调函数参考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 [更多...](_camera.md#setcallback) | -| [GetCameraIds](_camera.md#getcameraids) (std::vector< std::string > &cameraIds)=0 | 获取当前可用的Camera设备ID列表。 [更多...](_camera.md#getcameraids) | -| [GetCameraAbility](_camera.md#getcameraability) (const std::string &cameraId, std::shared_ptr< CameraAbility > &ability)=0 | 获取Camera设备能力集合。 [更多...](_camera.md#getcameraability) | -| [OpenCamera](_camera.md#opencamera) (const std::string &cameraId, const OHOS::sptr< [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) > &callback, OHOS::sptr< [ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) > &device)=0 | 打开Camera设备。 [更多...](_camera.md#opencamera) | -| [SetFlashlight](_camera.md#setflashlight) (const std::string &cameraId, bool &isEnable)=0 | 打开或关闭闪光灯。 [更多...](_camera.md#setflashlight) | - - -### 静态 Public 成员函数 - - | 静态 Public 成员函数 | 描述 | -| -------- | -------- | -| [Get](_camera.md#get) (const char \*serviceName) | 获取ICameraHost实例。 [更多...](_camera.md#get) | - - -## **详细描述** - -Camera服务的管理类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md deleted file mode 100644 index 7a0885b50d8f9647c9fd0dc82e9684dd2acdf255..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md +++ /dev/null @@ -1,26 +0,0 @@ -# OHOS::Camera::ICameraHostCallback - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.HostCallback") | IPC通信token校验。 | -| [OnCameraStatus](_camera.md#oncamerastatus) (const std::string &cameraId, [CameraStatus](_camera.md#camerastatus) status)=0 | 用于Camera设备状态变化时上报状态信息给调用者。 [更多...](_camera.md#oncamerastatus) | -| [OnFlashlightStatus](_camera.md#onflashlightstatus) (const std::string &cameraId, [FlashlightStatus](_camera.md#flashlightstatus) status)=0 | 用于在闪光灯状态变化时上报状态信息给调用者。 [更多...](_camera.md#onflashlightstatus) | -| [OnCameraEvent](_camera.md#oncameraevent) (const std::string &cameraId, [CameraEvent](_camera.md#cameraevent) event)=0 | 在相机事件发生时调用。 [更多...](_camera.md#oncameraevent) | - - -## **详细描述** - -Camera服务的管理回调。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md deleted file mode 100644 index f8793d89a49086de20c50ba6beb49a85107eaba9..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md +++ /dev/null @@ -1,26 +0,0 @@ -# OHOS::Camera::IOfflineStreamOperator - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.OfflineStreamOperator") | IPC通信token校验。 | -| [CancelCapture](_camera.md#cancelcapture-12) (int captureId)=0 | 取消捕获请求。 [更多...](_camera.md#cancelcapture-12) | -| [ReleaseStreams](_camera.md#releasestreams-12) (const std::vector< int > &streamIds)=0 | 释放离线流。 [更多...](_camera.md#releasestreams-12) | -| [Release](_camera.md#release) ()=0 | 释放所有离线流。 [更多...](_camera.md#release) | - - -## **详细描述** - -离线流的操作类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md deleted file mode 100644 index b38ca7889204518e9f9321b212375022a92b2acd..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md +++ /dev/null @@ -1,33 +0,0 @@ -# OHOS::Camera::IStreamOperator - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperator") | IPC通信token校验。 | -| [IsStreamsSupported](_camera.md#isstreamssupported) ([OperationMode](_camera.md#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting, const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &info, [StreamSupportType](_camera.md#streamsupporttype) &type)=0 | 查询是否支持添加参数对应的流 [更多...](_camera.md#isstreamssupported) | -| [CreateStreams](_camera.md#createstreams) (const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &streamInfos)=0 | 创建流。 [更多...](_camera.md#createstreams) | -| [ReleaseStreams](_camera.md#releasestreams-22) (const std::vector< int > &streamIds)=0 | 释放流。 [更多...](_camera.md#releasestreams-22) | -| [CommitStreams](_camera.md#commitstreams) ([OperationMode](_camera.md#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting)=0 | 配置流。 [更多...](_camera.md#commitstreams) | -| [GetStreamAttributes](_camera.md#getstreamattributes) (std::vector< std::shared_ptr< [StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) >> &attributes)=0 | 获取流的属性。 [更多...](_camera.md#getstreamattributes) | -| [AttachBufferQueue](_camera.md#attachbufferqueue) (int streamId, const OHOS::sptr< OHOS::IBufferProducer > &producer)=0 | 绑定生产者句柄和指定流。 [更多...](_camera.md#attachbufferqueue) | -| [DetachBufferQueue](_camera.md#detachbufferqueue) (int streamId)=0 | 解除生产者句柄和指定流的绑定关系。 [更多...](_camera.md#detachbufferqueue) | -| [Capture](_camera.md#capture) (int captureId, const std::shared_ptr< [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) > &info, bool isStreaming)=0 | 捕获图像。 [更多...](_camera.md#capture) | -| [CancelCapture](_camera.md#cancelcapture-22) (int captureId)=0 | 取消捕获。 [更多...](_camera.md#cancelcapture-22) | -| [ChangeToOfflineStream](_camera.md#changetoofflinestream) (const std::vector< int > &streamIds, OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) > &offlineOperator)=0 | 将指定流转换成离线流。 [更多...](_camera.md#changetoofflinestream) | - - -## **详细描述** - -流的操作类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md deleted file mode 100644 index 4935fd6e235e1850ee9309db17f28910e75f5996..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md +++ /dev/null @@ -1,27 +0,0 @@ -# OHOS::Camera::IStreamOperatorCallback - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperatorCallback") | IPC通信token校验。 | -| [OnCaptureStarted](_camera.md#oncapturestarted) (int32_t captureId, const std::vector< int32_t > &streamIds)=0 | 捕获开始回调,在捕获开始时调用。 [更多...](_camera.md#oncapturestarted) | -| [OnCaptureEnded](_camera.md#oncaptureended) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) >> &infos)=0 | 捕获结束回调,在捕获结束时调用。 [更多...](_camera.md#oncaptureended) | -| [OnCaptureError](_camera.md#oncaptureerror) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) >> &infos)=0 | 捕获错误回调,在捕获过程中发生错误时调用。 [更多...](_camera.md#oncaptureerror) | -| [OnFrameShutter](_camera.md#onframeshutter) (int32_t captureId, const std::vector< int32_t > &streamIds, uint64_t timestamp)=0 | 帧捕获回调。 [更多...](_camera.md#onframeshutter) | - - -## **详细描述** - -流的操作回调类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md deleted file mode 100644 index bff01127d61678c5dcd89a5655ecbad50c4312ad..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md +++ /dev/null @@ -1,31 +0,0 @@ -# OHOS::Camera::StreamAttribute - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [streamId_](_camera.md#streamid-24) | 流的ID,用于在设备内唯一标识一条流。 | -| [width_](_camera.md#width-22) | 图像宽度。 | -| [height_](_camera.md#height-22) | 图像高度。 | -| [overrideFormat_](_camera.md#overrideformat) | 重写的图像格式。 | -| [overrideDatasapce_](_camera.md#overridedataspace) | 重写的图像颜色空间。| -| [producerUsage_](_camera.md#producerusage) | 重写后的生产者的使用方式。 | -| [producerBufferCount_](_camera.md#producerbuffercount) | 重写后的生产者缓存数量。 | -| [maxBatchCaptureCount_](_camera.md#maxbatchcapturecount) | 连拍支持的最大捕获帧数量。 | -| [maxCaptureCount_](_camera.md#maxcapturecount) | 最大的并发捕获请求个数,默认为1。 | - - -## **详细描述** - -流的属性。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md deleted file mode 100644 index 613378d52a494833e1cdc354f7b0b2f4ee1ecdd7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md +++ /dev/null @@ -1,32 +0,0 @@ -# OHOS::Camera::StreamInfo - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [streamId_](_camera.md#streamid-14) | 流的ID,用于在设备内唯一标识一条流。 | -| [width_](_camera.md#width-12) | 图像宽度。 | -| [height_](_camera.md#height-12) | 图像高度。 | -| [format_](_camera.md#format) | 图像格式。 | -| [dataspace_](_camera.md#dataspace) | 图像颜色空间。 | -| [intent_](_camera.md#intent) | 流类型。 | -| [tunneledMode_](_camera.md#tunneledmode) | 隧道模式,值为true时开启,false关闭。 | -| [bufferQueue_](_camera.md#bufferqueue) | 图形提供的生产者句柄。 | -| [minFrameDuration_](_camera.md#minframeduration) | 最小帧间隔。 | -| [encodeType_](_camera.md#encodetype) | 编码类型。 | - - -## **详细描述** - -流信息,用于创建流时传入相关的配置参数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md deleted file mode 100644 index 0ae62b90c880862107a3d949d7b659b322ca278e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md +++ /dev/null @@ -1,25 +0,0 @@ -# OHOS::USB::USBDeviceInfo - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [status](_u_s_b.md#status) | USB设备状态 | -| [busNum](_u_s_b.md#busnum-12) | USB总线编号 | -| [devNum](_u_s_b.md#devnum) | USB设备编号 | - - -## **详细描述** - -USB设备信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md deleted file mode 100644 index 545ea45988ed42a69dd6b855e100795956fb4850..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md +++ /dev/null @@ -1,27 +0,0 @@ -# OHOS::USB::UsbCtrlTransfer - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [requestType](_u_s_b.md#requesttype) | 请求类型 | -| [requestCmd](_u_s_b.md#requestcmd) | 请求命令字 | -| [value](_u_s_b.md#value) | 请求值 | -| [index](_u_s_b.md#index) | 索引 | -| [timeout](_u_s_b.md#timeout) | 超时时间 | - - -## **详细描述** - -USB控制传输。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md deleted file mode 100644 index 5df0bae75c4fc4c442c14211b38e55b2b928dba5..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md +++ /dev/null @@ -1,24 +0,0 @@ -# OHOS::USB::UsbDev - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [busNum](_u_s_b.md#busnum-22) | USB总线编号 | -| [devAddr](_u_s_b.md#devaddr) | USB设备地址 | - - -## **详细描述** - -USB设备。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md deleted file mode 100644 index c576768593247cab80492de2de938a982745071c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md +++ /dev/null @@ -1,35 +0,0 @@ -# OHOS::USB::UsbInfo - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| [setDevInfoStatus](_u_s_b.md#setdevinfostatus) (int32_t status) | 设置USB设备状态。 [更多...](_u_s_b.md#setdevinfostatus) | -| [setDevInfoBusNum](_u_s_b.md#setdevinfobusnum) (int32_t busNum) | 设置USB总线编号。 [更多...](_u_s_b.md#setdevinfobusnum) | -| [setDevInfoDevNum](_u_s_b.md#setdevinfodevnum) (int32_t devNum) | 设置USB设备编号。 [更多...](_u_s_b.md#setdevinfodevnum) | -| [getDevInfoStatus](_u_s_b.md#getdevinfostatus) () const | 获取USB设备状态。 [更多...](_u_s_b.md#getdevinfostatus) | -| [getDevInfoBusNum](_u_s_b.md#getdevinfobusnum) () const | 获取USB总线编号。 [更多...](_u_s_b.md#getdevinfobusnum) | -| [getDevInfoDevNum](_u_s_b.md#getdevinfodevnum) () const | 获取USB设备编号。 [更多...](_u_s_b.md#getdevinfodevnum) | - - -### Private 成员变量 - - | Private 成员变量 | 描述 | -| -------- | -------- | -| [USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) devInfo | USB设备信息。 | - - -## **详细描述** - -USB设备信息类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md deleted file mode 100644 index e58adfe5cdf7a56550c81967622d862343ac384f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md +++ /dev/null @@ -1,24 +0,0 @@ -# OHOS::USB::UsbPipe - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [interfaceId](_u_s_b.md#interfaceid) | USB设备接口ID | -| [endpointId](_u_s_b.md#endpointid) | USB设备端点ID | - - -## **详细描述** - -管道信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md deleted file mode 100644 index 9bc4102d6e28c072dee510f953bb241cf9413766..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md +++ /dev/null @@ -1,62 +0,0 @@ -# OHOS::USB::UsbdClient - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| [OpenDevice](_u_s_b.md#opendevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 打开设备,建立连接。 [更多...](_u_s_b.md#opendevice) | -| [CloseDevice](_u_s_b.md#closedevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 关闭设备,释放与设备相关的所有系统资源。 [更多...](_u_s_b.md#closedevice) | -| [GetDeviceDescriptor](_u_s_b.md#getdevicedescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获取设备描述符。 [更多...](_u_s_b.md#getdevicedescriptor) | -| [GetStringDescriptor](_u_s_b.md#getstringdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | 根据String ID获取设备的字符串描述符。 [更多...](_u_s_b.md#getstringdescriptor) | -| [GetConfigDescriptor](_u_s_b.md#getconfigdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | 根据config ID获取设备的配置描述符config。 [更多...](_u_s_b.md#getconfigdescriptor) | -| [GetRawDescriptor](_u_s_b.md#getrawdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获取原始描述符。 [更多...](_u_s_b.md#getrawdescriptor) | -| [GetFileDescriptor](_u_s_b.md#getfiledescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, int32_t &fd) | 获取文件描述符。 [更多...](_u_s_b.md#getfiledescriptor) | -| [SetConfig](_u_s_b.md#setconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t configIndex) | 设置当前的config信息。 [更多...](_u_s_b.md#setconfig) | -| [GetConfig](_u_s_b.md#getconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t &configIndex) | 获取当前的config信息。 [更多...](_u_s_b.md#getconfig) | -| [ClaimInterface](_u_s_b.md#claiminterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t force) | 打开接口,并声明独占接口,必须在数据传输前执行。 [更多...](_u_s_b.md#claiminterface) | -| [ReleaseInterface](_u_s_b.md#releaseinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid) | 关闭接口,释放接口的占用,在停止数据传输后执行。 [更多...](_u_s_b.md#releaseinterface) | -| [SetInterface](_u_s_b.md#setinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t altIndex) | 设置指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择。 [更多...](_u_s_b.md#setinterface) | -| [BulkTransferRead](_u_s_b.md#bulktransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行批量数据读取,返回读取的数据和长度,端点方向必须为数据读取,可以设置超时时间。 [更多...](_u_s_b.md#bulktransferread) | -| [BulkTransferWrite](_u_s_b.md#bulktransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, const std::vector< uint8_t > &data) | 在给定端点上执行批量数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](_u_s_b.md#bulktransferwrite) | -| [ControlTransfer](_u_s_b.md#controltransfer) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) &ctrl, std::vector< uint8_t > &data) | 对此设备执行端点零的控制事务,传输方向由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ,则传输是写入,如果是USB_DIR_IN ,则传输是读取。 [更多...](_u_s_b.md#controltransfer) | -| [InterruptTransferRead](_u_s_b.md#interrupttransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行中断数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 [更多...](_u_s_b.md#interrupttransferread) | -| [InterruptTransferWrite](_u_s_b.md#interrupttransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行中断数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](_u_s_b.md#interrupttransferwrite) | -| [IsoTransferRead](_u_s_b.md#isotransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行等时数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 [更多...](_u_s_b.md#isotransferread) | -| [IsoTransferWrite](_u_s_b.md#isotransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行等时数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](_u_s_b.md#isotransferwrite) | -| [RequestQueue](_u_s_b.md#requestqueue) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const std::vector< uint8_t > &clientData, const std::vector< uint8_t > &buffer) | 将指定的端点进行异步数据发送或者接收请求,数据传输方向由端点方向决定。 [更多...](_u_s_b.md#requestqueue) | -| [RequestWait](_u_s_b.md#requestwait) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &clientData, std::vector< uint8_t > &buffer, int32_t timeout) | 等待RequestQueue异步请求的操作结果。 [更多...](_u_s_b.md#requestwait) | -| [RequestCancel](_u_s_b.md#requestcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 取消待处理的数据请求。 [更多...](_u_s_b.md#requestcancel) | -| [GetCurrentFunctions](_u_s_b.md#getcurrentfunctions) (int32_t &funcs) | 获取从设备支持的功能列表(按位域表示)(从设备)。 [更多...](_u_s_b.md#getcurrentfunctions) | -| [SetCurrentFunctions](_u_s_b.md#setcurrentfunctions) (int32_t funcs) | 设置从设备支持的功能列表(按位域表示)(从设备)。 [更多...](_u_s_b.md#setcurrentfunctions) | -| [SetPortRole](_u_s_b.md#setportrole) (int32_t portId, int32_t powerRole, int32_t dataRole) | 设置port端口的角色。 [更多...](_u_s_b.md#setportrole) | -| [QueryPort](_u_s_b.md#queryport) (int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode) | 查询port端口的当前设置。 [更多...](_u_s_b.md#queryport) | -| [BindUsbdSubscriber](_u_s_b.md#bindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 绑定订阅者。 [更多...](_u_s_b.md#bindusbdsubscriber) | -| [UnbindUsbdSubscriber](_u_s_b.md#unbindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 解绑订阅者。 [更多...](_u_s_b.md#unbindusbdsubscriber) | -| [RegBulkCallback](_u_s_b.md#regbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const sptr< IRemoteObject > &cb) | 注册批量传输异步回调函数。 [更多...](_u_s_b.md#regbulkcallback) | -| [UnRegBulkCallback](_u_s_b.md#unregbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 注销批量传输异步回调函数。 [更多...](_u_s_b.md#unregbulkcallback) | -| [BulkRead](_u_s_b.md#bulkread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批量传输异步读数据。 [更多...](_u_s_b.md#bulkread) | -| [BulkWrite](_u_s_b.md#bulkwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批量传输异步写数据。 [更多...](_u_s_b.md#bulkwrite) | -| [BulkCancel](_u_s_b.md#bulkcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 批量传输异步取消接口,用于取消当前接口的异步批量读写操作。 [更多...](_u_s_b.md#bulkcancel) | - - -### 静态 Public 成员函数 - - | 静态 Public 成员函数 | 描述 | -| -------- | -------- | -| [GetInstance](_u_s_b.md#getinstance) () | 获取实例。 | - - -## 详细描述 - -USB驱动客户端类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md deleted file mode 100644 index 57043338245c2dc4c9531bb08ba21e2abd987d9e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md +++ /dev/null @@ -1,41 +0,0 @@ -# OHOS::USB::UsbdSubscriber - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### Public 成员函数 - - | Public 成员函数 | 描述 | -| -------- | -------- | -| [DeviceEvent](_u_s_b.md#deviceevent) (const [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) &info)=0 | 设备事件。 [更多...](_u_s_b.md#deviceevent) | -| [PortChangedEvent](_u_s_b.md#portchangedevent) (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode)=0 | 端口改变事件。 [更多...](_u_s_b.md#portchangedevent) | -| [OnRemoteRequest](_u_s_b.md#onremoterequest) (uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override | 远程请求。 [更多...](_u_s_b.md#onremoterequest) | - - -### Private 成员函数 - - | Private 成员函数 | 描述 | -| -------- | -------- | -| [OHOS::USB::UsbdSubscriber::ParserUsbInfo](_u_s_b.md#parserusbinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) | 解析USB设备信息。 [更多...](_u_s_b.md#parserusbinfo) | -| [OHOS::USB::UsbdSubscriber::ParserPortInfo](_u_s_b.md#parserportinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) | 解析USB设备端口信息。 [更多...](_u_s_b.md#parserportinfo) | - - -## **详细描述** - -USB驱动订阅类。 - -**Since:** - -3.0 - -**Version:** - -1.0 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md b/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md index 9b59c569ce179b8ea38d724027c1726aeeaf40c1..34b9713074eade2f98e39c2e9aa645cb7cd67e3f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md +++ b/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +Codec buffer信息的定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [bufferId](#bufferid) | buffer的ID。 | | [size](#size) | 结构体大小。 | @@ -30,11 +32,6 @@ | [flag](#flag) | 标志。 | -## **详细描述** - -Codec buffer信息的定义。 - - ## **类成员变量说明** @@ -47,7 +44,7 @@ uint32_t OmxCodecBuffer::allocLen **描述:** -申请的buffer大小 +申请的buffer大小。 ### buffer @@ -59,7 +56,7 @@ uint8_t* OmxCodecBuffer::buffer **描述:** -编码或者解码使用的buffer +编码或者解码使用的buffer。 ### bufferId @@ -71,7 +68,7 @@ uint32_t OmxCodecBuffer::bufferId **描述:** -buffer ID +buffer ID。 ### bufferLen @@ -83,7 +80,7 @@ uint32_t OmxCodecBuffer::bufferLen **描述:** -buffer大小 +buffer大小。 ### bufferType @@ -95,7 +92,7 @@ enum CodecBufferType OmxCodecBuffer::bufferType **描述:** -buffer类型 +buffer类型。 ### fenceFd @@ -107,7 +104,7 @@ int32_t OmxCodecBuffer::fenceFd **描述:** -该描述符来自buffer消费者,Codec等待成功后才可以使用输入或者输出buffer +该描述符来自buffer消费者,Codec等待成功后才可以使用输入或者输出buffer。 ### filledLen @@ -119,7 +116,7 @@ uint32_t OmxCodecBuffer::filledLen **描述:** -填充的buffer大小 +填充的buffer大小。 ### flag @@ -131,7 +128,7 @@ uint32_t OmxCodecBuffer::flag **描述:** -标志 +标志。 ### offset @@ -143,7 +140,7 @@ uint32_t OmxCodecBuffer::offset **描述:** -有效数据从缓冲区开始的起始偏移量 +有效数据从缓冲区开始的起始偏移量。 ### pts @@ -155,7 +152,7 @@ int64_t OmxCodecBuffer::pts **描述:** -时间戳 +时间戳。 ### size @@ -167,7 +164,7 @@ uint32_t OmxCodecBuffer::size **描述:** -结构体大小 +结构体大小。 ### type @@ -179,7 +176,7 @@ enum ShareMemTypes OmxCodecBuffer::type **描述:** -共享内存类型 +共享内存类型。 ### version @@ -191,4 +188,4 @@ union OMX_VERSIONTYPE OmxCodecBuffer::version **描述:** -组件版本信息 +组件版本信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md index 9e2a1a49e5be8d62450f959d90cca14151476c7e..8a10abb5afe0b23f994349952633fca6574d9387 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义口令认证驱动的枚举类和数据结构。 + +**Since:** + +3.2 + **所属模块:** [HdfPinAuth](_hdf_pin_auth.md) @@ -13,33 +19,24 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [ExecutorInfo](_executor_info.md) | 执行器信息。 [更多...](_executor_info.md) | -| [TemplateInfo](_template_info.md) | 凭据模版信息。 [更多...](_template_info.md) | +| [ExecutorInfo](_executor_info.md) | 执行器信息。 | +| [TemplateInfo](_template_info.md) | 凭据模版信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](_hdf_pin_auth.md#authtype) : int {   PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 [更多...](_hdf_face_auth.md#authtype) | -| [ExecutorRole](_hdf_pin_auth.md#executorrole) : int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_face_auth.md#executorrole) | -| [ExecutorSecureLevel](_hdf_pin_auth.md#executorsecurelevel) : int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](_hdf_face_auth.md#executorsecurelevel) | -| [CommandId](_hdf_pin_auth.md#commandid) : int { DEFAULT = 0 } | 枚举口令认证功能相关操作命令。 [更多...](_hdf_face_auth.md#commandid) | +| [AuthType](_hdf_pin_auth.md#authtype): int {   PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](_hdf_pin_auth.md#executorrole): int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](_hdf_pin_auth.md#executorsecurelevel): int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [CommandId](_hdf_pin_auth.md#commandid): int { DEFAULT = 0 } | 枚举口令认证功能相关操作命令。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.pin_auth.v1_0 | 口令认证接口的包路径 | - - -## **详细描述** - -定义口令认证驱动的枚举类和数据结构。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_port_info.md b/zh-cn/device-dev/reference/hdi-apis/_port_info.md new file mode 100644 index 0000000000000000000000000000000000000000..80422dc158b7ddc3353f149bcababf3303f10b93 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_port_info.md @@ -0,0 +1,82 @@ +# PortInfo + + +## **概述** + +USB设备端口信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [portId](#portid) | USB设备端口ID。 | +| [powerRole](#powerrole) | USB设备电源角色。 | +| [dataRole](#datarole) | USB设备数据角色。 | +| [mode](#mode) | USB设备模式。 | + + +## **类成员变量说明** + + +### dataRole + + +``` +int PortInfo::dataRole +``` + +**描述:** + +USB设备数据角色。 + + +### mode + + +``` +int PortInfo::mode +``` + +**描述:** + +USB设备模式。 + + +### portId + + +``` +int PortInfo::portId +``` + +**描述:** + +USB设备端口ID。 + + +### powerRole + + +``` +int PortInfo::powerRole +``` + +**描述:** + +USB设备电源角色。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md index 179b60a2a0a0261d0e9d3c8afd29316395f440ef..30be1eeab46b01def03497a8d4ae50c4517e2e92 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md @@ -3,40 +3,37 @@ ## **概述** -**所属模块:** - -[Power](power.md) - +电源相关的数据类型。 -## **汇总** +电源管理中使用的数据类型,包括命令参数、回调参数和系统状态。 +**Since:** -### 枚举 +3.1 - | 枚举 | 描述 | -| -------- | -------- | -| [PowerHdfCmd](power.md#powerhdfcmd) {   CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND,   CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电源命令的参数。 [更多...](power.md#powerhdfcmd) | -| [PowerHdfCallbackCmd](power.md#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电源状态回调的参数。 [更多...](power.md#powerhdfcallbackcmd) | -| [PowerHdfState](power.md#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电源的状态。 [更多...](power.md#powerhdfstate) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.power.v1_0 | 电源管理接口的包路径 | +[Power](power.md) -## **详细描述** +## **汇总** -电源相关的数据类型。 -电源管理中使用的数据类型,包括命令参数、回调参数和系统状态。 +### 枚举 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [PowerHdfCmd](power.md#powerhdfcmd) {   CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND,   CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电源命令的参数。 | +| [PowerHdfCallbackCmd](power.md#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电源状态回调的参数。 | +| [PowerHdfState](power.md#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电源的状态。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电源模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md b/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md index 75be9d799ef7eb95d18e7484fcf739a32cf44408..b10f8ce64080ce7d2becd8ca098d5f5836573efc 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md +++ b/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +上屏时间戳结构体定义。 + +**相关模块:** [Display](_display.md) @@ -13,12 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [type](_display.md#type-33) | 上屏时间戳类型 | +| [type](_display.md#type-37) | 上屏时间戳类型 | | [time](_display.md#time) | 类型对应的值 | - - -## **详细描述** - -上屏时间戳结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_projection_screen_cmd_param.md b/zh-cn/device-dev/reference/hdi-apis/_projection_screen_cmd_param.md new file mode 100644 index 0000000000000000000000000000000000000000..baac9ef747bea6a6dd2036e24677077acffefeba --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_projection_screen_cmd_param.md @@ -0,0 +1,56 @@ +# ProjectionScreenCmdParam + + +## **概述** + +投屏参数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [cmdId](#cmdid) | 投屏命令ID。 | +| [buf](#buf) | 投屏命令内容。 | + + +## **类成员变量说明** + + +### buf + + +``` +byte [] ProjectionScreenCmdParam::buf +``` + +**描述:** + +投屏命令内容。 + + +### cmdId + + +``` +int ProjectionScreenCmdParam::cmdId +``` + +**描述:** + +投屏命令ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_property_object.md b/zh-cn/device-dev/reference/hdi-apis/_property_object.md index 5520d0be40f9064035c5f374f32739ebe89798dc..2bc7c1197be43e77c135cfc654ea93bf5487f1e9 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_property_object.md +++ b/zh-cn/device-dev/reference/hdi-apis/_property_object.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +定义包含名称、属性ID和值的属性对象。 + +**相关模块:** [Display](_display.md) @@ -13,13 +15,8 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [name](_display.md#name-12) [PROPERTY_NAME_LEN] | 属性名称 | +| [name](_display.md#name-12) | 属性名称 | | [propId](_display.md#propid) | 属性ID | | [value](_display.md#value-12) | 属性值 | - - -## **详细描述** - -定义包含名称、属性ID和值的属性对象。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_r_g_b_color.md b/zh-cn/device-dev/reference/hdi-apis/_r_g_b_color.md new file mode 100644 index 0000000000000000000000000000000000000000..2dad0607e021b2ba53ffc416191414cc21f9b20c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_r_g_b_color.md @@ -0,0 +1,82 @@ +# RGBColor + + +## **概述** + +定义灯的RGB模式。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [brightness](#brightness) | 亮度值,范围为0-255。 | +| [r](#r) | 红色值,范围为0-255。 | +| [g](#g) | 绿色值,范围为0-255。 | +| [b](#b) | 蓝色值,范围为0-255。 | + + +## **类成员变量说明** + + +### b + + +``` +int RGBColor::b +``` + +**描述:** + +蓝色值,范围为0-255。 + + +### brightness + + +``` +int RGBColor::brightness +``` + +**描述:** + +亮度值,范围为0-255。 + + +### g + + +``` +int RGBColor::g +``` + +**描述:** + +绿色值,范围为0-255。 + + +### r + + +``` +int RGBColor::r +``` + +**描述:** + +红色值,范围为0-255。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_range_value.md b/zh-cn/device-dev/reference/hdi-apis/_range_value.md index 723b312f4a6bb0b12078398487a4ba026204d60d..5afe5c033bd0a41a78f7e27f7cfd3bcf030781a4 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_range_value.md +++ b/zh-cn/device-dev/reference/hdi-apis/_range_value.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +取值范围的定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [min](#min) | 最小值 | -| [max](#max) | 最大值 | - - -## **详细描述** - -取值范围的定义。 +| [min](#min) | 最小值。 | +| [max](#max) | 最大值。 | ## **类成员变量说明** @@ -36,7 +33,7 @@ int32_t RangeValue::max **描述:** -最大值 +最大值。 ### min @@ -48,4 +45,4 @@ int32_t RangeValue::min **描述:** -最小值 +最小值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_rect.md b/zh-cn/device-dev/reference/hdi-apis/_rect.md index c241e45e26485c1110984ac3a9bd24cfecb53422..350fd817c80e9404dfa0e74ba9fe4111432ec635 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_rect.md +++ b/zh-cn/device-dev/reference/hdi-apis/_rect.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +矩形的定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,15 +15,10 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](#width) | 矩形的宽 | -| [height](#height) | 矩形的高 | - - -## **详细描述** - -矩形的定义。 +| [width](#width) | 矩形的宽。 | +| [height](#height) | 矩形的高。 | ## **类成员变量说明** @@ -36,7 +33,7 @@ int32_t Rect::height **描述:** -矩形的高 +矩形的高。 ### width @@ -48,4 +45,4 @@ int32_t Rect::width **描述:** -矩形的宽 +矩形的宽。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_rectangle.md b/zh-cn/device-dev/reference/hdi-apis/_rectangle.md index 374827e42143f6317681811d5d2c53c30469ced8..3f26acf96fe0616a6adcca985d4fada805616e80 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_rectangle.md +++ b/zh-cn/device-dev/reference/hdi-apis/_rectangle.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +矩形描述结构体定义,用于硬件加速绘制矩形。 + +**相关模块:** [Display](_display.md) @@ -13,12 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [rect](_display.md#rect) | 矩形区域 | -| [color](_display.md#color-33) | 矩形颜色 | - - -## **详细描述** - -矩形描述结构体定义,用于硬件加速绘制矩形。 +| [rect](_display.md#rect-13) | 矩形区域 | +| [color](_display.md#color-35) | 矩形颜色 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md b/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md index 4fcebffea49a53a5907520898ee73d4e84f4b09e..3c44bee576d39e82ce87ee18ad846d0761c5866f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md @@ -3,6 +3,16 @@ ## **概述** +调度信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,7 +23,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [scheduleId](#scheduleid) | 调度ID,用于标识一次操作请求的执行器调度过程。 | | [templateIds](#templateids) | 模版ID列表。 | @@ -23,19 +33,6 @@ | [executors](#executors) | 执行器信息列表。 | -## **详细描述** - -调度信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor.md b/zh-cn/device-dev/reference/hdi-apis/_sensor.md deleted file mode 100644 index 14532c876f32809336fcc266e4e145f2a4eb5a2a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_sensor.md +++ /dev/null @@ -1,326 +0,0 @@ -# Sensor - - -## **汇总** - - -### 文件 - -| 文件 | 描述 | -| -------- | -------- | -| [sensor_if.h](sensor__if_8h.md) | Sensor模块对外通用的接口声明文件,提供获取传感器设备信息、订阅/取消订阅传感器数据、 使能/去使能传感器、设置传感器模式、设置传感器精度,量程等可选配置接口定义。 | -| [sensor_type.h](sensor__type_8h.md) | 定义传感器模块所使用的传感器类型,传感器信息,传感器数据结构等数据类型。 | - - -### 类 - -| 类 | 描述 | -| -------- | -------- | -| [SensorInterface](_sensor_interface.md) | 提供sensor设备基本控制操作接口。 [更多...](_sensor_interface.md) | -| [SensorInformation](_sensor_information.md) | 定义传感器基本信息。 [更多...](_sensor_information.md) | -| [SensorEvents](_sensor_events.md) | 上报传感器数据结构。 [更多...](_sensor_events.md) | - - -### 宏定义 - -| 宏定义 | 描述 | -| -------- | -------- | -| [SENSOR_NAME_MAX_LEN](#sensor_name_max_len)   32 | Sensor名称的最大长度。 | -| [SENSOR_VERSION_MAX_LEN](#sensor_version_max_len)   16 | Sensor版本号的最大长度。 | - - -### 类型定义 - -| 类型定义 | 描述 | -| -------- | -------- | -| ([RecordDataCallback](#recorddatacallback)) (const struct [SensorEvents](_sensor_events.md) \*) | 传感器上报数据回调函数的定义,传感器服务用户在订阅传感器时, 需要注册上报数据回调函数,传感器使能后,传感器服务用户可以接受到传感器数据,详见[SensorInterface](_sensor_interface.md)。 [更多...](#recorddatacallback) | - - -### 枚举 - -| 枚举 | 描述 | -| -------- | -------- | -| [SensorStatus](#sensorstatus) { SENSOR_SUCCESS = 0, SENSOR_FAILURE = -1, SENSOR_NOT_SUPPORT = -2, SENSOR_INVALID_PARAM = -3,   SENSOR_INVALID_SERVICE = -4, SENSOR_NULL_PTR = -5 } | 定义传感器模块返回值类型。 [更多...](#sensorstatus) | -| [SensorTypeTag](#sensortypetag) { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_ACCELEROMETER = 1, SENSOR_TYPE_GYROSCOPE = 2, SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3,   SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, SENSOR_TYPE_AMBIENT_LIGHT = 5, SENSOR_TYPE_MAGNETIC_FIELD = 6, SENSOR_TYPE_CAPACITIVE = 7,   SENSOR_TYPE_BAROMETER = 8, SENSOR_TYPE_TEMPERATURE = 9, SENSOR_TYPE_HALL = 10, SENSOR_TYPE_GESTURE = 11,   SENSOR_TYPE_PROXIMITY = 12, SENSOR_TYPE_HUMIDITY = 13, SENSOR_TYPE_MEDICAL_BEGIN = 128, SENSOR_TYPE_MEDICAL_END = 160,   SENSOR_TYPE_PHYSICAL_MAX = 255, SENSOR_TYPE_ORIENTATION = 256, SENSOR_TYPE_GRAVITY = 257, SENSOR_TYPE_LINEAR_ACCELERATION = 258,   SENSOR_TYPE_ROTATION_VECTOR = 259, SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, SENSOR_TYPE_GAME_ROTATION_VECTOR = 262,   SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, SENSOR_TYPE_SIGNIFICANT_MOTION = 264, SENSOR_TYPE_PEDOMETER_DETECTION = 265, SENSOR_TYPE_PEDOMETER = 266,   SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, SENSOR_TYPE_HEART_RATE = 278, SENSOR_TYPE_DEVICE_ORIENTATION = 279, SENSOR_TYPE_WEAR_DETECTION = 280,   SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, SENSOR_TYPE_MAX } | 定义传感器类型标识。 [更多...](#sensortypetag) | -| [SensorAccuracyType](#sensoraccuracytype) { SENSOR_NO_ACCURACY = 0, SENSOR_LOW_ACCURACY = 1, SENSOR_MEDIUM_ACCURACY = 2, SENSOR_HIGH_ACCURACY = 3,   SENSOR_MAX_ACCURACY } | 传感器的精度类型。 [更多...](#sensoraccuracytype) | -| [SensorRangeType](#sensorrangetype) { SENSOR_RANGE_LEVEL1 = 0, SENSOR_RANGE_LEVEL2 = 1, SENSOR_RANGE_LEVEL3 = 2, SENSOR_RANGE_LEVEL_MAX } | 传感器的量程级别。 [更多...](#sensorrangetype) | -| [SensorModeType](#sensormodetype) { SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3,   SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | 传感器的工作模式。 [更多...](#sensormodetype) | -| [SensorGroupType](#sensorgrouptype) { TRADITIONAL_SENSOR_TYPE = 0, MEDICAL_SENSOR_TYPE = 1, SENSOR_GROUP_TYPE_MAX } | 枚举传感器的硬件服务组。 [更多...](#sensorgrouptype) | - - -### 函数 - -| 函数 | 描述 | -| -------- | -------- | -| [NewSensorInterfaceInstance](#newsensorinterfaceinstance) (void) | 创建传感器接口实例。 [更多...](#newsensorinterfaceinstance) | -| [FreeSensorInterfaceInstance](#freesensorinterfaceinstance) (void) | 释放传感器接口实例。 [更多...](#freesensorinterfaceinstance) | - - -## **详细描述** - -传感器设备驱动对传感器服务提供通用的接口能力。 - -模块提供传感器服务对传感器驱动访问统一接口,服务获取驱动对象或者代理后, 通过其提供的各类方法,以传感器id区分访问不同类型传感器设备,实现获取传感器设备信息、订阅/取消订阅传感器数据、 使能/去使能传感器、设置传感器模式、设置传感器精度、量程等可选配置等。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -## **宏定义说明** - - -### SENSOR_NAME_MAX_LEN - - -``` -#define SENSOR_NAME_MAX_LEN 32 -``` - -**描述:** - -Sensor名称的最大长度。 - - -### SENSOR_VERSION_MAX_LEN - - -``` -#define SENSOR_VERSION_MAX_LEN 16 -``` - -**描述:** - -Sensor版本号的最大长度。 - - -## **类型定义说明** - - -### RecordDataCallback - - -``` -typedef int32_t(* RecordDataCallback) (const struct SensorEvents *) -``` - -**描述:** - -传感器上报数据回调函数的定义,传感器服务用户在订阅传感器时, 需要注册上报数据回调函数,传感器使能后,传感器服务用户可以接受到传感器数据,详见[SensorInterface](_sensor_interface.md)。 - - -## **枚举类型说明** - - -### SensorAccuracyType - - -``` -enum SensorAccuracyType -``` - -**描述:** - -传感器的精度类型。 - -| 枚举值 | 描述 | -| -------- | -------- | -| SENSOR_NO_ACCURACY | 无精度类型。 | -| SENSOR_LOW_ACCURACY | 低精度类型。 | -| SENSOR_MEDIUM_ACCURACY | 中等精度类型。 | -| SENSOR_HIGH_ACCURACY | 高精度类型。 | -| SENSOR_MAX_ACCURACY | 最大精度类型。 | - - -### SensorGroupType - - -``` -enum SensorGroupType -``` - -**描述:** - -枚举传感器的硬件服务组。 - -| 枚举值 | 描述 | -| -------- | -------- | -| TRADITIONAL_SENSOR_TYPE | 传统传感器类型,传感器ID枚举值范围为128-160。 | -| MEDICAL_SENSOR_TYPE | 医疗传感器类型,传感器ID枚举值范围不在128-160之间。 | -| SENSOR_GROUP_TYPE_MAX | 最大传感器类型。 | - - -### SensorModeType - - -``` -enum SensorModeType -``` - -**描述:** - -传感器的工作模式。 - -| 枚举值 | 描述 | -| -------- | -------- | -| SENSOR_MODE_DEFAULT | 传感器默认工作模式状态。 | -| SENSOR_MODE_REALTIME | 传感器实时工作模式状态,一组数据上报一次。 | -| SENSOR_MODE_ON_CHANGE | 传感器实时工作模式状态,状态变更上报一次。 | -| SENSOR_MODE_ONE_SHOT | 传感器实时工作模式状态,只上报一次。 | -| SENSOR_MODE_FIFO_MODE | 传感器缓存工作模式状态,根据配置的缓存大小上报。 | -| SENSOR_MODE_MAX | 传感器最大类型标识。 | - - -### SensorRangeType - - -``` -enum SensorRangeType -``` - -**描述:** - -传感器的量程级别。 - -| 枚举值 | 描述 | -| -------- | -------- | -| SENSOR_RANGE_LEVEL1 | 量程级别1。 | -| SENSOR_RANGE_LEVEL2 | 量程级别2。 | -| SENSOR_RANGE_LEVEL3 | 量程级别3。 | -| SENSOR_RANGE_LEVEL_MAX | 量程最大级别。 | - - -### SensorStatus - - -``` -enum SensorStatus -``` - -**描述:** - -定义传感器模块返回值类型。 - -| 枚举值 | 描述 | -| -------- | -------- | -| SENSOR_SUCCESS | 传感器执行成功。 | -| SENSOR_FAILURE | 传感器执行失败。 | -| SENSOR_NOT_SUPPORT | 传感器不支持。 | -| SENSOR_INVALID_PARAM | 传感器无效参数。 | -| SENSOR_INVALID_SERVICE | 传感器无效服务。 | -| SENSOR_NULL_PTR | 传感器空指针。 | - - -### SensorTypeTag - - -``` -enum SensorTypeTag -``` - -**描述:** - -定义传感器类型标识。 - -| 枚举值 | 描述 | -| -------- | -------- | -| SENSOR_TYPE_NONE | 空传感器类型,用于测试。 | -| SENSOR_TYPE_ACCELEROMETER | 加速度传感器。 | -| SENSOR_TYPE_GYROSCOPE | 陀螺仪传感器。 | -| SENSOR_TYPE_PHOTOPLETHYSMOGRAPH | 心率传感器。 | -| SENSOR_TYPE_ELECTROCARDIOGRAPH | 心电传感器。 | -| SENSOR_TYPE_AMBIENT_LIGHT | 环境光传感器。 | -| SENSOR_TYPE_MAGNETIC_FIELD | 地磁传感器。 | -| SENSOR_TYPE_CAPACITIVE | 电容传感器。 | -| SENSOR_TYPE_BAROMETER | 气压计传感器。 | -| SENSOR_TYPE_TEMPERATURE | 温度传感器。 | -| SENSOR_TYPE_HALL | 霍尔传感器。 | -| SENSOR_TYPE_GESTURE | 手势传感器。 | -| SENSOR_TYPE_PROXIMITY | 接近光传感器。 | -| SENSOR_TYPE_HUMIDITY | 湿度传感器。 | -| SENSOR_TYPE_MEDICAL_BEGIN | 医疗传感器ID枚举值范围的开始。 | -| SENSOR_TYPE_MEDICAL_END | 医疗传感器ID枚举值范围的结束。 | -| SENSOR_TYPE_PHYSICAL_MAX | 物理传感器最大类型。 | -| SENSOR_TYPE_ORIENTATION | 方向传感器。 | -| SENSOR_TYPE_GRAVITY | 重力传感器。 | -| SENSOR_TYPE_LINEAR_ACCELERATION | 线性加速度传感器。 | -| SENSOR_TYPE_ROTATION_VECTOR | 旋转矢量传感器。 | -| SENSOR_TYPE_AMBIENT_TEMPERATURE | 环境温度传感器 | -| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | 未校准磁场传感器。 | -| SENSOR_TYPE_GAME_ROTATION_VECTOR | 游戏旋转矢量传感器。 | -| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | 未校准陀螺仪传感器。 | -| SENSOR_TYPE_SIGNIFICANT_MOTION | 大幅度动作传感器。 | -| SENSOR_TYPE_PEDOMETER_DETECTION | 计步器检测传感器。 | -| SENSOR_TYPE_PEDOMETER | 计步器传感器。 | -| SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | 地磁旋转矢量传感器。 | -| SENSOR_TYPE_HEART_RATE | 心率传感器。 | -| SENSOR_TYPE_DEVICE_ORIENTATION | 设备方向传感器。 | -| SENSOR_TYPE_WEAR_DETECTION | 佩戴检测传感器。 | -| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | 未校准加速度传感器。 | -| SENSOR_TYPE_MAX | 传感器类型最大个数标识。 | - - -## **函数说明** - - -### FreeSensorInterfaceInstance() - - -``` -int32_t FreeSensorInterfaceInstance (void ) -``` - -**描述:** - -释放传感器接口实例。 - -**返回:** - -如果释放实例成功,则返回0。 - -如果释放实例失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -### NewSensorInterfaceInstance() - - -``` -const struct SensorInterface* NewSensorInterfaceInstance (void ) -``` - -**描述:** - -创建传感器接口实例。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 表示传感器ID。有关详细信息,详见[SensorTypeTag](#sensortypetag)。 | -| cb | 表示要注册的回调函数。有关详细信息,详见[RecordDataCallback](#recorddatacallback)。 | - -**返回:** - -如果创建实例成功,则返回非零值。 - -如果创建实例失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md deleted file mode 100644 index 399be8a87a2254510a176a0053cb7182e00bd953..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md +++ /dev/null @@ -1,122 +0,0 @@ -# SensorEvents - - -## **概述** - -**所属模块:** - -[Sensor](_sensor.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [sensorId](#sensorid) | 传感器的标识号。 | -| [version](#version) | 传感器算法版本号。 | -| [timestamp](#timestamp) | 传感器数据生成时间。 | -| [option](#option) | 传感器量程精度可选配置。 | -| [mode](#mode) | 传感器工作模式。 | -| [data](#data) | 传感器数据地址。 | -| [dataLen](#datalen) | 传感器数据长度。 | - - -## **详细描述** - -上报传感器数据结构。 - -上报传感器设备数据事件信息包括传感器的标识号、传感器算法版本号、传感器数据生成时间、传感器量程精度可选配置、传感器工作模式、传感器数据地址、传感器数据长度。 - -**Since:** - -2.2 - - -## **类成员变量说明** - - -### data - - -``` -uint8_t* SensorEvents::data -``` - -**描述:** - -传感器数据地址。 - - -### mode - - -``` -int32_t SensorEvents::mode -``` - -**描述:** - -传感器工作模式。 - - -### option - - -``` -uint32_t SensorEvents::option -``` - -**描述:** - -传感器量程精度可选配置。 - - -### sensorId - - -``` -int32_t SensorEvents::sensorId -``` - -**描述:** - -传感器的标识号。 - - -### timestamp - - -``` -int64_t SensorEvents::timestamp -``` - -**描述:** - -传感器数据生成时间。 - - -### version - - -``` -int32_t SensorEvents::version -``` - -**描述:** - -传感器算法版本号。 - - -### dataLen - - -``` -int32_t SensorEvents::dataLen -``` - -**描述:** - -传感器算法版本号。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md deleted file mode 100644 index 083c23aab81e737015db46d92d10380f6775cbdb..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md +++ /dev/null @@ -1,148 +0,0 @@ -# SensorInformation - - -## **概述** - -**所属模块:** - -[Sensor](_sensor.md) - - -## **汇总** - - -### Public 属性 - -| Public 属性 | 描述 | -| -------- | -------- | -| [sensorName](#sensorname) [[SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen)] | 传感器名称。 | -| [vendorName](#vendorname) [[SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen)] | 传感器设备厂商。 | -| [firmwareVersion](#firmwareversion) [[SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen)] | 传感器固件版本号。 | -| [hardwareVersion](#hardwareversion)
[[SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen)] | 传感器硬件版本号。 | -| [sensorTypeId](#sensortypeid) | 传感器类型编号。 | -| [sensorId](#sensorid) | 传感器的标识号,由传感器驱动开发者定义。 | -| [maxRange](#maxrange) | 传感器的最大量程。 | -| [accuracy](#accuracy) | 传感器的精度。 | -| [power](#power) | 传感器的功耗。 | - - -## **详细描述** - -定义传感器基本信息。 - -一个传感器设备信息包括传感器名字、设备厂商、固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗。 - -**Since:** - -2.2 - - -## **类成员变量说明** - - -### accuracy - - -``` -float SensorInformation::accuracy -``` - -**描述:** - -传感器的精度。 - - -### firmwareVersion - - -``` -char SensorInformation::firmwareVersion[SENSOR_VERSION_MAX_LEN] -``` - -**描述:** - -传感器固件版本号。 - - -### hardwareVersion - - -``` -char SensorInformation::hardwareVersion[SENSOR_VERSION_MAX_LEN] -``` - -**描述:** - -传感器硬件版本号。 - - -### maxRange - - -``` -float SensorInformation::maxRange -``` - -**描述:** - -传感器的最大量程。 - - -### sensorId - - -``` -int32_t SensorInformation::sensorId -``` - -**描述:** - -传感器的标识号,由传感器驱动开发者定义。 - - -### sensorName - - -``` -char SensorInformation::sensorName[SENSOR_NAME_MAX_LEN] -``` - -**描述:** - -传感器名称。 - - -### sensorTypeId - - -``` -int32_t SensorInformation::sensorTypeId -``` - -**描述:** - -传感器类型编号,唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 - - -### vendorName - - -``` -char SensorInformation::vendorName[SENSOR_NAME_MAX_LEN] -``` - -**描述:** - -传感器设备厂商。 - - -### power - - -``` -char SensorInformation::power -``` - -**描述:** - -传感器的功耗。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md deleted file mode 100644 index a6c64a9af33a52941b36c03b13843f780e9d518f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md +++ /dev/null @@ -1,234 +0,0 @@ -# SensorInterface - - -## **概述** - -**所属模块:** - -[Sensor](_sensor.md) - - -## **汇总** - - -### Public 属性 - -| Public 属性 | 描述 | -| -------- | -------- | -| ( [GetAllSensors](#getallsensors) )([out] struct [SensorInformation](_sensor_information.md) \*\*sensorInfo, [out] int32_t \*count) | 获取当前系统中所有类型的传感器信息。 [更多...](#getallsensors) | -| ( [Enable](#enable) )([in] int32_t sensorId) | 根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 [更多...](#enable) | -| ( [Disable](#disable) )([in] int32_t sensorId) | 根据传感器设备类型标识去使能传感器信息列表里存在的设备。 [更多...](#disable) | -| ( [SetBatch](#setbatch) )([in] int32_t sensorId, [in] int64_t samplingInterval, [in] int64_t reportInterval) | 设置指定传感器的数据采样间隔和数据上报间隔。 [更多...](#setbatch) | -| ( [SetMode](#setmode) )([in] int32_t sensorId, [in] int32_t mode) | 设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 [更多...](#setmode) | -| ( [SetOption](#setoption) )([in] int32_t sensorId, [in] uint32_t option) | 设置指定传感器量程、精度等可选配置。 [更多...](#setoption) | -| ( [Register](#register) )([in] int32_t groupId, [in] [RecordDataCallback](_sensor.md#recorddatacallback) cb) | 订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 [更多...](#register) | -| ( [Unregister](#unregister) )([in] int32_t groupId, [in] [RecordDataCallback](_sensor.md#recorddatacallback) cb) | 订阅者取消注册传感器数据回调函数。 [更多...](#unregister) | - - -## **详细描述** - -提供sensor设备基本控制操作接口。 - -结构体提供获取传感器设备信息、订阅/取消订阅传感器数据、使能/去使能传感器、设置传感器模式、设置传感器精度、量程等可选配置接口定义。 - - -## **类成员变量说明** - - -### Disable - - -``` -int32_t(* SensorInterface::Disable) ([in] int32_t sensorId) -``` - -**描述:** - -根据传感器设备类型标识去使能传感器信息列表里存在的设备。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### Enable - - -``` -int32_t(* SensorInterface::Enable) ([in] int32_t sensorId) -``` - -**描述:** - -根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### GetAllSensors - - -``` -int32_t(* SensorInterface::GetAllSensors) ([out] struct SensorInformation **sensorInfo,[out] int32_t *count) -``` - -**描述:** - -获取当前系统中所有类型的传感器信息。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorInfo | 输出系统中注册的所有传感器信息,一种类型传感器信息包括传感器名字、设备厂商、 固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗,详见[SensorInformation](_sensor_information.md)。 | -| count | 输出系统中注册的传感器数量。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### Register - - -``` -int32_t(* SensorInterface::Register) ([in] int32_t groupId,[in] RecordDataCallback cb) -``` - -**描述:** - -订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| groupId | 传感器组ID。 sensorId枚举值范围为128-160,表示已订阅医疗传感器服务,只需成功订阅一次,无需重复订阅。 sensorId枚举值范围不在128-160之间,这意味着传统传感器已订阅,只需成功订阅一次,无需重复订阅。 | -| cb | 要注册的回调函数,详见[RecordDataCallback](_sensor.md#recorddatacallback)。 | - -**返回:** - -如果注册回调函数成功,则返回0。 - -如果注册回调函数失败,则返回负数。 - - -### SetBatch - - -``` -int32_t(* SensorInterface::SetBatch) ([in] int32_t sensorId,[in] int64_t samplingInterval,[in] int64_t reportInterval) -``` - -**描述:** - -设置指定传感器的数据采样间隔和数据上报间隔。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 | -| samplingInterval | 设置指定传感器的数据采样间隔,单位纳秒。 | -| reportInterval | 表示传感器数据上报间隔,单位纳秒。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - - -### SetMode - - -``` -int32_t(* SensorInterface::SetMode) ([in] int32_t sensorId,[in] int32_t mode) -``` - -**描述:** - -设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 | -| mode | 传感器的数据上报模式,详见[SensorModeType](_sensor.md#sensormodetype)。 | - -**返回:** - -如果设置传感器数据报告模式成功,则返回0。 - -如果设置传感器数据报告模式失败,则返回负数。 - - -### SetOption - - -``` -int32_t(* SensorInterface::SetOption) ([in] int32_t sensorId,[in] uint32_t option) -``` - -**描述:** - -设置指定传感器量程、精度等可选配置。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| sensorId | 唯一标识一个传感器设备类型,详见[SensorTypeTag](_sensor.md#sensortypetag)。 | -| option | 传感器的量程、精度等配置。 | - -**返回:** - -如果设置参数成功,则返回0。 - -如果设置参数失败,则返回负数。 - - -### Unregister - - -``` -int32_t(* SensorInterface::Unregister) ([in] int32_t groupId,[in] RecordDataCallback cb) -``` - -**描述:** - -订阅者取消注册传感器数据回调函数。 - -**参数:** - -| 名称 | 描述 | -| -------- | -------- | -| groupId | 传感器组ID。 sensorId枚举值范围为128-160,表示已订阅医疗传感器服务。只需成功取消订阅一次,无需重复取消订阅。 sensorId枚举值范围不在128-160之间,这意味着传统传感器已订阅。并且成功取消订阅。 | -| cb | 要取消注册的回调函数,详见[RecordDataCallback](_sensor.md#recorddatacallback)。 | - -**返回:** - -如果取消注册回调函数成功,则返回0。 - -如果取消注册回调函数失败,则返回负数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..8eadb3a7c36ddf82a854b6a9e9c264e2abf80b9b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sensor_types_8idl.md @@ -0,0 +1,45 @@ +# SensorTypes.idl + + +## **概述** + +定义传感器模块所使用的传感器类型,传感器信息,传感器数据结构等数据类型。 + +**Since:** + +2.2 + +**Version:** + +1.0 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfSensorInformation](_hdf_sensor_information.md) | 定义传感器的基本信息。 | +| [HdfSensorEvents](_hdf_sensor_events.md) | 定义传感器上报的数据。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfSensorTypeTag](sensor.md#hdfsensortypetag) {   HDF_SENSOR_TYPE_NONE = 0, HDF_SENSOR_TYPE_ACCELEROMETER = 1, HDF_SENSOR_TYPE_GYROSCOPE = 2, HDF_SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3,   HDF_SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, HDF_SENSOR_TYPE_AMBIENT_LIGHT = 5, HDF_SENSOR_TYPE_MAGNETIC_FIELD = 6, HDF_SENSOR_TYPE_CAPACITIVE = 7,   HDF_SENSOR_TYPE_BAROMETER = 8, HDF_SENSOR_TYPE_TEMPERATURE = 9, HDF_SENSOR_TYPE_HALL = 10, HDF_SENSOR_TYPE_GESTURE = 11,   HDF_SENSOR_TYPE_PROXIMITY = 12, HDF_SENSOR_TYPE_HUMIDITY = 13, HDF_SENSOR_TYPE_MEDICAL_BEGIN = 128, HDF_SENSOR_TYPE_MEDICAL_END = 160,   HDF_SENSOR_TYPE_PHYSICAL_MAX = 255, HDF_SENSOR_TYPE_ORIENTATION = 256, HDF_SENSOR_TYPE_GRAVITY = 257, HDF_SENSOR_TYPE_LINEAR_ACCELERATION = 258,   HDF_SENSOR_TYPE_ROTATION_VECTOR = 259, HDF_SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, HDF_SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, HDF_SENSOR_TYPE_GAME_ROTATION_VECTOR = 262,   HDF_SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, HDF_SENSOR_TYPE_SIGNIFICANT_MOTION = 264, HDF_SENSOR_TYPE_PEDOMETER_DETECTION = 265, HDF_SENSOR_TYPE_PEDOMETER = 266,   HDF_SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, HDF_SENSOR_TYPE_HEART_RATE = 278, HDF_SENSOR_TYPE_DEVICE_ORIENTATION = 279, HDF_SENSOR_TYPE_WEAR_DETECTION = 280,   HDF_SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, HDF_SENSOR_TYPE_MAX } | 定义传感器类型标识。 | +| [HdfSensorGroupType](sensor.md#hdfsensorgrouptype) { HDF_TRADITIONAL_SENSOR_TYPE = 0, HDF_MEDICAL_SENSOR_TYPE = 1, HDF_SENSOR_GROUP_TYPE_MAX } | 枚举传感器的硬件服务组。 | +| [HdfSensorModeType](sensor.md#hdfsensormodetype) {   SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3,   SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | 传感器的工作模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.sensor.v1_0 | Sensor模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_sta_info.md b/zh-cn/device-dev/reference/hdi-apis/_sta_info.md deleted file mode 100644 index 605e17a4f2e3e629a11939553baf0b28cbf0561e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_sta_info.md +++ /dev/null @@ -1,46 +0,0 @@ -# StaInfo - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| [mac](#mac) [[WIFI_MAC_ADDR_LENGTH](_w_l_a_n.md#ga27ea7645cf89c113dae48346e19a676f)] | STA的MAC地址 | - - -## **详细描述** - -描述与AP连接的STA的基本信息。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类成员变量说明** - - -### mac - - -``` -unsigned char StaInfo::mac[WIFI_MAC_ADDR_LENGTH] -``` - -**描述:** - -STA的MAC地址。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_stream_attribute.md b/zh-cn/device-dev/reference/hdi-apis/_stream_attribute.md new file mode 100644 index 0000000000000000000000000000000000000000..0f27781eb80cac98f6a7ed813503f715d4220486 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_stream_attribute.md @@ -0,0 +1,139 @@ +# StreamAttribute + + +## **概述** + +流的属性。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [streamId_](#streamid) | 流的ID,用于在设备内唯一标识一条流。 | +| [width_](#width) | 图像宽度。 | +| [height_](#height) | 图像高度。 | +| [overrideFormat_](#overrideformat) | 重写的图像格式。 | +| [overrideDataspace_](#overridedataspace) | 重写的图像颜色空间 | +| [producerUsage_](#producerusage) | 重写后的生产者的使用方式。 | +| [producerBufferCount_](#producerbuffercount) | 重写后的生产者缓存数量。 | +| [maxBatchCaptureCount_](#maxbatchcapturecount) | 连拍支持的最大捕获帧数量。 | +| [maxCaptureCount_](#maxcapturecount) | 最大的并发捕获请求个数,默认为1。 | + + +## **类成员变量说明** + + +### height_ + + +``` +int StreamAttribute::height_ +``` + +**描述:** + +图像高度。 + + +### maxBatchCaptureCount_ + + +``` +int StreamAttribute::maxBatchCaptureCount_ +``` + +**描述:** + +连拍支持的最大捕获帧数量。 + + +### maxCaptureCount_ + + +``` +int StreamAttribute::maxCaptureCount_ +``` + +**描述:** + +最大的并发捕获请求个数,默认为1。 + + +### overrideDataspace_ + + +``` +int StreamAttribute::overrideDataspace_ +``` + +**描述:** + +重写的图像颜色空间。 + + +### overrideFormat_ + + +``` +int StreamAttribute::overrideFormat_ +``` + +**描述:** + +重写的图像格式。 + + +### producerBufferCount_ + + +``` +int StreamAttribute::producerBufferCount_ +``` + +**描述:** + +重写后的生产者缓存数量。 + + +### producerUsage_ + + +``` +int StreamAttribute::producerUsage_ +``` + +**描述:** + +重写后的生产者的使用方式。 + + +### streamId_ + + +``` +int StreamAttribute::streamId_ +``` + +**描述:** + +流的ID,用于在设备内唯一标识一条流。 + + +### width_ + + +``` +int StreamAttribute::width_ +``` + +**描述:** + +图像宽度。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_stream_info.md b/zh-cn/device-dev/reference/hdi-apis/_stream_info.md new file mode 100644 index 0000000000000000000000000000000000000000..ee81d8c68b65077efd2955c34d50b3d27ce0100b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_stream_info.md @@ -0,0 +1,152 @@ +# StreamInfo + + +## **概述** + +流信息,用于创建流时传入相关的配置参数。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [streamId_](#streamid) | 流的ID,用于在设备内唯一标识一条流。 | +| [width_](#width) | 图像宽度。 | +| [height_](#height) | 图像高度。 | +| [format_](#format) | 图像格式。 | +| [dataspace_](#dataspace) | 图像颜色空间。 | +| [intent_](#intent) | 流类型。 | +| [tunneledMode_](#tunneledmode) | 隧道模式,值为true时开启,false关闭。 | +| [bufferQueue_](#bufferqueue) | 图形提供的生产者句柄。 | +| [minFrameDuration_](#minframeduration) | 最小帧间隔。 | +| [encodeType_](#encodetype) | 编码类型。 | + + +## **类成员变量说明** + + +### bufferQueue_ + + +``` +BufferProducerSequenceable StreamInfo::bufferQueue_ +``` + +**描述:** + +图形提供的生产者句柄。 + + +### dataspace_ + + +``` +int StreamInfo::dataspace_ +``` + +**描述:** + +图像颜色空间。 + + +### encodeType_ + + +``` +enum EncodeType StreamInfo::encodeType_ +``` + +**描述:** + +编码类型。 + + +### format_ + + +``` +int StreamInfo::format_ +``` + +**描述:** + +图像格式。 + + +### height_ + + +``` +int StreamInfo::height_ +``` + +**描述:** + +图像高度。 + + +### intent_ + + +``` +enum StreamIntent StreamInfo::intent_ +``` + +**描述:** + +流类型。 + + +### minFrameDuration_ + + +``` +int StreamInfo::minFrameDuration_ +``` + +**描述:** + +最小帧间隔。 + + +### streamId_ + + +``` +int StreamInfo::streamId_ +``` + +**描述:** + +流的ID,用于在设备内唯一标识一条流。 + + +### tunneledMode_ + + +``` +boolean StreamInfo::tunneledMode_ +``` + +**描述:** + +隧道模式,值为true时开启,false关闭。 开启隧道模式后,HAL不直接和上层交互,通过图形提供的生产者句柄来传递帧数据, 对于一些IOT设备,可能不需要或者不支持预览流的图像数据缓存流转,此时需要关闭隧道模式。 + + +### width_ + + +``` +int StreamInfo::width_ +``` + +**描述:** + +图像宽度。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md b/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md index 22e7876400f9ef145757edc027231d5053b53499..d185ae8f897719c5e443d35bef17317916d79566 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md +++ b/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +SupportBuffer类型定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [size](#size) | 结构体大小 | | [version](#version) | 组件版本信息 | @@ -21,11 +23,6 @@ | [bufferTypes](#buffertypes) | 支持的所有Buffer类型 | -## **详细描述** - -SupportBuffer类型定义。 - - ## **类成员变量说明** @@ -38,7 +35,7 @@ uint32_t SupportBufferType::bufferTypes **描述:** -支持的所有Buffer类型 +支持的所有Buffer类型。 ### portIndex @@ -50,7 +47,7 @@ uint32_t SupportBufferType::portIndex **描述:** -端口索引 +端口索引。 ### size @@ -62,7 +59,7 @@ uint32_t SupportBufferType::size **描述:** -结构体大小 +结构体大小。 ### version @@ -74,4 +71,4 @@ union OMX_VERSIONTYPE SupportBufferType::version **描述:** -组件版本信息 +组件版本信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_template_info.md b/zh-cn/device-dev/reference/hdi-apis/_template_info.md index 9bdd2da28e29d9067964f47ecb713d2fff8f2a7e..eefb0c607c9e6f08ae07274f7711a98d0dcf7793 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_template_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_template_info.md @@ -3,6 +3,16 @@ ## **概述** +凭据模版信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) | [HdfPinAuth](_hdf_pin_auth.md) @@ -13,27 +23,14 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [executorType](#executortype) | 执行器类型,根据执行器支持的算法类型进行分类。 | -| [lockoutDuration](#lockoutduration) | 认证方式被冻结的时间。 | -| [remainAttempts](#remainattempts) | 认证方式距离被冻结的可处理认证请求次数。 | +| [freezingTime](#freezingtime) | 认证方式被冻结的时间。 | +| [remainTimes](#remaintimes) | 认证方式距离被冻结的可处理认证请求次数。 | | [extraInfo](#extrainfo) | 其他相关信息,用于支持信息扩展。 | -## **详细描述** - -凭据模版信息。 - -**Since:** - -3.2 - -**Version:** - -1.0 - - ## **类成员变量说明** @@ -61,11 +58,11 @@ unsigned char [] TemplateInfo::extraInfo 其他相关信息,用于支持信息扩展。 -### lockoutDuration +### freezingTime ``` -int TemplateInfo::lockoutDuration +int TemplateInfo::freezingTime ``` **描述:** @@ -73,11 +70,11 @@ int TemplateInfo::lockoutDuration 认证方式被冻结的时间。 -### remainAttempts +### remainTimes ``` -int TemplateInfo::remainAttempts +int TemplateInfo::remainTimes ``` **描述:** diff --git a/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md index 38c78e4de0d69fd3c775a820e311780c09d6482f..8a9f62560247133588da745fba6962eaf13b0120 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md @@ -3,39 +3,36 @@ ## **概述** -**所属模块:** - -[Thermal](thermal.md) - +设备发热状态相关的数据类型。 -## **汇总** +热管理中使用的数据类型,包括设备发热的信息和设备发热的信息列表。 +**Since:** -### 类 +3.1 - | 类 | 描述 | -| -------- | -------- | -| [ThermalZoneInfo](_thermal_zone_info.md) | 设备发热的信息。 [更多...](_thermal_zone_info.md) | -| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备发热的信息列表。 [更多...](_hdf_thermal_callback_info.md) | +**Version:** +1.0 -### 变量 +**相关模块:** - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.thermal.v1_0 | 设备温度管理接口的包路径 | +[Thermal](thermal.md) -## **详细描述** +## **汇总** -设备发热状态相关的数据类型。 -热管理中使用的数据类型,包括设备发热的信息和设备发热的信息列表。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [ThermalZoneInfo](_thermal_zone_info.md) | 设备发热的信息。 | +| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备发热的信息列表。 | -3.1 -**Version:** +### 关键字 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | Thermal模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md b/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md index 6c60b3463c1d06fa6efc51a5d5c0ba07fc3be39f..55c9cd68298c64581d78f868a3678c556f2b17dd 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md @@ -3,7 +3,13 @@ ## **概述** -**所属模块:** +设备发热的信息。 + +**Since:** + +3.1 + +**相关模块:** [Thermal](thermal.md) @@ -13,21 +19,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [type](#type) | 发热器件的类型。 | | [temp](#temp) | 器件的温度值。 | -## **详细描述** - -设备发热的信息。 - -**Since:** - -3.1 - - ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md deleted file mode 100644 index b924caff85bec0cdd0dcac7a8eefa0fca8334854..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md +++ /dev/null @@ -1,49 +0,0 @@ -# Types.idl - - -## **概述** - -**所属模块:** - -[Battery](battery.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [BatteryInfo](_battery_info.md) | 电池相关信息。 [更多...](_battery_info.md) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [BatteryHealthState](battery.md#batteryhealthstate) {   BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE,   BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | 电池的健康状态。 [更多...](battery.md#batteryhealthstate) | -| [BatteryChargeState](battery.md#batterychargestate) {   CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL,   CHARGE_STATE_RESERVED } | 电池的充电状态。 [更多...](battery.md#batterychargestate) | -| [BatteryPluggedType](battery.md#batterypluggedtype) {   PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS,   PLUGGED_TYPE_BUTT } | 电池的充电设备类型。 [更多...](battery.md#batterypluggedtype) | - - -### 变量 - - | 变量 名称 | 描述 | -| -------- | -------- | -| package ohos.hdi.battery.v1_0 | 电池信息接口的包路径 | - - -## **详细描述** - -电池信息相关数据类型。 - -电池信息中使用的数据类型,包括健康状态、充电状态、充电设备类型和电池信息结构。 - -**Since:** - -3.1 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md b/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md deleted file mode 100644 index 3753bc9918d7c0294c6ac0a78719179b8c252740..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md +++ /dev/null @@ -1,1863 +0,0 @@ -# USB - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [usb_info.h](usb__info_8h.md) | USB驱动订阅模块使用的数据类型。 | -| [usbd_client.h](usbd__client_8h.md) | 声明标准USB驱动接口函数。 | -| [usbd_subscriber.h](usbd__subscriber_8h.md) | USB驱动订阅模块。 | -| [usbd_type.h](usbd__type_8h.md) | USB驱动模块接口定义中使用的自定义数据类型。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信息。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | -| [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | USB设备信息类。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | -| [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | Usb驱动类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | -| [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | 订阅类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | -| [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | USB设备。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | -| [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | 管道信息。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | -| [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | USB控制传输。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| [USB_MAX_INTERFACES](#usb\_max\_interfaces)   32 | USB设备最大接口数量。 | - - -### 静态常量 - - | 静态常量 | 描述 | -| -------- | -------- | -| [USB_ENDPOINT_DIR_MASK](#usb\_endpoint\_dir\_mask)   0x80 | 从地址中提取USB Endpoint方向的位掩码。 | -| [USB_ENDPOINT_DIR_IN](#usb\_endpoint\_dir\_in)   0x80 | USB Endpoint从设备到主机的数据方向。 | -| [USB_ENDPOINT_DIR_OUT](#usb\_endpoint\_dir\_out)   0 | USB Endpoint从主机到设备的数据方向。 | - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| ([UsbdRequestCallback](#usbdrequestcallback)) (uint8_t \*requestArg) | 请求回调函数。[更多...](#usbdrequestcallback) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [UsbdBulkCbCmd](#usbdbulkcbcmd) { CMD_USBD_BULK_CALLBACK_READ, CMD_USBD_BULK_CALLBACK_WRITE } | 批量回调命令字。 [更多...](#usbdbulkcbcmd) | -| [UsbdDeviceAction](#usbddeviceaction) { ACT_DEVUP = 0, ACT_DEVDOWN, ACT_UPDEVICE, ACT_DOWNDEVICE } | 主机端和设备端插拔事件。 [更多...](#usbddeviceaction) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [OHOS::USB::UsbInfo::setDevInfoStatus](#setdevinfostatus) (int32_t status) | 设置USB设备状态。 [更多...](#setdevinfostatus) | -| [OHOS::USB::UsbInfo::setDevInfoBusNum](#setdevinfobusnum) (int32_t busNum) | 设置USB总线编号。 [更多...](#setdevinfobusnum) | -| [OHOS::USB::UsbInfo::setDevInfoDevNum](#setdevinfodevnum) (int32_t devNum) | 设置USB设备编号。 [更多...](#setdevinfodevnum) | -| [OHOS::USB::UsbInfo::getDevInfoStatus](#getdevinfostatus) () const | 获取USB设备状态。 [更多...](#getdevinfostatus) | -| [OHOS::USB::UsbInfo::getDevInfoBusNum](#getdevinfobusnum) () const | 获取USB总线编号。 [更多...](#getdevinfobusnum) | -| [OHOS::USB::UsbInfo::getDevInfoDevNum](#getdevinfodevnum) () const | 获取USB设备编号。 [更多...](#getdevinfodevnum) | -| [OHOS::USB::UsbdClient::GetInstance](#getinstance) ()  | 获取实例。 [更多...](#getinstance) | -| [OHOS::USB::UsbdClient::OpenDevice](#opendevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 打开设备,建立连接。 [更多...](#opendevice) | -| [OHOS::USB::UsbdClient::CloseDevice](#closedevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 关闭设备,释放与设备相关的所有系统资源。 [更多...](#closedevice) | -| [OHOS::USB::UsbdClient::GetDeviceDescriptor](#getdevicedescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获取设备描述符。 [更多...](#getdevicedescriptor) | -| [OHOS::USB::UsbdClient::GetStringDescriptor](#getstringdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | 根据String ID获取设备的字符串描述符。 [更多...](#getstringdescriptor) | -| [OHOS::USB::UsbdClient::GetConfigDescriptor](#getconfigdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | 根据config ID获取设备的配置描述符config。 [更多...](#getconfigdescriptor) | -| [OHOS::USB::UsbdClient::GetRawDescriptor](#getrawdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获取原始描述符。 [更多...](#getrawdescriptor) | -| [OHOS::USB::UsbdClient::GetFileDescriptor](#getfiledescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, int32_t &fd) | 获取文件描述符。 [更多...](#getfiledescriptor) | -| [OHOS::USB::UsbdClient::SetConfig](#setconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t configIndex) | 设置当前的config信息。 [更多...](#setconfig) | -| [OHOS::USB::UsbdClient::GetConfig](#getconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t &configIndex) | 获取当前的config信息。 [更多...](#getconfig) | -| [OHOS::USB::UsbdClient::ClaimInterface](#claiminterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t force) | 打开接口,并声明独占接口,必须在数据传输前执行。 [更多...](#claiminterface) | -| [OHOS::USB::UsbdClient::ReleaseInterface](#releaseinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid) | 关闭接口,释放接口的占用,在停止数据传输后执行。 [更多...](#releaseinterface) | -| [OHOS::USB::UsbdClient::SetInterface](#setinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t altIndex) | 设置指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择。 [更多...](#setinterface) | -| [OHOS::USB::UsbdClient::BulkTransferRead](#bulktransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行批量数据读取,返回读取的数据和长度,端点方向必须为数据读取,可以设置超时时间。 [更多...](#bulktransferread) | -| [OHOS::USB::UsbdClient::BulkTransferWrite](#bulktransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, const std::vector< uint8_t > &data) | 在给定端点上执行批量数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](#bulktransferwrite) | -| [OHOS::USB::UsbdClient::ControlTransfer](#controltransfer) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) &ctrl, std::vector< uint8_t > &data) | 对此设备执行端点零的控制事务,传输方向由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ,则传输是写入,如果是USB_DIR_IN ,则传输是读取。 [更多...](#controltransfer) | -| [OHOS::USB::UsbdClient::InterruptTransferRead](#interrupttransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行中断数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 [更多...](#interrupttransferread) | -| [OHOS::USB::UsbdClient::InterruptTransferWrite](#interrupttransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行中断数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](#interrupttransferwrite) | -| [OHOS::USB::UsbdClient::IsoTransferRead](#isotransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行等时数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 [更多...](#isotransferread) | -| [OHOS::USB::UsbdClient::IsoTransferWrite](#isotransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行等时数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 [更多...](#isotransferwrite) | -| [OHOS::USB::UsbdClient::RequestQueue](#requestqueue) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const std::vector< uint8_t > &clientData, const std::vector< uint8_t > &buffer) | 将指定的端点进行异步数据发送或者接收请求,数据传输方向由端点方向决定。 [更多...](#requestqueue) | -| [OHOS::USB::UsbdClient::RequestWait](#requestwait) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &clientData, std::vector< uint8_t > &buffer, int32_t timeout) | 等待RequestQueue异步请求的操作结果。 [更多...](#requestwait) | -| [OHOS::USB::UsbdClient::RequestCancel](#requestcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 取消待处理的数据请求。 [更多...](#requestcancel) | -| [OHOS::USB::UsbdClient::GetCurrentFunctions](#getcurrentfunctions) (int32_t &funcs) | 获取从设备支持的功能列表(按位域表示)(从设备)。 [更多...](#getcurrentfunctions) | -| [OHOS::USB::UsbdClient::SetCurrentFunctions](#setcurrentfunctions) (int32_t funcs) | 设置从设备支持的功能列表(按位域表示)(从设备)。 [更多...](#setcurrentfunctions) | -| [OHOS::USB::UsbdClient::SetPortRole](#setportrole) (int32_t portId, int32_t powerRole, int32_t dataRole) | 设置port端口的角色。 [更多...](#setportrole) | -| [OHOS::USB::UsbdClient::QueryPort](#queryport) (int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode) | 查询port端口的当前设置。 [更多...](#queryport) | -| [OHOS::USB::UsbdClient::BindUsbdSubscriber](#bindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 绑定订阅者。 [更多...](#bindusbdsubscriber) | -| [OHOS::USB::UsbdClient::UnbindUsbdSubscriber](#unbindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 解绑订阅者。 [更多...](#unbindusbdsubscriber) | -| [OHOS::USB::UsbdClient::RegBulkCallback](#regbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const sptr< IRemoteObject > &cb) | 注册批量传输异步回调函数。 [更多...](#regbulkcallback) | -| [OHOS::USB::UsbdClient::UnRegBulkCallback](#unregbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 注销批量传输异步回调函数。 [更多...](#unregbulkcallback) | -| [OHOS::USB::UsbdClient::BulkRead](#bulkread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批量传输异步读数据。 [更多...](#bulkread) | -| [OHOS::USB::UsbdClient::BulkWrite](#bulkwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批量传输异步写数据。 [更多...](#bulkwrite) | -| [OHOS::USB::UsbdClient::BulkCancel](#bulkcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 批量传输异步取消接口,用于取消当前接口的异步批量读写操作。 [更多...](#bulkcancel) | -| [OHOS::USB::UsbdSubscriber::DeviceEvent](#deviceevent) (const [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) &info)=0 | 设备事件。 [更多...](#deviceevent) | -| [OHOS::USB::UsbdSubscriber::PortChangedEvent](#portchangedevent) (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode)=0 | 端口改变事件。 [更多...](#portchangedevent) | -| [OHOS::USB::UsbdSubscriber::OnRemoteRequest](#onremoterequest) (uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override | 远程请求。 [更多...](#onremoterequest) | -| [OHOS::USB::UsbdSubscriber::ParserUsbInfo](#parserusbinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) | 解析USB设备信息。 [更多...](#parserusbinfo) | -| [OHOS::USB::UsbdSubscriber::ParserPortInfo](#parserportinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) | 解析USB设备端口信息。 [更多...](#parserportinfo) | - - -### 变量 - - | 变量 | 描述 | -| -------- | -------- | -| [OHOS::USB::USBDeviceInfo::status](#status) | USB设备状态 | -| [OHOS::USB::USBDeviceInfo::busNum](#busnum-12) | USB总线编号 | -| [OHOS::USB::USBDeviceInfo::devNum](#devnum) | USB设备编号 | -| [OHOS::USB::UsbDev::busNum](#busnum-22) | USB总线编号 | -| [OHOS::USB::UsbDev::devAddr](#devaddr) | USB设备地址 | -| [OHOS::USB::UsbPipe::interfaceId](#interfaceid) | USB设备接口ID | -| [OHOS::USB::UsbPipe::endpointId](#endpointid) | USB设备端点ID | -| [OHOS::USB::UsbCtrlTransfer::requestType](#requesttype) | 请求类型 | -| [OHOS::USB::UsbCtrlTransfer::requestCmd](#requestcmd) | 请求命令字 | -| [OHOS::USB::UsbCtrlTransfer::value](#value) | 请求值 | -| [OHOS::USB::UsbCtrlTransfer::index](#index) | 索引 | -| [OHOS::USB::UsbCtrlTransfer::timeout](#timeout) | 超时时间 | -| [OHOS::USB::UsbInfo::devInfo](#devinfo ) | USB设备信息 | - - -## **详细描述** - -定义(USB)功能的标准API接口。 - -该模块用于获取描述符、接口对象、请求对象和提交请求的自定义数据类型和函数。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -## **宏定义说明** - - -### USB_MAX_INTERFACES - - -``` -#define USB_MAX_INTERFACES 32 -``` - -**描述:** - -USB设备最大接口数量 - - -## **静态常量说明** - -### USB_ENDPOINT_DIR_MASK - -``` -static const int32_t USB_ENDPOINT_DIR_MASK = 0x80 -``` - -**描述:** - -从地址中提取USB Endpoint方向的位掩码 - - -### USB_ENDPOINT_DIR_IN - -``` -static const int32_t USB_ENDPOINT_DIR_IN = 0x80 -``` - -**描述:** - -USB Endpoint从设备到主机的数据方向 - -### USB_ENDPOINT_DIR_OUT - -``` -static const int32_t USB_ENDPOINT_DIR_OUT = 0 -``` - -**描述:** - -USB Endpoint从主机到设备的数据方向 - - -## **类型定义说明** - - -### UsbdRequestCallback - - -``` -typedef void(* UsbdRequestCallback) (uint8_t *requestArg) -``` - -**描述:** - -请求回调函数 - - -## **枚举类型说明** - - -### UsbdBulkCbCmd - - -``` -enum UsbdBulkCbCmd -``` - -**描述:** - -批量回调命令字。 - - | 枚举值 | 描述 | -| -------- | -------- | -| CMD_USBD_BULK_CALLBACK_READ | 批量回调读取 | -| CMD_USBD_BULK_CALLBACK_WRITE | 批量回调写入 | - - -### UsbdDeviceAction - - -``` -enum UsbdDeviceAction -``` - -**描述:** - -主机端和设备端插拔事件。 - - | 枚举值 | 描述 | -| -------- | -------- | -| ACT_DEVUP | 主机端接入设备 | -| ACT_DEVDOWN | 主机端拔出设备 | -| ACT_UPDEVICE | 设备连接 | -| ACT_DOWNDEVICE | 设备断开 | - - -## **函数说明** - - -### BindUsbdSubscriber() - - -``` -int32_t OHOS::USB::UsbdClient::BindUsbdSubscriber (const sptr< UsbdSubscriber > & subscriber) -``` - -**描述:** - -绑定订阅者。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| subscriber | 输入参数,订阅者信息,详见[UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### BulkCancel() - - -``` -int32_t OHOS::USB::UsbdClient::BulkCancel (const UsbDev & dev, const UsbPipe & pipe ) -``` - -**描述:** - -批量传输异步取消接口,用于取消当前接口的异步批量读写操作。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### BulkRead() - - -``` -int32_t OHOS::USB::UsbdClient::BulkRead (const UsbDev & dev, const UsbPipe & pipe, sptr< Ashmem > & ashmem ) -``` - -**描述:** - -批量传输异步读数据。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| ashmem | 输出参数,为共享内存,用于存放读取的数据,详见**Ashmem**。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### BulkTransferRead() - - -``` -int32_t OHOS::USB::UsbdClient::BulkTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行批量数据读取,返回读取的数据和长度,端点方向必须为数据读取,可以设置超时时间。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输出参数,获取写入的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### BulkTransferWrite() - - -``` -int32_t OHOS::USB::UsbdClient::BulkTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, const std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行批量数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输入参数,写入的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### BulkWrite() - - -``` -int32_t OHOS::USB::UsbdClient::BulkWrite (const UsbDev & dev, const UsbPipe & pipe, sptr< Ashmem > & ashmem ) -``` - -**描述:** - -批量传输异步写数据。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| ashmem | 输入参数,为共享内存,用于存放需要写入的数据,详见**Ashmem**。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### ClaimInterface() - - -``` -int32_t OHOS::USB::UsbdClient::ClaimInterface (const UsbDev & dev, uint8_t interfaceid, uint8_t force ) -``` - -**描述:** - -打开接口,并声明独占接口,必须在数据传输前执行。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| interfaceid | 输入参数,USB设备interface ID。 | -| force | 输入参数,是否强制: 1强制 0不强制。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### CloseDevice() - - -``` -int32_t OHOS::USB::UsbdClient::CloseDevice (const UsbDev & dev) -``` - -**描述:** - -关闭设备,释放与设备相关的所有系统资源。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### ControlTransfer() - - -``` -int32_t OHOS::USB::UsbdClient::ControlTransfer (const UsbDev & dev, const UsbCtrlTransfer & ctrl, std::vector< uint8_t > & data ) -``` - -**描述:** - -对此设备执行端点零的控制事务,传输方向由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ,则传输是写入,如果是USB_DIR_IN ,则传输是读取。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| ctrl | 输入参数,USB设备控制数据包结构,详见[UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md)。 | -| data | 输入/输出参数,读取/写入的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### DeviceEvent() - - -``` -virtual int32_t OHOS::USB::UsbdSubscriber::DeviceEvent (const UsbInfo & info) -``` - -**描述:** - -设备事件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | 输入参数,USB设备信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetConfig() - - -``` -int32_t OHOS::USB::UsbdClient::GetConfig (const UsbDev & dev, uint8_t & configIndex ) -``` - -**描述:** - -获取当前的config信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| configIndex | 输出参数,USB设备config信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetConfigDescriptor() - - -``` -int32_t OHOS::USB::UsbdClient::GetConfigDescriptor (const UsbDev & dev, uint8_t descId, std::vector< uint8_t > & descriptor ) -``` - -**描述:** - -根据config ID获取设备的配置描述符config。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| descId | 输入参数,USB的config ID。 | -| descriptor | 输出参数,获取USB设备config信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetCurrentFunctions() - - -``` -int32_t OHOS::USB::UsbdClient::GetCurrentFunctions (int32_t & funcs) -``` - -**描述:** - -获取从设备支持的功能列表(按位域表示)(从设备)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| funcs | 输出参数,获取当前设备的function的值。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetDeviceDescriptor() - - -``` -int32_t OHOS::USB::UsbdClient::GetDeviceDescriptor (const UsbDev & dev, std::vector< uint8_t > & descriptor ) -``` - -**描述:** - -获取设备描述符。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| descriptor | 输出参数,USB设备描述符信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### getDevInfoBusNum() - - -``` -int32_t OHOS::USB::UsbInfo::getDevInfoBusNum () const -``` - -**描述:** - -获取USB总线编号。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输出参数,USB总线编号。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### getDevInfoDevNum() - - -``` -int32_t OHOS::USB::UsbInfo::getDevInfoDevNum () const -``` - -**描述:** - -获取USB设备编号。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输出参数,USB设备编号。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### getDevInfoStatus() - - -``` -int32_t OHOS::USB::UsbInfo::getDevInfoStatus () const -``` - -**描述:** - -获取USB设备状态。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输出参数,设备状态。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetFileDescriptor() - - -``` -int32_t OHOS::USB::UsbdClient::GetFileDescriptor (const UsbDev & dev, int32_t & fd ) -``` - -**描述:** - -获取文件描述符。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| fd | 输出参数,USB设备文件描述符。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetRawDescriptor() - - -``` -int32_t OHOS::USB::UsbdClient::GetRawDescriptor (const UsbDev & dev, std::vector< uint8_t > & descriptor ) -``` - -**描述:** - -获取原始描述符。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| descriptor | 输出参数,USB设备原始描述符。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### GetStringDescriptor() - - -``` -int32_t OHOS::USB::UsbdClient::GetStringDescriptor (const UsbDev & dev, uint8_t descId, std::vector< uint8_t > & descriptor ) -``` - -**描述:** - -根据String ID获取设备的字符串描述符。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| descId | 输入参数,USB的string ID。 | -| descriptor | 输出参数,获取USB设备config信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### InterruptTransferRead() - - -``` -int32_t OHOS::USB::UsbdClient::InterruptTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行中断数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输出参数,读取的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### InterruptTransferWrite() - - -``` -int32_t OHOS::USB::UsbdClient::InterruptTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行中断数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输入参数,写入的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### IsoTransferRead() - - -``` -int32_t OHOS::USB::UsbdClient::IsoTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行等时数据读取, 返回读取的数据和长度,端点方向必须为数据读取。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输出参数,读取的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### IsoTransferWrite() - - -``` -int32_t OHOS::USB::UsbdClient::IsoTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) -``` - -**描述:** - -在给定端点上执行等时数据写入, 返回读取的数据和长度,端点方向必须为数据写入。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| timeout | 输入参数,超时时间。 | -| data | 输入参数,读取的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### OnRemoteRequest() - - -``` -int32_t OHOS::USB::UsbdSubscriber::OnRemoteRequest (uint32_t code, MessageParcel & data, MessageParcel & reply, MessageOption & option ) -``` - -**描述:** - -远程请求。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| code | 输入参数,命令字。 | -| data | 输入参数,待解析的数据。 | -| reply | 输出参数,返回的数据。 | -| option | 输入参数,选项数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### OpenDevice() - - -``` -int32_t OHOS::USB::UsbdClient::OpenDevice (const UsbDev & dev) -``` - -**描述:** - -打开设备,建立连接。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### ParserUsbInfo() - - -``` -static int32_t OHOS::USB::UsbdSubscriber::ParserUsbInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) -``` - -**描述:** - -解析USB设备信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| data | 输入参数,命令字。| -| reply | 输出参数,返回的数据。 | -| option | 输入参数,选项数据。| -| info | 输出参数,USB设备信息。| - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - -### ParserPortInfo() - - -``` -static int32_t OHOS::USB::UsbdSubscriber::ParserPortInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) -``` - -**描述:** - -解析USB设备端口信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| data | 输入参数,命令字。| -| reply | 输出参数,返回的数据。 | -| option | 输入参数,选项数据。| -| info | 输出参数,USB设备端口信息。| - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### PortChangedEvent() - - -``` -virtual int32_t OHOS::USB::UsbdSubscriber::PortChangedEvent (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode ) -``` - -**描述:** - -端口改变事件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| portId | 输入参数,端口ID。 | -| powerRole | 输入参数,电源角色的值。 | -| dataRole | 输入参数,数据角色的值。 | -| mode | 输入参数,端口模式的值。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### QueryPort() - - -``` -int32_t OHOS::USB::UsbdClient::QueryPort (int32_t & portId, int32_t & powerRole, int32_t & dataRole, int32_t & mode ) -``` - -**描述:** - -查询port端口的当前设置。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| portId | 输出参数,port接口ID。 | -| powerRole | 输出参数,电源角色的值。 | -| dataRole | 输出参数,数据角色的值。 | -| mode | 输出参数,模式的值。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### RegBulkCallback() - - -``` -int32_t OHOS::USB::UsbdClient::RegBulkCallback (const UsbDev & dev, const UsbPipe & pipe, const sptr< IRemoteObject > & cb ) -``` - -**描述:** - -注册批量传输异步回调函数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| cb | 输入参数,回调函数对象的引用。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### ReleaseInterface() - - -``` -int32_t OHOS::USB::UsbdClient::ReleaseInterface (const UsbDev & dev, uint8_t interfaceid ) -``` - -**描述:** - -关闭接口,释放接口的占用,在停止数据传输后执行。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| interfaceid | 输入参数,USB设备interface ID。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### RequestCancel() - - -``` -int32_t OHOS::USB::UsbdClient::RequestCancel (const UsbDev & dev, const UsbPipe & pipe ) -``` - -**描述:** - -取消待处理的数据请求。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### RequestQueue() - - -``` -int32_t OHOS::USB::UsbdClient::RequestQueue (const UsbDev & dev, const UsbPipe & pipe, const std::vector< uint8_t > & clientData, const std::vector< uint8_t > & buffer ) -``` - -**描述:** - -将指定的端点进行异步数据发送或者接收请求,数据传输方向由端点方向决定。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | -| clientData | 输入参数,用户数据。 | -| buffer | 输入参数,传输的数据。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### RequestWait() - - -``` -int32_t OHOS::USB::UsbdClient::RequestWait (const UsbDev & dev, std::vector< uint8_t > & clientData, std::vector< uint8_t > & buffer, int32_t timeout ) -``` - -**描述:** - -等待RequestQueue异步请求的操作结果。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| clientData | 输入参数,用户数据。 | -| buffer | 输入参数,传输数据。 | -| timeout | 输入参数,超时时间。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### SetConfig() - - -``` -int32_t OHOS::USB::UsbdClient::SetConfig (const UsbDev & dev, uint8_t configIndex ) -``` - -**描述:** - -设置当前的config信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| configIndex | 输入参数,USB设备config信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### SetCurrentFunctions() - - -``` -int32_t OHOS::USB::UsbdClient::SetCurrentFunctions (int32_t funcs) -``` - -**描述:** - -设置从设备支持的功能列表(按位域表示)(从设备)。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| funcs | 输入参数,传入设备支持的function的值。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### setDevInfoBusNum() - - -``` -void OHOS::USB::UsbInfo::setDevInfoBusNum (int32_t busNum) -``` - -**描述:** - -设置USB总线编号。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输入参数,USB总线编号。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### setDevInfoDevNum() - - -``` -void OHOS::USB::UsbInfo::setDevInfoDevNum (int32_t devNum) -``` - -**描述:** - -设置USB设备编号。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输入参数,USB设备编号。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### setDevInfoStatus() - - -``` -void OHOS::USB::UsbInfo::setDevInfoStatus (int32_t status) -``` - -**描述:** - -设置USB设备状态。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| status | 输入参数,设备状态。 | - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### SetInterface() - - -``` -int32_t OHOS::USB::UsbdClient::SetInterface (const UsbDev & dev, uint8_t interfaceid, uint8_t altIndex ) -``` - -**描述:** - -设置指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| interfaceid | 输入参数,USB设备interface ID。 | -| altIndex | 输入参数,interface的AlternateSetting信息。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### SetPortRole() - - -``` -int32_t OHOS::USB::UsbdClient::SetPortRole (int32_t portId, int32_t powerRole, int32_t dataRole ) -``` - -**描述:** - -设置port端口的角色。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| portId | 输入参数,port接口ID。 | -| powerRole | 输入参数,电源角色的值。 | -| dataRole | 输入参数,数据角色的值。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### UnbindUsbdSubscriber() - - -``` -int32_t OHOS::USB::UsbdClient::UnbindUsbdSubscriber (const sptr< UsbdSubscriber > & subscriber) -``` - -**描述:** - -解绑订阅者。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| subscriber | 输入参数,订阅者信息,详见[UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -### UnRegBulkCallback() - - -``` -int32_t OHOS::USB::UsbdClient::UnRegBulkCallback (const UsbDev & dev, const UsbPipe & pipe ) -``` - -**描述:** - -注销批量传输异步回调函数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| dev | 输入参数,USB设备地址信息,详见[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | -| pipe | 输入参数,USB设备pipe信息,详见[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | - -**返回:** - -0 表示操作成功。 - -非零值 表示操作失败。 - -**Since:** - -3.0 - -**Version:** - -1.0 - -### GetInstance() - - -``` -OHOS::USB::UsbdClient::GetInstance() -``` - -**描述:** - -获取实例。 - -**Since:** - -3.0 - -**Version:** - -1.0 - - -## **变量说明** - - -### busNum [1/2] - - -``` -int32_t OHOS::USB::USBDeviceInfo::busNum -``` - -**描述:** - -USB总线编号 - - -### busNum [2/2] - - -``` -uint8_t OHOS::USB::UsbDev::busNum -``` - -**描述:** - -USB总线编号 - - -### devAddr - - -``` -uint8_t OHOS::USB::UsbDev::devAddr -``` - -**描述:** - -USB设备地址 - -### devInfo - - -``` -OHOS::USB::UsbInfo devInfo -``` - -**描述:** - -USB设备信息 - - -### devNum - - -``` -int32_t OHOS::USB::USBDeviceInfo::devNum -``` - -**描述:** - -USB设备编号 - - -### endpointId - - -``` -uint8_t OHOS::USB::UsbPipe::endpointId -``` - -**描述:** - -USB设备端点ID - - -### index - - -``` -int32_t OHOS::USB::UsbCtrlTransfer::index -``` - -**描述:** - -索引 - - -### interfaceId - - -``` -uint8_t OHOS::USB::UsbPipe::interfaceId -``` - -**描述:** - -USB设备接口ID - - -### requestCmd - - -``` -int32_t OHOS::USB::UsbCtrlTransfer::requestCmd -``` - -**描述:** - -请求命令字 - - -### requestType - - -``` -int32_t OHOS::USB::UsbCtrlTransfer::requestType -``` - -**描述:** - -请求类型 - - -### status - - -``` -int32_t OHOS::USB::USBDeviceInfo::status -``` - -**描述:** - -USB设备状态 - - -### timeout - - -``` -int32_t OHOS::USB::UsbCtrlTransfer::timeout -``` - -**描述:** - -超时时间 - - -### value - - -``` -int32_t OHOS::USB::UsbCtrlTransfer::value -``` - -**描述:** - -请求值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_u_s_b_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_u_s_b_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..deb045d7748f4af7f67570f90c437bdeeeccaa9a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_u_s_b_device_info.md @@ -0,0 +1,69 @@ +# USBDeviceInfo + + +## **概述** + +USB设备信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [status](#status) | USB设备状态。 | +| [busNum](#busnum) | USB设备总线编号。 | +| [devNum](#devnum) | USB设备编号。 | + + +## **类成员变量说明** + + +### busNum + + +``` +int USBDeviceInfo::busNum +``` + +**描述:** + +USB设备总线编号。 + + +### devNum + + +``` +int USBDeviceInfo::devNum +``` + +**描述:** + +USB设备编号。 + + +### status + + +``` +int USBDeviceInfo::status +``` + +**描述:** + +USB设备状态。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_usb_ctrl_transfer.md b/zh-cn/device-dev/reference/hdi-apis/_usb_ctrl_transfer.md new file mode 100644 index 0000000000000000000000000000000000000000..99202a9155522e5e3dca0223a93e744ba3547979 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_usb_ctrl_transfer.md @@ -0,0 +1,95 @@ +# UsbCtrlTransfer + + +## **概述** + +USB设备控制传输信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [requestType](#requesttype) | 请求类型。 | +| [requestCmd](#requestcmd) | 请求命令。 | +| [value](#value) | 请求值。 | +| [index](#index) | 索引值。 | +| [timeout](#timeout) | 超时时间。 | + + +## **类成员变量说明** + + +### index + + +``` +int UsbCtrlTransfer::index +``` + +**描述:** + +索引值。 + + +### requestCmd + + +``` +int UsbCtrlTransfer::requestCmd +``` + +**描述:** + +请求命令。 + + +### requestType + + +``` +int UsbCtrlTransfer::requestType +``` + +**描述:** + +请求类型。 + + +### timeout + + +``` +int UsbCtrlTransfer::timeout +``` + +**描述:** + +超时时间。 + + +### value + + +``` +int UsbCtrlTransfer::value +``` + +**描述:** + +请求值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_usb_dev.md b/zh-cn/device-dev/reference/hdi-apis/_usb_dev.md new file mode 100644 index 0000000000000000000000000000000000000000..996d138ed2b6d2d3f5614c3de4d88a52a89abb00 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_usb_dev.md @@ -0,0 +1,56 @@ +# UsbDev + + +## **概述** + +USB设备地址信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [busNum](#busnum) | USB设备总线编号。 | +| [devAddr](#devaddr) | USB设备地址。 | + + +## **类成员变量说明** + + +### busNum + + +``` +unsigned char UsbDev::busNum +``` + +**描述:** + +USB设备总线编号。 + + +### devAddr + + +``` +unsigned char UsbDev::devAddr +``` + +**描述:** + +USB设备地址。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_usb_pipe.md b/zh-cn/device-dev/reference/hdi-apis/_usb_pipe.md new file mode 100644 index 0000000000000000000000000000000000000000..983703acd118e39830f6bea2ea9ebfc699aec1a1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_usb_pipe.md @@ -0,0 +1,56 @@ +# UsbPipe + + +## **概述** + +USB设备管道信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [intfId](#intfid) | USB设备接口ID。 | +| [endpointId](#endpointid) | USB设备端点ID。 | + + +## **类成员变量说明** + + +### endpointId + + +``` +unsigned char UsbPipe::endpointId +``` + +**描述:** + +USB设备端点ID。 + + +### intfId + + +``` +unsigned char UsbPipe::intfId +``` + +**描述:** + +USB设备接口ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_usb_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_usb_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b5e18db841fdd6735867dcfc5c257030401df1f2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_usb_types_8idl.md @@ -0,0 +1,39 @@ +# UsbTypes.idl + + +## **概述** + +USB驱动相关的数据类型。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [PortInfo](_port_info.md) | USB设备端口信息。 | +| [UsbDev](_usb_dev.md) | USB设备地址信息。 | +| [UsbPipe](_usb_pipe.md) | USB设备管道信息。 | +| [UsbCtrlTransfer](_usb_ctrl_transfer.md) | USB设备控制传输信息。 | +| [USBDeviceInfo](_u_s_b_device_info.md) | USB设备信息。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.usb.v1_0 | USB驱动接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md b/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md index 99e2e88d43d8cea5b32d737fca929bc64e8772cb..1ded6ee6683da725b0f7d5018e586857715a02c3 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md +++ b/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +UseBuffer类型定义。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [size](#size) | 结构体大小 | -| [version](#version) | 组件版本信息 | -| [portIndex](#portindex) | 端口索引 | -| [bufferType](#buffertype) | Buffer类型 | - - -## **详细描述** - -UseBuffer类型定义。 +| [size](#size) | 结构体大小。 | +| [version](#version) | 组件版本信息。 | +| [portIndex](#portindex) | 端口索引。 | +| [bufferType](#buffertype) | Buffer类型。 | ## **类成员变量说明** @@ -38,7 +35,7 @@ uint32_t UseBufferType::bufferType **描述:** -Buffer类型 +Buffer类型。 ### portIndex @@ -50,7 +47,7 @@ uint32_t UseBufferType::portIndex **描述:** -端口索引 +端口索引。 ### size @@ -62,7 +59,7 @@ uint32_t UseBufferType::size **描述:** -结构体大小 +结构体大小。 ### version @@ -74,4 +71,4 @@ union OMX_VERSIONTYPE UseBufferType::version **描述:** -组件版本信息 +组件版本信息。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md index fe896715602f302e112f2b7ce8a6965bc4a6b264..9100113265ad2a7134733b9f1b0c3c5d65f925d7 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义用户认证驱动的枚举类和数据结构。 + +**Since:** + +3.2 + **所属模块:** [HdfUserAuth](_hdf_user_auth.md) @@ -13,42 +19,33 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信息。 [更多...](_executor_register_info.md) | -| [ExecutorInfo](_executor_info.md) | 执行器信息。 [更多...](_executor_info.md) | -| [ScheduleInfo](_schedule_info.md) | 调度信息。 [更多...](_schedule_info.md) | -| [AuthSolution](_auth_solution.md) | 认证方案。 [更多...](_auth_solution.md) | -| [ExecutorSendMsg](_executor_send_msg.md) | 执行器发送的消息。 [更多...](_executor_send_msg.md) | -| [AuthResultInfo](_auth_result_info.md) | 用户身份认证结果信息。 [更多...](_auth_result_info.md) | -| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信息。 [更多...](_identify_result_info.md) | -| [EnrollParam](_enroll_param.md) | 注册认证凭据参数。 [更多...](_enroll_param.md) | -| [CredentialInfo](_credential_info.md) | 认证凭据信息。 [更多...](_credential_info.md) | -| [EnrolledInfo](_enrolled_info.md) | 注册信息。 [更多...](_enrolled_info.md) | -| [EnrollResultInfo](_enroll_resultinfo.md) | 录入结果信息。[更多...](_enroll_resultinfo.md) | +| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信息。 | +| [ExecutorInfo](_user_executor_info.md) | 执行器信息。 | +| [ScheduleInfo](_schedule_info.md) | 调度信息。 | +| [AuthSolution](_auth_solution.md) | 认证方案。 | +| [ExecutorSendMsg](_executor_send_msg.md) | 执行器发送的消息。 | +| [AuthResultInfo](_auth_result_info.md) | 用户身份认证结果信息。 | +| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信息。 | +| [EnrollParam](_enroll_param.md) | 注册认证凭据参数。 | +| [CredentialInfo](_credential_info.md) | 认证凭据信息。 | +| [EnrolledInfo](_enrolled_info.md) | 注册信息。 | +| [EnrollResultInfo](_enroll_resultinfo.md) | 录入结果信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AuthType](_hdf_user_auth.md#authtype) : int {   PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认证凭据类型。 [更多...](_hdf_user_auth.md#authtype) | -| [ExecutorRole](_hdf_user_auth.md#executorrole) : int {   COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_user_auth.md#executorrole) | -| [ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel) : int {   ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 [更多...](_hdf_user_auth.md#executorsecurelevel) | -| [PinSubType](_hdf_user_auth.md#pinsubtype) : int {   PIN\_SIX = 10000, PIN\_NUMBER = 10001, PIN\_MIX = 10002 } | 口令认证子类型。 [更多...](_hdf_user_auth.md#pinsubtype) | +| [AuthType](_hdf_user_auth.md#authtype): int { PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认证凭据类型。 | +| [ExecutorRole](_hdf_user_auth.md#executorrole): int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 | +| [ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel): int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全等级。 | +| [PinSubType](_hdf_user_auth.md#pinsubtype) : int { PIN_SIX = 10000, PIN_NUMBER = 10001, PIN_MIX = 10002 } | 口令认证子类型。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.user_auth.v1_0 | 用户认证接口的包路径 | - - -## **详细描述** - -定义用户认证驱动的枚举类和数据结构。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md b/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md index 126685bf071258a5a15d65dc8804d274f1a55325..f19e9e25e402e9ee90326ba0be87827ca0e795ea 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md @@ -3,33 +3,30 @@ ## **概述** -**所属模块:** - -[HdfUserAuth](_hdf_user_auth.md) - +执行器信息。 -## **汇总** +**Since:** +3.2 -### Public 属性 +**Version:** - | Public 属性 | 描述 | -| -------- | -------- | -| executorIndex | 用户认证框架的执行器索引。 | -| info | 执行器注册信息。 | +1.0 +**所属模块:** -## **详细描述** +[HdfUserAuth](_hdf_user_auth.md) -执行器信息。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 属性 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [executorIndex](#executorindex) | 用户认证框架的执行器索引。 | +| [info](#info) | 执行器注册信息。 | ## **类成员变量说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_buffer.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_buffer.md new file mode 100644 index 0000000000000000000000000000000000000000..a97cf039e42f39b062e85430da1ad5b162af3c7d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_buffer.md @@ -0,0 +1,25 @@ +# VGUBuffer + + +## **概述** + +硬件加速渲染位图缓存。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [pixelFormat](_display.md#pixelformat) | 像素格式 | +| [width](_display.md#width-89) | 位图宽度 | +| [height](_display.md#height-88) | 位图高度 | +| [stride](_display.md#stride-22) | 位图stride | +| [virAddr](_display.md#viraddr-22) | 位图缓存的虚拟地址 | +| [phyAddr](_display.md#phyaddr-33) | 位图缓存的物理地址 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_color_stop.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_color_stop.md new file mode 100644 index 0000000000000000000000000000000000000000..3662d99760a72075354044443a391cda7f5b7467 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_color_stop.md @@ -0,0 +1,21 @@ +# VGUColorStop + + +## **概述** + +渐变颜色分布位置。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [stop](_display.md#stop) | 颜色偏移位置, 值范围是 0.0 ~ 1.0 | +| [color](_display.md#color-45) | 偏移位置对应颜色 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_conic.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_conic.md new file mode 100644 index 0000000000000000000000000000000000000000..25f37b5675cc7b63da2b8157e7c4bd1184cd45c0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_conic.md @@ -0,0 +1,21 @@ +# VGUConic + + +## **概述** + +圆锥渐变。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [cx](_display.md#cx) | 圆弧中心x坐标 | +| [cy](_display.md#cy) | 圆弧中心y坐标 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_fill_attr.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_fill_attr.md new file mode 100644 index 0000000000000000000000000000000000000000..04291c89067099b4f9efa3518f54ef7c7143ae4c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_fill_attr.md @@ -0,0 +1,20 @@ +# VGUFillAttr + + +## **概述** + +填充路径的属性。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [rule](_display.md#rule) | 填充规格 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_funcs.md new file mode 100644 index 0000000000000000000000000000000000000000..c8bc61bb2de2a5599fb9a90aac52d1951253235b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_funcs.md @@ -0,0 +1,30 @@ +# VGUFuncs + + +## **概述** + +定义2D硬件加速驱动函数。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| ([VGUFuncs::InitVgu](_display.md#initvgu) )(void) | 初始化硬件加速。 | +| ([VGUFuncs::DeinitVgu](_display.md#deinitvgu) )(void) | 去初始化硬件加速。 | +| ([VGUFuncs::QueryCapability](_display.md#querycapability))(uint32_t cap) | 查询硬件能力集。 | +| ([VGUFuncs::RenderFill](_display.md#renderfill))(VGUSurface \*target, const VGUPath \*path, const VGUMatrix3 \*matrix, const VGUFillAttr \*attr, const VGUPaintStyle \*style) | 使用指定的渲染对象来填充路径。 | +| ([VGUFuncs::RenderStroke](_display.md#renderstroke) )(VGUSurface \*target, const VGUPath \*path, const VGUMatrix3 \*matrix, const VGUStrokeAttr \*attr, const VGUPaintStyle \*style) | 使用指定的渲染对象来描边路径。 | +| ([VGUFuncs::RenderBlur](_display.md#renderblur) )(VGUSurface \*target, uint16_t blur) | 对目标表面进行模糊处理。 | +| ([VGUFuncs::RenderBlit](_display.md#renderblit) )(VGUSurface \*target, const VGUImage \*src, uint32_t color) | 对图像进行搬移操作。 | +| ([VGUFuncs::RenderBlitN](_display.md#renderblitn) )(VGUSurface \*target, const VGUImage \*src, uint16_t count, uint32_t color) | 对多个源图像进行叠加操作。 | +| ([VGUFuncs::RenderClearRect](_display.md#renderclearrect) )(VGUSurface \*target, const VGURect \*rect, uint32_t color, uint8_t opacity) | 对指定矩形进行颜色清除操作。 | +| ([VGUFuncs::RenderCancel](_display.md#rendercancel) )() | 取消硬件加速渲染。 | +| ([VGUFuncs::RenderSync](_display.md#rendersync) )(int32_t timeOut) | 同步硬件加速模块绘制或搬移操作。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_gradient.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_gradient.md new file mode 100644 index 0000000000000000000000000000000000000000..644e6a342e722b09cd4cd33b780c82bd36d977c0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_gradient.md @@ -0,0 +1,28 @@ +# VGUGradient + + +## **概述** + +渐变对象。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [matrix](_display.md#matrix-22) | 针对渐变对象的变换矩阵 | +| [colorStops](_display.md#colorstops) | 渐变停止颜色数组指针 | +| [stopCount](_display.md#stopcount) | 渐变停止颜色个数 | +| [linear](_display.md#linear) | 线性渐变对象 | +| [radial](_display.md#radial) | 辐射渐变对象 | +| [conic](_display.md#conic) | 圆锥渐变对象 | +| [type](_display.md#type-67) | 渐变类型 | +| [spread](_display.md#spread) | 渐变延伸模式 | +| [opacity](_display.md#opacity-23) | 透明度,范围0~255。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_image.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_image.md new file mode 100644 index 0000000000000000000000000000000000000000..d0de468a5b24d6256b121c39d8242766cb62dc93 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_image.md @@ -0,0 +1,23 @@ +# VGUImage + + +## **概述** + +图像对象。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [buffer](_display.md#buffer-33) | 图像存储缓存。 | +| [matrix](_display.md#matrix-12) | 图像矩阵变换,该参数为空,则内部使用单位变换矩阵。 | +| [rect](_display.md#rect-33) | 图像截取矩形,该参数为空,则截取整个图像。 | +| [opacity](_display.md#opacity-13) | 透明度,范围0~255。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_linear.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_linear.md new file mode 100644 index 0000000000000000000000000000000000000000..e666fe236fbe80b1ce0bde1c42152afbb4efd17a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_linear.md @@ -0,0 +1,23 @@ +# VGULinear + + +## **概述** + +线性渐变。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [x1](_display.md#x1-23) | 线性渐变起点水平坐标 | +| [y1](_display.md#y1-23) | 线性渐变起点垂直坐标 | +| [x2](_display.md#x2) | 线性渐变终点水平坐标 | +| [y2](_display.md#y2) | 线性渐变终点垂直坐标 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_mask_layer.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_mask_layer.md new file mode 100644 index 0000000000000000000000000000000000000000..4dab4c31fb6de03edcc6dfdbf3ce040d2177e26a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_mask_layer.md @@ -0,0 +1,21 @@ +# VGUMaskLayer + + +## **概述** + +定义蒙版图层。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [buffer](_display.md#buffer-13) | 蒙版缓存 | +| [rect](_display.md#rect-23) | 蒙版矩形 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_matrix3.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_matrix3.md new file mode 100644 index 0000000000000000000000000000000000000000..96ae437c094298bcfb1bd9e7fc98d528f7e2fd59 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_matrix3.md @@ -0,0 +1,21 @@ +# VGUMatrix3 + + +## **概述** + +定义变换矩阵。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [m](_display.md#m) [3][3] | 3x3变换矩阵 | +| [type](_display.md#type-57) | 矩阵变换类型,简单变换为缩放,平移,90度倍数旋转 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_paint_style.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_paint_style.md new file mode 100644 index 0000000000000000000000000000000000000000..96b7fcc92129c17a1d6cd7f6059affdf0280c295 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_paint_style.md @@ -0,0 +1,23 @@ +# VGUPaintStyle + + +## **概述** + +填充或描边路径的渲染风格。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [gradient](_display.md#gradient) | 渐变对象 | +| [pattern](_display.md#pattern) | 图片模式对象 | +| [solid](_display.md#solid) | 颜色对象 | +| [type](_display.md#type-77) | 渲染类型 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_path.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_path.md new file mode 100644 index 0000000000000000000000000000000000000000..6aaf6ea7f61305fa825e664d2a33f0d9f3cd43c4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_path.md @@ -0,0 +1,25 @@ +# VGUPath + + +## **概述** + +路径对象,存放路径命令和坐标数据。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [segment](_display.md#segment) | 存放路径命令数据 | +| [numSegments](_display.md#numsegments) | 路径命令总数 | +| [data](_display.md#data-22) | 存放路径命令对应坐标数据 | +| [type](_display.md#type-47) | 路径数据存储类型 | +| [enAlias](_display.md#enalias) | 抗锯齿开关 | +| [boundBox](_display.md#boundbox) | 路径最大边界 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_pattern.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_pattern.md new file mode 100644 index 0000000000000000000000000000000000000000..0a703728ea6b9fd15e3c8a4b57b6355177dc6491 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_pattern.md @@ -0,0 +1,22 @@ +# VGUPattern + + +## **概述** + +图片模式对象。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [image](_display.md#image) | 图像对象 | +| [wrapx](_display.md#wrapx) | 图像水平方向平铺类型 | +| [wrapy](_display.md#wrapy) | 图像垂直方向平铺类型 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_point.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_point.md new file mode 100644 index 0000000000000000000000000000000000000000..1d7c6a08a3f967bf5ed110d8e7f84762984ecde4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_point.md @@ -0,0 +1,21 @@ +# VGUPoint + + +## **概述** + +坐标点对象。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [x](_display.md#x-34) | 点水平坐标 | +| [y](_display.md#y-34) | 点垂直坐标 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_radial.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_radial.md new file mode 100644 index 0000000000000000000000000000000000000000..f31d962ebf8de392564085f8651a8b3fdd126fa3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_radial.md @@ -0,0 +1,25 @@ +# VGURadial + + +## **概述** + +辐射渐变。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [x0](_display.md#x0-22) | 内圈圆心水平坐标 | +| [y0](_display.md#y0-22) | 内圈圆心垂直坐标 | +| [r0](_display.md#r0) | 内圈圆半径 | +| [x1](_display.md#x1-33) | 外圈圆心水平坐标 | +| [y1](_display.md#y1-33) | 外圈圆心垂直坐标 | +| [r1](_display.md#r1) | 外圈圆半径 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_rect.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_rect.md new file mode 100644 index 0000000000000000000000000000000000000000..161290841e1bd96ba476ae2e5b14001543bfaa70 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_rect.md @@ -0,0 +1,23 @@ +# VGURect + + +## **概述** + +矩形对象。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [x](_display.md#x-44) | 矩形水平起始坐标 | +| [y](_display.md#y-44) | 矩形垂直起始坐标 | +| [w](_display.md#w-22) | 矩形宽度 | +| [h](_display.md#h-22) | 矩形高度 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_solid.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_solid.md new file mode 100644 index 0000000000000000000000000000000000000000..676479dc7b2dce3b259fba117e30f8a5a29befae --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_solid.md @@ -0,0 +1,21 @@ +# VGUSolid + + +## **概述** + +颜色对象 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [color](_display.md#color-55) | 颜色值 | +| [opacity](_display.md#opacity-33) | 透明度.,取值范围 0 ~ 255。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_stroke_attr.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_stroke_attr.md new file mode 100644 index 0000000000000000000000000000000000000000..50e0672bf8078048db4c8698d1fe41162754668f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_stroke_attr.md @@ -0,0 +1,23 @@ +# VGUStrokeAttr + + +## **概述** + +描边路径的属性。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [cap](_display.md#cap) | 线帽类型 | +| [join](_display.md#join) | 联结类型 | +| [miterLimit](_display.md#miterlimit) | 最大斜切长度 | +| [width](_display.md#width-99) | 线宽 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_v_g_u_surface.md b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_surface.md new file mode 100644 index 0000000000000000000000000000000000000000..bfd04bcea0e682456704e2e100a679be38279eb6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_v_g_u_surface.md @@ -0,0 +1,26 @@ +# VGUSurface + + +## **概述** + +2D硬件加速绘制目标表面。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [buffer](_display.md#buffer-23) | 位图缓存 | +| [clipRect](_display.md#cliprect) | 矩形剪切域,如果为空,整个表面直接渲染。 | +| [clipPath](_display.md#clippath) | 路径剪切域,如果为空,整个表面直接渲染。 | +| [clipType](_display.md#cliptype) | 表面剪切类型 | +| [mask](_display.md#mask) | 蒙版图层, 可以为空。 | +| [blend](_display.md#blend) | 混合叠加模式 | +| [filter](_display.md#filter) | 图像滤波类型 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md b/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md index dc697ac80a3a92a5e11de4a8454af11cf5bc5a5b..afafaf1ca376e5543550c8f8fda49dbfa920bd87 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md +++ b/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +用于验证内存分配信息的结构体定义。 + +**相关模块:** [Display](_display.md) @@ -13,14 +15,9 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [width](_display.md#width-77) | 分配内存的宽度 | -| [height](_display.md#height-77) | 分配内存的高度 | +| [width](_display.md#width-79) | 分配内存的宽度 | +| [height](_display.md#height-78) | 分配内存的高度 | | [usage](_display.md#usage-22) | 内存的用处 | | [format](_display.md#format-22) | 分配内存的像素格式 | - - -## **详细描述** - -用于验证内存分配信息的结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_vibrator.md b/zh-cn/device-dev/reference/hdi-apis/_vibrator.md deleted file mode 100644 index b3d4c3a0a251d34fd3722591f477e63b3f86f38e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_vibrator.md +++ /dev/null @@ -1,171 +0,0 @@ -# Vibrator - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [vibrator_if.h](vibrator__if_8h.md) | 定义马达数据结构,包括马达模式和效果振动。 | -| [vibrator_type.h](vibrator__type_8h.md) | 定义马达数据结构,包括马达模式和效果振动。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [VibratorInterface](_vibrator_interface.md) | 提供Vibrator设备基本控制操作接口。[更多...](_vibrator_interface.md) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [VibratorMode](#vibratormode) { VIBRATOR_MODE_ONCE = 0, VIBRATOR_MODE_PRESET = 1, VIBRATOR_MODE_BUTT } | 枚举马达振动模式。 [更多...](#vibratormode) | -| [VibratorStatus](#vibratorstatus) { VIBRATOR_SUCCESS = 0, VIBRATOR_NOT_PERIOD = -1,  VIBRATOR_NOT_INTENSITY  = -2,  VIBRATOR_NOT_FREQUENCY= -3} | 枚举马达振动模式。[更多...](#vibratorstatus) | -| [VibratorInfo](#vibratorinfo) { isSupportIntensity, isSupportFrequency, intensityMaxValue, intensityMinValue, frequencyMaxValue, frequencyMinValue} | 定义马达参数。[更多...](#vibratorinfo) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [NewVibratorInterfaceInstance](#newvibratorinterfaceinstance) (void) | 创建一个VibratorInterface实例。 [更多...](#newvibratorinterfaceinstance) | -| [FreeVibratorInterfaceInstance](#freevibratorinterfaceinstance) (void) | 释放VibratorInterface实例以及相关资源。 [更多...](#freevibratorinterfaceinstance) | - - -## **详细描述** - -马达驱动对马达服务提供通用的接口能力。 - -服务获取驱动对象或者代理后,马达服务启动或停止振动。 通过驱动程序对象或代理提供使用功能。 - -**Since:** - -2.2 - -**版本** - -1.0: - - -## **枚举类型说明** - - -### VibratorMode - - -``` -enum VibratorMode -``` - -**描述:** - -枚举马达振动模式。 - - | 枚举值 | 描述 | -| -------- | -------- | -| VIBRATOR_MODE_ONCE | 表示给定持续时间内的一次性振动。 | -| VIBRATOR_MODE_PRESET | 表示具有预置效果的周期性振动。 | -| VIBRATOR_MODE_BUTT | 表示效果模式无效。 | - - -### VibratorStatus - - -``` -enum VibratorStatus -``` - -**描述:** - -枚举马达振动模式。 - - | 枚举值 | 描述 | -| -------- | -------- | -| VIBRATOR_SUCCESS | 操作成功。 | -| VIBRATOR_NOT_PERIOD | 不支持振动周期设置。 | -| VIBRATOR_NOT_INTENSITY | 不支持振幅设置。 | -| VIBRATOR_NOT_FREQUENCY | 不支持频率设置。 | - - -### VibratorInfo - - -``` -enum VibratorInfo -``` - -**描述:** - -定义马达参数。 - -参数包括设置马达振幅和频率以及振幅和频率的范围。 - - | 枚举值 | 描述 | -| -------- | -------- | -| isSupportIntensity | 设置马达振幅。1表示支持,0表示不支持。 | -| isSupportFrequency | 设置马达频率。1表示支持,0表示不支持。 | -| intensityMaxValue | 最大振幅。 | -| intensityMinValue | 最小振幅。 | -| frequencyMaxValue | 最大频率。 | -| frequencyMinValue | 最小频率。 | - - -## **函数说明** - - -### FreeVibratorInterfaceInstance() - - -``` -int32_t FreeVibratorInterfaceInstance (void ) -``` - -**描述:** - -释放VibratorInterface实例以及相关资源。 - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -### NewVibratorInterfaceInstance() - - -``` -const struct VibratorInterface* NewVibratorInterfaceInstance (void ) -``` - -**描述:** - -创建一个VibratorInterface实例。 - -获的马达接口实例可用于控制马达按照配置进行振动。 - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md b/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md deleted file mode 100644 index 3812f340bae039c6c2d64f9cb25ffa59bab7b3b8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md +++ /dev/null @@ -1,208 +0,0 @@ -# VibratorInterface - - -## **概述** - -**所属模块:** - -[Vibrator](_vibrator.md) - - -## **汇总** - - -### Public 属性 - - | Public 属性 | 描述 | -| -------- | -------- | -| ( [StartOnce](#startonce) )([in] uint32_t duration) | 控制马达以执行给定持续时间的一次性振动。 [更多...](#startonce) | -| ( [Start](#start) )([in] const char \*effectType) | 控制马达以预置效果执行周期性振动。 [更多...](#start) | -| ( [Stop](#stop) )([in] enum [VibratorMode](_vibrator.md#vibratormode) mode) | 停止马达振动。 [更多...](#stop) | -| ( [GetVibratorInfo](#getvibratorinfo))([out] struct VibratorInfo \*\*vibratorInfo) | 获取有关系统中支持设置振幅和频率的所有马达信息。[更多...](#getvibratorinfo) | -| ( [EnableVibratorModulation](#enablevibratormodulation))(uint32_t duration, int32_t intensity, int32_t frequency) | 根据传入的振动效果启动马达。 [更多...](#enablevibratormodulation) | - - -## **详细描述** - -提供Vibrator设备基本控制操作接口。 - -操作包括马达模式和效果振动、停止马达振动。 - - -## **类成员变量说明** - - -### Start - - -``` -int32_t(*VibratorInterface::Start) ([in] const char *effectType) -``` - -**描述:** - -控制马达以预置效果执行周期性振动。 - -单次振动与周期振动相互排斥。在执行一次性振动之前,需退出周期性振动。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| effectType | 指向指示预置效果类型的指针。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -### StartOnce - - -``` -int32_t(*VibratorInterface::StartOnce) ([in] uint32_t duration) -``` - -**描述:** - -控制马达以执行给定持续时间的一次性振动。 - -单次振动与周期振动相互排斥。在执行一次性振动之前,需退出周期性振动。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| duration | 指示一次性振动的持续时间,以毫秒为单位。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -### Stop - - -``` -int32_t(*VibratorInterface::Stop) ([in] enum VibratorMode mode) -``` - -**描述:** - -停止马达振动。 - -马达启动前,必须在任何模式下停止振动。此功能用在振动过程之后。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| mode | 指示振动模式,可以是一次性或周期性的,详见[VibratorMode](_vibrator.md#vibratormode)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -2.2 - -**Version:** - -1.0 - - -### GetVibratorInfo - - -``` -int32_t (*VibratorInterface::GetVibratorInfo)([out] struct VibratorInfo **vibratorInfo) -``` - -**描述:** - -获取有关系统中支持设置振幅和频率的所有马达信息。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| vibratorInfo | 表示指向马达信息的指针,详见 [VibratorInfo](_vibrator.md#vibratorinfo)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -3.2 - -**Version:** - -1.1 - - -### EnableVibratorModulation - - -``` -int32_t (*VibratorInterface::EnableVibratorModulation)(uint32_t duration, int32_t intensity, int32_t frequency); -``` - -**描述:** - -根据传入的振动效果启动马达。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| duration | 表示马达振动的持续时间,以毫秒为单位。 | -| intensity | 表示振动周期内的马达振幅。 | -| frequency | 表示振动周期内的马达频率。 | - -**返回:** - -如果操作成功,则返回0。 - -如果不支持振动周期设置,则返回-1。 - -如果不支持振幅设置,则返回-2。 - -如果不支持频率设置,则返回-3。 - - -**Since:** - - -3.2 - - -**Version:** - - -1.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_vibrator_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_vibrator_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..fcb8a8a80b0538a70f9221b15f7ad8ed36df28ed --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_vibrator_types_8idl.md @@ -0,0 +1,42 @@ +# VibratorTypes.idl + + +## **概述** + +定义马达数据结构,包括马达振动模式和马达参数。 + +**Since:** + +3.2 + +**Version:** + +1.1 + +**相关模块:** + +[Vibrator](vibrator.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfVibratorInfo](_hdf_vibrator_info.md) | 定义马达参数。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfVibratorMode](vibrator.md#hdfvibratormode) { HDF_VIBRATOR_MODE_ONCE, HDF_VIBRATOR_MODE_PRESET, HDF_VIBRATOR_MODE_BUTT } | 枚举马达的振动模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.vibrator.v1_1 | 马达模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md index 0b3aea7ea7efe0a9d32a357d6432cc438d455b36..e97bf3ac18a1d93424dc80ab64fb7d13d9bc671b 100644 --- a/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md +++ b/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义视频编解码能力。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,7 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [minSize](#minsize) | 支持的最小分辨率 | | [maxSize](#maxsize) | 支持的最大分辨率 | @@ -21,12 +23,7 @@ | [blockCount](#blockcount) | 支持的块数量范围 | | [blocksPerSecond](#blockspersecond) | 每秒可处理的块数量范围 | | [blockSize](#blocksize) | 支持的块大小 | -| [supportPixFmts](#supportpixfmts) [[PIX_FORMAT_NUM](_codec.md#gadb8c6478388b68c09835ebe093a8920a)] | 支持的像素格式 | - - -## **详细描述** - -定义视频编解码能力。 +| [supportPixFmts](#supportpixfmts) [[PIX_FORMAT_NUM](codec.md#gadb8c6478388b68c09835ebe093a8920a)] | 支持的像素格式 | ## **类成员变量说明** @@ -41,7 +38,7 @@ RangeValue VideoPortCap::blockCount **描述:** -支持的块数量范围 +支持的块数量范围。 ### blockSize @@ -53,7 +50,7 @@ Rect VideoPortCap::blockSize **描述:** -支持的块大小 +支持的块大小。 ### blocksPerSecond @@ -65,7 +62,7 @@ RangeValue VideoPortCap::blocksPerSecond **描述:** -每秒可处理的块数量范围 +每秒可处理的块数量范围。 ### maxSize @@ -77,7 +74,7 @@ Rect VideoPortCap::maxSize **描述:** -支持的最大分辨率 +支持的最大分辨率。 ### minSize @@ -89,7 +86,7 @@ Rect VideoPortCap::minSize **描述:** -支持的最小分辨率 +支持的最小分辨率。 ### supportPixFmts @@ -101,7 +98,7 @@ int32_t VideoPortCap::supportPixFmts[PIX_FORMAT_NUM] **描述:** -支持的像素格式 +支持的像素格式,详见**OMX_COLOR_FORMATTYPE**。 ### whAlignment @@ -113,4 +110,4 @@ Alignment VideoPortCap::whAlignment **描述:** -宽高对齐值 +宽高对齐值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md b/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md deleted file mode 100644 index 1abeadfea0e954a557e821a716cab04c96aa158c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md +++ /dev/null @@ -1,304 +0,0 @@ -# WLAN - - -## **汇总** - - -### 文件 - - | 文件 | 描述 | -| -------- | -------- | -| [wifi_hal.h](wifi__hal_8h.md) | 提供给WLAN服务的WLAN基本能力接口。 | -| [wifi_hal_ap_feature.h](wifi__hal__ap__feature_8h.md) | 提供WLAN的AP特性能力(获取与AP连接的STA的基本信息、设置国家码)。 | -| [wifi_hal_base_feature.h](wifi__hal__base__feature_8h.md) | 提供WLAN基本特性能力。 | -| [wifi_hal_sta_feature.h](wifi__hal__sta__feature_8h.md) | 提供WLAN的STA特性能力。 | - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [IWiFi](_i_wi_fi.md) | HAL对WLAN服务提供的基本能力。 [更多...](_i_wi_fi.md) | -| [StaInfo](_sta_info.md) | 描述与AP连接的STA的基本信息 [更多...](_sta_info.md) | -| [IWiFiAp](_i_wi_fi_ap.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,并包含AP模式下获取连接STA的信息和设置国家码的功能。 [更多...](_i_wi_fi_ap.md) | -| [IWiFiBaseFeature](_i_wi_fi_base_feature.md) | WLAN基本特性操作接口,包括获取网卡名称,设置MAC地址,设置发射功率等公共能力接口。 [更多...](_i_wi_fi_base_feature.md) | -| [IWiFiSta](_i_wi_fi_sta.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,额外包含设置扫描单个MAC地址功能。 [更多...](_i_wi_fi_sta.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| IFNAME_MAX_LEN    16 | 网卡名称最大长度。 | -| WIFI_MAC_ADDR_LENGTH    6 | WLAN的MAC地址长度。 | -| ERR_UNAUTH_ACCESS    (-6) | 定义访问失败错误码。 | - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| ([CallbackFunc](#callbackfunc)) (uint32_t event, void \*data, const char \*ifName) | 定义IWiFi回调函数的原型,监听异步事件。 [更多...](#callbackfunc) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [FeatureType](#featuretype) {   PROTOCOL_80211_IFTYPE_UNSPECIFIED, PROTOCOL_80211_IFTYPE_ADHOC, PROTOCOL_80211_IFTYPE_STATION, PROTOCOL_80211_IFTYPE_AP,   PROTOCOL_80211_IFTYPE_AP_VLAN, PROTOCOL_80211_IFTYPE_WDS, PROTOCOL_80211_IFTYPE_MONITOR, PROTOCOL_80211_IFTYPE_MESH_POINT,   PROTOCOL_80211_IFTYPE_P2P_CLIENT, PROTOCOL_80211_IFTYPE_P2P_GO, PROTOCOL_80211_IFTYPE_P2P_DEVICE, PROTOCOL_80211_IFTYPE_NUM } | 枚举WLAN相关特性的类型[FeatureType](#featuretype)。 [更多...](#featuretype) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [WifiConstruct](#wificonstruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)中能力接口。 [更多...](#wificonstruct) | -| [WifiDestruct](#wifidestruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 销毁IWiFi结构体并释放相关资源。 [更多...](#wifidestruct) | -| [InitApFeature](#initapfeature) (struct [IWiFiAp](_i_wi_fi_ap.md) \*\*fe) | 初始化AP特性。WLAN服务在创建AP类型的特性[FeatureType](#featuretype)时调用。 [更多...](#initapfeature) | -| [InitBaseFeature](#initbasefeature) (struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*fe) | WLAN服务创建任何类型的特性{\@Link FeatureType}时,都需要调用此函数。 [更多...](#initbasefeature) | -| [InitStaFeature](#initstafeature) (struct [IWiFiSta](_i_wi_fi_sta.md) \*\*fe) | 初始化STA特性。WLAN服务在创建STA类型的特性[FeatureType](#featuretype)时调用。 [更多...](#initstafeature) | - - -## **详细描述** - -WLAN模块向上层WLAN服务提供了统一接口。 - -HDI层开发人员可根据WLAN模块提供的向上统一接口获取如下能力:建立/关闭WLAN热点,扫描,关联WLAN热点,WLAN平台芯片管理,网络数据缓冲的申请、释放、移动等操作,网络设备管理,电源管理等。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **类型定义说明** - - -### CallbackFunc - - -``` -typedef int32_t(* CallbackFunc) (uint32_t event, void *data, const char *ifName) -``` - -**描述:** - -定义IWiFi回调函数的原型,监听异步事件。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| event | 输入参数,回调传入的事件类型标识。 | -| data | 输入参数,回调传入的数据。 | -| ifName | 输入参数,网卡名称。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -## **枚举类型说明** - - -### FeatureType - - -``` -enum FeatureType -``` - -**描述:** - -枚举WLAN相关特性的类型[FeatureType](#featuretype)。 - - | 枚举值 | 描述 | -| -------- | -------- | -| PROTOCOL_80211_IFTYPE_UNSPECIFIED | 未定义的类型 | -| PROTOCOL_80211_IFTYPE_ADHOC | 特设型网络 | -| PROTOCOL_80211_IFTYPE_STATION | 工作站 | -| PROTOCOL_80211_IFTYPE_AP | 接入点 | -| PROTOCOL_80211_IFTYPE_AP_VLAN | 虚拟接入点 | -| PROTOCOL_80211_IFTYPE_WDS | 无线分布式系统 | -| PROTOCOL_80211_IFTYPE_MONITOR | 网络监听器 | -| PROTOCOL_80211_IFTYPE_MESH_POINT | 组网 | -| PROTOCOL_80211_IFTYPE_P2P_CLIENT | 对等网络客户端 | -| PROTOCOL_80211_IFTYPE_P2P_GO | 对等网络群组所有者 | -| PROTOCOL_80211_IFTYPE_P2P_DEVICE | 对等网络设备 | -| PROTOCOL_80211_IFTYPE_NUM | 网口的数目 | - - -## **函数说明** - - -### InitApFeature() - - -``` -int32_t InitApFeature (struct IWiFiAp **fe) -``` - -**描述:** - -初始化AP特性。WLAN服务在创建AP类型的特性[FeatureType](#featuretype)时调用。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| fe | 输入参数,AP特性[IWiFiAp](_i_wi_fi_ap.md)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### InitBaseFeature() - - -``` -int32_t InitBaseFeature (struct IWiFiBaseFeature **fe) -``` - -**描述:** - -WLAN服务创建任何类型的特性{\@Link FeatureType}时,都需要调用此函数。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| fe | 输入参数,基本特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### InitStaFeature() - - -``` -int32_t InitStaFeature (struct IWiFiSta **fe) -``` - -**描述:** - -初始化STA特性。WLAN服务在创建STA类型的特性[FeatureType](#featuretype)时调用。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| fe | 输出参数,STA特性[IWiFiSta](_i_wi_fi_sta.md)。 | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### WifiConstruct() - - -``` -int32_t WifiConstruct (struct IWiFi **wifiInstance) -``` - -**描述:** - -创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)中能力接口。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| wifiInstance | HAL服务对象[IWiFi](_i_wi_fi.md) | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 - - -### WifiDestruct() - - -``` -int32_t WifiDestruct (struct IWiFi **wifiInstance) -``` - -**描述:** - -销毁IWiFi结构体并释放相关资源。 - -**参数:** - - | 名称 | 描述 | -| -------- | -------- | -| wifiInstance | HAL服务对象[IWiFi](_i_wi_fi.md) | - -**返回:** - -如果操作成功,则返回0。 - -如果操作失败,则返回负值。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_w_r_g_b_color.md b/zh-cn/device-dev/reference/hdi-apis/_w_r_g_b_color.md new file mode 100644 index 0000000000000000000000000000000000000000..a083af89d8eaca3564777e6d1274f1e21076157f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_w_r_g_b_color.md @@ -0,0 +1,82 @@ +# WRGBColor + + +## **概述** + +定义灯的WRGB模式。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [w](#w) | 白色值,范围为0-255。 | +| [r](#r) | 红色值,范围为0-255。 | +| [g](#g) | 绿色值,范围为0-255。 | +| [b](#b) | 蓝色值,范围为0-255。 | + + +## **类成员变量说明** + + +### b + + +``` +int WRGBColor::b +``` + +**描述:** + +蓝色值,范围为0-255。 + + +### g + + +``` +int WRGBColor::g +``` + +**描述:** + +绿色值,范围为0-255。 + + +### r + + +``` +int WRGBColor::r +``` + +**描述:** + +红色值,范围为0-255。 + + +### w + + +``` +int WRGBColor::w +``` + +**描述:** + +白色值,范围为0-255。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_wifi_station_info.md b/zh-cn/device-dev/reference/hdi-apis/_wifi_station_info.md new file mode 100644 index 0000000000000000000000000000000000000000..3ae0f0f9ae61ea3f63febc2fadae143602c7b36e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_wifi_station_info.md @@ -0,0 +1,147 @@ +# WifiStationInfo + + +## **概述** + +STA的信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [rxRate](#rxrate) | 接收速率。 | +| [txRate](#txrate) | 发送速率。 | +| [flags](#flags) | 速率传输类型。 | +| [rxVhtmcs](#rxvhtmcs) | 接收VHT-MCS(Very High Throughput Modulation and Coding Scheme)配置。 | +| [txVhtmcs](#txvhtmcs) | 发送VHT-MCS(Very High Throughput Modulation and Coding Scheme)配置。 | +| [rxMcs](#rxmcs) | 接收MCS(Modulation and Coding Scheme)索引。 | +| [txMcs](#txmcs) | 发送MCS(Modulation and Coding Scheme)索引。 | +| [rxVhtNss](#rxvhtnss) | 接收VHT-NSS(Very High Throughput Number of Spatial Streams)配置。 | +| [txVhtNss](#txvhtnss) | 发送VHT-NSS(Very High Throughput Number of Spatial Streams)配置。 | + + +## **类成员变量说明** + + +### flags + + +``` +unsigned int WifiStationInfo::flags +``` + +**描述:** + +速率传输类型。 + + +### rxMcs + + +``` +unsigned char WifiStationInfo::rxMcs +``` + +**描述:** + +接收MCS(Modulation and Coding Scheme)索引。 + + +### rxRate + + +``` +unsigned int WifiStationInfo::rxRate +``` + +**描述:** + +接收速率。 + + +### rxVhtmcs + + +``` +unsigned char WifiStationInfo::rxVhtmcs +``` + +**描述:** + +接收VHT-MCS(Very High Throughput Modulation and Coding Scheme)配置。 + + +### rxVhtNss + + +``` +unsigned char WifiStationInfo::rxVhtNss +``` + +**描述:** + +接收VHT-NSS(Very High Throughput Number of Spatial Streams)配置。 + + +### txMcs + + +``` +unsigned char WifiStationInfo::txMcs +``` + +**描述:** + +发送MCS(Modulation and Coding Scheme)索引。 + + +### txRate + + +``` +unsigned int WifiStationInfo::txRate +``` + +**描述:** + +发送速率。 + + +### txVhtmcs + + +``` +unsigned char WifiStationInfo::txVhtmcs +``` + +**描述:** + +发送VHT-MCS(Very High Throughput Modulation and Coding Scheme)配置。 + + +### txVhtNss + + +``` +unsigned char WifiStationInfo::txVhtNss +``` + +**描述:** + +发送VHT-NSS(Very High Throughput Number of Spatial Streams)配置。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_wlan_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_wlan_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..03cc663f0672292fae1a77a5f912f80050ee946f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_wlan_types_8idl.md @@ -0,0 +1,46 @@ +# WlanTypes.idl + + +## **概述** + +WLAN模块中使用的数据类型,包括feature对象信息、STA信息、扫描信息、网络设备信息等。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfFeatureInfo](_hdf_feature_info.md) | feature对象信息。 | +| [HdfStaInfo](_hdf_sta_info.md) | STA的信息。 | +| [HdfWifiDriverScanSsid](_hdf_wifi_driver_scan_ssid.md) | WiFi扫描参数SSID信息。 | +| [HdfWifiScan](_hdf_wifi_scan.md) | WiFi扫描参数。 | +| [HdfNetDeviceInfo](_hdf_net_device_info.md) | 网络设备信息。 | +| [HdfNetDeviceInfoResult](_hdf_net_device_info_result.md) | 网络设备信息集合。 | +| [HdfWifiScanResult](_hdf_wifi_scan_result.md) | WiFi扫描结果。 | +| [HdfWifiInfo](_hdf_wifi_info.md) | WiFi频段信息。 | +| [MeasChannelParam](_meas_channel_param.md) | 信道测量参数。 | +| [MeasChannelResult](_meas_channel_result.md) | 信道测量结果。 | +| [ProjectionScreenCmdParam](_projection_screen_cmd_param.md) | 投屏参数。 | +| [WifiStationInfo](_wifi_station_info.md) | STA的信息。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.wlan.v1_0 | WLAN模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_yun_desc_info_.md b/zh-cn/device-dev/reference/hdi-apis/_yun_desc_info_.md new file mode 100644 index 0000000000000000000000000000000000000000..248ce34a95277a447f7a2c07d77b4155ee135898 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_yun_desc_info_.md @@ -0,0 +1,26 @@ +# YUVDescInfo + + +## **概述** + +YUV描述信息结构体定义。 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [baseAddr](_display.md#baseaddr) | 内存的初始地址 | +| [yOffset](_display.md#yoffset) | Y的偏移量 | +| [uOffset](_display.md#uoffset) | U的偏移量 | +| [vOffset](_display.md#voffset) | V的偏移量 | +| [yStride](_display.md#ystride) | Y的stride信息 | +| [uvStride](_display.md#uvstride) | UV的stride信息 | +| [uvStep](_display.md#uvstep) | UV的step信息 | diff --git a/zh-cn/device-dev/reference/hdi-apis/activity_recognition.md b/zh-cn/device-dev/reference/hdi-apis/activity_recognition.md new file mode 100644 index 0000000000000000000000000000000000000000..d7eb2ef08f3d82c16c9b20a8859c8080d90dfbca --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/activity_recognition.md @@ -0,0 +1,91 @@ +# HdiActivityRecognition + + +## **概述** + +提供订阅和获取用户行为的API。 + +MSDP(Multimodal Sensor Data Platform)可以获取行为识别驱动程序的对象或代理,然后调用该对象或代理提供的API, 获取设备支持的行为类型,订阅或取消订阅不同的行为事件,获取当前的行为事件,以及获取设备缓存的行为事件。 + +**Since**: + +3.2 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [ActivityRecognitionTypes.idl](activity_recognition_types_idl.md) | 定义行为识别模块使用的数据类型。 | +| [IActivityChangedCallback.idl](_i_activity_changed_callback_8idl.md) | 定义行为识别数据上报回调函数接口。 | +| [IActivityInterface.idl](_i_activity_interface_8idl.md) | 声明行为识别模块提供的API,用于获取设备支持的行为类型,订阅或取消订阅不同的行为事件,获取当前的行为事件,以及获取设备缓存的行为事件。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ActRecognitionEvent](_act_recognition_event.md) | 定义行为事件上报的数据结构。 | +| [IActivityChangedCallback](interface_i_activity_changed_callback.md) | 定义上报行为事件的回调函数。 | +| [IActivityInterface](interface_i_activity_interface.md) | 定义对行为识别进行基本操作的接口。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [ActRecognitionEventType](#actrecognitioneventtype) { ACT_RECOGNITION_EVENT_ENTER = 0x01, ACT_RECOGNITION_EVENT_EXIT = 0x02 } | 枚举行为事件的类型。 | +| [ActRecognitionPowerMode](#actrecognitionpowermode) { ACT_RECOGNITION_NORMAL_MODE = 0, ACT_RECOGNITION_LOW_POWER_MODE = 1 } | 枚举功耗模式的类型。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.activity_recognition.v1_0 | 行为识别模块接口的包路径。 | + + +## **枚举类型说明** + + +### ActRecognitionEventType + + +``` +enum ActRecognitionEventType +``` + +**描述:** + +枚举行为事件的类型。 + +支持的行为包括:车载、骑车、步行、跑步、静止、快走、高铁、未知、电梯、相对静止、手持步行、躺卧、乘机、地铁等。 + + | 枚举值 | 描述 | +| -------- | -------- | +| ACT_RECOGNITION_EVENT_ENTER | 进入某一行为 | +| ACT_RECOGNITION_EVENT_EXIT | 退出某一行为 | + + +### ActRecognitionPowerMode + + +``` +enum ActRecognitionPowerMode +``` + +**描述:** + +枚举功耗模式的类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| ACT_RECOGNITION_NORMAL_MODE | 普通模式,不论主核是否休眠都会进行行为事件的上报。 | +| ACT_RECOGNITION_LOW_POWER_MODE | 低功耗模式,主核休眠时,不会进行行为事件的上报。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/activity_recognition_types_idl.md b/zh-cn/device-dev/reference/hdi-apis/activity_recognition_types_idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b57d375dc22f3750b7c3423b7e91224934b44c65 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/activity_recognition_types_idl.md @@ -0,0 +1,43 @@ +# ActivityRecognitionTypes.idl + + +## **概述** + +定义行为识别模块使用的数据类型。 + +**Since**: + +3.2 + +**Version**: + +1.0 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ActRecognitionEvent](_act_recognition_event.md) | 定义行为事件上报的数据结构。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype) { ACT_RECOGNITION_EVENT_ENTER = 0x01, ACT_RECOGNITION_EVENT_EXIT = 0x02 } | 枚举行为事件的类型。 | +| [ActRecognitionPowerMode](activity_recognition.md#actrecognitionpowermode) { ACT_RECOGNITION_NORMAL_MODE = 0, ACT_RECOGNITION_LOW_POWER_MODE = 1 } | 枚举功耗模式的类型。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.activity_recognition.v1_0 | 行为识别模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/annotated.md b/zh-cn/device-dev/reference/hdi-apis/annotated.md new file mode 100644 index 0000000000000000000000000000000000000000..1b11935d7048c296973c1cfb3958f85c7a849c9e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/annotated.md @@ -0,0 +1,365 @@ +# 结构体 + + + +- **[YUVDescInfo](_yun_desc_info_.md)** + +- **[ExtDataHandle](_ext_data_handle.md)** + +- **[ActRecognitionEvent](_act_recognition_event.md)** + +- **[AllocInfo](_alloc_info.md)** + +- **[Alignment](_alignment.md)** + +- **[AudioAdapter](_audio_adapter.md)** + +- **[AudioAdapterDescriptor](_audio_adapter_descriptor.md)** + +- **[AudioAttribute](_audio_attribute.md)** + +- **[AudioCapture](_audio_capture.md)** + +- **[AudioControl](_audio_control.md)** + +- **[AudioDevExtInfo](_audio_dev_ext_info.md)** + +- **[AudioDeviceDescriptor](_audio_device_descriptor.md)** + +- **[AudioManager](_audio_manager.md)** + +- **[AudioMixExtInfo](_audio_mix_ext_info.md)** + +- **[AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md)** + +- **[AudioPort](_audio_port.md)** + +- **[AudioPortCap](audio_portcap.md)** + +- **[AudioPortCapability](_audio_port_capability.md)** + +- **[AudioRender](_audio_render.md)** + +- **[AudioRoute](_audio_route.md)** + +- **[AudioRouteNode](_audio_route_node.md)** + +- **[AudioSampleAttributes](_audio_sample_attributes.md)** + +- **[AudioScene](_audio_scene.md)** + +- **[AudioSceneDescriptor](_audio_scene_descriptor.md)** + +- **[AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md)** + +- **[AudioSessionExtInfo](_audio_session_ext_info.md)** + +- **[AudioSubPortCapability](_audio_sub_port_capability.md)** + +- **[AudioTimeStamp](_audio_time_stamp.md)** + +- **[AudioVolume](_audio_volume.md)** + +- **[AuthResultInfo](_auth_result_info.md)** + +- **[AuthSolution](_auth_solution.md)** + +- **[BufferData](_buffer_data.md)** + +- **[BatteryInfo](_battery_info.md)** + +- **[CaptureEndedInfo](_capture_ended_info.md)** + +- **[CaptureErrorInfo](_capture_error_info.md)** + +- **[CaptureInfo](_capture_info.md)** + +- **[CodecCallbackType](_codec_callback_type.md)** + +- **[CodecCompCapability](_codec_comp_capability.md)** + +- **[CodecComponentManager](_codec_component_manager.md)** + +- **[CodecComponentType](_codec_component_type.md)** + +- **[ColorValue](union_color_value.md)** + +- **[CompVerInfo](_comp_ver_info.md)** + +- **[CredentialInfo](_credential_info.md)** + +- **[DeviceFuncs](_device_funcs.md)** + +- **[DisplayCapability](_display_capability.md)** + +- **[DisplayInfo](_display_info.md)** + +- **[DisplayModeInfo](_display_mode_info.md)** + +- **[EnrolledInfo](_enrolled_info.md)** + +- **[EnrollParam](_enroll_param.md)** + +- **[EnrollResultInfo](_enroll_resultinfo.md)** + +- **[EventInfo](_event_info.md)** + +- **[ExecutorInfo](_executor_info.md)** + +- **[ExecutorInfo](_user_executor_info.md)** + +- **[ExecutorRegisterInfo](_executor_register_info.md)** + +- **[ExecutorSendMsg](_executor_send_msg.md)** + +- **[GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md)** + +- **[GfxFuncs](_gfx_funcs.md)** + +- **[GfxOpt](_gfx_opt.md)** + +- **[GrallocFuncs](_gralloc_funcs.md)** + +- **[HdfFeatureInfo](_hdf_feature_info.md)** + +- **[HdfLightColor](_hdf_light_color.md)** + +- **[HdfLightEffect](_hdf_light_effect.md)** + +- **[HdfLightFlashEffect](_hdf_light_flash_effect.md)** + +- **[HdfLightInfo](_hdf_light_info.md)** + +- **[HdfMotionEvent](_hdf_motion_event.md)** + +- **[HdfNetDeviceInfo](_hdf_net_device_info.md)** + +- **[HdfNetDeviceInfoResult](_hdf_net_device_info_result.md)** + +- **[HdfSensorEvents](_hdf_sensor_events.md)** + +- **[HdfSensorInformation](_hdf_sensor_information.md)** + +- **[HdfStaInfo](_hdf_sta_info.md)** + +- **[HdfThermalCallbackInfo](_hdf_thermal_callback_info.md)** + +- **[HdfVibratorInfo](_hdf_vibrator_info.md)** + +- **[HdfWifiDriverScanSsid](_hdf_wifi_driver_scan_ssid.md)** + +- **[HdfWifiInfo](_hdf_wifi_info.md)** + +- **[HdfWifiScan](_hdf_wifi_scan.md)** + +- **[HdfWifiScanResult](_hdf_wifi_scan_result.md)** + +- **[HDRCapability](_h_d_r_capability.md)** + +- **[HDRMetaData](_h_d_r_meta_data.md)** + +- **[IActivityChangedCallback](interface_i_activity_changed_callback.md)** + +- **[IActivityInterface](interface_i_activity_interface.md)** + +- **[IBatteryCallback](interface_i_battery_callback.md)** + +- **[IBatteryInterface](interface_i_battery_interface.md)** + +- **[ICameraDevice](interface_i_camera_device.md)** + +- **[ICameraDeviceCallback](interface_i_camera_device_callback.md)** + +- **[ICameraHost](interface_i_camera_host.md)** + +- **[ICameraHostCallback](interface_i_camera_host_callback.md)** + +- **[ICircle](_i_circle.md)** + +- **[IdentifyResultInfo](_identify_result_info.md)** + +- **[IExecutor](interface_i_executor.md)** + +- **[IExecutor](interface_pin_i_executor.md)** + +- **[IExecutorCallback](interface_i_executor_callback.md)** + +- **[IExecutorCallback](interface_pin_i_executor_callback.md)** + +- **[IFaceAuthInterface](interface_i_face_auth_interface.md)** + +- **[ILine](_i_line.md)** + +- **[IInputInterface](_i_input_interface.md)** + +- **[ILightInterface](interface_i_light_interface.md)** + +- **[IMotionCallback](interface_i_motion_callback.md)** + +- **[IMotionInterface](interface_i_motion_interface.md)** + +- **[InputController](_input_controller.md)** + +- **[InputDevAbility](_input_dev_ability.md)** + +- **[InputDevAttr](_input_dev_attr.md)** + +- **[InputDevDesc](_input_dev_desc.md)** + +- **[InputDeviceInfo](_input_device_info.md)** + +- **[InputDevIdentify](_input_dev_identify.md)** + +- **[InputDimensionInfo](_input_dimension_info.md)** + +- **[InputEventCb](_input_event_cb.md)** + +- **[InputEventPackage](_input_event_package.md)** + +- **[IPowerHdiCallback](interface_i_power_hdi_callback.md)** + +- **[InputExtraCmd](_input_extra_cmd.md)** + +- **[InputHostCb](_input_host_cb.md)** + +- **[InputHotPlugEvent](_input_hot_plug_event.md)** + +- **[InputManager](_input_manager.md)** + +- **[InputReporter](_input_reporter.md)** + +- **[IOfflineStreamOperator](interface_i_offline_stream_operator.md)** + +- **[IPinAuthInterface](interface_i_pin_auth_interface.md)** + +- **[IPowerInterface](interface_i_power_interface.md)** + +- **[IRect](_i_rect.md)** + +- **[ISensorCallback](interface_i_sensor_callback.md)** + +- **[ISensorInterface](interface_i_sensor_interface.md)** + +- **[IStreamOperator](interface_i_stream_operator.md)** + +- **[IStreamOperatorCallback](interface_i_stream_operator_callback.md)** + +- **[ISurface](_i_surface.md)** + +- **[IThermalCallback](interface_i_thermal_callback.md)** + +- **[IThermalInterface](interface_i_thermal_interface.md)** + +- **[IUsbdBulkCallback](interface_i_usbd_bulk_callback.md)** + +- **[IUsbdSubscriber](interface_i_usbd_subscriber.md)** + +- **[IUsbInterface](interface_i_usb_interface.md)** + +- **[IUserAuthInterface](interface_i_user_auth_interface.md)** + +- **[IVibratorInterface](interface_i_vibrator_interface.md)** + +- **[IWlanCallback](interface_i_wlan_callback.md)** + +- **[IWlanInterface](interface_i_wlan_interface.md)** + +- **[LayerAlpha](_layer_alpha.md)** + +- **[LayerBuffer](_layer_buffer.md)** + +- **[LayerFuncs](_layer_funcs.md)** + +- **[LayerInfo](_layer_info.md)** + +- **[MeasChannelParam](_meas_channel_param.md)** + +- **[MeasChannelResult](_meas_channel_result.md)** + +- **[OmxCodecBuffer](_omx_codec_buffer.md)** + +- **[PortCap](union_port_cap.md)** + +- **[PortInfo](_port_info.md)** + +- **[PresentTimestamp](_present_timestamp.md)** + +- **[PropertyObject](_property_object.md)** + +- **[ProjectionScreenCmdParam](_projection_screen_cmd_param.md)** + +- **[RangeValue](_range_value.md)** + +- **[Rect](_rect.md)** + +- **[Rectangle](_rectangle.md)** + +- **[RGBColor](_r_g_b_color.md)** + +- **[ScheduleInfo](_schedule_info.md)** + +- **[StreamAttribute](_stream_attribute.md)** + +- **[StreamInfo](_stream_info.md)** + +- **[SupportBufferType](_support_buffer_type.md)** + +- **[TemplateInfo](_template_info.md)** + +- **[ThermalZoneInfo](_thermal_zone_info.md)** + +- **[UsbCtrlTransfer](_usb_ctrl_transfer.md)** + +- **[UsbDev](_usb_dev.md)** + +- **[USBDeviceInfo](_u_s_b_device_info.md)** + +- **[UsbPipe](_usb_pipe.md)** + +- **[UseBufferType](_use_buffer_type.md)** + +- **[VerifyAllocInfo](_verify_alloc_info.md)** + +- **[VGUBuffer](_v_g_u_buffer.md)** + +- **[VGUColorStop](_v_g_u_color_stop.md)** + +- **[VGUConic](_v_g_u_conic.md)** + +- **[VGUFillAttr](_v_g_u_fill_attr.md)** + +- **[VGUFuncs](_v_g_u_funcs.md)** + +- **[VGUGradient](_v_g_u_gradient.md)** + +- **[VGUImage](_v_g_u_image.md)** + +- **[VGULinear](_v_g_u_linear.md)** + +- **[VGUMaskLayer](_v_g_u_mask_layer.md)** + +- **[VGUMatrix3](_v_g_u_matrix3.md)** + +- **[VGUPaintStyle](_v_g_u_paint_style.md)** + +- **[VGUPath](_v_g_u_path.md)** + +- **[VGUPattern](_v_g_u_pattern.md)** + +- **[VGUPoint](_v_g_u_point.md)** + +- **[VGURadial](_v_g_u_radial.md)** + +- **[VGURect](_v_g_u_rect.md)** + +- **[VGUSolid](_v_g_u_solid.md)** + +- **[VGUStrokeAttr](_v_g_u_stroke_attr.md)** + +- **[VGUSurface](_v_g_u_surface.md)** + +- **[VideoPortCap](_video_port_cap.md)** + +- **[WifiStationInfo](_wifi_station_info.md)** + +- **[WRGBColor](_w_r_g_b_color.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md index 39a1c6b4c753d39fa2c89bf7aea12435a1a1397d..c0b214a7cd1bb4ac363ddbcd0086614b7f24ba42 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio适配器的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适配器接口 [更多...](_audio_adapter.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio适配器的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适配器接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md index 095bcf40db692f78de203acd93a8bf9d0058821d..b17a4f40f36f38c8056a2444c545dafce407eb94 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio属性的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioAttribute](_audio_attribute.md) | AudioAttribute音频属性接口 [更多...](_audio_attribute.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio属性的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioAttribute](_audio_attribute.md) | AudioAttribute音频属性接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md index 62573f64322601ee09e1172bb3e0036654ad439d..d4579c7564d0c68e2822d437b78c59d792348bed 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio录音的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioCapture](_audio_capture.md) | AudioCapture音频录音接口 [更多...](_audio_capture.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio录音的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioCapture](_audio_capture.md) | AudioCapture音频录音接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md index 04254ba25ab995425f023c5dc54a8ee23a340fb1..ae8509fca29ab27aaa8d7cbaf26b4b23a90ca89e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio控制的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioControl](_audio_control.md) | AudioControl音频控制接口 [更多...](_audio_control.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio控制的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioControl](_audio_control.md) | AudioControl音频控制接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md index 7ac28b26d6aa3f47e03f6eee4990e6b5da257a86..921f549ce6aa3caeaf9129910c921ac999674d9c 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +Audio适配器管理及加载的接口定义文件。 + +**Since:** + +1.0 + +**Version:** + +1.0 + +**相关模块:** [Audio](_audio.md) @@ -13,26 +23,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioManager](_audio_manager.md) | AudioManager音频适配器管理接口 [更多...](_audio_manager.md) | +| [AudioManager](_audio_manager.md) | AudioManager音频适配器管理接口 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GetAudioManagerFuncs](_audio.md#getaudiomanagerfuncs) (void) | 获取音频适配器管理接口的操作函数列表,详情参考[AudioManager](_audio_manager.md)[更多...](_audio.md#getaudiomanagerfuncs) | - - -## **详细描述** - -Audio适配器管理及加载的接口定义文件。 - -**Since:** - -1.0 - -**Version:** - -1.0 +| [GetAudioManagerFuncs](_audio.md#getaudiomanagerfuncs) (void) | 获取音频适配器管理接口的操作函数列表,详情参考[AudioManager](_audio_manager.md)。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md index 7f1d7eaa28d7a5ecf2edba37ea302a9d8b96463b..873f032825cf98823f9e3518f79416f366745e77 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio播放的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioRender](_audio_render.md) | AudioRender音频播放接口 [更多...](_audio_render.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio播放的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioRender](_audio_render.md) | AudioRender音频播放接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md index 09b3026f883670d286ec9bedca1e4a27f8a65d54..fefc2bec5aa19e1e1abbe0537f02fc995fc346e0 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio场景的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioScene](_audio_scene.md) | AudioScene音频场景接口 [更多...](_audio_scene.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio场景的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioScene](_audio_scene.md) | AudioScene音频场景接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md index 5d038c1abc9b3780f27c3a1143fd02639cc99119..2f334779b02ffa64ba585e3713edad9b9ccf0371 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +Audio模块接口定义中使用的自定义数据类型,包括音频端口、适配器描述符、设备描述符、场景描述符、采样属性、时间戳等。 + +**Since:** + +1.0 + +**Version:** + +1.0 + +**相关模块:** [Audio](_audio.md) @@ -13,63 +23,48 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioPort](_audio_port.md) | 音频端口 [更多...](_audio_port.md) | -| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适配器描述符 [更多...](_audio_adapter_descriptor.md) | -| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备描述符 [更多...](_audio_device_descriptor.md) | -| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景描述符 [更多...](_audio_scene_descriptor.md) | -| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 [更多...](union_audio_scene_descriptor_1_1_scene_desc.md) | -| [AudioSampleAttributes](_audio_sample_attributes.md) | 音频采样属性 [更多...](_audio_sample_attributes.md) | -| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 [更多...](_audio_time_stamp.md) | -| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 [更多...](_audio_sub_port_capability.md) | -| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 [更多...](_audio_port_capability.md) | -| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 [更多...](_audio_mmap_buffer_descripter.md) | -| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息 [更多...](_audio_dev_ext_info.md) | -| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 [更多...](_audio_mix_ext_info.md) | -| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 [更多...](_audio_session_ext_info.md) | -| [AudioRouteNode](_audio_route_node.md) | 音频路由节点 [更多...](_audio_route_node.md) | -| [AudioRoute](_audio_route.md) | 音频路由信息 [更多...](_audio_route.md) | +| [AudioPort](_audio_port.md) | 音频端口 | +| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适配器描述符 | +| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备描述符 | +| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景描述符 | +| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景描述 | +| [AudioSampleAttributes](_audio_sample_attributes.md) | 音频采样属性 | +| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 | +| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 | +| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 | +| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 | +| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息. | +| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 | +| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 | +| [AudioRouteNode](_audio_route_node.md) | 音频路由节点. | +| [AudioRoute](_audio_route.md) | 音频路由信息. | ### 类型定义 - | 类型定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) | 音频句柄 | -| ([RenderCallback](_audio.md#rendercallback)) (enum [AudioCallbackType](_audio.md#audiocallbacktype), void \*reserved, void \*cookie) | 回调函数指针 [更多...](_audio.md#rendercallback) | +| AudioHandle | 音频句柄 | +| ([RenderCallback](_audio.md#rendercallback)) (enum AudioCallbackType, void \*reserved, void \*cookie) | 回调函数指针 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [AudioPortDirection](_audio.md#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端口的类型 [更多...](_audio.md#audioportdirection) | -| [AudioPortPin](_audio.md#audioportpin) {   PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u,   PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u,   PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适配器端口的PIN脚 [更多...](_audio.md#audioportpin) | -| [AudioCategory](_audio.md#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) [更多...](_audio.md#audiocategory) | -| [AudioFormat](_audio.md#audioformat) {   AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u,   AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u,   AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u,   AUDIO_FORMAT_G726 = 0x2000003u } | 音频格式 [更多...](_audio.md#audioformat) | -| [AudioChannelMask](_audio.md#audiochannelmask) { AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通道掩码(mask) [更多...](_audio.md#audiochannelmask) | -| [AudioSampleRatesMask](_audio.md#audiosampleratesmask) {   AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u,   AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u,   AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | 音频采样频率MASK [更多...](_audio.md#audiosampleratesmask) | -| [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) { PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端口的数据透传模式 [更多...](_audio.md#audioportpassthroughmode) | -| [AudioSampleFormat](_audio.md#audiosampleformat) {   AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 原始音频样本格式 [更多...](_audio.md#audiosampleformat) | -| [AudioChannelMode](_audio.md#audiochannelmode) {   AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE,   AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频播放的通道模式 [更多...](_audio.md#audiochannelmode) | -| [AudioDrainNotifyType](_audio.md#audiodrainnotifytype) { AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结束类型 [更多...](_audio.md#audiodrainnotifytype) | -| [AudioCallbackType](_audio.md#audiocallbacktype) {   AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL,   AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 [更多...](_audio.md#audiocallbacktype) | -| [AudioPortRole](_audio.md#audioportrole) { AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端口角色 [更多...](_audio.md#audioportrole) | -| [AudioPortType](_audio.md#audioporttype) { AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端口类型. [更多...](_audio.md#audioporttype) | -| [AudioSessionType](_audio.md#audiosessiontype) { AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端口会话类型 [更多...](_audio.md#audiosessiontype) | - - -## **详细描述** - -Audio模块接口定义中使用的自定义数据类型 - -Audio模块接口定义中使用的自定义数据类型,包括音频端口、适配器描述符、设备描述符、场景描述符、采样属性、时间戳等。 - -**Since:** - -1.0 - -**Version:** - -1.0 +| [AudioPortDirection](_audio.md#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端口的类型 | +| [AudioPortPin](_audio.md#audioportpin) { PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u,   PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u,   PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适配器端口的PIN脚 | +| [AudioCategory](_audio.md#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) | +| [AudioFormat](_audio.md#audioformat){ AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u,   AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u,   AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u,   AUDIO_FORMAT_G726 = 0x2000003u } | 音频格式 | +| [AudioChannelMask](_audio.md#audiochannelmask){ AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通道掩码(mask) | +| [AudioSampleRatesMask](_audio.md#audiosampleratesmask){ AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u,   AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u,   AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | 音频采样频率MASK | +| [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode){ PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端口的数据透传模式 | +| [AudioSampleFormat](_audio.md#audiosampleformat){ AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P } | 原始音频样本格式 | +| [AudioChannelMode](_audio.md#audiochannelmode){  AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE,   AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频播放的通道模式 | +| [AudioDrainNotifyType](_audio.md#audiodrainnotifytype){ AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结束类型 | +| [AudioCallbackType](_audio.md#audiocallbacktype){ AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL,   AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 | +| [AudioPortRole](_audio.md#audioportrole){ AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端口角色 | +| [AudioPortType](_audio.md#audioporttype){ AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端口类型. | +| [AudioSessionType](_audio.md#audiosessiontype){ AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端口会话类型 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md index 743fa7b97a30dd5cf2fa49bc650e50de06928579..429de22809856c4523e327aa2861ce4590e3950d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Audio](_audio.md) - +Audio音量的接口定义文件。 -## **汇总** +**Since:** +1.0 -### 类 +**Version:** - | 类 | 描述 | -| -------- | -------- | -| [AudioVolume](_audio_volume.md) | AudioVolume音频音量接口 [更多...](_audio_volume.md) | +1.0 +**相关模块:** -## **详细描述** +[Audio](_audio.md) -Audio音量的接口定义文件。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [AudioVolume](_audio_volume.md) | AudioVolume音频音量接口 | diff --git a/zh-cn/device-dev/reference/hdi-apis/audio_portcap.md b/zh-cn/device-dev/reference/hdi-apis/audio_portcap.md new file mode 100644 index 0000000000000000000000000000000000000000..2b1d6cf7178cf68030c31ef537da5b9c6e2caa13 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio_portcap.md @@ -0,0 +1,79 @@ +# AudioPortCap + + +## **概述** + +定义音频编解码能力。 + +**所属模块:** + +[Codec](codec.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [sampleFormats](#sampleformats) [SAMPLE_FMT_NUM] | 支持的音频采样格式,详见[AudioSampleFormat](codec.md#audiosampleformat)。 | +| [sampleRate](#samplerate) [SAMPLE_RATE_NUM] | 支持的音频采样率,详见[AudioSampleRate](codec.md#audiosamplerate)。 | +| [channelLayouts](#channellayouts) [CHANNEL_NUM] | 支持的音频通道数channel layouts。 | +| [channelCount](#channelcount) [CHANNEL_NUM] | 支持的音频通道数。 | + + +## **详细描述** + +定义音频编解码能力。 + + +## **类成员变量说明** + + +### channelCount + + +``` +int32_t AudioPortCap::channelCount[CHANNEL_NUM] +``` + +**描述:** + +支持的音频通道数 + + +### channelLayouts + + +``` +int32_t AudioPortCap::channelLayouts[CHANNEL_NUM] +``` + +**描述:** + +支持的音频通道数channel layouts + + +### sampleFormats + + +``` +int32_t AudioPortCap::sampleFormats[SAMPLE_FMT_NUM] +``` + +**描述:** + +支持的音频采样格式,详见[AudioSampleFormat](codec.md#audiosampleformat) + + +### sampleRate + + +``` +int32_t AudioPortCap::sampleRate[SAMPLE_RATE_NUM] +``` + +**描述:** + +支持的音频采样率,详见[AudioSampleRate](codec.md#audiosamplerate) diff --git a/zh-cn/device-dev/reference/hdi-apis/battery.md b/zh-cn/device-dev/reference/hdi-apis/battery.md index 1a16568662ace94731352b6bf85f4da96607314b..bb3e111a477ae5f1171dee8f2cead9e2072528d7 100644 --- a/zh-cn/device-dev/reference/hdi-apis/battery.md +++ b/zh-cn/device-dev/reference/hdi-apis/battery.md @@ -1,56 +1,54 @@ # Battery +## **概述** + +电池模块为电池服务提供的获取、订阅电池信息的接口。 服务获取此模块的对象或代理后,可以调用相关的接口获取电池信息、订阅电池信息的变化。 + +**Since**: + +3.2 + +**Version**: + +1.0 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [IBatteryCallback.idl](_i_battery_callback_8idl.md) | 电池信息的回调。 | | [IBatteryInterface.idl](_i_battery_interface_8idl.md) | 获取、订阅电池信息的接口。 | -| [Types.idl](_types_8idl.md) | 电池信息相关数据类型。 | +| [BatteryTypes.idl](battery_types_idl.md) | 电池信息相关数据类型。 | ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IBatteryCallback](interface_i_battery_callback.md) | 电池信息的回调。 [更多...](interface_i_battery_callback.md) | -| [IBatteryInterface](interface_i_battery_interface.md) | 获取、订阅电池信息的接口。 [更多...](interface_i_battery_interface.md) | -| [BatteryInfo](_battery_info.md) | 电池相关信息。 [更多...](_battery_info.md) | +| [IBatteryCallback](interface_i_battery_callback.md) | 电池信息的回调。 | +| [IBatteryInterface](interface_i_battery_interface.md) | 获取、订阅电池信息的接口。 | +| [BatteryInfo](_battery_info.md) | 电池相关信息。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [BatteryHealthState](#batteryhealthstate) {   BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE,   BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | 电池的健康状态。 [更多...](#batteryhealthstate) | -| [BatteryChargeState](#batterychargestate) {   CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL,   CHARGE_STATE_RESERVED } | 电池的充电状态。 [更多...](#batterychargestate) | -| [BatteryPluggedType](#batterypluggedtype) {   PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS,   PLUGGED_TYPE_BUTT } | 电池的充电设备类型。 [更多...](#batterypluggedtype) | +| [BatteryHealthState](#batteryhealthstate) {   BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE,   BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | 电池的健康状态。 | +| [BatteryChargeState](#batterychargestate) {   CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL,   CHARGE_STATE_RESERVED } | 电池的充电状态。 | +| [BatteryPluggedType](#batterypluggedtype) {   PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS,   PLUGGED_TYPE_BUTT } | 电池的充电设备类型。 | -### 变量 +### 关键字 - | 变量 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| package ohos.hdi.battery.v1_0 | 电池信息接口的包路径 | - - -## **详细描述** - -提供获取、订阅电池信息的接口。 - -电池模块为电池服务提供的获取、订阅电池信息的接口。 服务获取此模块的对象或代理后,可以调用相关的接口获取电池信息、订阅电池信息的变化。 - -**Since:** - -3.1 - -**Version:** - -1.0 +| package ohos.hdi.battery.v1_0 | 电池模块接口的包路径。 | ## **枚举类型说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/battery_types_idl.md b/zh-cn/device-dev/reference/hdi-apis/battery_types_idl.md new file mode 100644 index 0000000000000000000000000000000000000000..c44dc0dd1388dcb423b6b57ecb229727d40a01bf --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/battery_types_idl.md @@ -0,0 +1,46 @@ +# Types.idl + + +## **概述** + +电池信息相关数据类型。 + +电池信息中使用的数据类型,包括健康状态、充电状态、充电设备类型和电池信息结构。 + +**Since**: + +3.1 + +**Version**: + +1.0 + +**相关模块:** + +[Battery](battery.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [BatteryInfo](_battery_info.md) | 电池相关信息。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [BatteryHealthState](battery.md#batteryhealthstate) { BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE,   BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | 电池的健康状态。 | +| [BatteryChargeState](battery.md#batterychargestate) { CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL,   CHARGE_STATE_RESERVED } | 电池的充电状态。 | +| [BatteryPluggedType](battery.md#batterypluggedtype) { PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS,   PLUGGED_TYPE_BUTT } | 电池的充电设备类型。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | 电池模块接口的包路径 | diff --git a/zh-cn/device-dev/reference/hdi-apis/camera.md b/zh-cn/device-dev/reference/hdi-apis/camera.md new file mode 100644 index 0000000000000000000000000000000000000000..5b5de306eac29c4a6357dd4b8443981d69ffc592 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/camera.md @@ -0,0 +1,285 @@ +# Camera + + +## **概述** + +Camera模块接口定义。 + +Camera模块涉及相机设备的操作、流的操作、离线流的操作和各种回调等。 + +**Since**: + +3.2 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraDevice.idl](_i_camera_device_8idl.md) | Camera设备操作接口。 | +| [ICameraDeviceCallback.idl](_i_camera_device_callback_8idl.md) | Camera设备的回调接口,主要包含Camera设备发生错误时和上报metadata的回调函数。 | +| [ICameraHost.idl](_i_camera_host_8idl.md) | Camera服务的管理类,对上层提供HDI接口。 | +| [ICameraHostCallback.idl](_i_camera_host_callback_8idl.md) | ICameraHost的回调接口,提供Camera设备和闪关灯状态变化的回调函数,回调函数由调用者实现。 | +| [IOfflineStreamOperator.idl](_i_offline_stream_operator_8idl.md) | 离线流的操作接口。 | +| [IStreamOperator.idl](_i_stream_operator_8idl.md) | 流的操作接口。 | +| [IStreamOperatorCallback.idl](_i_stream_operator_callback_8idl.md) | [IStreamOperator](interface_i_stream_operator.md)相关的回调,这些回调均由调用者实现。 | +| [Types.idl](camera_2v1__0_2_types_8idl.md) | Camera模块HDI接口使用的数据类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ICameraDevice](interface_i_camera_device.md) | 定义Camera设备基本的操作。 | +| [ICameraDeviceCallback](interface_i_camera_device_callback.md) | 定义Camera设备回调操作。 | +| [ICameraHost](interface_i_camera_host.md) | 定义Camera设备功能操作。 | +| [ICameraHostCallback](interface_i_camera_host_callback.md) | 定义Camera设备功能回调操作。 | +| [IOfflineStreamOperator](interface_i_offline_stream_operator.md) | 定义Camera设备离线流操作。 | +| [IStreamOperator](interface_i_stream_operator.md) | 定义Camera设备流操作。 | +| [IStreamOperatorCallback](interface_i_stream_operator_callback.md) | 定义Camera设备流回调操作。 | +| [StreamInfo](_stream_info.md) | 流信息,用于创建流时传入相关的配置参数。 | +| [StreamAttribute](_stream_attribute.md) | 流的属性。 | +| [CaptureInfo](_capture_info.md) | 捕获请求的相关信息。 | +| [CaptureEndedInfo](_capture_ended_info.md) | 捕获结束相关信息,用于捕获结束回调[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)。 | +| [CaptureErrorInfo](_capture_error_info.md) | 流错误信息,用于回调[OnCaptureError](interface_i_stream_operator_callback.md#oncaptureerror)。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [CamRetCode](#camretcode) {   NO_ERROR = 0, CAMERA_BUSY = -1, INSUFFICIENT_RESOURCES = -2, INVALID_ARGUMENT = -3,   METHOD_NOT_SUPPORTED = -4, CAMERA_CLOSED = -5, DEVICE_ERROR = -6, NO_PERMISSION = -7 } | HDI接口的返回值。 | +| [ResultCallbackMode](#resultcallbackmode) { PER_FRAME = 0, ON_CHANGED = 1 } | metadata的上报模式。 | +| [OperationMode](#operationmode) { NORMAL = 0 } | 流的使用模式。 | +| [StreamIntent](#streamintent) { PREVIEW = 0, VIDEO = 1, STILL_CAPTURE = 2, POST_VIEW = 3,   ANALYZE = 4, CUSTOM = 5 } | 流的类型。 | +| [EncodeType](#encodetype) { ENCODE_TYPE_NULL = 0, ENCODE_TYPE_H264 = 1, ENCODE_TYPE_H265 = 2, ENCODE_TYPE_JPEG = 3 } | 流数据的编码类型。 | +| [StreamSupportType](#streamsupporttype) { DYNAMIC_SUPPORTED = 0, RE_CONFIGURED_REQUIRED = 1, NOT_SUPPORTED = 2 } | 对动态配置流的支持类型,使用场景参考[IsStreamsSupported](interface_i_stream_operator.md#isstreamssupported)。 | +| [CameraStatus](#camerastatus) { UN_AVAILABLE = 0, AVAILABLE = 1 } | Camera设备状态。 | +| [FlashlightStatus](#flashlightstatus) { FLASHLIGHT_OFF = 0, FLASHLIGHT_ON = 1, FLASHLIGHT_UNAVAILABLE = 2 } | 闪光灯状态。 | +| [CameraEvent](#cameraevent) { CAMERA_EVENT_DEVICE_ADD = 0, CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 | +| [ErrorType](#errortype) {   FATAL_ERROR = 0, REQUEST_TIMEOUT = 1, DRIVER_ERROR = 2, DEVICE_PREEMPT = 3,   DEVICE_DISCONNECT = 4, DCAMERA_ERROR_BEGIN = 1024, DCAMERA_ERROR_DEVICE_IN_USE, DCAMERA_ERROR_NO_PERMISSION } | 设备错误类型,用于设备错误回调[OnError](interface_i_camera_device_callback.md#onerror)。 | +| [StreamError](#streamerror) { UNKNOWN_ERROR = 0, BUFFER_LOST = 1 } | 流错误类型,用于流错误类型[CaptureErrorInfo](_capture_error_info.md)。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | +| sequenceable ohos.hdi.camera.v1_0.BufferProducerSequenceable | ohos.hdi.camera.v1_0序列,可用缓冲区生成器。 | + + +## **枚举类型说明** + + +### CameraEvent + + +``` +enum CameraEvent +``` + +**描述:** + +Camera事件。 + + | 枚举值 | 描述 | +| -------- | -------- | +| CAMERA_EVENT_DEVICE_ADD | Camera设备增加事件。 | +| CAMERA_EVENT_DEVICE_RMV | Camera设备删除事件。 | + + +### CameraStatus + + +``` +enum CameraStatus +``` + +**描述:** + +Camera设备状态。 + + | 枚举值 | 描述 | +| -------- | -------- | +| UN_AVAILABLE | 设备当前不在位或者不可用。 | +| AVAILABLE | 设备当前可用。 | + + +### CamRetCode + + +``` +enum CamRetCode +``` + +**描述:** + +HDI接口的返回值。 + + | 枚举值 | 描述 | +| -------- | -------- | +| NO_ERROR | 调用成功。 | +| CAMERA_BUSY | 设备当前忙。 | +| INSUFFICIENT_RESOURCES | 资源不足。 | +| INVALID_ARGUMENT | 参数错误。 | +| METHOD_NOT_SUPPORTED | 不支持当前调用方法。 | +| CAMERA_CLOSED | Camera设备已经关闭。 | +| DEVICE_ERROR | 驱动层发生严重错误。 | +| NO_PERMISSION | 无权限访问设备。 | + + +### EncodeType + + +``` +enum EncodeType +``` + +**描述:** + +流数据的编码类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| ENCODE_TYPE_NULL | 未设置编码类型 | +| ENCODE_TYPE_H264 | 编码类型为H264。 | +| ENCODE_TYPE_H265 | 编码类型为H265。 | +| ENCODE_TYPE_JPEG | 编码类型为JPEG。 | + + +### ErrorType + + +``` +enum ErrorType +``` + +**描述:** + +设备错误类型,用于设备错误回调[OnError](interface_i_camera_device_callback.md#onerror)。 + + | 枚举值 | 描述 | +| -------- | -------- | +| FATAL_ERROR | 严重错误,需要关闭Camera设备。 | +| REQUEST_TIMEOUT | 请求超时,需要关闭Camera设备。 | +| DRIVER_ERROR | 驱动程序中发生错误。 | +| DEVICE_PREEMPT | 设备被抢占。 | +| DEVICE_DISCONNECT | 设备已断开连接。 | +| DCAMERA_ERROR_BEGIN | 分布式像机错误开始的标识。 | +| DCAMERA_ERROR_DEVICE_IN_USE | 分布式像机设备忙。 | +| DCAMERA_ERROR_NO_PERMISSION | 没有访问分布式摄像机设备的权限。 | + + +### FlashlightStatus + + +``` +enum FlashlightStatus +``` + +**描述:** + +闪光灯状态。 + + | 枚举值 | 描述 | +| -------- | -------- | +| FLASHLIGHT_OFF | 闪光灯关闭。 | +| FLASHLIGHT_ON | 闪光灯开启。 | +| FLASHLIGHT_UNAVAILABLE | 闪光灯当前不可用。 | + + +### OperationMode + + +``` +enum OperationMode +``` + +**描述:** + +流的使用模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| NORMAL | 普通模式。 | + + +### ResultCallbackMode + + +``` +enum ResultCallbackMode +``` + +**描述:** + +metadata的上报模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| PER_FRAME | 逐帧上报。 | +| ON_CHANGED | 设备状态变化时上报。 | + + +### StreamError + + +``` +enum StreamError +``` + +**描述:** + +流错误类型,用于流错误类型[CaptureErrorInfo](_capture_error_info.md)。 + + | 枚举值 | 描述 | +| -------- | -------- | +| UNKNOWN_ERROR | 流未知错误。 | +| BUFFER_LOST | 丢包。 | + + +### StreamIntent + + +``` +enum StreamIntent +``` + +**描述:** + +流的类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| PREVIEW | 流数据用于显示,即预览流。 | +| VIDEO | 流数据用于编码生成录像,即录像流。 | +| STILL_CAPTURE | 流数据用于编码生成照片,即拍照流。 | +| POST_VIEW | 流数据用于保存缩略图。 | +| ANALYZE | 流数据用于图像分析。 | +| CUSTOM | 自定义类型。 | + + +### StreamSupportType + + +``` +enum StreamSupportType +``` + +**描述:** + +对动态配置流的支持类型,使用场景参考[IsStreamsSupported](interface_i_stream_operator.md#isstreamssupported)。 + + | 枚举值 | 描述 | +| -------- | -------- | +| DYNAMIC_SUPPORTED | 支持动态配置流,对应的流参数直接生效。 | +| RE_CONFIGURED_REQUIRED | 不支持动态配置流,对应的参数需要停止流然后重新配置流才能生效。 | +| NOT_SUPPORTED | 不支持对应的流参数配置。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/camera_2v1__0_2_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/camera_2v1__0_2_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..51e4d8c25dee501dab05ef3101f224e828c374b8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/camera_2v1__0_2_types_8idl.md @@ -0,0 +1,57 @@ +# Types.idl + + +## **概述** + +Camera模块HDI接口使用的数据类型。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [StreamInfo](_stream_info.md) | 流信息,用于创建流时传入相关的配置参数。 | +| [StreamAttribute](_stream_attribute.md) | 流的属性。 | +| [CaptureInfo](_capture_info.md) | 捕获请求的相关信息。 | +| [CaptureEndedInfo](_capture_ended_info.md) | 捕获结束相关信息,用于捕获结束回调[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)。 | +| [CaptureErrorInfo](_capture_error_info.md) | 流错误信息,用于回调[OnCaptureError](interface_i_stream_operator_callback.md#oncaptureerror)。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [CamRetCode](camera.md#camretcode) {   NO_ERROR = 0, CAMERA_BUSY = -1, INSUFFICIENT_RESOURCES = -2, INVALID_ARGUMENT = -3,   METHOD_NOT_SUPPORTED = -4, CAMERA_CLOSED = -5, DEVICE_ERROR = -6, NO_PERMISSION = -7 } | HDI接口的返回值。 | +| [ResultCallbackMode](camera.md#resultcallbackmode) { PER_FRAME = 0, ON_CHANGED = 1 } | metadata的上报模式。 | +| [OperationMode](camera.md#operationmode) { NORMAL = 0 } | 流的使用模式。 | +| [StreamIntent](camera.md#streamintent) { PREVIEW = 0, VIDEO = 1, STILL_CAPTURE = 2, POST_VIEW = 3,   ANALYZE = 4, CUSTOM = 5 } | 流的类型。 | +| [EncodeType](camera.md#encodetype) { ENCODE_TYPE_NULL = 0, ENCODE_TYPE_H264 = 1, ENCODE_TYPE_H265 = 2, ENCODE_TYPE_JPEG = 3 } | 流数据的编码类型。 | +| [StreamSupportType](camera.md#streamsupporttype) { DYNAMIC_SUPPORTED = 0, RE_CONFIGURED_REQUIRED = 1, NOT_SUPPORTED = 2 } | 对动态配置流的支持类型,使用场景参考[IsStreamsSupported](interface_i_stream_operator.md#isstreamssupported)。 | +| [CameraStatus](camera.md#camerastatus) { UN_AVAILABLE = 0, AVAILABLE = 1 } | Camera设备状态。 | +| [FlashlightStatus](camera.md#flashlightstatus) { FLASHLIGHT_OFF = 0, FLASHLIGHT_ON = 1, FLASHLIGHT_UNAVAILABLE = 2 } | 闪光灯状态。 | +| [CameraEvent](camera.md#cameraevent) { CAMERA_EVENT_DEVICE_ADD = 0, CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 | +| [ErrorType](camera.md#errortype) {   FATAL_ERROR = 0, REQUEST_TIMEOUT = 1, DRIVER_ERROR = 2, DEVICE_PREEMPT = 3,   DEVICE_DISCONNECT = 4, DCAMERA_ERROR_BEGIN = 1024, DCAMERA_ERROR_DEVICE_IN_USE, DCAMERA_ERROR_NO_PERMISSION } | 设备错误类型,用于设备错误回调[OnError](interface_i_camera_device_callback.md#onerror)。 | +| [StreamError](camera.md#streamerror) { UNKNOWN_ERROR = 0, BUFFER_LOST = 1 } | 流错误类型,用于流错误类型[CaptureErrorInfo](_capture_error_info.md)。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.camera.v1_0 | Camera设备接口的包路径。 | +| sequenceable ohos.hdi.camera.v1_0.BufferProducerSequenceable | ohos.hdi.camera.v1_0序列,可用缓冲区生成器。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec.md b/zh-cn/device-dev/reference/hdi-apis/codec.md new file mode 100644 index 0000000000000000000000000000000000000000..94f2cc468c9d22a470f36129b1b182ff16b7d5ba --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec.md @@ -0,0 +1,473 @@ +# Codec + + +## **概述** + +Codec模块接口定义。 + +Codec模块涉及自定义类型、音视频编解码组件初始化、参数设置、数据的轮转和控制等。 + +**Since**: + +3.1 + +**Version**: + +2.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [codec_callback_if.h](codec_callback_if_h.md) | 主要包括回调函数接口定义。 | +| [codec_common_type.h](codec_common_type_h.md) | Codec模块接口定义中使用的自定义数据类型。 | +| [codec_component_if.h](codec_component_if_h.md) | 主要包括Codec组件接口定义。 | +| [codec_component_manager.h](codec__component__manager_h.md) | 主要包括Codec组件管理类接口。 | +| [codec_component_type.h](codec__component__type_h.md) | Codec模块接口定义中使用的自定义数据类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecCallbackType](_codec_callback_type.md) | Codec回调接口定义。 | +| [Alignment](_alignment.md) | 对齐结构定义,包含宽高的对齐值。 | +| [Rect](_rect.md) | 矩形的定义。 | +| [RangeValue](_range_value.md) | 取值范围的定义。 | +| [CodecComponentType](_codec_component_type.md) | Codec组件接口定义。 | +| [CodecComponentManager](_codec_component_manager.md) | Codec组件管理类接口定义。 | +| [VideoPortCap](_video_port_cap.md) | 定义视频编解码能力。 | +| [AudioPortCap](audio_portcap.md) | 定义音频编解码能力。 | +| [PortCap](union_port_cap.md) | 定义音视频编解码能力。 | +| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解码能力。 | +| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec buffer信息的定义。 | +| [CompVerInfo](_comp_ver_info.md) | 定义组件版本信息。 | +| [EventInfo](_event_info.md) | 定义事件上报信息。 | +| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义。 | +| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义。 | +| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义。 | + + +### 宏定义 + + | 名称 | 描述 | +| -------- | -------- | +| SAMPLE_FMT_NUM    32 | 采样格式最大值。 | +| UUID_LENGTH    128 | 定义UUID长度。 | +| PIX_FORMAT_NUM    16 | 支持的像素格式数组大小。 | +| SAMPLE_FORMAT_NUM    12 | 支持的音频采样格式数组大小。 | +| SAMPLE_RATE_NUM    16 | 支持的音频采样率数组大小。 | +| CHANNEL_NUM    16 | 支持的音频通道数组大小。 | +| NAME_LENGTH    32 | 组件名称大小。 | +| PROFILE_NUM    256 | 支持的profile数组大小。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecType](#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER,   INVALID_TYPE } | 枚举编解码的类型。 | +| [Profile](#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE,   AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000,   AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codec规格。 | +| [AudioSampleRate](#audiosamplerate) { AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000,   AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100,   AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | 枚举音频采样率。 | +| [CodecCapsMask](#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举播放能力。 | +| [CodecProcessMode](#codecprocessmode) { PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100,   PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解码处理模式。 | +| [AvCodecRole](#avcodecrole) {   MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000,   MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726,   MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解码组件类型。 | +| [AudioSampleFormat](#audiosampleformat) {  AUDIO_SAMPLE_FORMAT_S8 = 0, AUDIO_SAMPLE_FORMAT_S8P = 1, AUDIO_SAMPLE_FORMAT_U8 = 2, AUDIO_SAMPLE_FORMAT_U8P = 3,   AUDIO_SAMPLE_FORMAT_S16 = 4, AUDIO_SAMPLE_FORMAT_S16P = 5, AUDIO_SAMPLE_FORMAT_U16 = 6, AUDIO_SAMPLE_FORMAT_U16P = 7,   AUDIO_SAMPLE_FORMAT_S24 = 8, AUDIO_SAMPLE_FORMAT_S24P = 9, AUDIO_SAMPLE_FORMAT_U24 = 10, AUDIO_SAMPLE_FORMAT_U24P = 11,   AUDIO_SAMPLE_FORMAT_S32 = 12, AUDIO_SAMPLE_FORMAT_S32P = 13, AUDIO_SAMPLE_FORMAT_U32 = 14, AUDIO_SAMPLE_FORMAT_U32P = 15,   AUDIO_SAMPLE_FORMAT_S64 = 16, AUDIO_SAMPLE_FORMAT_S64P = 17, AUDIO_SAMPLE_FORMAT_U64 = 18, AUDIO_SAMPLE_FORMAT_U64P = 19,   AUDIO_SAMPLE_FORMAT_F32 = 20, AUDIO_SAMPLE_FORMAT_F32P = 21, AUDIO_SAMPLE_FORMAT_F64 = 22, AUDIO_SAMPLE_FORMAT_F64P = 23,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 枚举音频采样格式。 | +| [CodecBufferType](#codecbuffertype) {   CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4,   CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型。 | +| [ShareMemTypes](#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内存类型。 | +| [OmxIndexCodecExType](#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index。 | +| [OmxVideoExType](#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编码类型。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecCallbackTypeGet](#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 | +| [CodecCallbackTypeRelease](#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 | +| [CodecComponentTypeGet](#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 | +| [CodecComponentTypeRelease](#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 | +| [GetCodecComponentManager](#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 | +| [CodecComponentManagerRelease](#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 | + + +## **枚举类型说明** + + +### AudioSampleFormat + + +``` +enum AudioSampleFormat +``` + +**描述:** + +枚举音频采样格式。 + +对于planar的采样格式,每个声道的数据是独立存储在data中;对于packed的采样格式,只使用第一个data,每个声道的数据是交错存储的。 + + | 枚举值 | 描述 | +| -------- | -------- | +| AUDIO_SAMPLE_FORMAT_S8 | 8bit位宽有符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_S8P | 8bit位宽有符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_U8 | 8bit位宽无符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_U8P | 8bit位宽无符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_S16 | 16bit位宽有符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_S16P | 16bit位宽有符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_U16 | 16bit位宽无符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_U16P | 16bit位宽无符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_S24 | 24bit位宽有符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_S24P | 24bit位宽有符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_U24 | 24bit位宽无符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_U24P | 24bit位宽无符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_S32 | 32bit位宽有符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_S32P | 32bit位宽有符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_U32 | 32bit位宽无符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_U32P | 32bit位宽无符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_S64 | 64bit位宽有符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_S64P | 64bit位宽有符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_U64 | 64bit位宽无符号交织样本。 | +| AUDIO_SAMPLE_FORMAT_U64P | 64bit位宽无符号非交织样本。 | +| AUDIO_SAMPLE_FORMAT_F32 | 32bit位宽浮点型交织样本。 | +| AUDIO_SAMPLE_FORMAT_F32P | 64bit位宽浮点型非交织样本。 | +| AUDIO_SAMPLE_FORMAT_F64 | 64bit位宽双精度浮点型交织样本。 | +| AUDIO_SAMPLE_FORMAT_F64P | 64bit位宽双精度浮点型非交织样本。 | +| AUDIO_SAMPLE_FMT_U8 | 无符号8位整型,打包格式。 | +| AUDIO_SAMPLE_FMT_S16 | 带符号16位整型,打包格式。 | +| AUDIO_SAMPLE_FMT_S32 | 带符号32位整型,打包格式。 | +| AUDIO_SAMPLE_FMT_FLOAT | 浮点型,打包格式。 | +| AUDIO_SAMPLE_FMT_DOUBLE | 双精度浮点型,打包格式。 | +| AUDIO_SAMPLE_FMT_U8P | 无符号8位整型,平面格式。 | +| AUDIO_SAMPLE_FMT_S16P | 带符号16位整型,平面格式。 | +| AUDIO_SAMPLE_FMT_S32P | 带符号32位整型,平面格式。 | +| AUDIO_SAMPLE_FMT_FLOATP | 浮点型,平面格式。 | +| AUDIO_SAMPLE_FMT_DOUBLEP | 双精度浮点型,平面格式。 | +| AUDIO_SAMPLE_FMT_INVALID | 无效采样格式。 | + + +### AudioSampleRate + + +``` +enum AudioSampleRate +``` + +**描述:** + +枚举音频采样率。 + + | 枚举值 | 描述 | +| -------- | -------- | +| AUD_SAMPLE_RATE_8000 | 8K采样率。 | +| AUD_SAMPLE_RATE_12000 | 12K采样率。 | +| AUD_SAMPLE_RATE_11025 | 11.025K采样率。 | +| AUD_SAMPLE_RATE_16000 | 16K采样率。 | +| AUD_SAMPLE_RATE_22050 | 22.050K采样率。 | +| AUD_SAMPLE_RATE_24000 | 24K采样率。 | +| AUD_SAMPLE_RATE_32000 | 32K采样率。 | +| AUD_SAMPLE_RATE_44100 | 44.1K采样率。 | +| AUD_SAMPLE_RATE_48000 | 48K采样率。 | +| AUD_SAMPLE_RATE_64000 | 64K采样率。 | +| AUD_SAMPLE_RATE_96000 | 96K采样率。 | +| AUD_SAMPLE_RATE_INVALID | 无效采样率。 | + + +### AvCodecRole + + +``` +enum AvCodecRole +``` + +**描述:** + +枚举音视频编解码组件类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| MEDIA_ROLETYPE_IMAGE_JPEG | 图像JPEG媒体类型。 | +| MEDIA_ROLETYPE_VIDEO_AVC | 视频H.264媒体类型。 | +| MEDIA_ROLETYPE_VIDEO_HEVC | 视频H.265媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_FIRST | 音频编解码器类型。 | +| MEDIA_ROLETYPE_AUDIO_AAC | 音频AAC媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_G711A | 音频G711A媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_G711U | 音频G711U媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_G726 | 音频G726媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_PCM | 音频PCM媒体类型。 | +| MEDIA_ROLETYPE_AUDIO_MP3 | 音频MP3媒体类型。 | +| MEDIA_ROLETYPE_INVALID | 无效媒体类型。 | + + +### CodecBufferType + + +``` +enum CodecBufferType +``` + +**描述:** + +定义buffer类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| CODEC_BUFFER_TYPE_INVALID | 无效buffer类型。 | +| CODEC_BUFFER_TYPE_VIRTUAL_ADDR | 虚拟地址类型。 | +| CODEC_BUFFER_TYPE_AVSHARE_MEM_FD | 共享内存类型。 | +| CODEC_BUFFER_TYPE_HANDLE | handle类型。 | +| CODEC_BUFFER_TYPE_DYNAMIC_HANDLE | 动态handle类型。 | + + +### CodecCapsMask + + +``` +enum CodecCapsMask +``` + +**描述:** + +枚举播放能力。 + + | 枚举值 | 描述 | +| -------- | -------- | +| CODEC_CAP_ADAPTIVE_PLAYBACK | 自适应播放能力。 | +| CODEC_CAP_SECURE_PLAYBACK | 安全播放能力。 | +| CODEC_CAP_TUNNEL_PLAYBACK | 通道播放能力。 | +| CODEC_CAP_MULTI_PLANE | 视频图像平面/音频通道平面能力。 | + + +### CodecProcessMode + + +``` +enum CodecProcessMode +``` + +**描述:** + +枚举编解码处理模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| PROCESS_BLOCKING_INPUT_BUFFER | 同步模式输入buffer。 | +| PROCESS_BLOCKING_OUTPUT_BUFFER | 同步模式输出buffer。 | +| PROCESS_BLOCKING_CONTROL_FLOW | 同步模式控制流。 | +| PROCESS_NONBLOCKING_INPUT_BUFFER | 异步模式输入buffer。 | +| PROCESS_NONBLOCKING_OUTPUT_BUFFER | 异步模式输出buffer。 | +| PROCESS_NONBLOCKING_CONTROL_FLOW | 异步模式控制流。 | + + +### CodecType + + +``` +enum CodecType +``` + +**描述:** + +枚举编解码的类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| VIDEO_DECODER | 视频解码类型。 | +| VIDEO_ENCODER | 视频编码类型。 | +| AUDIO_DECODER | 音频解码类型。 | +| AUDIO_ENCODER | 音频编码类型。 | +| INVALID_TYPE | 无效类型。 | + + +### OmxIndexCodecExType + + +``` +enum OmxIndexCodecExType +``` + +**描述:** + +枚举Codec扩展index。 + + | 枚举值 | 描述 | +| -------- | -------- | +| OMX_IndexExtBufferTypeStartUnused | BufferType 扩展index。 | +| OMX_IndexParamSupportBufferType | SupportBuffer类型。 | +| OMX_IndexParamUseBufferType | UseBuffer类型。 | +| OMX_IndexParamGetBufferHandleUsage | GetBufferHandleUsage类型。 | + + +### OmxVideoExType + + +``` +enum OmxVideoExType +``` + +**描述:** + +枚举Codec扩展编码类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| OMX_VIDEO_CodingHEVC | HEVC编码类型。 | + + +### Profile + + +``` +enum Profile +``` + +**描述:** + +枚举Codec规格。 + + | 枚举值 | 描述 | +| -------- | -------- | +| INVALID_PROFILE | 无效的规格。 | +| AAC_LC_PROFILE | AAC低复杂度规格。 | +| AAC_MAIN_PROFILE | AAC主规格。 | +| AAC_HE_V1_PROFILE | AAC高效率和频带重现规格,又称为HEAAC,AAC+,或者AACPlusV1。 | +| AAC_HE_V2_PROFILE | AAC高效率和频带重现以及变量立体声规格,又称为AAC++或者AACPlusV2。 | +| AAC_LD_PROFILE | AAC低延迟规格。 | +| AAC_ELD_PROFILE | AAC增强型低延迟规格。 | +| AVC_BASELINE_PROFILE | H.264低规格。 | +| AVC_MAIN_PROFILE | H.264主规格。 | +| AVC_HIGH_PROFILE | H.264高规格。 | +| HEVC_MAIN_PROFILE | H.265主规格。 | +| HEVC_MAIN_10_PROFILE | H.265 10比特主规格。 | + + +### ShareMemTypes + + +``` +enum ShareMemTypes +``` + +**描述:** + +枚举共享内存类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| READ_WRITE_TYPE | 可读可写的共享内存类型。 | +| READ_ONLY_TYPE | 可读的共享内存类型。 | + + +## **函数说明** + + +### CodecCallbackTypeGet() + + +``` +struct CodecCallbackType* CodecCallbackTypeGet (struct HdfRemoteService * remote) +``` + +**描述:** + +实例化CodecCallbackType对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| remote | 输入参数,指向HdfRemoteService的指针。 | + +**返回:** + +实例化CodecCallbackType对象。 + + +### CodecCallbackTypeRelease() + + +``` +void CodecCallbackTypeRelease (struct CodecCallbackType * instance) +``` + +**描述:** + +释放CodecCallbackType对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| instance | 输入参数,指向CodecCallbackType实例的指针。 | + + +### CodecComponentManagerRelease() + + +``` +void CodecComponentManagerRelease (void ) +``` + +**描述:** + +释放CodecComponentManager对象。 + + +### CodecComponentTypeGet() + + +``` +struct CodecComponentType* CodecComponentTypeGet (struct HdfRemoteService * remote) +``` + +**描述:** + +实例化CodecComponentType对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| remote | 输入参数,指向RemoteService的指针。 | + +**返回:** + +实例化的CodecComponentType对象。 + + +### CodecComponentTypeRelease() + + +``` +void CodecComponentTypeRelease (struct CodecComponentType * instance) +``` + +**描述:** + +释放CodecComponentType对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| instance | 输入参数,指向CodecComponentType实例的指针。 | + + +### GetCodecComponentManager() + + +``` +struct CodecComponentManager* GetCodecComponentManager (void ) +``` + +**描述:** + +实例化CodecComponentManager对象。 + +**返回:** + +实例化的CodecComponentManager对象。 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md deleted file mode 100644 index 901abda364d0489a74a9b6c5808360a2886eb36b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md +++ /dev/null @@ -1,41 +0,0 @@ -# codec_callback_if.h - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [CodecCallbackType](_codec_callback_type.md) | Codec回调接口定义。 [更多...](_codec_callback_type.md) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [CodecCallbackTypeGet](_codec.md#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 [更多...](_codec.md#codeccallbacktypeget) | -| [CodecCallbackTypeRelease](_codec.md#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 [更多...](_codec.md#codeccallbacktyperelease) | - - -## **详细描述** - -主要包括回调函数接口定义。 - -Codec模块事件上报、上报输入buffer和输出buffer处理完毕等接口定义。 - -**Since:** - -3.1 - -**Version:** - -2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md deleted file mode 100644 index 7f573637c2dbff1f5945f81c5dc0bb57550d2999..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md +++ /dev/null @@ -1,46 +0,0 @@ -# codec_common_type.h - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [Alignment](_alignment.md) | 对齐结构定义,包含宽高的对齐值 [更多...](_alignment.md) | -| [Rect](_rect.md) | 矩形的定义 [更多...](_rect.md) | -| [RangeValue](_range_value.md) | 取值范围的定义 [更多...](_range_value.md) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [CodecType](_codec.md#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER,   INVALID_TYPE } | 枚举编解码的类型 [更多...](_codec.md#codectype) | -| [Profile](_codec.md#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE,   AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000,   AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codec规格 [更多...](_codec.md#profile) | -| [AudioSampleRate](_codec.md#audiosamplerate) {   AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000,   AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100,   AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | 枚举音频采样率 [更多...](_codec.md#audiosamplerate) | -| [CodecCapsMask](_codec.md#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举播放能力 [更多...](_codec.md#codeccapsmask) | -| [CodecProcessMode](_codec.md#codecprocessmode) {   PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100,   PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解码处理模式 [更多...](_codec.md#codecprocessmode) | - - -## **详细描述** - -Codec模块接口定义中使用的自定义数据类型。 - -Codec模块接口定义中使用的自定义数据类型,包括编解码类型、音视频参数、buffer定义等。 - -**Since:** - -3.1 - -**Version:** - -2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md deleted file mode 100644 index 4e4587ac518b6a11993f76ff6f599d9d05f76bd8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md +++ /dev/null @@ -1,41 +0,0 @@ -# codec_component_if.h - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [CodecComponentType](_codec_component_type.md) | Codec组件接口定义。 [更多...](_codec_component_type.md) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [CodecComponentTypeGet](_codec.md#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 [更多...](_codec.md#codeccomponenttypeget) | -| [CodecComponentTypeRelease](_codec.md#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 [更多...](_codec.md#codeccomponenttyperelease) | - - -## **详细描述** - -主要包括Codec组件接口定义。 - -Codec模块提供了获取组件信息、给组件发送命令、组件参数设置、buffer轮转和控制等接口定义。创建组件后,可使用下列接口进行编解码处理。 - -**Since:** - -3.1 - -**Version:** - -2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md deleted file mode 100644 index 77ea946aef35c4d7d6254e37baee11b398c7b68f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md +++ /dev/null @@ -1,41 +0,0 @@ -# codec_component_manager.h - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [CodecComponentManager](_codec_component_manager.md) | Codec组件管理类接口定义。 [更多...](_codec_component_manager.md) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [GetCodecComponentManager](_codec.md#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 [更多...](_codec.md#getcodeccomponentmanager) | -| [CodecComponentManagerRelease](_codec.md#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 [更多...](_codec.md#codeccomponentmanagerrelease) | - - -## **详细描述** - -主要包括Codec组件管理类接口。 - -Codec模块获取组件编解码能力集、创建组件和销毁组件等接口定义。 - -**Since:** - -3.1 - -**Version:** - -2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_h.md new file mode 100644 index 0000000000000000000000000000000000000000..27d7f244b3cdb5e768f53319582e80b79834a3ca --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_h.md @@ -0,0 +1,38 @@ +# codec_component_manager.h + + +## **概述** + +主要包括Codec组件管理类接口。 + +Codec模块获取组件编解码能力集、创建组件和销毁组件等接口定义。 + +**Since**: + +3.1 + +**Version**: + +2.0 + +**相关模块:** + +[Codec](codec.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecComponentManager](_codec_component_manager.md) | Codec组件管理类接口定义。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [GetCodecComponentManager](codec.md#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 | +| [CodecComponentManagerRelease](codec.md#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md deleted file mode 100644 index c83e715ec17f67d91ff5dd89e44ffa81c5dbe3a7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md +++ /dev/null @@ -1,68 +0,0 @@ -# codec_component_type.h - - -## **概述** - -**所属模块:** - -[Codec](_codec.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [VideoPortCap](_video_port_cap.md) | 定义视频编解码能力 [更多...](_video_port_cap.md) | -| [AudioPortCap](_audio_port_cap.md) | 定义音频编解码能力 [更多...](_audio_port_cap.md) | -| [PortCap](union_port_cap.md) | 定义音视频编解码能力 [更多...](union_port_cap.md) | -| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解码能力 [更多...](_codec_comp_capability.md) | -| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec buffer信息的定义 [更多...](_omx_codec_buffer.md) | -| [CompVerInfo](_comp_ver_info.md) | 定义组件版本信息 [更多...](_comp_ver_info.md) | -| [EventInfo](_event_info.md) | 定义事件上报信息 [更多...](_event_info.md) | -| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义. [更多...](_support_buffer_type.md) | -| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义 [更多...](_use_buffer_type.md) | -| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义 [更多...](_get_buffer_handle_usage_params.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| [SAMPLE_FMT_NUM](_codec.md#ga9bda75c363e9bcff915cdd521dd7ba84)   32 | 采样格式最大值 | -| [UUID_LENGTH](_codec.md#ga9226162b034cc837cd977f0fcf611c2c)   128 | 定义UUID长度 | -| [PIX_FORMAT_NUM](_codec.md#gadb8c6478388b68c09835ebe093a8920a)   16 | 支持的像素格式数组大小 | -| [SAMPLE_FORMAT_NUM](_codec.md#gaf958b9cc535f6260e2e8b7ce42c89946)   12 | 支持的音频采样格式数组大小 | -| [SAMPLE_RATE_NUM](_codec.md#ga0d905eaa05b4b6fcec76924eb795d7fe)   16 | 支持的音频采样率数组大小 | -| [CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1)   16 | 支持的音频通道数组大小 | -| [NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17)   32 | 组件名称大小 | -| [PROFILE_NUM](_codec.md#gaab6353cb3662bdc672ae8ab90df529ce)   256 | 支持的profile数组大小 | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [AvCodecRole](_codec.md#avcodecrole) { MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000,   MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726,   MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解码组件类型 [更多...](_codec.md#avcodecrole) | -| [AudioSampleFormat](_codec.md#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P,   AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P,   AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P,   AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P,   AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P,   AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 枚举音频采样格式 [更多...](_codec.md#audiosampleformat) | -| [CodecBufferType](_codec.md#codecbuffertype) { CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4,   CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型 [更多...](_codec.md#codecbuffertype) | -| [ShareMemTypes](_codec.md#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内存类型 [更多...](_codec.md#sharememtypes) | -| [OmxIndexCodecExType](_codec.md#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index [更多...](_codec.md#omxindexcodecextype) | -| [OmxVideoExType](_codec.md#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编码类型 [更多...](_codec.md#omxvideoextype) | - - -## **详细描述** - -Codec模块接口定义中使用的自定义数据类型。 - -Codec模块接口定义中使用的自定义数据类型,包括编解码类型、音视频参数、buffer定义等。 - -**Since:** - -3.1 - -**Version:** - -2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__type_h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__type_h.md new file mode 100644 index 0000000000000000000000000000000000000000..b6ddc54e8b1acbe57d7207ef04e78df87a3a85c6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__component__type_h.md @@ -0,0 +1,64 @@ +# codec_component_type.h + + +## **概述** + + +Codec模块接口定义中使用的自定义数据类型,包括编解码类型、音视频参数、buffer定义等。 + +**Since**: + +3.1 + +**Version**: + +2.0 + +**相关模块:** + +[Codec](codec.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [VideoPortCap](_video_port_cap.md) | 定义视频编解码能力。 | +| [AudioPortCap](audio_portcap.md) | 定义音频编解码能力。 | +| [PortCap](union_port_cap.md) | 定义音视频编解码能力。 | +| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解码能力。 | +| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec buffer信息的定义。 | +| [CompVerInfo](_comp_ver_info.md) | 定义组件版本信息。 | +| [EventInfo](_event_info.md) | 定义事件上报信息。 | +| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义。 | +| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义。 | +| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义。 | + + +### 宏定义 + + | 名称 | 描述 | +| -------- | -------- | +| [SAMPLE_FMT_NUM](codec.md#宏定义)   32 | 采样格式最大值。 | +| [UUID_LENGTH](codec.md#宏定义)   128 | 定义UUID长度。 | +| [PIX_FORMAT_NUM](codec.md#宏定义)   16 | 支持的像素格式数组大小。 | +| [SAMPLE_FORMAT_NUM](codec.md#宏定义)   12 | 支持的音频采样格式数组大小。 | +| [SAMPLE_RATE_NUM](codec.md#宏定义)   16 | 支持的音频采样率数组大小。 | +| [CHANNEL_NUM](codec.md#宏定义)   16 | 支持的音频通道数组大小。 | +| [NAME_LENGTH](codec.md#宏定义)   32 | 组件名称大小。 | +| [PROFILE_NUM](codec.md#宏定义)   256 | 支持的profile数组大小。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [AvCodecRole](codec.md#avcodecrole) { MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000,   MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726,   MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解码组件类型。 | +| [AudioSampleFormat](codec.md#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8 = 0, AUDIO_SAMPLE_FORMAT_S8P = 1, AUDIO_SAMPLE_FORMAT_U8 = 2, AUDIO_SAMPLE_FORMAT_U8P = 3,   AUDIO_SAMPLE_FORMAT_S16 = 4, AUDIO_SAMPLE_FORMAT_S16P = 5, AUDIO_SAMPLE_FORMAT_U16 = 6, AUDIO_SAMPLE_FORMAT_U16P = 7,   AUDIO_SAMPLE_FORMAT_S24 = 8, AUDIO_SAMPLE_FORMAT_S24P = 9, AUDIO_SAMPLE_FORMAT_U24 = 10, AUDIO_SAMPLE_FORMAT_U24P = 11,   AUDIO_SAMPLE_FORMAT_S32 = 12, AUDIO_SAMPLE_FORMAT_S32P = 13, AUDIO_SAMPLE_FORMAT_U32 = 14, AUDIO_SAMPLE_FORMAT_U32P = 15,   AUDIO_SAMPLE_FORMAT_S64 = 16, AUDIO_SAMPLE_FORMAT_S64P = 17, AUDIO_SAMPLE_FORMAT_U64 = 18, AUDIO_SAMPLE_FORMAT_U64P = 19,   AUDIO_SAMPLE_FORMAT_F32 = 20, AUDIO_SAMPLE_FORMAT_F32P = 21, AUDIO_SAMPLE_FORMAT_F64 = 22, AUDIO_SAMPLE_FORMAT_F64P = 23,   AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT,   AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P,   AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | 枚举音频采样格式。 | +| [CodecBufferType](codec.md#codecbuffertype) { CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4,   CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型。 | +| [ShareMemTypes](codec.md#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内存类型。 | +| [OmxIndexCodecExType](codec.md#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index。 | +| [OmxVideoExType](codec.md#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编码类型。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec_callback_if_h.md b/zh-cn/device-dev/reference/hdi-apis/codec_callback_if_h.md new file mode 100644 index 0000000000000000000000000000000000000000..a7939a857bd0ce8d162e7d3a326ac0b60d73d2f7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec_callback_if_h.md @@ -0,0 +1,38 @@ +# codec_callback_if.h + + +## **概述** + +主要包括回调函数接口定义。 + +Codec模块事件上报、上报输入buffer和输出buffer处理完毕等接口定义。 + +**Since**: + +3.1 + +**Version**: + +2.0 + +**相关模块:** + +[Codec](codec.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecCallbackType](_codec_callback_type.md) | Codec回调接口定义。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecCallbackTypeGet](codec.md#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 | +| [CodecCallbackTypeRelease](codec.md#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec_common_type_h.md b/zh-cn/device-dev/reference/hdi-apis/codec_common_type_h.md new file mode 100644 index 0000000000000000000000000000000000000000..e603fbceb5d28d40eaee42bc5607b1f7cd6bd0fc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec_common_type_h.md @@ -0,0 +1,41 @@ +# codec_common_type.h + + +## **概述** + +Codec模块接口定义中使用的自定义数据类型,包括编解码类型、音视频参数、buffer定义等。 + +**Since**: + +3.1 + +**Version**: + +2.0 + +**相关模块:** + +[Codec](codec.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [Alignment](_alignment.md) | 对齐结构定义,包含宽高的对齐值。 | +| [Rect](_rect.md) | 矩形的定义。 | +| [RangeValue](_range_value.md) | 取值范围的定义。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecType](codec.md#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER,   INVALID_TYPE  } | 枚举编解码的类型。 | +| [Profile](codec.md#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE,   AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000,   AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codec规格。 | +| [AudioSampleRate](codec.md#audiosamplerate) { AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000,   AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100,   AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | 枚举音频采样率。 | +| [CodecCapsMask](codec.md#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举播放能力。 | +| [CodecProcessMode](codec.md#codecprocessmode) { PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100,   PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解码处理模式。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec_component_if_h.md b/zh-cn/device-dev/reference/hdi-apis/codec_component_if_h.md new file mode 100644 index 0000000000000000000000000000000000000000..9be7901fd0dd367ba09dc8983ec89b0aab9408d4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec_component_if_h.md @@ -0,0 +1,38 @@ +# codec_component_if.h + + +## **概述** + +主要包括Codec组件接口定义。 + +Codec模块提供了获取组件信息、给组件发送命令、组件参数设置、buffer轮转和控制等接口定义。创建组件后,可使用下列接口进行编解码处理。 + +**Since**: + +3.1 + +**Version**: + +2.0 + +**相关模块:** + +[Codec](codec.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecComponentType](_codec_component_type.md) | Codec组件接口定义。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [CodecComponentTypeGet](codec.md#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 | +| [CodecComponentTypeRelease](codec.md#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md index 7d8bb2f45071341bc1b4ab3536019f659b723353..d4dbfccb78d814df1741d41ff282bd9f83109253 100644 --- a/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +显示设备控制接口声明。 + +**Since:** + +1.0 + +**Version:** + +2.0 + +**相关模块:** [Display](_display.md) @@ -13,36 +23,23 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [DeviceFuncs](_device_funcs.md) | 显示设备控制接口结构体,定义显示设备控制接口函数指针。 [更多...](_device_funcs.md) | +| [DeviceFuncs](_device_funcs.md) | 显示设备控制接口结构体,定义显示设备控制接口函数指针。 | ### 类型定义 - | 类型定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| ([HotPlugCallback](_display.md#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | 热插拔事件回调。[更多...](_display.md#hotplugcallback) | -| ([VBlankCallback](_display.md#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 [更多...](_display.md#vblankcallback) | -| ([RefreshCallback](_display.md#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调。[更多...](_display.md#refreshcallback) | +| ([HotPlugCallback](_display.md#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | 热插拔事件回调 | +| ([VBlankCallback](_display.md#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 | +| ([RefreshCallback](_display.md#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [DeviceInitialize](_display.md#deviceinitialize) ([DeviceFuncs](_device_funcs.md) \*\*funcs) | 实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 [更多...](_display.md#deviceinitialize) | -| [DeviceUninitialize](_display.md#deviceuninitialize) ([DeviceFuncs](_device_funcs.md) \*funcs) | 取消显示设备控制接口的初始化,释放控制接口使用到的资源。 [更多...](_display.md#deviceuninitialize) | - - -## **详细描述** - -显示设备控制接口声明。 - -**Since:** - -1.0 - -**Version:** - -2.0 +| [DeviceInitialize](_display.md#deviceinitialize)(DeviceFuncs \*\*funcs) | 实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口。 | +| [DeviceUninitialize](_display.md#deviceuninitialize)(DeviceFuncs \*funcs) | 取消显示设备控制接口的初始化,释放控制接口使用到的资源。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md index 10cc061b8db3075f786370c338472ba45f72102c..e26796cb53997141fd676af7ccd1051d8ba66784 100644 --- a/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +显示硬件加速驱动接口声明。 + +**Since:** + +1.0 + +**Version:** + +1.0 + +**相关模块:** [Display](_display.md) @@ -13,27 +23,14 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GfxFuncs](_gfx_funcs.md) | 显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 [更多...](_gfx_funcs.md) | +| [GfxFuncs](_gfx_funcs.md) | 显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GfxInitialize](_display.md#gfxinitialize) ([GfxFuncs](_gfx_funcs.md) \*\*funcs) | 获取硬件加速相关的操作接口指针。 [更多...](_display.md#gfxinitialize) | -| [GfxUninitialize](_display.md#gfxuninitialize) ([GfxFuncs](_gfx_funcs.md) \*funcs) | 释放硬件加速相关的操作接口指针。 [更多...](_display.md#gfxuninitialize) | - - -## **详细描述** - -显示硬件加速驱动接口声明。 - -**Since:** - -1.0 - -**Version:** - -1.0 +| [GfxInitialize](_display.md#gfxinitialize)(GfxFuncs \*\*funcs) | 获取硬件加速相关的操作接口指针。 | +| [GfxUninitialize](_display.md#gfxuninitialize)(GfxFuncs \*funcs) | 释放硬件加速相关的操作接口指针。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md index e75c7d78987dd301d0011d5afe4990a67e05db5d..5b6ae08c24a3de8b4602cb6c78666012066a656d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +显示内存驱动接口声明。 + +**Since:** + +1.0 + +**Version:** + +2.0 + +**相关模块:** [Display](_display.md) @@ -13,27 +23,14 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GrallocFuncs](_gralloc_funcs.md) | 显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 [更多...](_gralloc_funcs.md) | +| [GrallocFuncs](_gralloc_funcs.md) | 显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [GrallocInitialize](_display.md#grallocinitialize) ([GrallocFuncs](_gralloc_funcs.md) \*\*funcs) | 初始化内存模块,并获取内存提供的操作接口。 [更多...](_display.md#grallocinitialize) | -| [GrallocUninitialize](_display.md#grallocuninitialize) ([GrallocFuncs](_gralloc_funcs.md) \*funcs) | 取消初始化内存模块,并释放内存操作接口指针。 [更多...](_display.md#grallocuninitialize) | - - -## **详细描述** - -显示内存驱动接口声明。 - -**Since:** - -1.0 - -**Version:** - -2.0 +| [GrallocInitialize](_display.md#grallocinitialize)(GrallocFuncs \*\*funcs) | 初始化内存模块,并获取内存提供的操作接口。 | +| [GrallocUninitialize](_display.md#grallocuninitialize)(GrallocFuncs \*funcs) | 取消初始化内存模块,并释放内存操作接口指针。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md index 6075edc6e52f07cd9762c2b0211ed9730a9df171..4924bc32fa02d6b8140a8bd09a1f12f498d489ce 100644 --- a/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +显示图层驱动接口声明。 + +**Since:** + +1.0 + +**Version:** + +2.0 + +**相关模块:** [Display](_display.md) @@ -13,27 +23,14 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 [更多...](_layer_funcs.md) | +| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 | ### 函数 - | 函数 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [LayerInitialize](_display.md#layerinitialize) ([LayerFuncs](_layer_funcs.md) \*\*funcs) | 实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 [更多...](_display.md#layerinitialize) | -| [LayerUninitialize](_display.md#layeruninitialize) ([LayerFuncs](_layer_funcs.md) \*funcs) | 取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 [更多...](_display.md#layeruninitialize) | - - -## **详细描述** - -显示图层驱动接口声明。 - -**Since:** - -1.0 - -**Version:** - -2.0 +| [LayerInitialize](_display.md#layerinitialize)(LayerFuncs \*\*funcs) | 实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 | +| [LayerUninitialize](_display.md#layeruninitialize)(LayerFuncs \*funcs) | 取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md index 8bccecc8f04c9d708a3212174c9213192c8c6a6f..bbf2dabaf247dda3f019bb5b8341ee96019e5f2a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md @@ -3,7 +3,17 @@ ## **概述** -**所属模块:** +显示类型定义,定义显示驱动接口所使用的数据类型。 + +**Since:** + +1.0 + +**Version:** + +2.0 + +**相关模块:** [Display](_display.md) @@ -13,70 +23,58 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [DisplayInfo](_display_info.md) | 定义显示信息结构体 [更多...](_display_info.md) | -| [LayerInfo](_layer_info.md) | 定义图层信息结构体 [更多...](_layer_info.md) | -| [LayerAlpha](_layer_alpha.md) | 定义图层Alpha信息的结构体 [更多...](_layer_alpha.md) | -| [BufferData](_buffer_data.md) | 定义一层的缓冲区数据,包括虚拟和物理内存地址。 [更多...](_buffer_data.md) | -| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于存放图层数据。 [更多...](_layer_buffer.md) | -| [IRect](_i_rect.md) | 定义矩形信息 [更多...](_i_rect.md) | -| [ISurface](_i_surface.md) | 用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 [更多...](_i_surface.md) | -| [ILine](_i_line.md) | 线条描述结构体定义,用于硬件加速绘制直线。 [更多...](_i_line.md) | -| [ICircle](_i_circle.md) | 圆形描述结构体定义,用于硬件加速绘制圆形。 [更多...](_i_circle.md) | -| [Rectangle](_rectangle.md) | 矩形描述结构体定义,用于硬件加速绘制矩形, [更多...](_rectangle.md) | -| [GfxOpt](_gfx_opt.md) | 图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 [更多...](_gfx_opt.md) | -| [PropertyObject](_property_object.md) | 定义包含名称、属性ID和值的属性对象。 [更多...](_property_object.md) | -| [DisplayCapability](_display_capability.md) | 定义输出性能。 [更多...](_display_capability.md) | -| [DisplayModeInfo](_display_mode_info.md) | 定义输出模式信息。 [更多...](_display_mode_info.md) | -| [AllocInfo](_alloc_info.md) | 定义关于要分配的内存的信息。 [更多...](_alloc_info.md) | -| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义 [更多...](_h_d_r_capability.md) | -| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数据结构体定义 [更多...](_h_d_r_meta_data.md) | -| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验证内存分配信息的结构体定义 [更多...](_verify_alloc_info.md) | -| [PresentTimestamp](_present_timestamp.md) | 上屏时间戳结构体定义 [更多...](_present_timestamp.md) | -| [__attribute__](____attribute____.md) | 扩展数据句柄结构体定义 [更多...](____attribute____.md) | +| [DisplayInfo](_display_info.md) | 定义显示信息结构体。 | +| [LayerInfo](_layer_info.md) | 定义图层信息结构体。 | +| [LayerAlpha](_layer_alpha.md) | 定义图层Alpha信息的结构体。 | +| [BufferData](_buffer_data.md) | 定义一层的缓冲区数据,包括虚拟和物理内存地址。 | +| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于存放图层数据。 | +| [IRect](_i_rect.md) | 定义矩形信息。 | +| [ISurface](_i_surface.md) | 用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 | +| [ILine](_i_line.md) | 线条描述结构体定义,用于硬件加速绘制直线。 | +| [ICircle](_i_circle.md) | 圆形描述结构体定义,用于硬件加速绘制圆形。 | +| [Rectangle](_rectangle.md) | 矩形描述结构体定义,用于硬件加速绘制矩形。 | +| [GfxOpt](_gfx_opt.md) | 图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 | +| [PropertyObject](_property_object.md) | 定义包含名称、属性ID和值的属性对象。 | +| [DisplayCapability](_display_capability.md) | 定义输出性能。 | +| [DisplayModeInfo](_display_mode_info.md) | 定义输出模式信息。 | +| [AllocInfo](_alloc_info.md) | 定义关于要分配的内存的信息。 | +| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义。 | +| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数据结构体定义。 | +| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验证内存分配信息的结构体定义。 | +| [PresentTimestamp](_present_timestamp.md) | 上屏时间戳结构体定义。 | +| [ExtDataHandle](_ext_data_handle.md) | 扩展数据句柄结构体定义。 | +| [YUVDescInfo](_yun_desc_info_.md) | YUV描述信息结构体定义。 | ### 宏定义 - | 宏定义 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| **PROPERTY_NAME_LEN**   50 | 属性名称长度 | +| [PROPERTY_NAME_LEN](_display.md#property_name_len)  50 | 属性名字长度。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [DispErrCode](_display.md#disperrcode) { DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3,   DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7,   DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 [更多...](_display.md#disperrcode) | -| [LayerType](_display.md#layertype) { LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SIDEBAND, LAYER_TYPE_CURSOR,   LAYER_TYPE_BUTT } | 图层类型定义。 [更多...](_display.md#layertype) | -| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3),   HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } |缓冲区定义。[更多...](_display.md#anonymous-enum) | -| [PixelFormat](_display.md#pixelformat) { PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565,   PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444,   PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888,   PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444,   PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888,   PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP,   PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P,   PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG,   PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDER_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | 像素格式类型定义。 [更多...](_display.md#pixelformat) | -| [TransformType](_display.md#transformtype) { ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270,   ROTATE_BUTT } | 图层变换类型定义。 [更多...](_display.md#transformtype) | -| [BlendType](_display.md#blendtype) { BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER,   BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT,   BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD,   BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD,   BLEND_BUTT } | 显示内存类型定义。 [更多...](_display.md#blendtype) | -| [RopType](_display.md#roptype) { ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN,   ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN,   ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN,   ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE,   ROP_BUTT } |硬件加速支持的ROP操作类型。 [更多...](_display.md#roptype) | -| [ColorKey](_display.md#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color key操作类型定义,即硬件加速支持的Color key操作类型。 [更多...](_display.md#colorkey) | -| [MirrorType](_display.md#mirrortype) { MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | 硬件加速支持的镜像操作类型定义 [更多...](_display.md#mirrortype) | -| [Connection](_display.md#connection) { CON_INVALID = 0, CONNECTED, DISCONNECTED } | 热插拔连接类型定义 [更多...](_display.md#connection) | -| [InterfaceType](_display.md#interfacetype) { DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656,   DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO,   DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接口类型。 [更多...](_display.md#interfacetype) | -| [DispPowerStatus](_display.md#disppowerstatus) { POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF,   POWER_STATUS_BUTT } | 枚举显示状态 [更多...](_display.md#disppowerstatus) | -| [CompositionType](_display.md#compositiontype) { COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO,   COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组合类型。 [更多...](_display.md#compositiontype) | -| [ColorGamut](_display.md#colorgamut) { COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_STANDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2,   COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6,   COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值 [更多...](_display.md#colorgamut) | -| [GamutMap](_display.md#gamutmap) { GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | 枚举色域的映射类型 [更多...](_display.md#gamutmap) | -| [ColorDataSpace](_display.md#colordataspace) {   COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003,   GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007,   GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100,   TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500,   TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900,   PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000,   BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED,   BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL,   DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL,   BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL,   BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型 [更多...](_display.md#colordataspace) | -| [HDRFormat](_display.md#hdrformat) { NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3,   HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDR格式 [更多...](_display.md#hdrformat) | -| [HDRMetadataKey](_display.md#hdrmetadatakey) { MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3,   MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7,   MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,   MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字 [更多...](_display.md#hdrmetadatakey) | -| [PresentTimestampType](_display.md#presenttimestamptype) { HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上屏时间戳类型枚举值 [更多...](_display.md#presenttimestamptype) | - - -## **详细描述** - -显示类型定义,定义显示驱动接口所使用的数据类型。 - -**Since:** - -1.0 - -**Version:** - -2.0 +| [DispErrCode](_display.md#disperrcode){ DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3,   DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7,   DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 | +| [LayerType](_display.md#layertype){ LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SDIEBAND, LAYER_TYPE_CURSOR,   LAYER_TYPE_BUTT } | 图层类型定义。 | +| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3),   HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } | 定义缓冲区使用。 | +| [PixelFormat](_display.md#pixelformat){ PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565,   PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444,   PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888,   PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444,   PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888,   PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP,   PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P,   PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG,   PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDER_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | 像素格式类型定义。 | +| [TransformType](_display.md#transformtype){ ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270,   ROTATE_BUTT } | 图层变换类型定义。 | +| [BlendType](_display.md#blendtype){ BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER,   BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT,   BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD,   BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD,   BLEND_BUTT } | 支持的图像混合类型。 | +| [RopType](_display.md#roptype){ ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN,   ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN,   ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN,   ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE,   ROP_BUTT } | 硬件加速支持的ROP操作类型。 | +| [ColorKey](_display.md#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color key操作类型定义,即硬件加速支持的Color key操作类型。 | +| [MirrorType](_display.md#mirrortype){ MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | 硬件加速支持的镜像操作类型定义。 | +| [Connection](_display.md#connection){ CON_INVALID = 0, CONNECTED, DISCONNECTED } | 热插拔连接类型定义。 | +| [InterfaceType](_display.md#interfacetype){ DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656,   DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO,   DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接口类型。 | +| [DispPowerStatus](_display.md#disppowerstatus){ POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF,   POWER_STATUS_BUTT } | 枚举显示状态。 | +| [CompositionType](_display.md#compositiontype){ COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO,   COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组合类型。 | +| [ColorGamut](_display.md#colorgamut){ COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_SATNDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2,   COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6,   COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值。 | +| [GamutMap](_display.md#gamutmap){ GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | 枚举色域的映射类型。 | +| [ColorDataSpace](_display.md#colordataspace){  COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003,   GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007,   GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100,   TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500,   TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900,   PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000,   BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED,   BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL,   DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL,   BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL,   BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型。 | +| [HDRFormat](_display.md#hdrformat){ NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3,   HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDR格式。 | +| [HDRMetadataKey](_display.md#hdrmetadatakey){  MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3,   MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7,   MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,   MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字。 | +| [PresentTimestampType](_display.md#presenttimestamptype){ HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上屏时间戳类型枚举值。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/display__vgu_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__vgu_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..77ed4834405cd20597f9a5213cb25ccbfb6aa00b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__vgu_8h.md @@ -0,0 +1,99 @@ +# display_vgu.h + + +## **概述** + +定义2D矢量硬件加速模块相关驱动函数。 + +**Since:** + +3.0 + +**相关模块:** + +[Display](_display.md) + + +## **汇总** + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [VGUPoint](_v_g_u_point.md) | 坐标点对象。 | +| [VGURect](_v_g_u_rect.md) | 矩形对象。 | +| [VGUPath](_v_g_u_path.md) | 路径对象,存放路径命令和坐标数据。 | +| [VGUMatrix3](_v_g_u_matrix3.md) | 变换矩阵。 | +| [VGUBuffer](_v_g_u_buffer.md) | 硬件加速渲染位图缓存。 | +| [VGUMaskLayer](_v_g_u_mask_layer.md) | 定义蒙版图层。 | +| [VGUSurface](_v_g_u_surface.md) | 2D硬件加速绘制目标表面。 | +| [VGUColorStop](_v_g_u_color_stop.md) | 渐变颜色分布位置。 | +| [VGULinear](_v_g_u_linear.md) | 线性渐变。 | +| [VGURadial](_v_g_u_radial.md) | 辐射渐变。 | +| [VGUConic](_v_g_u_conic.md) | 圆锥渐变。 | +| [VGUImage](_v_g_u_image.md) | 图像对象。 | +| [VGUPattern](_v_g_u_pattern.md) | 图片模式对象。 | +| [VGUGradient](_v_g_u_gradient.md) | 渐变对象。 | +| [VGUSolid](_v_g_u_solid.md) | 颜色对象。 | +| [VGUPaintStyle](_v_g_u_paint_style.md) | 填充或描边路径的渲染风格。 | +| [VGUFillAttr](_v_g_u_fill_attr.md) | 填充路径的属性。 | +| [VGUStrokeAttr](_v_g_u_stroke_attr.md) | 描边路径的属性。 | +| [VGUFuncs](_v_g_u_funcs.md) | 定义2D硬件加速驱动函数。 | + + +### 宏定义 + + | 名称 | 描述 | +| -------- | -------- | +| HDI_VGU_SCALAR_IS_FLOAT   1 | VGU标量是否为浮点型 | + + +### 类型定义 + + | 名称 | 描述 | +| -------- | -------- | +| [VGUScalar](_display.md#vguscalar) | VGU标量 | +| [VGUPixelFormat](_display.md#vgupixelformat) | 像素格式。 | +| [VGUBlendType](_display.mdvgublendtype) | 混合操作类型。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [VGUPathDataType](_display.md#vgupathdatatype){ VGU_DATA_TYPE_S16 = 0, VGU_DATA_TYPE_S32, VGU_DATA_TYPE_F32 } | 路径坐标数据类型。 | +| [VGUCapability](_display.md#vgucapability){ VGU_CAP_BLIT = (1 << 0), VGU_CAP_BLIT_NUM = (1 << 1), VGU_CAP_PATH = (1 << 2), VGU_CAP_FILTER_BLUR = (1 << 3) } | 硬件加速能力。 | +| [VGUResult](_display.md#vguresult){   VGU_SUCCESS = 0, VGU_NO_SUPPORT = -1, VGU_OPERATION_FAILED = -2, VGU_OUT_OF_MEMORY = -3,   VGU_TIMEOUT = -4, VGU_INVALID_PARAMETER = -5, VGU_BUSY = -6, VGU_NO_CONTEXT = -7 } | 错误码定义。 | +| [VGULineCap](_display.md#vgulinecap){ VGU_LINECAP_BUTT = 0, VGU_LINECAP_ROUND, VGU_LINECAP_SQUARE } | 线帽。 | +| [VGUJointType](_display.md#vgujointtype){ VGU_LINE_JOIN_MITER = 0, VGU_LINE_JOIN_ROUND, VGU_LINE_JOIN_BEVEL, VGU_LINE_JOIN_BUTT } | 联接类型。 | +| [VGUFilter](_display.md#vgufilter){ VGU_FILTER_BILINEAR = 0, VGU_FILTER_NEAREST, VGU_FILTER_LINEAR, VGU_FILTER_BUTT } | 图像滤波类型。 | +| [VGUFillRule](_display.md#vgufillrule){ VGU_RULE_WINDING = 0, VGU_RULE_EVEN_ODD, VGU_RULE_BUTT } | 填充规则定义。 | +| [VGUFillSpread](_display.md#vgufillspread){ VGU_SPREAD_PAD = 0, VGU_SPREAD_REFLECT, VGU_SPREAD_REPEAT, VGU_SPREAD_BUTT } | 渐变填充区域外的延展类型。 | +| [VGUWrapType](_display.md#vguwraptype){ VGU_WRAP_REFLECT = 0, VGU_WRAP_REPEAT, VGU_WRAP_BUTT } | 图像模式填充延展类型。 | +| [VGUPathCmd](_display.md#vgupathcmd){   VGU_PATH_CMD_CLOSE = 0, VGU_PATH_CMD_MOVE, VGU_PATH_CMD_LINE, VGU_PATH_CMD_HLINE,   VGU_PATH_CMD_VLINE, VGU_PATH_CMD_QUAD, VGU_PATH_CMD_CUBIC, VGU_PATH_CMD_SQUAD,   VGU_PATH_CMD_SCUBIC, VGU_PATH_CMD_BUTT } | 路径绘制指令类型。 | +| [VGUTransformType](_display.md#vgutransformtype){ VGU_TRANSFORM_TRANSLATE = (1 << 0), VGU_TRANSFORM_SCALE = (1 << 1), VGU_TRANSFORM_ROTATE_90 = (1 << 2), VGU_TRANSFORM_ROTATE_180 = (1 << 3),   VGU_TRANSFORM_ROTATE_270 = (1 << 4), VGU_TRANSFORM_OTHER = (1 << 16) } | 变换类型。 | +| [VGUClipType](_display.md#vgucliptype){ VGU_CLIP_RECT = 0, VGU_CLIP_PATH, VGU_CLIP_BUTT } | 绘制表面剪切类型。 | +| [VGUGradientType](_display.md#vgugradienttype){ VGU_GRADIENT_LINEAR = 0, VGU_GRADIENT_RADIAL, VGU_GRADIENT_CONIC, VGU_GRADIENT_BUTT } | 渐变类型。 | +| [VGUPaintType](_display.md#vgupainttype){ VGU_PAINT_SOLID = 0, VGU_PAINT_GRADIENT, VGU_PAINT_PATTERN, VGU_PAINT_BUTT } | 渲染对象。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [VGUPathInit](_display.md#vgupathinit)(VGUPath \*path, VGUPathDataType type, const uint8_t \*segments, int numSegments, const uint8_t \*data, bool enAlias, VGURect boundBox) | 初始化路径对象。 | +| [VGUPathAppend](_display.md#vgupathappend)(VGUPath \*path, const VGUPath \*subpath) | 添加子路径到当前路径中。 | +| [VGUPathClear](_display.md#vgupathclear)(VGUPath \*path) | 清除路径对象内存。 | +| [VGUMatrixIdentity](_display.md#vgumatrixidentity)(VGUMatrix3 \*matrix) | 初始化矩阵对象为单位矩阵。 | +| [VGUMatrixScale](_display.md#vgumatrixscale)(VGUMatrix3 \*matrix, float xScale, float yScale) | 矩阵变换缩放。 | +| [VGUMatrixRotate](_display.md#vgumatrixrotate)(VGUMatrix3 \*matrix, float degree) | 矩阵变换旋转。 | +| [VGUMatrixTranslate](_display.md#vgumatrixtranslate)(VGUMatrix3 \*matrix, float x, float y) | 矩阵变换平移。 | +| [VGUGradientColorStop](_display.md#vgugradientcolorstop)(VGUGradient \*gradient, const VGUColorStop \*colorStop, uint32_t count) | 对渐变添加ColorStop。 | +| [VGUGradientClearStop](_display.md#vgugradientclearstop)(VGUGradient \*gradient) | 清除ColorStop。 | +| [VGUGradientMatrix](_display.md#vgugradientmatrix)(VGUGradient \*gradient, const VGUMatrix3 \*matrix) | 设置渐变对象的变换矩阵。 | +| [VGUGradientLinear](_display.md#vgugradientlinear)(VGUGradient \*gradient, const VGUPoint \*p1, const VGUPoint \*p2) | 创建线性渐变对象。 | +| [VGUGradientRadial](_display.md#vgugradientradial)(VGUGradient \*gradient, const VGUPoint \*p1, VGUScalar r1, const VGUPoint \*p2, VGUScalar r2) | 创建辐射渐变对象 | +| [VGUGradientConic](_display.md#vgugradientconic)(VGUGradient \*gradient, VGUScalar cx, VGUScalar cy) | 创建圆锥渐变对象。 | +| [VGUInitialize](_display.md#vguinitialize)(VGUFuncs \*\*funcs) | 获取硬件加速相关的操作接口指针。 | +| [VGUUninitialize](_display.md#vguuninitialize)(VGUFuncs \*funcs) | 去初始化硬件加速模块,同时释放硬件加速模块操作函数指针。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md index 746f21f26106445e5134a3ac3b3878cc4d96098a..f10ada48070e6ba28b3e710c710f13cf97c6608f 100644 --- a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 + +**Since:** + +3.2 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IExecutor](interface_i_executor.md) | 定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 [更多...](interface_i_executor.md) | +| [IExecutor](interface_i_executor.md) | 定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.face_auth.v1_0 | 人脸认证接口的包路径。 | - - -## **详细描述** - -定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md index ae11adf2057ae5a01e3d4c363b60754ac0754783..89c668dc7fcf495eb6d5710d3fcb68b36b87686e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义异步API接口回调,用于返回异步接口的请求处理结果和信息。 + +**Since:** + +3.2 + **所属模块:** [HdfFaceAuth](_hdf_face_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IExecutorCallback](interface_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_i_executor.md)。 [更多...](interface_i_executor_callback.md) | +| [IExecutorCallback](interface_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_i_executor.md)。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.face_auth.v1_0 | 人脸认证接口的包路径 | - - -## **详细描述** - -定义异步API接口回调,用于返回异步接口的请求处理结果和信息。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/files.md b/zh-cn/device-dev/reference/hdi-apis/files.md new file mode 100644 index 0000000000000000000000000000000000000000..c4c4f5171e25975eb0c0e29c0c73ed189c29a62d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/files.md @@ -0,0 +1,145 @@ +# 头文件 + + + +- **[audio_adapter.h](audio__adapter_8h.md)** + +- **[audio_attribute.h](audio__attribute_8h.md)** + +- **[audio_capture.h](audio__capture_8h.md)** + +- **[audio_control.h](audio__control_8h.md)** + +- **[audio_manager.h](audio__manager_8h.md)** + +- **[audio_render.h](audio__render_8h.md)** + +- **[audio_scene.h](audio__scene_8h.md)** + +- **[audio_types.h](audio__types_8h.md)** + +- **[audio_volume.h](audio__volume_8h.md)** + +- **[codec_callback_if.h](codec_callback_if_h.md)** + +- **[codec_common_type.h](codec_common_type_h.md)** + +- **[codec_component_if.h](codec_component_if_h.md)** + +- **[codec_component_manager.h](codec__component__manager_h.md)** + +- **[codec_component_type.h](codec__component__type_h.md)** + +- **[display_device.h](display__device_8h.md)** + +- **[display_gfx.h](display__gfx_8h.md)** + +- **[display_gralloc.h](display__gralloc_8h.md)** + +- **[display_layer.h](display__layer_8h.md)** + +- **[display_type.h](display__type_8h.md)** + +- **[display_vgu.h](display__vgu_8h.md)** + +- **[input_controller.h](input__controller_8h.md)** + +- **[input_manager.h](input__manager_8h.md)** + +- **[input_reporter.h](input__reporter_8h.md)** + +- **[input_type.h](input__type_8h.md)** + +- **[ActivityRecognitionTypes.idl](activity_recognition_types_idl.md)** + +- **[Types.idl](battery_types_idl.md)** + +- **[IExecutor.idl](face__auth_2_i_executor_8idl.md)** + +- **[IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md)** + +- **[FaceAuthTypes.idl](_face_auth_types_8idl.md)** + +- **[PinAuthTypes.idl](_pin_auth_types_8idl.md)** + +- **[IExecutor.idl](pin__auth_2_i_executor_8idl.md)** + +- **[IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md)** + +- **[IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md)** + +- **[IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md)** + +- **[IUserAuthInterface.idl](_i_user_auth_interface_8idl.md)** + +- **[UserAuthTypes.idl](_user_auth_types_8idl.md)** + +- **[IActivityChangedCallback.idl](_i_activity_changed_callback_8idl.md)** + +- **[IActivityInterface.idl](_i_activity_interface_8idl.md)** + +- **[IBatteryCallback.idl](_i_battery_callback_8idl.md)** + +- **[IBatteryInterface.idl](_i_battery_interface_8idl.md)** + +- **[ICameraDevice.idl](_i_camera_device_8idl.md)** + +- **[ICameraDeviceCallback.idl](_i_camera_device_callback_8idl.md)** + +- **[ICameraHostCallback.idl](_i_camera_host_callback_8idl.md)** + +- **[ICameraHost.idl](_i_camera_host_8idl.md)** + +- **[ILightInterface.idl](_i_light_interface_8idl.md)** + +- **[IMotionCallback.idl](_i_motion_callback_8idl.md)** + +- **[IMotionInterface.idl](_i_motion_interface_8idl.md)** + +- **[IOfflineStreamOperator.idl](_i_offline_stream_operator_8idl.md)** + +- **[IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md)** + +- **[IPowerInterface.idl](_i_power_interface_8idl.md)** + +- **[ISensorCallback.idl](_i_sensor_callback_8idl.md)** + +- **[ISensorInterface.idl](_i_sensor_interface_8idl.md)** + +- **[IStreamOperator.idl](_i_stream_operator_8idl.md)** + +- **[IStreamOperatorCallback.idl](_i_stream_operator_callback_8idl.md)** + +- **[IThermalCallback.idl](_i_thermal_callback_8idl.md)** + +- **[IThermalInterface.idl](_i_thermal_interface_8idl.md)** + +- **[IUsbdBulkCallback.idl](_i_usbd_bulk_callback_8idl.md)** + +- **[IUsbInterface.idl](_i_usb_interface_8idl.md)** + +- **[IUsbdSubscriber.idl](_i_usbd_subscriber_8idl.md)** + +- **[IVibratorInterface.idl](_i_vibrator_interface_8idl.md)** + +- **[IWlanCallback.idl](_i_wlan_callback_8idl.md)** + +- **[IWlanInterface.idl](_i_wlan_interface_8idl.md)** + +- **[LightTypes.idl](_light_types_8idl.md)** + +- **[MotionTypes.idl](_motion_types_8idl.md)** + +- **[PowerTypes.idl](_power_types_8idl.md)** + +- **[SensorTypes.idl](_sensor_types_8idl.md)** + +- **[ThermalTypes.idl](_thermal_types_8idl.md)** + +- **[Types.idl](camera_2v1__0_2_types_8idl.md)** + +- **[UsbTypes.idl](_usb_types_8idl.md)** + +- **[VibratorTypes.idl](_vibrator_types_8idl.md)** + +- **[WlanTypes.idl](_wlan_types_8idl.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md deleted file mode 100644 index 91b9f1c93460824bf925388ebdfba6f93a5d0c2e..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# icamera_device.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | Camera设备操作。 | - - -## **详细描述** - -Camera设备操作接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md deleted file mode 100644 index d70ccf005f7eae0f6882672fd0761781959b8276..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# icamera_device_callback.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | Camera设备操作回调。 | - - -## **详细描述** - -Camera设备的回调接口,主要包含camera设备发生错误时和上报metadata的回调函数。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md deleted file mode 100644 index e7991b95aeef1a42960f000d2132442d4542f37c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# icamera_host.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | Camera服务的管理类。 | - - -## **详细描述** - -Camera服务的管理类,对上层提供HDI接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md deleted file mode 100644 index f63aab515a0770f65885e0107c20df7e016c9149..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# icamera_host_callback.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | Camera服务的管理回调。 | - - -## **详细描述** - -ICameraHost的回调接口,提供Camera设备和闪关灯状态变化的回调函数,回调函数由调用者实现。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/input.md b/zh-cn/device-dev/reference/hdi-apis/input.md new file mode 100644 index 0000000000000000000000000000000000000000..4e58d0dde9250ce07d777c7e2192f2f08f27753a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/input.md @@ -0,0 +1,333 @@ +# Input + + +## **概述** + +Input模块驱动接口声明。 + +本模块为Input服务提供相关驱动接口,包括Input设备的打开和关闭、Input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 + +**Since**: + +1.0 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [input_controller.h](input__controller_8h.md) | 描述Input设备业务控制相关的接口声明。 | +| [input_manager.h](input__manager_8h.md) | 描述Input设备管理相关的接口声明。 | +| [input_reporter.h](input__reporter_8h.md) | 描述Input设备数据上报相关的接口声明。 | +| [input_type.h](input__type_8h.md) | Input设备相关的类型定义,定义了Input设备驱动接口所使用的结构体及枚举类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [InputController](_input_controller.md) | 提供Input设备业务控制相关的接口。 | +| [InputManager](_input_manager.md) | 提供Input设备管理相关的接口。 | +| [IInputInterface](_i_input_interface.md) | 定义用于提供Input设备驱动程序功能的接口。 | +| [InputReporter](_input_reporter.md) | 提供Input设备数据上报相关的接口。 | +| [InputEventPackage](_input_event_package.md) | Input事件数据包结构。 | +| [InputHotPlugEvent](_input_hot_plug_event.md) | 热插拔事件数据包结构。 | +| [InputDevDesc](_input_dev_desc.md) | Input设备描述信息。 | +| [InputEventCb](_input_event_cb.md) | 此结构体定义了输入事件回调函数并提供给Input服务使用。 | +| [InputHostCb](_input_host_cb.md) | 此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 | +| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,存储支持事件的位图。 | +| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信息。 | +| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信息。 | +| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 | +| [InputDeviceInfo](_input_device_info.md) | Input设备基础设备信息。 | +| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数据结构。 | + + +### 宏定义 + + | 名称 | 描述 | +| -------- | -------- | +| [MAX_INPUT_DEV_NUM](#max_input_dev_num)   32 | Input设备数量的最大值。 | +| [CHIP_INFO_LEN](#chip_info_len)   10 | 芯片信息长度。 | +| [CHIP_NAME_LEN](#chip_name_len)   10 | 芯片名称长度。 | +| [VENDOR_NAME_LEN](#vendor_name_len)   10 | 厂商名称长度。 | +| [DEV_NAME_LEN](#dev_name_len)   64 | Input设备名称长度。 | +| [SELF_TEST_RESULT_LEN](#self_test_result_len)   20 | 自测结果长度。 | +| [DEV_MANAGER_SERVICE_NAME](#dev_manager_service_name)   "hdf_input_host" | Input设备节点服务名称。 | +| [DIV_ROUND_UP](#div_round_up)(nr, d)   (((nr) + (d) - 1) / (d)) | 向上取整计算公式。 | +| [BYTE_HAS_BITS](#byte_has_bits)   8 | 一个字节所包含的比特数。 | +| [BITS_TO_UINT64](#bits_to_uint64)(count)   [DIV_ROUND_UP](#div_round_up)(count, [BYTE_HAS_BITS](#byte_has_bits) \* sizeof(uint64_t)) | 比特与64位无符号整数的转换公式。 | +| [HDF_FF_CNT](#hdf_ff_cnt)   (0x7f + 1) | Input设备发送力反馈命令的数量最大值。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [RetStatus](#retstatus) {   INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3,   INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 | +| [InputDevType](#inputdevtype) {   INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE,   INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 | +| [PowerStatus](#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN } | 定义电源状态。 | +| [CapacitanceTest](#capacitancetest) {   BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST,   TEST_TYPE_UNKNOWN } | 定义容值测试类型。 | + + +### 函数 + + | 名称 | 描述 | +| -------- | -------- | +| [GetInputInterface](#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | Input服务通过调用此接口获取操作Input设备的所有接口。 | + + +## **宏定义说明** + + +### BITS_TO_UINT64 + + +``` +#define BITS_TO_UINT64( count) DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(uint64_t)) +``` + +**描述:** + +比特与64位无符号整数的转换公式 + + +### BYTE_HAS_BITS + + +``` +#define BYTE_HAS_BITS 8 +``` + +**描述:** + +一个字节所包含的比特数 + + +### CHIP_INFO_LEN + + +``` +#define CHIP_INFO_LEN 10 +``` + +**描述:** + +芯片信息长度 + + +### CHIP_NAME_LEN + + +``` +#define CHIP_NAME_LEN 10 +``` + +**描述:** + +芯片名称长度 + + +### DEV_MANAGER_SERVICE_NAME + + +``` +#define DEV_MANAGER_SERVICE_NAME "hdf_input_host" +``` + +**描述:** + +Input设备节点服务名称 + + +### DEV_NAME_LEN + + +``` +#define DEV_NAME_LEN 64 +``` + +**描述:** + +Input设备名称长度 + + +### DIV_ROUND_UP + + +``` +#define DIV_ROUND_UP( nr, d ) (((nr) + (d) - 1) / (d)) +``` + +**描述:** + +向上取整计算公式 + + +### HDF_FF_CNT + + +``` +#define HDF_FF_CNT (0x7f + 1) +``` + +**描述:** + +Input设备发送力反馈命令的数量最大值 + + +### MAX_INPUT_DEV_NUM + + +``` +#define MAX_INPUT_DEV_NUM 32 +``` + +**描述:** + +Input设备数量的最大值 + + +### SELF_TEST_RESULT_LEN + + +``` +#define SELF_TEST_RESULT_LEN 20 +``` + +**描述:** + +自测试结果长度 + + +### VENDOR_NAME_LEN + + +``` +#define VENDOR_NAME_LEN 10 +``` + +**描述:** + +厂商名称长度 + + +## **枚举类型说明** + + +### CapacitanceTest + + +``` +enum CapacitanceTest +``` + +**描述:** + +定义容值测试类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| BASE_TEST | 基础容值测试 | +| FULL_TEST | 全量容值自检测试 | +| MMI_TEST | MMI容值测试 | +| RUNNING_TEST | 老化容值测试 | +| TEST_TYPE_UNKNOWN | 未知的测试类型 | + + +### InputDevType + + +``` +enum InputDevType +``` + +**描述:** + +定义Input设备类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| INDEV_TYPE_TOUCH | 触摸屏 | +| INDEV_TYPE_KEY | 物理按键 | +| INDEV_TYPE_KEYBOARD | 键盘 | +| INDEV_TYPE_MOUSE | 鼠标 | +| INDEV_TYPE_BUTTON | 虚拟按键 | +| INDEV_TYPE_CROWN | 表冠 | +| INDEV_TYPE_ENCODER | 自定义编码的特定功能或者事件 | +| INDEV_TYPE_UNKNOWN | 未知输入设备类型 | + + +### PowerStatus + + +``` +enum PowerStatus +``` + +**描述:** + +定义电源状态。 + + | 枚举值 | 描述 | +| -------- | -------- | +| INPUT_RESUME | 正常唤醒 | +| INPUT_SUSPEND | 休眠下电模式 | +| INPUT_LOW_POWER | 休眠低功耗模式 | +| INPUT_POWER_STATUS_UNKNOWN | 未知电源状态 | + + +### RetStatus + + +``` +enum RetStatus +``` + +**描述:** + +定义返回值类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| INPUT_SUCCESS | 成功 | +| INPUT_FAILURE | 失败 | +| INPUT_INVALID_PARAM | 无效参数 | +| INPUT_NOMEM | 内存不足 | +| INPUT_NULL_PTR | 空指针 | +| INPUT_TIMEOUT | 执行超时 | +| INPUT_UNSUPPORTED | 特性不支持 | + + +## **函数说明** + + +### GetInputInterface() + + +``` +int32_t GetInputInterface (IInputInterface ** interface) +``` + +**描述:** + +Input服务通过调用此接口获取操作Input设备的所有接口。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| interface | 对Input设备进行接口操作的指针,通常在Input服务启动后,通过调用此函数获取Input设备操作接口。 | + +**返回:** + +INPUT_SUCCESS 表示执行成功。 + +其他值表示执行失败,具体错误码查看[RetStatus](#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md index f89f9a17d20e7b32832471a655cb880bdab0abbd..0036ad9e3661c7213b8f1c7906b0f330453b098a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Input](_input.md) - +描述Input设备业务控制相关的接口声明。 -## **汇总** +**Since**: +1.0 -### 类 +**Version**: - | 类 | 描述 | -| -------- | -------- | -| [InputController](_input_controller.md) | 提供Input设备业务控制相关的接口。 [更多...](_input_controller.md) | +1.0 +**相关模块:** -## **详细描述** +[Input](input.md) -描述Input设备业务控制相关的接口声明。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [InputController](_input_controller.md) | 提供Input设备业务控制相关的接口。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md index 245d9225041d3f59c2e7e344294361e0a36e066b..a93402294a89293abbfed1fc7bc5b74a7844b96a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md @@ -3,38 +3,34 @@ ## **概述** -**所属模块:** - -[Input](_input.md) +描述Input设备管理相关的接口声明。 +**Since**: -## **汇总** +1.0 +**Version**: -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [InputManager](_input_manager.md) | 提供Input设备管理相关的接口。 [更多...](_input_manager.md) | -| [IInputInterface](_i_input_interface.md) | 定义用于提供输入设备驱动能力的接口。[更多...](_i_input_interface.md) | +1.0 +**相关模块:** -### 函数 +[Input](input.md) - | 函数 | 描述 | -| -------- | -------- | -| [GetInputInterface](_input.md#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | Input服务通过调用此接口获取操作Input设备的所有接口。 [更多...](_input.md#getinputinterface) | -| [ReleaseInputInterface](_input.md#releaseinputinterface) ([IInputInterface](_i_input_interface.md) \*\*inputInterface) | Input服务通过调用此接口释放操作Input设备的所有接口。 [更多...](_input.md#releaseinputinterface) | +## **汇总** -## **详细描述** -描述Input设备管理相关的接口声明。 +### 类 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [InputManager](_input_manager.md) | 提供Input设备管理相关的接口。 | +| [IInputInterface](_i_input_interface.md) | 定义用于提供Input设备驱动程序功能的接口。 | -1.0 -**Version:** +### 函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [GetInputInterface](input.md#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | Input服务通过调用此接口获取操作Input设备的所有接口。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md index f537d55f387293772c63fc1446483d6629dc4166..acd441d4b5cea53936c99582849805da425ccfb8 100644 --- a/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md @@ -3,29 +3,26 @@ ## **概述** -**所属模块:** - -[Input](_input.md) - +描述Input设备数据上报相关的接口声明。 -## **汇总** +**Since**: +1.0 -### 类 +**Version**: - | 类 | 描述 | -| -------- | -------- | -| [InputReporter](_input_reporter.md) | 提供Input设备数据上报相关的接口。 [更多...](_input_reporter.md) | +1.0 +**相关模块:** -## **详细描述** +[Input](input.md) -描述Input设备数据上报相关的接口声明。 -**Since:** +## **汇总** -1.0 -**Version:** +### 类 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [InputReporter](_input_reporter.md) | 提供Input设备数据上报相关的接口。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md index 73d10e58c09a8c28292362c505269a7ec79f1371..44430e50ce053966b1da33e26c65a5ed9147260e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md +++ b/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md @@ -3,66 +3,65 @@ ## **概述** -**所属模块:** +Input设备相关的类型定义。 -[Input](_input.md) +定义了Input设备驱动接口所使用的结构体及枚举类型。 +**Since**: -## **汇总** +1.0 +**Version**: -### 类 +1.0 - | 类 | 描述 | -| -------- | -------- | -| [InputEventPackage](_event_package.md) | Input事件数据包结构。 [更多...](_event_package.md) | -| [InputHotPlugEvent](_input_hotplug_event.md) | 热插拔事件数据包结构。 [更多...](_input_hotplug_event.md) | -| [InputDevDesc](_input_dev_desc.md) | Input设备描述信息。 [更多...](_input_dev_desc.md) | -| [InputEventCb](_input_report_event_cb.md) | 此结构体定义了输入事件回调函数并提供给Input服务使用。 [更多...](_input_report_event_cb.md) | -| [InputHostCb](_input_host_cb.md) | 此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 [更多...](_input_host_cb.md) | -| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,存储支持事件的位图。 [更多...](_input_dev_ability.md) | -| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信息。 [更多...](_input_dimension_info.md) | -| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信息。 [更多...](_input_dev_identify.md) | -| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 [更多...](_input_dev_attr.md) | -| [InputDeviceInfo](_device_info.md) | Input设备基础设备信息。 [更多...](_device_info.md) | -| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数据结构。 [更多...](_input_extra_cmd.md) | +**相关模块:** +[Input](input.md) -### 宏定义 - | 宏定义 | 描述 | -| -------- | -------- | -| **MAX_INPUT_DEV_NUM**   32 | Input设备最大数量。 | -| **DEV_NAME_LEN**   64 | Input设备名称长度。 | -| **CHIP_INFO_LEN**   10 | 芯片信息长度。 | -| **CHIP_NAME_LEN**   10 | 芯片名称长度。 | -| **VENDOR_NAME_LEN**   10 | 厂商名称长度。 | -| **SELF_TEST_RESULT_LEN**   20 | 自测结果长度。 | -| **DEV_MANAGER_SERVICE_NAME**   "hdf_input_host" | Input设备节点服务名称。 | -| **DIV_ROUND_UP(nr, d)**  (((nr) + (d) - 1) / (d)) | 向上取整计算公式。| -| **BYTE_HAS_BITS**  8 | 一个字节所包含的比特数。 | -| **BITS_TO_UINT64(count)**  DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(uint64_t)) | 比特与64位无符号整数的转换公式。 | -| **HDF_FF_CNT**  (0x7f + 1) | Input设备发送力反馈命令的数量最大值。| +## **汇总** -### 枚举 +### 类 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [RetStatus](_input.md#retstatus) { INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3,   INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 [更多...](_input.md#retstatus) | -| [InputDevType](_input.md#inputdevtype) { INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE,   INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 [更多...](_input.md#inputdevtype) | -| [PowerStatus](_input.md#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN } | 定义电源状态。 [更多...](_input.md#powerstatus) | -| [CapacitanceTest](_input.md#capacitancetest) { BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST,   TEST_TYPE_UNKNOWN } | 定义容值测试类型。 [更多...](_input.md#capacitancetest) | - +| [InputEventPackage](_input_event_package.md) | Input事件数据包结构。 | +| [InputHotPlugEvent](_input_hot_plug_event.md) | 热插拔事件数据包结构。 | +| [InputDevDesc](_input_dev_desc.md) | Input设备描述信息。 | +| [InputEventCb](_input_event_cb.md) | 此结构体定义了输入事件回调函数并提供给Input服务使用。 | +| [InputHostCb](_input_host_cb.md) | 此结构体定义了热插拔事件上报回调函数并提供给Input服务使用。 | +| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,存储支持事件的位图。 | +| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信息。 | +| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信息。 | +| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 | +| [InputDeviceInfo](_input_device_info.md) | Input设备基础设备信息。 | +| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数据结构。 | -## **详细描述** -Input设备相关的类型定义,定义了Input设备驱动接口所使用的结构体及枚举类型。 +### 宏定义 -**Since:** + | 名称 | 描述 | +| -------- | -------- | +| [MAX_INPUT_DEV_NUM](input.md#max_input_dev_num)   32 | Input设备数量的最大值。 | +| [CHIP_INFO_LEN](input.md#chip_info_len)   10 | 芯片信息长度。 | +| [CHIP_NAME_LEN](input.md#chip_name_len)   10 | 芯片名称长度。 | +| [VENDOR_NAME_LEN](input.md#vendor_name_len)   10 | 厂商名称长度。 | +| [DEV_NAME_LEN](input.md#dev_name_len)   64 | Input设备名称长度。 | +| [SELF_TEST_RESULT_LEN](input.md#self_test_result_len)   20 | 自测结果长度。 | +| [DEV_MANAGER_SERVICE_NAME](input.md#dev_manager_service_name)   "hdf_input_host" | Input设备节点服务名称。 | +| [DIV_ROUND_UP](input.md#div_round_up)(nr, d)   (((nr) + (d) - 1) / (d)) | 向上取整计算公式。 | +| [BYTE_HAS_BITS](input.md#byte_has_bits)   8 | 一个字节所包含的比特数。 | +| [BITS_TO_UINT64](input.md#bits_to_uint64)(count)   [DIV_ROUND_UP](input.md#div_round_up)(count, [BYTE_HAS_BITS](input.md#byte_has_bits) \* sizeof(uint64_t)) | 比特与64位无符号整数的转换公式。 | +| [HDF_FF_CNT](input.md#hdf_ff_cnt)   (0x7f + 1) | Input设备发送力反馈命令的数量最大值。 | -1.0 -**Version:** +### 枚举 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [RetStatus](input.md#retstatus) { INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3,   INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 | +| [InputDevType](input.md#inputdevtype) { INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE,   INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 | +| [PowerStatus](input.md#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN  } | 定义电源状态。 | +| [CapacitanceTest](input.md#capacitancetest) { BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST,   TEST_TYPE_UNKNOWN } | 定义容值测试类型。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_changed_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_changed_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..46600f68482f434d220249120b97408550662fae --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_changed_callback.md @@ -0,0 +1,51 @@ +# IActivityChangedCallback + + +## **概述** + +定义上报行为事件的回调函数 + +用户在获得订阅的行为事件或获取设备缓存的行为事件前,需要先注册该回调函数。只有当订阅的行为发生时,行为数据才会通过回调函数进行上报。 详情可参考[IActivityInterface](interface_i_activity_interface.md)。 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnActivityChanged](#onactivitychanged) ([in] struct [ActRecognitionEvent](_act_recognition_event.md)[] event) | 定义上报行为事件的回调函数。 | + + +## **成员函数说明** + + +### OnActivityChanged() + + +``` +IActivityChangedCallback::OnActivityChanged ([in] struct ActRecognitionEvent[] event) +``` + +**描述:** + +定义上报行为事件的回调函数。 + +数据会通过该回调函数进行上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 上报的数据。详见[ActRecognitionEvent](_act_recognition_event.md)定义。 | + +**返回:** + +如果回调函数上报数据成功,则返回0。 + +如果回调函数上报数据成功,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..8893cf8972fa3e4911632190735b53bf0874cd2d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_activity_interface.md @@ -0,0 +1,209 @@ +# IActivityInterface + + +## **概述** + +定义对行为识别进行基本操作的接口。 + +接口包含注册回调函数,取消注册回调函数,获取设备支持的行为类型,获取当前设备的行为类型,订阅和取消订阅行为事件,获取设备缓存的行为事件。 + +**相关模块:** + +[HdiActivityRecognition](activity_recognition.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [RegisterActRecognitionCallback](#registeractrecognitioncallback) ([in] [IActivityChangedCallback](interface_i_activity_changed_callback.md) callbackObj) | 注册回调函数。 | +| [UnregisterActRecognitionCallback](#unregisteractrecognitioncallback) ([in] [IActivityChangedCallback](interface_i_activity_changed_callback.md) callbackObj) | 取消注册回调函数。 | +| [GetSupportActivity](#getsupportactivity) ([out] String[] activity) | 获取设备支持的行为类型。 | +| [GetCurrentActivity](#getcurrentactivity) ([out] struct [ActRecognitionEvent](_act_recognition_event.md)[] event) | 获取当前的行为事件。 | +| [EnableActRecognitionEvent](#enableactrecognitionevent) ([in] int activity, [in] int eventType, [in] long maxReportLatencyNs, [in] int powerMode) | 订阅某个行为事件。 | +| [DisableActRecognitionEvent](#disableactrecognitionevent) ([in] int activity, [in] int eventType) | 取消订阅某个行为事件。 | +| [FlushActivity](#flushactivity) () | 数据刷新。 | + + +## **成员函数说明** + + +### DisableActRecognitionEvent() + + +``` +IActivityInterface::DisableActRecognitionEvent ([in] int activity, [in] int eventType ) +``` + +**描述:** + +取消订阅某个行为事件。 + +取消订阅某个之前订阅过的行为事件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| activity | 取消订阅的行为,参考[EnableActRecognitionEvent](#enableactrecognitionevent)接口的activity参数。 | +| eventType | 事件类型,参考[ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype)定义。可以填充1(进入)或2(退出),也可以填充3(同时订阅进入和退出)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### EnableActRecognitionEvent() + + +``` +IActivityInterface::EnableActRecognitionEvent ([in] int activity, [in] int eventType, [in] long maxReportLatencyNs, [in] int powerMode ) +``` + +**描述:** + +订阅某个行为事件。 + +订阅某个行为事件后,若该行为事件有发生,则会在一定时间内上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| activity | 订阅的行为,通过[GetSupportActivity](#getsupportactivity)得到设备支持的所有行为,然后将行为列表中需要订阅的行为下标作为参数填充。 | +| eventType | 事件类型,参考[ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype)定义。可以填充1(进入)或2(退出),也可以填充3(同时订阅进入和退出)。 | +| maxReportLatencyNs | 最大上报时间间隔,单位是纳秒。若该时间间隔内有订阅的行为事件发生,则会上报。若存在多个订阅的行为,取最小的时间间隔。 | +| powerMode | 功耗模式。参考[ActRecognitionPowerMode](activity_recognition.md#actrecognitionpowermode)定义。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### FlushActivity() + + +``` +IActivityInterface::FlushActivity () +``` + +**描述:** + +数据刷新。 + +刷新设备缓存的所有行为事件并上报。 + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetCurrentActivity() + + +``` +IActivityInterface::GetCurrentActivity ([out] struct ActRecognitionEvent[] event) +``` + +**描述:** + +获取当前的行为事件。 + +在调用该接口前,必须先要调用[EnableActRecognitionEvent](#enableactrecognitionevent)接口对行为进行使能。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 返回当前设备的行为事件,可能有多个行为共存,详见[ActRecognitionEvent](_act_recognition_event.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetSupportActivity() + + +``` +IActivityInterface::GetSupportActivity ([out] String[] activity) +``` + +**描述:** + +获取设备支持的行为类型。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| activity | 参数类型为字符串,输出设备支持的行为类型。 包括:"inVehicle" 、"onBicycle"、"walking"、"running"、"still"、"fast_walking"、"high_speed_rail" "unknown"、"elevator"、"relative_still"、"walking_handhold"、"lying_posture"、"plane"、"metro"等。对应[ActRecognitionEventType](activity_recognition.md#actrecognitioneventtype)中的类型。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### RegisterActRecognitionCallback() + + +``` +IActivityInterface::RegisterActRecognitionCallback ([in] IActivityChangedCallback callbackObj) +``` + +**描述:** + +注册回调函数。 + +用户在获得订阅的行为事件或获取设备缓存的行为事件前,需要先注册该回调函数。数据会通过回调函数进行上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 要注册的回调函数,只需成功订阅一次,无需重复订阅。详见[IActivityChangedCallback](interface_i_activity_changed_callback.md)。 | + +**返回:** + +如果注册回调函数成功,则返回0。 + +如果注册回调函数失败,则返回负值。 + + +### UnregisterActRecognitionCallback() + + +``` +IActivityInterface::UnregisterActRecognitionCallback ([in] IActivityChangedCallback callbackObj) +``` + +**描述:** + +取消注册回调函数。 + +取消之前注册的回调函数。当不需要使用行为识别功能,或需要更换回调函数时,需要取消注册回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 要取消注册的回调函数,只需成功取消订阅一次,无需重复取消订阅。详见[IActivityChangedCallback](interface_i_activity_changed_callback.md)。 | + +**返回:** + +如果取消注册回调函数成功,则返回0。 + +如果取消注册回调函数失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md index cafdf21cd8e3a4d1eccbe3d8fa82ddb1256470a1..5a744f65c56a8a585963b582dcb42141ea9408c3 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md @@ -3,30 +3,27 @@ ## **概述** -**所属模块:** - -[Battery](battery.md) - +电池信息的回调。 -## **汇总** +服务创建此回调对象后,可以调用[IBatteryInterface](interface_i_battery_interface.md)的接口注册回调,从而订阅电池信息的变化。 +**Since:** -### Public 成员函数 +3.1 - | Public 成员函数 | 描述 | -| -------- | -------- | -| [Update](#update) ([in] struct [BatteryInfo](_battery_info.md) event) | 电池信息的回调方法。 [更多...](#update) | +**相关模块:** +[Battery](battery.md) -## **详细描述** -电池信息的回调。 +## **汇总** -服务创建此回调对象后,可以调用IBatteryInterface的接口注册回调,从而订阅电池信息的变化。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [Update](#update) ([in] struct [BatteryInfo](_battery_info.md) event) | 电池信息的回调方法。 | ## **成员函数说明** @@ -45,12 +42,12 @@ IBatteryCallback::Update ([in] struct BatteryInfo event) 当电池信息发生变化时,将通过此方法的参数返回给服务。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | event | 电池信息,如电量,电压,健康状态等。 | -**参见:** +**参见:** [BatteryInfo](_battery_info.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md index d82964f347df262b4764b633f78815fb8257cf52..89ef2cb9d5b9aadcae91f5f9729f95c98a026430 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md @@ -3,45 +3,42 @@ ## **概述** -**所属模块:** +获取、订阅电池信息的接口。 -[Battery](battery.md) +服务获取此对象后,可以调用相关的接口获取、订阅电池信息。 +**Since:** -## **汇总** +3.1 +**相关模块:** -### Public 成员函数 +[Battery](battery.md) - | Public 成员函数 | 描述 | -| -------- | -------- | -| [Register](#register) ([in] [IBatteryCallback](interface_i_battery_callback.md) event) | 注册电池信息的回调。 [更多...](#register) | -| [UnRegister](#unregister) () | 取消注册电池信息的回调。 [更多...](#unregister) | -| [ChangePath](#changepath) ([in] String path) | 设置电池信息节点的路径。 [更多...](#changepath) | -| [GetCapacity](#getcapacity) ([out] int capacity) | 获取电池的电量百分比。 [更多...](#getcapacity) | -| [GetVoltage](#getvoltage) ([out] int voltage) | 获取电池的电压,单位微伏。 [更多...](#getvoltage) | -| [GetTemperature](#gettemperature) ([out] int temperature) | 获取电池的充电温度,单位0.1摄氏度。 [更多...](#gettemperature) | -| [GetHealthState](#gethealthstate) ([out] enum [BatteryHealthState](battery.md#batteryhealthstate) healthState) | 获取电池的健康状态。 [更多...](#gethealthstate) | -| [GetPluggedType](#getpluggedtype) ([out] enum [BatteryPluggedType](battery.md#batterypluggedtype) pluggedType) | 获取充电设备类型。 [更多...](#getpluggedtype) | -| [GetChargeState](#getchargestate) ([out] enum [BatteryChargeState](battery.md#batterychargestate) chargeState) | 获取充电状态。 [更多...](#getchargestate) | -| [GetPresent](#getpresent) ([out] boolean present) | 获取是否支持电池或者电池是否在位。 [更多...](#getpresent) | -| [GetTechnology](#gettechnology) ([out] String technology) | 获取电池的技术型号。 [更多...](#gettechnology) | -| [GetTotalEnergy](#gettotalenergy) ([out] int totalEnergy) | 获取电池的总容量。 [更多...](#gettotalenergy) | -| [GetCurrentAverage](#getcurrentaverage) ([out] int curAverage) | 获取电池的平均电流。 [更多...](#getcurrentaverage) | -| [GetCurrentNow](#getcurrentnow) ([out] int curNow) | 获取电池的电流。 [更多...](#getcurrentnow) | -| [GetRemainEnergy](#getremainenergy) ([out] int remainEnergy) | 获取电池的剩余容量。 [更多...](#getremainenergy) | -| [GetBatteryInfo](#getbatteryinfo) ([out] struct [BatteryInfo](_battery_info.md) info) | 获取电池的全部信息。 [更多...](#getbatteryinfo) | - - -## **详细描述** -获取、订阅电池信息的接口。 +## **汇总** -服务获取此对象后,可以调用相关的接口获取、订阅电池信息。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [Register](#register) ([in] [IBatteryCallback](interface_i_battery_callback.md) event) | 注册电池信息的回调。 | +| [UnRegister](#unregister) () | 取消注册电池信息的回调。 | +| [ChangePath](#changepath) ([in] String path) | 设置电池信息节点的路径。 | +| [GetCapacity](#getcapacity) ([out] int capacity) | 获取电池的电量百分比。 | +| [GetVoltage](#getvoltage) ([out] int voltage) | 获取电池的电压,单位微伏。 | +| [GetTemperature](#gettemperature) ([out] int temperature) | 获取电池的充电温度,单位0.1摄氏度。 | +| [GetHealthState](#gethealthstate) ([out] enum [BatteryHealthState](battery.md#batteryhealthstate) healthState) | 获取电池的健康状态。 | +| [GetPluggedType](#getpluggedtype) ([out] enum [BatteryPluggedType](battery.md#batterypluggedtype) pluggedType) | 获取充电设备类型。 | +| [GetChargeState](#getchargestate) ([out] enum [BatteryChargeState](battery.md#batterychargestate) chargeState) | 获取充电状态。 | +| [GetPresent](#getpresent) ([out] boolean present) | 获取是否支持电池或者电池是否在位。 | +| [GetTechnology](#gettechnology) ([out] String technology) | 获取电池的技术型号。 | +| [GetTotalEnergy](#gettotalenergy) ([out] int totalEnergy) | 获取电池的总容量。 | +| [GetCurrentAverage](#getcurrentaverage) ([out] int curAverage) | 获取电池的平均电流。 | +| [GetCurrentNow](#getcurrentnow) ([out] int curNow) | 获取电池的电流。 | +| [GetRemainEnergy](#getremainenergy) ([out] int remainEnergy) | 获取电池的剩余容量。 | +| [GetBatteryInfo](#getbatteryinfo) ([out] struct [BatteryInfo](_battery_info.md) info) | 获取电池的全部信息。 | ## **成员函数说明** @@ -58,13 +55,13 @@ IBatteryInterface::ChangePath ([in] String path) 设置电池信息节点的路径。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | path | 输入参数,电池信息节点的路径。 | -**返回:** +**返回:** HDF_SUCCESS 表示路径设置成功。 @@ -80,17 +77,17 @@ IBatteryInterface::GetBatteryInfo ([out] struct BatteryInfo info) 获取电池的全部信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| info | 输出参数,电池的全部信息。 | +| info | 电池的全部信息。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 -**参见:** +**参见:** [BatteryInfo](_battery_info.md) @@ -106,13 +103,13 @@ IBatteryInterface::GetCapacity ([out] int capacity) 获取电池的电量百分比。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| capacity | 输出参数,表示电量的百分比值。 | +| capacity | 表示电量的百分比值。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -128,17 +125,17 @@ IBatteryInterface::GetChargeState ([out] enum BatteryChargeState chargeState) 获取充电状态。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| chargeState | 输出参数,表示充电状态。 | +| chargeState | 表示充电状态。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 -**参见:** +**参见:** [BatteryChargeState](battery.md#batterychargestate) @@ -154,13 +151,13 @@ IBatteryInterface::GetCurrentAverage ([out] int curAverage) 获取电池的平均电流。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| totalEnergy | 输出参数,表示电池的平均电流,单位毫安。 | +| totalEnergy | 表示电池的平均电流,单位毫安。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -176,13 +173,13 @@ IBatteryInterface::GetCurrentNow ([out] int curNow) 获取电池的电流。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| curNow | 输出参数,表示电池的实时电流,单位毫安。 | +| curNow | 表示电池的实时电流,单位毫安。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -198,17 +195,17 @@ IBatteryInterface::GetHealthState ([out] enum BatteryHealthState healthState) 获取电池的健康状态。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| healthState | 输出参数,表示电池健康状态。 | +| healthState | 表示电池健康状态。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 -**参见:** +**参见:** [BatteryHealthState](battery.md#batteryhealthstate) @@ -224,17 +221,17 @@ IBatteryInterface::GetPluggedType ([out] enum BatteryPluggedType pluggedType) 获取充电设备类型。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| pluggedType | 输出参数,表示充电设备类型。 | +| pluggedType | 表示充电设备类型。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 -**参见:** +**参见:** [BatteryPluggedType](battery.md#batterypluggedtype) @@ -250,13 +247,13 @@ IBatteryInterface::GetPresent ([out] boolean present) 获取是否支持电池或者电池是否在位。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| present | 输出参数,表示是否支持电池或者电池是否在位。true表示支持或在位,false表示不支持或不在位。 | +| present | 表示是否支持电池或者电池是否在位。true表示支持或在位,false表示不支持或不在位。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -272,13 +269,13 @@ IBatteryInterface::GetRemainEnergy ([out] int remainEnergy) 获取电池的剩余容量。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| remainEnergy | 输出参数,表示电池的剩余容量,单位毫安时。 | +| remainEnergy | 表示电池的剩余容量,单位毫安时。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -294,13 +291,13 @@ IBatteryInterface::GetTechnology ([out] String technology) 获取电池的技术型号。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| technology | 输出参数,当前电池技术型号。 | +| technology | 当前电池技术型号。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -316,13 +313,13 @@ IBatteryInterface::GetTemperature ([out] int temperature) 获取电池的充电温度,单位0.1摄氏度。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| temperature | 输出参数,表示电池温度。 | +| temperature | 表示电池温度。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -338,13 +335,13 @@ IBatteryInterface::GetTotalEnergy ([out] int totalEnergy) 获取电池的总容量。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| totalEnergy | 输出参数,表示电池的总容量,单位毫安时。 | +| totalEnergy | 表示电池的总容量,单位毫安时。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -360,13 +357,13 @@ IBatteryInterface::GetVoltage ([out] int voltage) 获取电池的电压,单位微伏。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| voltage | 输出参数,表示电池的电压。 | +| voltage | 表示电池的电压。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 @@ -382,13 +379,13 @@ IBatteryInterface::Register ([in] IBatteryCallback event) 注册电池信息的回调。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| event | 输入参数,服务注册的回调。 | +| event | 服务注册的回调。 | -**返回:** +**返回:** HDF_SUCCESS 表示注册成功。 @@ -404,6 +401,6 @@ IBatteryInterface::UnRegister () 取消注册电池信息的回调。 -**返回:** +**返回:** HDF_SUCCESS 表示取消注册成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device.md new file mode 100644 index 0000000000000000000000000000000000000000..dfdbd5798cfab2244627da14132333bc0f9385de --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device.md @@ -0,0 +1,206 @@ +# ICameraDevice + + +## **概述** + +定义Camera设备基本的操作。 + +设置流回调接口、更新控制参数、执行metadata相关操作。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [GetStreamOperator](#getstreamoperator) ([in] [IStreamOperatorCallback](interface_i_stream_operator_callback.md) callbackObj, [out] [IStreamOperator](interface_i_stream_operator.md) streamOperator) | 获取流操作句柄。 | +| [UpdateSettings](#updatesettings) ([in] unsigned char[] settings) | 更新设备控制参数。 | +| [SetResultMode](#setresultmode) ([in] enum [ResultCallbackMode](camera.md#resultcallbackmode) mode) | 设置metadata上报模式,逐帧上报还是设备状态变化时上报。 | +| [GetEnabledResults](#getenabledresults) ([out] int[] results) | 查询使能的metadata。 | +| [EnableResult](#enableresult) ([in] int[] results) | 打开metadata上报开关。 | +| [DisableResult](#disableresult) ([in] int[] results) | 关闭metadata上报开关。 | +| [Close](#close) () | 关闭当前Camera设备。 | + + +## **成员函数说明** + + +### Close() + + +``` +ICameraDevice::Close () +``` + +**描述:** + +关闭当前Camera设备。 + +**参见:** + +OpenCamera + + +### DisableResult() + + +``` +ICameraDevice::DisableResult ([in] int[] results) +``` + +**描述:** + +关闭metadata上报开关。 + +屏蔽之后,相应的**OnResult**不再上报,需[EnableResult](#enableresult)使能之后才上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| results | 需要关闭上报开关的metadata。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[EnableResult](#enableresult) + + +### EnableResult() + + +``` +ICameraDevice::EnableResult ([in] int[] results) +``` + +**描述:** + +打开metadata上报开关。 + +**OnResult**只上报此接口使能后的metadata。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| results | 需要打开上报开关的多个metadata。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[DisableResult](#disableresult) + + +### GetEnabledResults() + + +``` +ICameraDevice::GetEnabledResults ([out] int[] results) +``` + +**描述:** + +查询使能的metadata。 + +[EnableResult](#enableresult)使能需要上报的metadata之后,可通过此接口查询使能的metadata。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| results | 所有使能的metadata的ID数组。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### GetStreamOperator() + + +``` +ICameraDevice::GetStreamOperator ([in] IStreamOperatorCallback callbackObj, [out] IStreamOperator streamOperator ) +``` + +**描述:** + +获取流操作句柄。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 设置流回调接口,详细可查看[IStreamOperatorCallback](interface_i_stream_operator_callback.md), 用于上报捕获开始[OnCaptureStarted](interface_i_stream_operator_callback.md#oncapturestarted),捕获结束[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended), 捕获错误等信息[OnCaptureError](interface_i_stream_operator_callback.md#oncaptureerror)。 | +| streamOperator | 返回流操作句柄。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### SetResultMode() + + +``` +ICameraDevice::SetResultMode ([in] enum ResultCallbackMode mode) +``` + +**描述:** + +设置metadata上报模式,逐帧上报还是设备状态变化时上报。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| mode | metadata的上报模式,逐帧上报或者设备状态变化时上报,查看[ResultCallbackMode](camera.md#resultcallbackmode)。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### UpdateSettings() + + +``` +ICameraDevice::UpdateSettings ([in] unsigned char[] settings) +``` + +**描述:** + +更新设备控制参数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| settings | Camera设置参数,包括sensor帧率,3A相关参数等。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..c8b090ed64b09494756add9d2d8d374d9d61a407 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_device_callback.md @@ -0,0 +1,64 @@ +# ICameraDeviceCallback + + +## **概述** + +定义Camera设备回调操作。 + +设置回调接口、返回错误信息和相关的metadata的回调。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnError](#onerror) ([in] enum [ErrorType](camera.md#errortype) type, [in] int errorCode) | 设备发生错误时调用,由调用者实现,用于返回错误信息给调用者。 | +| [OnResult](#onresult) ([in] unsigned long timestamp, [in] unsigned char[] result) | 上报Camera设备相关的metadata的回调,上报方式查看[SetResultMode](interface_i_camera_device.md#setresultmode)。 | + + +## **成员函数说明** + + +### OnError() + + +``` +ICameraDeviceCallback::OnError ([in] enum ErrorType type, [in] int errorCode ) +``` + +**描述:** + +设备发生错误时调用,由调用者实现,用于返回错误信息给调用者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| type | 错误类型,具体可参考[ErrorType](camera.md#errortype)。 | +| errorCode | 错误码,当前暂未使用。 | + + +### OnResult() + + +``` +ICameraDeviceCallback::OnResult ([in] unsigned long timestamp, [in] unsigned char[] result ) +``` + +**描述:** + +上报Camera设备相关的metadata的回调,上报方式查看[SetResultMode](interface_i_camera_device.md#setresultmode)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| timestamp | metadata上报的时间戳。 | +| result | 上报的metadata,由[EnableResult](interface_i_camera_device.md#enableresult)指定, 可通过[GetEnabledResults](interface_i_camera_device.md#getenabledresults)查询,[DisableResult](interface_i_camera_device.md#disableresult)关闭上报开关。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host.md new file mode 100644 index 0000000000000000000000000000000000000000..b0b98e04d60e673f47de01a23ca248f26181de4e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host.md @@ -0,0 +1,173 @@ +# ICameraHost + + +## **概述** + +定义Camera设备功能操作。 + +设置回调接口、返回设备ID列表、打开并执行Camera设备的相关操作。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [SetCallback](#setcallback) ([in] [ICameraHostCallback](interface_i_camera_host_callback.md) callbackObj) | 设置ICameraHost回调接口,回调函数参考[ICameraHostCallback](interface_i_camera_host_callback.md)。 | +| [GetCameraIds](#getcameraids) ([out] String[] cameraIds) | 获取当前可用的Camera设备ID列表。 | +| [GetCameraAbility](#getcameraability) ([in] String cameraId, [out] unsigned char[] cameraAbility) | 获取Camera设备能力集合。 | +| [OpenCamera](#opencamera) ([in] String cameraId, [in] [ICameraDeviceCallback](interface_i_camera_device_callback.md) callbackObj, [out] [ICameraDevice](interface_i_camera_device.md) device) | 打开Camera设备。 | +| [SetFlashlight](#setflashlight) ([in] String cameraId, [in] boolean isEnable) | 打开或关闭闪光灯。 | + + +## **成员函数说明** + + +### GetCameraAbility() + + +``` +ICameraHost::GetCameraAbility ([in] String cameraId, [out] unsigned char[] cameraAbility ) +``` + +**描述:** + +获取Camera设备能力集合。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 用于指定要操作的Camera设备,通过[GetCameraIds](#getcameraids)获取。 | +| cameraAbility | 返回cameraId对应Camera设备的能力集合。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[GetCameraIds](#getcameraids) + + +### GetCameraIds() + + +``` +ICameraHost::GetCameraIds ([out] String[] cameraIds) +``` + +**描述:** + +获取当前可用的Camera设备ID列表。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraIds | 返回当前可用的设备列表。 | + +**返回:** + +NO_ERROR 表示执行成功; + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[GetCameraAbility](#getcameraability) + + +### OpenCamera() + + +``` +ICameraHost::OpenCamera ([in] String cameraId, [in] ICameraDeviceCallback callbackObj, [out] ICameraDevice device ) +``` + +**描述:** + +打开Camera设备。 + +打开指定的Camera设备,通过此接口可以获取到ICameraDevice对象,通过ICameraDevice对象可以操作具体的Camera设备。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 需要打开的Camera设备ID,可通过[GetCameraIds](#getcameraids)接口获取当前已有Camera设备列表。 | +| callbackObj | Camera设备相关的回调函数,具体参见[ICameraDeviceCallback](interface_i_camera_device_callback.md)。 | +| device | 返回当前要打开的Camera设备ID对应的ICameraDevice对象。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[GetCameraIds](#getcameraids) + + +### SetCallback() + + +``` +ICameraHost::SetCallback ([in] ICameraHostCallback callbackObj) +``` + +**描述:** + +设置ICameraHost回调接口,回调函数参考[ICameraHostCallback](interface_i_camera_host_callback.md)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 要设置的回调函数。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### SetFlashlight() + + +``` +ICameraHost::SetFlashlight ([in] String cameraId, [in] boolean isEnable ) +``` + +**描述:** + +打开或关闭闪光灯。 + +该接口只能由打开cameraId指定Camera设备的调用者调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 闪光灯对应的Camera设备ID。 | +| isEnable | 表示是否打开闪光灯,true表示打开,false表示关闭。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[GetCameraIds](#getcameraids) diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..27aa0722f85d4d52c59782e28959586260553bd2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_camera_host_callback.md @@ -0,0 +1,84 @@ +# ICameraHostCallback + + +## **概述** + +定义Camera设备功能回调操作。 + +设置回调接口、返回设备状态编号、闪光灯状态以及相应的事件ID。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnCameraStatus](#oncamerastatus) ([in] String cameraId, [in] enum [CameraStatus](camera.md#camerastatus) status) | 用于Camera设备状态变化时上报状态信息给调用者。 | +| [OnFlashlightStatus](#onflashlightstatus) ([in] String cameraId, [in] enum [FlashlightStatus](camera.md#flashlightstatus) status) | 用于在闪光灯状态变化时上报状态信息给调用者。 | +| [OnCameraEvent](#oncameraevent) ([in] String cameraId, [in] enum [CameraEvent](camera.md#cameraevent) event) | 在相机事件发生时调用。 | + + +## **成员函数说明** + + +### OnCameraEvent() + + +``` +ICameraHostCallback::OnCameraEvent ([in] String cameraId, [in] enum CameraEvent event ) +``` + +**描述:** + +在相机事件发生时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 表示相机事件绑定的相机ID。 | +| event | 表示相机事件类型。事件类型查看[CameraEvent](camera.md#cameraevent)。 | + + +### OnCameraStatus() + + +``` +ICameraHostCallback::OnCameraStatus ([in] String cameraId, [in] enum CameraStatus status ) +``` + +**描述:** + +用于Camera设备状态变化时上报状态信息给调用者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 状态发生变化的Camera设备ID。 | +| status | 最新的设备状态。 | + + +### OnFlashlightStatus() + + +``` +ICameraHostCallback::OnFlashlightStatus ([in] String cameraId, [in] enum FlashlightStatus status ) +``` + +**描述:** + +用于在闪光灯状态变化时上报状态信息给调用者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cameraId | 状态发生变化的闪关灯所绑定的Camera设备ID。 | +| status | 最新的闪光灯状态。状态值查看[CameraStatus](camera.md#camerastatus)。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md index 32a215289c1ff2bba8aaf381d61f8a6fa930a816..b5b3b5b1702c0cb94e109fd84c07108ea230689a 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md @@ -3,40 +3,37 @@ ## **概述** -**所属模块:** - -[HdfFaceAuth](_hdf_face_auth.md) - +定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 -## **汇总** +**Since:** +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [GetExecutorInfo](#getexecutorinfo) ([out] struct [ExecutorInfo](_executor_info.md) executorInfo) | 获取执行器信息,人脸认证服务将执行器注册到用户认证框架时需要通过该接口获取对应信息。 [更多...](#getexecutorinfo) | -| [GetTemplateInfo](#gettemplateinfo) ([in] unsigned long templateId, [out] struct [TemplateInfo](_template_info.md) templateInfo) | 获取凭据模版信息。 [更多...](#gettemplateinfo) | -| [OnRegisterFinish](#onregisterfinish-12) ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完成执行器注册,对人脸特征模版进行对账,用于删除无效的人脸特征模板及相关信息。 [更多...](#onregisterfinish-12) | -| [Enroll](#enroll) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 注册人脸特征模版。 [更多...](#enroll) | -| [Authenticate](#authenticate) ([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 人脸认证。 [更多...](#authenticate) | -| [Identify](#identify) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 人脸识别。 [更多...](#identify) | -| [Delete](#delete) ([in] unsigned long[] templateIdList) | 删除人脸特征模版。 [更多...](#delete) | -| [Cancel](#cancel) ([in] unsigned long scheduleId) | 取消操作请求。 [更多...](#cancel) | -| [SendCommand](#sendcommand) ([in] int commandId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 发送人脸认证功能相关操作命令。 [更多...](#sendcommand) | +1.0 +**所属模块:** -## **详细描述** +[HdfFaceAuth](_hdf_face_auth.md) -定义执行器接口,用于获取执行器,获取凭据模版信息,注册人脸特征模版,进行用户人脸认证,删除人脸特征模版等。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [GetExecutorInfo](#getexecutorinfo)([out] struct ExecutorInfo executorInfo) | 获取执行器信息,人脸认证服务将执行器注册到用户认证框架时需要通过该接口获取对应信息。 | +| [GetTemplateInfo](#gettemplateinfo)([in] unsigned long templateId, [out] struct TemplateInfo templateInfo) | 获取凭据模版信息。 | +| [OnRegisterFinish](#onregisterfinish)([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完成执行器注册,对人脸特征模版进行对账,用于删除无效的人脸特征模板及相关信息。 | +| [Enroll](#enroll)([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 注册人脸特征模版。 | +| [Authenticate](#authenticate)([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 人脸认证。 | +| [Identify](#identify)([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 人脸识别。 | +| [Delete](#delete)([in] unsigned long[] templateIdList) | 删除人脸特征模版。 | +| [Cancel](#cancel)([in] unsigned long scheduleId) | 取消操作请求。 | +| [SendCommand](#sendcommand)([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 发送人脸认证功能相关操作命令。 | ## **成员函数说明** @@ -218,7 +215,7 @@ IExecutor::Identify ([in] unsigned long scheduleId, [in] unsigned char[] extraIn 非0 表示操作失败。 -### OnRegisterFinish() [1/2] +### OnRegisterFinish() ``` @@ -285,7 +282,7 @@ IExecutor::SendCommand ([in] int commandId, [in] unsigned char[] extraInfo, [in] | 名称 | 描述 | | -------- | -------- | -| commandId | 操作命令ID[CommandId](_hdf_pin_auth.md#commandid)。 | +| commandId | 操作命令ID。 | | extraInfo | 其他相关信息,用于支持信息扩展。 | | callbackObj | 回调对象[IExecutorCallback](interface_i_executor_callback.md)。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md index 356027165c4b9f5acaef72e9ca8b398f881cf954..639f188b4cbedf4cbf7d4d1efd0884f6578e70d1 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md @@ -3,43 +3,40 @@ ## **概述** -**所属模块:** - -[HdfFaceAuth](_hdf_face_auth.md) - +定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_i_executor.md)。 -## **汇总** +**Since:** +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [OnResult](#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义操作结果回调函数。 [更多...](#onresult) | -| [OnTip](#ontip) ([in] int acquire, [in] unsigned char[] extraInfo) | 定义操作过程信息反馈回调函数。 [更多...](#ontip) | +1.0 +**所属模块:** -## **详细描述** +[HdfFaceAuth](_hdf_face_auth.md) -定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_i_executor.md)。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [OnResult](#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义操作结果回调函数。 | +| [OnAcquireInfo](#onacquireinfo) ([in] int acquire, [in] unsigned char[] extraInfo) | 定义操作过程信息反馈回调函数。 | ## **成员函数说明** -### OnTip() +### OnAcquireInfo() ``` -IExecutorCallback::OnTip ([in] int tip, [in] unsigned char[] extraInfo ) +IExecutorCallback::OnAcquireInfo ([in] int acquire, [in] unsigned char[] extraInfo ) ``` **描述:** @@ -50,7 +47,7 @@ IExecutorCallback::OnTip ([in] int tip, [in] unsigned char[] extraInfo ) | 名称 | 描述 | | -------- | -------- | -| tip | 提示信息编码[FaceTipsCode](_hdf_face_auth.md#facetipscode)。 | +| acquire | 提示信息编码[FaceTipsCode](_hdf_face_auth.md#facetipscode)。 | | extraInfo | 其他相关信息,用于支持信息扩展。 | **返回:** diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md index 32041928f7fe5e3bbd82e4861cb8d86733d4bc7d..d92d37b17762985a90a29d72c49aaa8c742e2c52 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md @@ -3,32 +3,29 @@ ## **概述** -**所属模块:** - -[HdfFaceAuth](_hdf_face_auth.md) - +定义获取人脸认证驱动的执行器列表接口。 -## **汇总** +**Since:** +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [GetExecutorList](#getexecutorlist) ([out] [IExecutor](interface_i_executor.md)[] executorList) | 获取执行器列表,人脸认证服务进程启动进行初始化操作时通过该接口获取人脸认证驱动支持的执行器列表。 [更多...](#getexecutorlist) | +1.0 +**所属模块:** -## **详细描述** +[HdfFaceAuth](_hdf_face_auth.md) -定义获取人脸认证驱动的执行器列表接口。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [GetExecutorList](#getexecutorlist) ([out] IExecutor[] executorList) | 获取执行器列表,人脸认证服务进程启动进行初始化操作时通过该接口获取人脸认证驱动支持的执行器列表。 | ## **成员函数说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_light_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_light_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..5a894832572b1c291dfe7c50bd28f2986c48683d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_light_interface.md @@ -0,0 +1,138 @@ +# ILightInterface + + +## **概述** + +提供灯模块基本操作接口。 + +操作包括获取灯的信息、打开或关闭灯、设置灯的亮度或闪烁模式。 + +**Since:** + +3.1 + +**Version:** + +1.0 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [GetLightInfo](#getlightinfo) ([out] struct [HdfLightInfo](_hdf_light_info.md)[] info) | 获取当前系统中所有类型的灯信息。 | +| [TurnOnLight](#turnonlight) ([in] int lightId, [in] struct [HdfLightEffect](_hdf_light_effect.md) effect) | 根据指定的灯类型ID打开列表中的可用灯。 | +| [TurnOnMultiLights](#turnonmultilights) ([in] int lightId, [in] struct [HdfLightColor](_hdf_light_color.md)[] colors) | 根据指定的灯类型ID打开相应灯中包含的多个子灯。 | +| [TurnOffLight](#turnofflight) ([in] int lightId) | 根据指定的灯类型ID关闭列表中的可用灯。 | + + +## **成员函数说明** + + +### GetLightInfo() + + +``` +ILightInterface::GetLightInfo ([out] struct HdfLightInfo[] info) +``` + +**描述:** + +获取当前系统中所有类型的灯信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| info | 表示指向灯信息的二级指针。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### TurnOffLight() + + +``` +ILightInterface::TurnOffLight ([in] int lightId) +``` + +**描述:** + +根据指定的灯类型ID关闭列表中的可用灯。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| lightId | 表示灯类型ID,详见[HdfLightId](light.md#hdflightid)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### TurnOnLight() + + +``` +ILightInterface::TurnOnLight ([in] int lightId, [in] struct HdfLightEffect effect ) +``` + +**描述:** + +根据指定的灯类型ID打开列表中的可用灯。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| lightId | 表示灯类型ID。详见[HdfLightId](light.md#hdflightid)。 | +| effect | 表示指向灯效果的指针,如果lightbrightness字段为0时, 灯的亮度根据HCS配置的默认亮度进行设置。详见[HdfLightEffect](_hdf_light_effect.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果不支持灯类型ID,则返回-1。 + +如果不支持闪烁设置,则返回-2。 + +如果不支持亮度设置,则返回-3。 + + +### TurnOnMultiLights() + + +``` +ILightInterface::TurnOnMultiLights ([in] int lightId, [in] struct HdfLightColor[] colors ) +``` + +**描述:** + +根据指定的灯类型ID打开相应灯中包含的多个子灯。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| lightId | 表示灯类型ID,详见[HdfLightId](light.md#hdflightid)。 | +| colors | 多个子灯对应的颜色和亮度, 详见[HdfLightColor](_hdf_light_color.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..39c11481f893e1741b5681eaf8d8be330cb2748a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_callback.md @@ -0,0 +1,53 @@ +# IMotionCallback + + +## **概述** + +定义上报手势识别数据回调函数。 + +手势识别用户在订阅手势识别数据时需要注册这个回调函数,只有当使能手势识别后,手势识别数据用户才会收到手势识别数据。 详情可参考[IMotionInterface](interface_i_motion_interface.md)。 + +**Since:** + +3.2 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnDataEvent](#ondataevent) ([in] struct [HdfMotionEvent](_hdf_motion_event.md) event) | 定义上报手势识别数据回调函数。 | + + +## **成员函数说明** + + +### OnDataEvent() + + +``` +IMotionCallback::OnDataEvent ([in] struct HdfMotionEvent event) +``` + +**描述:** + +定义上报手势识别数据回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 回调函数上报的数据。详见[HdfMotionEvent](_hdf_motion_event.md)。 | + +**返回:** + +如果回调函数上报数据成功,则返回0。 + +如果回调函数上报数据失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..80d8001ff267ae63338d19099a0887fc3868479c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_motion_interface.md @@ -0,0 +1,118 @@ +# IMotionInterface + + +## **概述** + +提供Motion设备基本控制操作接口。 + +接口提供使能/去使能手势识别、订阅/取消订阅手势识别数据功能。 + +**相关模块:** + +[Motion](motion.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [EnableMotion](#enablemotion) ([in] int motionType) | 使能手势识别。 | +| [DisableMotion](#disablemotion) ([in] int motionType) | 去使能手势识别。 | +| [Register](#register) ([in] [IMotionCallback](interface_i_motion_callback.md) callbackObj) | 订阅者注册手势识别数据回调函数,如果注册成功,系统会将获取到的手势识别数据上报给订阅者。 | +| [Unregister](#unregister) ([in] [IMotionCallback](interface_i_motion_callback.md) callbackObj) | 订阅者取消注册手势识别数据回调函数。 | + + +## **成员函数说明** + + +### DisableMotion() + + +``` +IMotionInterface::DisableMotion ([in] int motionType) +``` + +**描述:** + +去使能手势识别。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| motionType | 手势识别类型,详见[HdfMotionTypeTag](motion.md#hdfmotiontypetag)。 | + + +### EnableMotion() + + +``` +IMotionInterface::EnableMotion ([in] int motionType) +``` + +**描述:** + +使能手势识别。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| motionType | 手势识别类型,详见[HdfMotionTypeTag](motion.md#hdfmotiontypetag)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Register() + + +``` +IMotionInterface::Register ([in] IMotionCallback callbackObj) +``` + +**描述:** + +订阅者注册手势识别数据回调函数,如果注册成功,系统会将获取到的手势识别数据上报给订阅者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 要注册的回调函数,只需成功订阅一次,无需重复订阅。详见[IMotionCallback](interface_i_motion_callback.md)。 | + +**返回:** + +如果注册回调函数成功,则返回0。 + +如果注册回调函数失败,则返回负值。 + + +### Unregister() + + +``` +IMotionInterface::Unregister ([in] IMotionCallback callbackObj) +``` + +**描述:** + +订阅者取消注册手势识别数据回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| callbackObj | 要取消注册的回调函数,只需成功取消订阅一次,无需重复取消订阅。详见[IMotionCallback](interface_i_motion_callback.md)。 | + +**返回:** + +如果取消注册回调函数成功,则返回0。 + +如果取消注册回调函数失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_offline_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_offline_stream_operator.md new file mode 100644 index 0000000000000000000000000000000000000000..c70eae568751d3d73bf45d1c734b8e3b092db0e9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_offline_stream_operator.md @@ -0,0 +1,97 @@ +# IOfflineStreamOperator + + +## **概述** + +定义Camera设备离线流操作。 + +对Camera设备离线流执行取消捕获和释放操作。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [CancelCapture](#cancelcapture) ([in] int captureId) | 取消捕获请求。 | +| [ReleaseStreams](#releasestreams) ([in] int[] streamIds) | 释放离线流。 | +| [Release](#release) () | 释放所有离线流。 释放流的前置条件:
1. 所有单次捕获的Capture处理完成。
2. 所有连续捕获请求都已经被CancelCapture。 | + + +## **成员函数说明** + + +### CancelCapture() + + +``` +IOfflineStreamOperator::CancelCapture ([in] int captureId) +``` + +**描述:** + +取消捕获请求。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识要取消的捕获请求。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### Release() + + +``` +IOfflineStreamOperator::Release () +``` + +**描述:** + +释放所有离线流。 释放流的前置条件: + +1. 所有单次捕获的Capture处理完成。 + +2. 所有连续捕获请求都已经被CancelCapture。 + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### ReleaseStreams() + + +``` +IOfflineStreamOperator::ReleaseStreams ([in] int[] streamIds) +``` + +**描述:** + +释放离线流。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamIds | 用于标识要释放的多条离线流。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md index c6d110537f39b948361d104ee1ab4978f141eca3..ae16e55ecdb3b44ad1329ab9a15d214e39c39a31 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md @@ -3,32 +3,29 @@ ## **概述** -**所属模块:** - -[HdfPinAuth](_hdf_pin_auth.md) - +定义获取口令认证驱动的执行器列表接口。 -## **汇总** +**Since:** +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [GetExecutorList](#getexecutorlist) ([out] [IExecutor](interface_pin_i_executor.md)[] executorList) | 获取执行器列表,口令认证服务进程启动进行初始化操作时通过该接口获取口令认证驱动支持的执行器列表。 [更多...](#getexecutorlist) | +1.0 +**所属模块:** -## **详细描述** +[HdfPinAuth](_hdf_pin_auth.md) -定义获取口令认证驱动的执行器列表接口。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [GetExecutorList](#getexecutorlist) ([out] IExecutor[] executorList) | 获取执行器列表,口令认证服务进程启动进行初始化操作时通过该接口获取口令认证驱动支持的执行器列表。 | ## **成员函数说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md index 993bd9ed6101f16f848009998b1088adb9a1f655..0aaecf4cb4a925d88ce4d78fbf2b37193886e0ad 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md @@ -3,31 +3,28 @@ ## **概述** -**所属模块:** - -[Power](power.md) - +休眠/唤醒状态的回调。 -## **汇总** +服务创建此回调对象后,可以调用IPowerInterface的接口注册回调,从而订阅休眠/唤醒状态的变化。 +**Since:** -### Public 成员函数 +3.1 - | Public 成员函数 | 描述 | -| -------- | -------- | -| [OnSuspend](#onsuspend) () | 休眠状态的回调方法。 [更多...](#onsuspend) | -| [OnWakeup](#onwakeup) () | 唤醒状态的回调方法。 [更多...](#onwakeup) | +**相关模块:** +[Power](power.md) -## **详细描述** -休眠/唤醒状态的回调。 +## **汇总** -服务创建此回调对象后,可以调用IPowerInterface的接口注册回调,从而订阅休眠/唤醒状态的变化。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [OnSuspend](#onsuspend) () | 休眠状态的回调方法。 | +| [OnWakeup](#onwakeup) () | 唤醒状态的回调方法。 | ## **成员函数说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md index 73d549879069aba5d3d0b90d89cc12631fda7d41..5118655d14fb8dad970f9ac638a5d680662349cc 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md @@ -3,36 +3,33 @@ ## **概述** -**所属模块:** - -[Power](power.md) - +休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 -## **汇总** +服务获取此对象后,可以调用相关的接口对设备进行休眠/唤醒、订阅休眠/唤醒状态和管理运行锁。 +**Since:** -### Public 成员函数 +3.1 - | Public 成员函数 | 描述 | -| -------- | -------- | -| [RegisterCallback](#registercallback) ([in] [IPowerHdiCallback](interface_i_power_hdi_callback.md) ipowerHdiCallback) | 注册休眠/唤醒状态的回调。 [更多...](#registercallback) | -| [StartSuspend](#startsuspend) () | 执行设备休眠操作。 [更多...](#startsuspend) | -| [StopSuspend](#stopsuspend) () | 执行设备唤醒操作。 [更多...](#stopsuspend) | -| [ForceSuspend](#forcesuspend) () | 执行设备强制休眠操作。 [更多...](#forcesuspend) | -| [SuspendBlock](#suspendblock) ([in] String name) | 打开运行锁,阻止休眠。 [更多...](#suspendblock) | -| [SuspendUnblock](#suspendunblock) ([in] String name) | 关闭运行锁,取消阻止休眠。 [更多...](#suspendunblock) | -| [PowerDump](#powerdump) ([out] String info) | 获取电源的Dump信息。 [更多...](#powerdump) | +**相关模块:** +[Power](power.md) -## **详细描述** -休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 +## **汇总** -服务获取此对象后,可以调用相关的接口对设备进行休眠/唤醒、订阅休眠/唤醒状态和管理运行锁。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [RegisterCallback](#registercallback) ([in] [IPowerHdiCallback](interface_i_power_hdi_callback.md) ipowerHdiCallback) | 注册休眠/唤醒状态的回调。 | +| [StartSuspend](#startsuspend) () | 执行设备休眠操作。 | +| [StopSuspend](#stopsuspend) () | 执行设备唤醒操作。 | +| [ForceSuspend](#forcesuspend) () | 执行设备强制休眠操作。 | +| [SuspendBlock](#suspendblock) ([in] String name) | 打开运行锁,阻止休眠。 | +| [SuspendUnblock](#suspendunblock) ([in] String name) | 关闭运行锁,取消阻止休眠。 | +| [PowerDump](#powerdump) ([out] String info) | 获取电源的Dump信息。 | ## **成员函数说明** @@ -49,7 +46,7 @@ IPowerInterface::ForceSuspend () 执行设备强制休眠操作。 -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 @@ -65,13 +62,13 @@ IPowerInterface::PowerDump ([out] String info) 获取电源的Dump信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | info | 输出参数,电源的Dump信息。 | -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 @@ -87,17 +84,17 @@ IPowerInterface::RegisterCallback ([in] IPowerHdiCallback ipowerHdiCallback) 注册休眠/唤醒状态的回调。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | ipowerHdiCallback | 输入参数,服务注册的回调。 | -**返回:** +**返回:** HDF_SUCCESS 表示注册成功。 -**参见:** +**参见:** [IPowerHdiCallback](interface_i_power_hdi_callback.md) @@ -113,7 +110,7 @@ IPowerInterface::StartSuspend () 执行设备休眠操作。 -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 @@ -129,7 +126,7 @@ IPowerInterface::StopSuspend () 执行设备唤醒操作。 -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 @@ -145,13 +142,13 @@ IPowerInterface::SuspendBlock ([in] String name) 打开运行锁,阻止休眠。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | name | 输入参数,运行锁的名称。 | -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 @@ -167,12 +164,12 @@ IPowerInterface::SuspendUnblock ([in] String name) 关闭运行锁,取消阻止休眠。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | name | 输入参数,运行锁的名称。 | -**返回:** +**返回:** HDF_SUCCESS 表示操作成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..56699b4b547f0a277e721dc1a186a6f1da74bae3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_callback.md @@ -0,0 +1,49 @@ +# ISensorCallback + + +## **概述** + +定义用于上报传感器数据的回调函数。 + +传感器用户订阅传感器数据,只在使能传感器后,传感器数据订阅者才能接收传感器数据。 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnDataEvent](#ondataevent) ([in] struct [HdfSensorEvents](_hdf_sensor_events.md) event) | 定义上报传感器数据的功能。 | + + +## **成员函数说明** + + +### OnDataEvent() + + +``` +ISensorCallback::OnDataEvent ([in] struct HdfSensorEvents event) +``` + +**描述:** + +定义上报传感器数据的功能。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 上报的传感器数据,详见[HdfSensorEvents](_hdf_sensor_events.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..be4ea74d8120858005132020f305985b2f322c06 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_sensor_interface.md @@ -0,0 +1,238 @@ +# ISensorInterface + + +## **概述** + +提供Sensor设备基本控制操作接口。 + +操作包括获取传感器设备信息、订阅/取消订阅传感器数据、使能/去使能传感器、设置传感器模式、设置传感器精度、量程等可选配置接口定义。 + +**Since:** + +2.2 + +**Version:** + +1.0 + +**相关模块:** + +[Sensor](sensor.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [GetAllSensorInfo](#getallsensorinfo) ([out] struct [HdfSensorInformation](_hdf_sensor_information.md)[] info) | 获取当前系统中所有类型的传感器信息。 | +| [Enable](#enable) ([in] int sensorId) | 根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 | +| [Disable](#disable) ([in] int sensorId) | 根据传感器设备类型标识去使能传感器信息列表里存在的设备。 | +| [SetBatch](#setbatch) ([in] int sensorId,[in] long samplingInterval, [in] long reportInterval) | 设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 | +| [SetMode](#setmode) ([in] int sensorId, [in] int mode) | 设置指定传感器数据上报模式。 | +| [SetOption](#setoption) ([in] int sensorId, [in] unsigned int option) | 设置指定传感器量程、精度等可选配置。 | +| [Register](#register) ([in] int groupId, [in] [ISensorCallback](interface_i_sensor_callback.md) callbackObj) | 订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 | +| [Unregister](#unregister) ([in] int groupId, [in] [ISensorCallback](interface_i_sensor_callback.md) callbackObj) | 订阅者取消注册传感器数据回调函数。 | + + +## **成员函数说明** + + +### Disable() + + +``` +ISensorInterface::Disable ([in] int sensorId) +``` + +**描述:** + +根据传感器设备类型标识去使能传感器信息列表里存在的设备。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](sensor.md#hdfsensortypetag)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Enable() + + +``` +ISensorInterface::Enable ([in] int sensorId) +``` + +**描述:** + +根据传感器设备类型标识使能传感器信息列表里存在的设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](sensor.md#hdfsensortypetag)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetAllSensorInfo() + + +``` +ISensorInterface::GetAllSensorInfo ([out] struct HdfSensorInformation[] info) +``` + +**描述:** + +获取当前系统中所有类型的传感器信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| 输出系统中注册的所有传感器信息,一种类型传感器信息包括传感器名字、设备厂商、 | 固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗,详见[HdfSensorInformation](_hdf_sensor_information.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Register() + + +``` +ISensorInterface::Register ([in] int groupId, [in] ISensorCallback callbackObj ) +``` + +**描述:** + +订阅者注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| groupId | 传感器组ID。 groupId枚举值范围为128-160,表示已订阅医疗传感器服务,只需成功订阅一次,无需重复订阅。 groupId枚举值范围不在128-160之间,这意味着传统传感器已订阅,只需成功订阅一次,无需重复订阅。 | +| callbackObj | 要注册的回调函数,详见[ISensorCallback](interface_i_sensor_callback.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负数。 + + +### SetBatch() + + +``` +ISensorInterface::SetBatch ([in] int sensorId, [in] long samplingInterval, [in] long reportInterval ) +``` + +**描述:** + +设置指定传感器的数据上报模式,不同的工作模式,上报数据的方式不同。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](sensor.md#hdfsensortypetag)。 | +| samplingInterval | 设置指定传感器的数据采样间隔,单位纳秒。 | +| reportInterval | 表示传感器数据上报间隔,单位纳秒。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetMode() + + +``` +ISensorInterface::SetMode ([in] int sensorId, [in] int mode ) +``` + +**描述:** + +设置指定传感器数据上报模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](sensor.md#hdfsensortypetag)。 | +| mode | 传感器的数据上报模式,详见[HdfSensorModeType](sensor.md#hdfsensormodetype)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负数。 + + +### SetOption() + + +``` +ISensorInterface::SetOption ([in] int sensorId, [in] unsigned int option ) +``` + +**描述:** + +设置指定传感器量程、精度等可选配置。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| sensorId | 唯一标识一个传感器设备类型,详见[HdfSensorTypeTag](sensor.md#hdfsensortypetag)。 | +| option | 表示要设置的选项,如测量范围和精度。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负数。 + + +### Unregister() + + +``` +ISensorInterface::Unregister ([in] int groupId, [in] ISensorCallback callbackObj ) +``` + +**描述:** + +订阅者取消注册传感器数据回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| groupId | 传感器组ID。 groupId枚举值范围为128-160,表示已订阅医疗传感器服务。只需成功取消订阅一次,无需重复取消订阅。 groupId枚举值范围不在128-160之间,这意味着传统传感器已订阅。并且成功取消订阅。 | +| callbackObj | 要取消注册的回调函数,详见[ISensorCallback](interface_i_sensor_callback.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator.md new file mode 100644 index 0000000000000000000000000000000000000000..98a762eceb7b11e0c574191f4586aa767a95ede1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator.md @@ -0,0 +1,325 @@ +# IStreamOperator + + +## **概述** + +定义Camera设备流操作。 + +对Camera设备执行流的创建、配置与添加参数、属性获取、句柄绑定与解除、图像捕获与取消、流的转换以及流释放操作。 + +流是指从底层设备输出,经本模块内部各环节处理,最终传递到上层服务或者应用的一组数据序列。 本模块支持的流的类型有预览流,录像流,拍照流等,更多类型可查看[StreamIntent](camera.md#streamintent)。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [IsStreamsSupported](#isstreamssupported) ([in] enum [OperationMode](camera.md#operationmode) mode, [in] unsigned char[] modeSetting, [in] struct [StreamInfo](_stream_info.md)[] infos, [out] enum [StreamSupportType](camera.md#streamsupporttype) type) | 查询是否支持添加参数对应的流。 | +| [CreateStreams](#createstreams) ([in] struct [StreamInfo](_stream_info.md)[] streamInfos) | 创建流。 | +| [ReleaseStreams](#releasestreams) ([in] int[] streamIds) | 释放流。 | +| [CommitStreams](#commitstreams) ([in] enum [OperationMode](camera.md#operationmode) mode, [in] unsigned char[] modeSetting) | 配置流。 | +| [GetStreamAttributes](#getstreamattributes) ([out] struct [StreamAttribute](_stream_attribute.md)[] attributes) | 获取流的属性。通过该接口获取的流属性可能会和[CreateStreams](#createstreams)输入的流信息存在差异。 | +| [AttachBufferQueue](#attachbufferqueue) ([in] int streamId, [in] BufferProducerSequenceable bufferProducer) | 绑定生产者句柄和指定流。 | +| [DetachBufferQueue](#detachbufferqueue) ([in] int streamId) | 解除生产者句柄和指定流的绑定关系。 | +| [Capture](#capture) ([in] int captureId, [in] struct [CaptureInfo](_capture_info.md) info, [in] boolean isStreaming) | 捕获图像。 | +| [CancelCapture](#cancelcapture) ([in] int captureId) | 取消连续捕获。捕获结束时,会调用[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)来通知调用者捕获的帧计数等信息。 | +| [ChangeToOfflineStream](#changetoofflinestream) ([in] int[] streamIds, [in] [IStreamOperatorCallback](interface_i_stream_operator_callback.md) callbackObj, [out] [IOfflineStreamOperator](interface_i_offline_stream_operator.md) offlineOperator) | 将指定流转换成离线流。 | + + +## **成员函数说明** + + +### AttachBufferQueue() + + +``` +IStreamOperator::AttachBufferQueue ([in] int streamId, [in] BufferProducerSequenceable bufferProducer ) +``` + +**描述:** + +绑定生产者句柄和指定流。 + +如果在[CreateStreams](#createstreams)创建流时已经指定了生产者句柄,则不需要调用该接口。如果需要重新绑定, 需先调用[DetachBufferQueue](#detachbufferqueue)进行解绑,然后再绑定。 对于一些IOT设备,可能不需要或者不支持预览流的图像数据缓存流转,那么不需要绑定生产者句柄, 此时在创建流时[CreateStreams](#createstreams)的[StreamInfo](_stream_info.md)参数的生产者句柄bufferQueue_为空,而 tunneledMode_需设置为false。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamId | 用于标识要绑定的流。 | +| bufferProducer | 生产者句柄。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[DetachBufferQueue](#detachbufferqueue) + + +### CancelCapture() + + +``` +IStreamOperator::CancelCapture ([in] int captureId) +``` + +**描述:** + +取消连续捕获。捕获结束时,会调用[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)来通知调用者捕获的帧计数等信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识要取消的捕获请求。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[Capture](#capture) + + +### Capture() + + +``` +IStreamOperator::Capture ([in] int captureId, [in] struct CaptureInfo info, [in] boolean isStreaming ) +``` + +**描述:** + +捕获图像。 + +本接口必须在调用[CommitStreams](#commitstreams)配置流之后调用。 图像捕获有两种模式,分别是连续捕获和单次捕获。 + +- 连续捕获即触发之后模块内部进行连续的捕获,消费者可以连续收到图像数据,不需要多次调用本接口,若再次调用了本接口, 则停止当前捕获,更新捕获信息,再进行一次新的捕获,多用于预览、录像或者连拍场景。 + +- 单次捕获即触发之后只捕获一帧图像数据,用于单次拍照场景。捕获启动时,会调用[OnCaptureStarted](interface_i_stream_operator_callback.md#oncapturestarted)来通知调用者捕获已经启动。 + +- 连续捕获需调用[CancelCapture](#cancelcapture)来停止捕获。捕获结束时,会调用[OnCaptureEnded](interface_i_stream_operator_callback.md#oncaptureended)来通知调用者捕获的帧计数等信息。 [CaptureInfo](_capture_info.md)的[enableShutterCallback_](_capture_info.md#enableshuttercallback)使能OnFrameShutter,使能后每次捕获触发OnFrameShutter。 对于多个流同时捕获的场景,本模块内部保证同时上报多路流捕获数据。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 捕获请求的唯一标识,由调用者指定,调用者需保证在Camera设备打开期间,捕获请求ID是唯一的。 | +| info | 捕获请求的参数信息,具体信息查看[CaptureInfo](_capture_info.md)。 | +| isStreaming | 是否连续捕获,true表示连续捕获,否则为单次捕获。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[OnFrameShutter](interface_i_stream_operator_callback.md#onframeshutter) + + +### ChangeToOfflineStream() + + +``` +IStreamOperator::ChangeToOfflineStream ([in] int[] streamIds, [in] IStreamOperatorCallback callbackObj, [out] IOfflineStreamOperator offlineOperator ) +``` + +**描述:** + +将指定流转换成离线流。 + +离线流只能由拍照流转换而来,其他流不支持。 一些设备处理能力有限,可能导致拍照时算法处理时间较长,从而引起捕获请求堆积在模块内部,而转换为离线 流之后,可关闭底层设备,由离线流接替,进行后续的处理。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamIds | 用于指定要转换成离线流的流集合。 | +| callbackObj | 用于设置离线流的回调。 | +| offlineOperator | 转换后的离线流。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### CommitStreams() + + +``` +IStreamOperator::CommitStreams ([in] enum OperationMode mode, [in] unsigned char[] modeSetting ) +``` + +**描述:** + +配置流。 + +本接口需在调用[CreateStreams](#createstreams)创建流之后调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| mode | 流运行的模式,支持的模式定义在[OperationMode](camera.md#operationmode)。 | +| modeSetting | 流的配置参数,包括帧率,ZOOM等信息。ZOOM:变焦 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### CreateStreams() + + +``` +IStreamOperator::CreateStreams ([in] struct StreamInfo[] streamInfos) +``` + +**描述:** + +创建流。 + +此函数接口依据输入的流信息创建流,调用该接口之前需先通过[IsStreamsSupported](#isstreamssupported)查询HAL是否支持要创建的流。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamInfos | 流信息列表,流信息定义在[StreamInfo](_stream_info.md)。输入的流信息可能会被修改,需通过[GetStreamAttributes](#getstreamattributes)获取最新的流属性。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### DetachBufferQueue() + + +``` +IStreamOperator::DetachBufferQueue ([in] int streamId) +``` + +**描述:** + +解除生产者句柄和指定流的绑定关系。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamId | 用于标识要解除绑定的流。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + +**参见:** + +[AttachBufferQueue](#attachbufferqueue) + + +### GetStreamAttributes() + + +``` +IStreamOperator::GetStreamAttributes ([out] struct StreamAttribute[] attributes) +``` + +**描述:** + +获取流的属性。通过该接口获取的流属性可能会和[CreateStreams](#createstreams)输入的流信息存在差异。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| attributes | 用于获取流的属性。在调用[CreateStreams](#createstreams)时,通过参数streamInfos携带的流信息可能会被重写。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### IsStreamsSupported() + + +``` +IStreamOperator::IsStreamsSupported ([in] enum OperationMode mode, [in] unsigned char[] modeSetting, [in] struct StreamInfo[] infos, [out] enum StreamSupportType type ) +``` + +**描述:** + +查询是否支持添加参数对应的流。 + +此函数接口根据输入的运行模式和配置信息以及当前模块中正在运行的流,查询是否支持动态添加流。 + +- 如果本模块支持在不停止其他流的情况下添加新流,或者即使停止其他流但上层服务或应用不感知, 则通过type参数返回DYNAMIC_SUPPORTED,上层服务或应用可以直接添加新流; + +- 如果本模块支持添加新流但需要上层服务或应用先停止所有流的捕获,则通过type参数返回RE_CONFIGURED_REQUIRED; + +- 如果不支持添加输入的新流,则返回NOT_SUPPORTED。 此函数需要在调用[CreateStreams](#createstreams)创建流之前调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| mode | 流的使用模式,支持的模式参考[OperationMode](camera.md#operationmode)。 | +| modeSetting | 流的配置,包括帧率,3A等配置信息。3A:自动曝光 (AE)、自动聚焦 (AF)、自动白平衡 (AWB) | +| infos | 流的配置信息,具体参考[StreamInfo](_stream_info.md)。 | +| type | 对动态配置流的支持类型,支持类型定义在[StreamSupportType](camera.md#streamsupporttype)。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 + + +### ReleaseStreams() + + +``` +IStreamOperator::ReleaseStreams ([in] int[] streamIds) +``` + +**描述:** + +释放流。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| streamIds | 要释放的流ID列表。 | + +**返回:** + +NO_ERROR 表示执行成功。 + +其他值表示执行失败,具体错误码查看[CamRetCode](camera.md#camretcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..0c1293b76174281509b427abc30d78bd51b17b55 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_stream_operator_callback.md @@ -0,0 +1,119 @@ +# IStreamOperatorCallback + + +## **概述** + +定义Camera设备流回调操作。 + +对Camera设备执行流回调的抓捕,结束,错误捕获和帧捕获等操作。 + +**相关模块:** + +[Camera](camera.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnCaptureStarted](#oncapturestarted) ([in] int captureId, [in] int[] streamIds) | 捕获开始回调,在捕获开始时调用。 | +| [OnCaptureEnded](#oncaptureended) ([in] int captureId, [in] struct [CaptureEndedInfo](_capture_ended_info.md)[] infos) | 捕获结束回调,在捕获结束时调用。 | +| [OnCaptureError](#oncaptureerror) ([in] int captureId, [in] struct [CaptureErrorInfo](_capture_error_info.md)[] infos) | 捕获错误回调,在捕获过程中发生错误时调用。 | +| [OnFrameShutter](#onframeshutter) ([in] int captureId, [in] int[] streamIds, [in] unsigned long timestamp) | 帧捕获回调。 | + + +## **成员函数说明** + + +### OnCaptureEnded() + + +``` +IStreamOperatorCallback::OnCaptureEnded ([in] int captureId, [in] struct CaptureEndedInfo[] infos ) +``` + +**描述:** + +捕获结束回调,在捕获结束时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识回调对应的捕获请求。 | +| infos | 捕获结束相关信息,具体结束相关信息查看[CaptureEndedInfo](_capture_ended_info.md)。 | + +**参见:** + +[OnCaptureStarted](#oncapturestarted) + + +### OnCaptureError() + + +``` +IStreamOperatorCallback::OnCaptureError ([in] int captureId, [in] struct CaptureErrorInfo[] infos ) +``` + +**描述:** + +捕获错误回调,在捕获过程中发生错误时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识回调对应的捕获请求。 | +| infos | 捕获错误信息列表,具体错误信息查看[CaptureErrorInfo](_capture_error_info.md)。 | + + +### OnCaptureStarted() + + +``` +IStreamOperatorCallback::OnCaptureStarted ([in] int captureId, [in] int[] streamIds ) +``` + +**描述:** + +捕获开始回调,在捕获开始时调用。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识回调对应的捕获请求。 | +| streamIds | 回调对应的流集合。 | + +**参见:** + +[OnCaptureEnded](#oncaptureended) + + +### OnFrameShutter() + + +``` +IStreamOperatorCallback::OnFrameShutter ([in] int captureId, [in] int[] streamIds, [in] unsigned long timestamp ) +``` + +**描述:** + +帧捕获回调。 + +通过**Capture**的输入参数[CaptureInfo](_capture_info.md)的enableShutterCallback_使能该回调, 使能后每次捕获均会触发此回调。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| captureId | 用于标识回调对应的捕获请求。 | +| streamIds | 回调对应的流集合。 | +| timestamp | 该接口被调用时的时间戳。 | + +**参见:** + +Capture diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md index b713dbcc70868b061dd239f2b0527d8c3e1652e6..96d23ab5bea3795d727408cd8be19ef490f957b7 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md @@ -3,30 +3,27 @@ ## **概述** -**所属模块:** - -[Thermal](thermal.md) - +订阅设备发热状态的回调。 -## **汇总** +服务创建此回调对象后,可以调用[IThermalInterface](interface_i_thermal_interface.md)的接口注册回调,从而订阅设备发热状态的变化。 +**Since:** -### Public 成员函数 +3.1 - | Public 成员函数 | 描述 | -| -------- | -------- | -| [OnThermalDataEvent](#onthermaldataevent) ([in] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 设备发热状态变化的回调方法。 [更多...](#onthermaldataevent) | +**相关模块:** +[Thermal](thermal.md) -## **详细描述** -订阅设备发热状态的回调。 +## **汇总** -服务创建此回调对象后,可以调用IThermalInterface的接口注册回调,从而订阅设备发热状态的变化。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [OnThermalDataEvent](#onthermaldataevent) ([in] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 设备发热状态变化的回调方法。 | ## **成员函数说明** @@ -45,12 +42,12 @@ IThermalCallback::OnThermalDataEvent ([in] struct HdfThermalCallbackInfo event) 当设备发热状态发生变化时,将通过此方法的参数返回给服务。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | -| event | 输入参数,设备发热信息,包括器件类型、器件温度。 | +| event | 设备发热信息,包括器件类型、器件温度。 | -**参见:** +**参见:** [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md index cffe822befa71b155d2095b34d79894ae12bbb08..d911533f458425c6c0e5afe889500d55de599b07 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md @@ -3,35 +3,32 @@ ## **概述** -**所属模块:** - -[Thermal](thermal.md) - +设备温度管理、控制及订阅接口。 -## **汇总** +服务获取此对象后,可以调用相关的接口管理、控制和订阅设备温度。 +**Since:** -### Public 成员函数 +3.1 - | Public 成员函数 | 描述 | -| -------- | -------- | -| [SetCpuFreq](#setcpufreq) ([in] int freq) | 设置CPU频率。 [更多...](#setcpufreq) | -| [SetGpuFreq](#setgpufreq) ([in] int freq) | 设置GPU频率。 [更多...](#setgpufreq) | -| [SetBatteryCurrent](#setbatterycurrent) ([in] int current) | 设置充电电流。 [更多...](#setbatterycurrent) | -| [GetThermalZoneInfo](#getthermalzoneinfo) ([out] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 获取设备发热的信息。 [更多...](#getthermalzoneinfo) | -| [Register](#register) ([in] [IThermalCallback](interface_i_thermal_callback.md) callbackObj) | 注册设备发热状态的回调。 [更多...](#register) | -| [Unregister](#unregister) () | 取消注册设备发热状态的回调。 [更多...](#unregister) | +**相关模块:** +[Thermal](thermal.md) -## **详细描述** -设备温度管理、控制及订阅接口。 +## **汇总** -服务获取此对象后,可以调用相关的接口管理、控制和订阅设备温度。 -**Since:** +### Public 成员函数 -3.1 + | 名称 | 描述 | +| -------- | -------- | +| [SetCpuFreq](#setcpufreq) ([in] int freq) | 设置CPU频率。 | +| [SetGpuFreq](#setgpufreq) ([in] int freq) | 设置GPU频率。 | +| [SetBatteryCurrent](#setbatterycurrent) ([in] int current) | 设置充电电流。 | +| [GetThermalZoneInfo](#getthermalzoneinfo) ([out] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 获取设备发热的信息。 | +| [Register](#register) ([in] [IThermalCallback](interface_i_thermal_callback.md) callbackObj) | 注册设备发热状态的回调。 | +| [Unregister](#unregister) () | 取消注册设备发热状态的回调。 | ## **成员函数说明** @@ -48,17 +45,17 @@ IThermalInterface::GetThermalZoneInfo ([out] struct HdfThermalCallbackInfo event 获取设备发热的信息。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | event | 输出参数,设备发热信息,包括器件类型、器件温度。 | -**返回:** +**返回:** HDF_SUCCESS 表示获取成功。 -**参见:** +**参见:** [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) @@ -74,17 +71,17 @@ IThermalInterface::Register ([in] IThermalCallback callbackObj) 注册设备发热状态的回调。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | callbackObj | 输入参数,服务注册的回调。 | -**返回:** +**返回:** HDF_SUCCESS 表示注册成功。 -**参见:** +**参见:** [IThermalCallback](interface_i_thermal_callback.md) @@ -100,13 +97,13 @@ IThermalInterface::SetBatteryCurrent ([in] int current) 设置充电电流。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | current | 输入参数,充电电流,单位毫安。 | -**返回:** +**返回:** HDF_SUCCESS 表示设置成功 @@ -122,13 +119,13 @@ IThermalInterface::SetCpuFreq ([in] int freq) 设置CPU频率。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | freq | 输入参数,设置CPU频率的值。 | -**返回:** +**返回:** HDF_SUCCESS 表示设置成功。 @@ -144,13 +141,13 @@ IThermalInterface::SetGpuFreq ([in] int freq) 设置GPU频率。 -**参数:** +**参数:** | 名称 | 描述 | | -------- | -------- | | freq | 输入参数,设置GPU频率的值。 | -**返回:** +**返回:** HDF_SUCCESS 表示设置成功。 @@ -166,6 +163,6 @@ IThermalInterface::Unregister () 取消注册设备发热状态的回调。 -**返回:** +**返回:** HDF_SUCCESS 表示取消注册成功。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_usb_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_usb_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..214049b2314770756eb8da433404716a06de8503 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_usb_interface.md @@ -0,0 +1,930 @@ +# IUsbInterface + + +## **概述** + +定义USB驱动基本的操作功能。 + +上层USB服务调用相关功能接口,可以打开/关闭设备,获取设备描述符,批量读取/写入数据等。 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OpenDevice](#opendevice) ([in] struct [UsbDev](_usb_dev.md) dev) | 打开设备,建立连接。 | +| [CloseDevice](#closedevice) ([in] struct [UsbDev](_usb_dev.md) dev) | 关闭设备,释放与设备相关的所有系统资源。 | +| [GetDeviceDescriptor](#getdevicedescriptor) ([in] struct [UsbDev](_usb_dev.md) dev, [out] unsigned char[] descriptor) | 获取设备描述符,设备描述符提供了关于设备、设备的配置以及任何设备所归属的类的信息。 | +| [GetStringDescriptor](#getstringdescriptor) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char descId, [out] unsigned char[] descriptor) | 根据设备的字符串ID获取字符串描述符,字符串描述符是提供一些设备接口相关的描述性信息,比如厂商的名字、产品序列号等。 | +| [GetConfigDescriptor](#getconfigdescriptor) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char descId, [out] unsigned char[] descriptor) | 根据设备的配置ID获取配置描述符,配置描述符包含有关配置及其接口、备用设置及其终结点的信息。 | +| [GetRawDescriptor](#getrawdescriptor) ([in] struct [UsbDev](_usb_dev.md) dev, [out] unsigned char[] descriptor) | 获取USB设备的原始描述符。 | +| [GetFileDescriptor](#getfiledescriptor) ([in] struct [UsbDev](_usb_dev.md) dev, [out] int fd) | 获取USB设备的文件描述符。 | +| [SetConfig](#setconfig) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char configIndex) | 设置USB设备当前的配置信息,USB设备被主机配置过后,主机可以使用设备提供的所有功能。 | +| [GetConfig](#getconfig) ([in] struct [UsbDev](_usb_dev.md) dev, [out] unsigned char configIndex) | 获取USB设备当前的配置信息。 | +| [ClaimInterface](#claiminterface) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char interfaceid, [in] unsigned char force) | 打开USB设备的接口并声明独占,必须在数据传输前执行。 | +| [ReleaseInterface](#releaseinterface) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char interfaceid) | 在停止数据传输后关闭占用的USB设备接口,并释放相关资源。 | +| [SetInterface](#setinterface) ([in] struct [UsbDev](_usb_dev.md) dev, [in] unsigned char interfaceid, [in] unsigned char altIndex) | 设置USB设备指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择。 | +| [BulkTransferRead](#bulktransferread) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [out] unsigned char[] data) | 在USB设备指定端点方向为读取时,执行批量数据读取。 | +| [BulkTransferWrite](#bulktransferwrite) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [in] unsigned char[] data) | 在USB设备指定端点方向为写入时,执行批量数据写入。 | +| [ControlTransferRead](#controltransferread) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbCtrlTransfer](_usb_ctrl_transfer.md) ctrl, [out] unsigned char[] data) | 在传输状态为读取并且控制端点是端点零时,对USB设备执行控制传输。 | +| [ControlTransferWrite](#controltransferwrite) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbCtrlTransfer](_usb_ctrl_transfer.md) ctrl, [in] unsigned char[] data) | 在传输状态为写入并且控制端点是端点零时,对USB设备执行控制传输。 | +| [InterruptTransferRead](#interrupttransferread) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [out] unsigned char[] data) | 在USB设备指定端点方向为数据读取时执行中断数据读取。 | +| [InterruptTransferWrite](#interrupttransferwrite) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [in] unsigned char[] data) | 在USB设备指定端点方向为写入时执行中断数据写入。 | +| [IsoTransferRead](#isotransferread) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [out] unsigned char[] data) | 在USB设备指定端点方向为读取时执行等时数据读取。 | +| [IsoTransferWrite](#isotransferwrite) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] int timeout, [in] unsigned char[] data) | 在USB设备指定端点方向为写入时执行等时数据写入。 | +| [RequestQueue](#requestqueue) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] unsigned char[] clientData, [in] unsigned char[] buffer) | 在USB设备指定端点上进行异步数据发送或者接收请求,数据传输方向由端点方向决定。 | +| [RequestWait](#requestwait) ([in] struct [UsbDev](_usb_dev.md) dev, [out] unsigned char[] clientData, [out] unsigned char[] buffer, [in] int timeout) | 等待RequestQueue异步请求的操作结果。 | +| [RequestCancel](#requestcancel) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe) | 取消待处理的数据请求。 | +| [GetCurrentFunctions](#getcurrentfunctions) ([out] int funcs) | 获取USB设备当前的功能(按位域表示)。 | +| [SetCurrentFunctions](#setcurrentfunctions) ([in] int funcs) | 设置USB设备当前的功能(按位域表示)。 | +| [SetPortRole](#setportrole) ([in] int portId, [in] int powerRole, [in] int dataRole) | 设置USB设备端口的角色。 | +| [QueryPort](#queryport) ([out] int portId, [out] int powerRole, [out] int dataRole, [out] int mode) | 查询USB设备端口的当前设置信息。 | +| [BindUsbdSubscriber](#bindusbdsubscriber) ([in] [IUsbdSubscriber](interface_i_usbd_subscriber.md) subscriber) | 绑定订阅者。 | +| [UnbindUsbdSubscriber](#unbindusbdsubscriber) ([in] [IUsbdSubscriber](interface_i_usbd_subscriber.md) subscriber) | 解绑订阅者。 | +| [RegBulkCallback](#regbulkcallback) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] [IUsbdBulkCallback](interface_i_usbd_bulk_callback.md) cb) | 注册批量传输异步回调函数。 | +| [UnRegBulkCallback](#unregbulkcallback) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe) | 注销批量传输异步回调函数。 | +| [BulkRead](#bulkread) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] Ashmem ashmem) | 批量传输异步读数据。 | +| [BulkWrite](#bulkwrite) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe, [in] Ashmem ashmem) | 批量传输异步写数据。 | +| [BulkCancel](#bulkcancel) ([in] struct [UsbDev](_usb_dev.md) dev, [in] struct [UsbPipe](_usb_pipe.md) pipe) | 批量传输异步取消接口,用于取消当前接口的异步批量读写操作。 | + + +## **成员函数说明** + + +### BindUsbdSubscriber() + + +``` +IUsbInterface::BindUsbdSubscriber ([in] IUsbdSubscriber subscriber) +``` + +**描述:** + +绑定订阅者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| subscriber | 订阅者信息,详见[IUsbdSubscriber](interface_i_usbd_subscriber.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### BulkCancel() + + +``` +IUsbInterface::BulkCancel ([in] struct UsbDev dev, [in] struct UsbPipe pipe ) +``` + +**描述:** + +批量传输异步取消接口,用于取消当前接口的异步批量读写操作。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### BulkRead() + + +``` +IUsbInterface::BulkRead ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] Ashmem ashmem ) +``` + +**描述:** + +批量传输异步读数据。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| ashmem | 共享内存,用于存放读取的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### BulkTransferRead() + + +``` +IUsbInterface::BulkTransferRead ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为读取时,执行批量数据读取。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 读取的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### BulkTransferWrite() + + +``` +IUsbInterface::BulkTransferWrite ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为写入时,执行批量数据写入。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 写入的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### BulkWrite() + + +``` +IUsbInterface::BulkWrite ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] Ashmem ashmem ) +``` + +**描述:** + +批量传输异步写数据。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| ashmem | 为共享内存,用于存放需要写入的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### ClaimInterface() + + +``` +IUsbInterface::ClaimInterface ([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char force ) +``` + +**描述:** + +打开USB设备的接口并声明独占,必须在数据传输前执行。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| interfaceid | USB设备接口ID。 | +| force | 是否强制,1表示强制,0表示不强制。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### CloseDevice() + + +``` +IUsbInterface::CloseDevice ([in] struct UsbDev dev) +``` + +**描述:** + +关闭设备,释放与设备相关的所有系统资源。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### ControlTransferRead() + + +``` +IUsbInterface::ControlTransferRead ([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [out] unsigned char[] data ) +``` + +**描述:** + +在传输状态为读取并且控制端点是端点零时,对USB设备执行控制传输。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| ctrl | USB设备控制数据,详见[UsbCtrlTransfer](_usb_ctrl_transfer.md)。 | +| data | 读取的数据。 | + +**返回:** + +0 表示成功。 + +非零值 表示失败。 + + +### ControlTransferWrite() + + +``` +IUsbInterface::ControlTransferWrite ([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [in] unsigned char[] data ) +``` + +**描述:** + +在传输状态为写入并且控制端点是端点零时,对USB设备执行控制传输。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| ctrl | USB设备控制数据,详见[UsbCtrlTransfer](_usb_ctrl_transfer.md)。 | +| data | 写入的数据。 | + +**返回:** + +0 表示成功。 + +非零值 表示失败。 + + +### GetConfig() + + +``` +IUsbInterface::GetConfig ([in] struct UsbDev dev, [out] unsigned char configIndex ) +``` + +**描述:** + +获取USB设备当前的配置信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| configIndex | USB设备配置信息的字符串描述符索引值(数字字符串)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetConfigDescriptor() + + +``` +IUsbInterface::GetConfigDescriptor ([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor ) +``` + +**描述:** + +根据设备的配置ID获取配置描述符,配置描述符包含有关配置及其接口、备用设置及其终结点的信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| descId | USB设备的配置ID。 | +| descriptor | 获取USB设备配置信息。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetCurrentFunctions() + + +``` +IUsbInterface::GetCurrentFunctions ([out] int funcs) +``` + +**描述:** + +获取USB设备当前的功能(按位域表示)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| funcs | 设备当前的功能值。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetDeviceDescriptor() + + +``` +IUsbInterface::GetDeviceDescriptor ([in] struct UsbDev dev, [out] unsigned char[] descriptor ) +``` + +**描述:** + +获取设备描述符,设备描述符提供了关于设备、设备的配置以及任何设备所归属的类的信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| descriptor | USB设备的描述符信息。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetFileDescriptor() + + +``` +IUsbInterface::GetFileDescriptor ([in] struct UsbDev dev, [out] int fd ) +``` + +**描述:** + +获取USB设备的文件描述符。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| fd | USB设备的文件描述符。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetRawDescriptor() + + +``` +IUsbInterface::GetRawDescriptor ([in] struct UsbDev dev, [out] unsigned char[] descriptor ) +``` + +**描述:** + +获取USB设备的原始描述符。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| descriptor | USB设备的原始描述符。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### GetStringDescriptor() + + +``` +IUsbInterface::GetStringDescriptor ([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor ) +``` + +**描述:** + +根据设备的字符串ID获取字符串描述符,字符串描述符是提供一些设备接口相关的描述性信息,比如厂商的名字、产品序列号等。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| descId | USB设备的描述符ID。 | +| descriptor | 获取USB设备的字符串描述符。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### InterruptTransferRead() + + +``` +IUsbInterface::InterruptTransferRead ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为数据读取时执行中断数据读取。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 读取的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### InterruptTransferWrite() + + +``` +IUsbInterface::InterruptTransferWrite ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为写入时执行中断数据写入。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 写入的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### IsoTransferRead() + + +``` +IUsbInterface::IsoTransferRead ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为读取时执行等时数据读取。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 读取的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### IsoTransferWrite() + + +``` +IUsbInterface::IsoTransferWrite ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data ) +``` + +**描述:** + +在USB设备指定端点方向为写入时执行等时数据写入。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| timeout | 超时时间。 | +| data | 写入的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### OpenDevice() + + +``` +IUsbInterface::OpenDevice ([in] struct UsbDev dev) +``` + +**描述:** + +打开设备,建立连接。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### QueryPort() + + +``` +IUsbInterface::QueryPort ([out] int portId, [out] int powerRole, [out] int dataRole, [out] int mode ) +``` + +**描述:** + +查询USB设备端口的当前设置信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| portId | USB设备端口ID。 | +| powerRole | USB设备电源角色。 | +| dataRole | USB设备数据角色。 | +| mode | USB设备模式。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### RegBulkCallback() + + +``` +IUsbInterface::RegBulkCallback ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] IUsbdBulkCallback cb ) +``` + +**描述:** + +注册批量传输异步回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| cb | 回调函数对象,详见[IUsbdBulkCallback](interface_i_usbd_bulk_callback.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### ReleaseInterface() + + +``` +IUsbInterface::ReleaseInterface ([in] struct UsbDev dev, [in] unsigned char interfaceid ) +``` + +**描述:** + +在停止数据传输后关闭占用的USB设备接口,并释放相关资源。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| interfaceid | USB设备接口ID。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### RequestCancel() + + +``` +IUsbInterface::RequestCancel ([in] struct UsbDev dev, [in] struct UsbPipe pipe ) +``` + +**描述:** + +取消待处理的数据请求。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### RequestQueue() + + +``` +IUsbInterface::RequestQueue ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] unsigned char[] clientData, [in] unsigned char[] buffer ) +``` + +**描述:** + +在USB设备指定端点上进行异步数据发送或者接收请求,数据传输方向由端点方向决定。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | +| clientData | 用户数据。 | +| buffer | 传输的数据。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### RequestWait() + + +``` +IUsbInterface::RequestWait ([in] struct UsbDev dev, [out] unsigned char[] clientData, [out] unsigned char[] buffer, [in] int timeout ) +``` + +**描述:** + +等待RequestQueue异步请求的操作结果。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| clientData | 用户数据。 | +| buffer | 传输的数据。 | +| timeout | 超时时间。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### SetConfig() + + +``` +IUsbInterface::SetConfig ([in] struct UsbDev dev, [in] unsigned char configIndex ) +``` + +**描述:** + +设置USB设备当前的配置信息,USB设备被主机配置过后,主机可以使用设备提供的所有功能。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| configIndex | USB设备配置信息的字符串描述符索引值(数字字符串)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### SetCurrentFunctions() + + +``` +IUsbInterface::SetCurrentFunctions ([in] int funcs) +``` + +**描述:** + +设置USB设备当前的功能(按位域表示)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| funcs | 待设置的设备功能值。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### SetInterface() + + +``` +IUsbInterface::SetInterface ([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char altIndex ) +``` + +**描述:** + +设置USB设备指定接口的备选设置,用于在具有相同ID但不同备用设置的两个接口之间进行选择。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| interfaceid | USB设备接口ID。 | +| altIndex | USB设备接口的备用设置信息。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### SetPortRole() + + +``` +IUsbInterface::SetPortRole ([in] int portId, [in] int powerRole, [in] int dataRole ) +``` + +**描述:** + +设置USB设备端口的角色。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| portId | USB设备端口ID。 | +| powerRole | 电源角色的值。 | +| dataRole | 数据角色的值。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### UnbindUsbdSubscriber() + + +``` +IUsbInterface::UnbindUsbdSubscriber ([in] IUsbdSubscriber subscriber) +``` + +**描述:** + +解绑订阅者。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| subscriber | 订阅者信息,详见[IUsbdSubscriber](interface_i_usbd_subscriber.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### UnRegBulkCallback() + + +``` +IUsbInterface::UnRegBulkCallback ([in] struct UsbDev dev, [in] struct UsbPipe pipe ) +``` + +**描述:** + +注销批量传输异步回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| dev | USB设备地址信息,详见[UsbDev](_usb_dev.md)。 | +| pipe | USB设备管道信息,详见[UsbPipe](_usb_pipe.md)。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_bulk_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_bulk_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..e533f6c6902b02b964b700fc67d532c4434145c4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_bulk_callback.md @@ -0,0 +1,84 @@ +# IUsbdBulkCallback + + +## **概述** + +USB驱动的回调函数。 + +当USB驱动进行批量传输异步读/写数据时调用回调函数,处理对应的结果。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [OnBulkWriteCallback](#onbulkwritecallback) ([in] int status, [in] int actLength) | 批量写数据的回调函数。 | +| [OnBulkReadCallback](#onbulkreadcallback) ([in] int status, [in] int actLength) | 批量读数据的回调函数。 | + + +## **成员函数说明** + + +### OnBulkReadCallback() + + +``` +IUsbdBulkCallback::OnBulkReadCallback ([in] int status, [in] int actLength ) +``` + +**描述:** + +批量读数据的回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| status | 完成状态。 | +| actLength | 读数据时实际接收的数据长度。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### OnBulkWriteCallback() + + +``` +IUsbdBulkCallback::OnBulkWriteCallback ([in] int status, [in] int actLength ) +``` + +**描述:** + +批量写数据的回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| status | 完成状态。 | +| actLength | 写数据时实际发送的数据长度。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_subscriber.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_subscriber.md new file mode 100644 index 0000000000000000000000000000000000000000..bcd7aef290c7cda9b8f80c06b3e51d98bf43140a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_usbd_subscriber.md @@ -0,0 +1,74 @@ +# IUsbdSubscriber + + +## **概述** + +定义USB驱动的订阅类相关函数。 + +当设备接入/断开会调用DeviceEvent进行信息上报。 当端口状态发生变化时会调用PortChangedEvent进行信息上报。 + +**相关模块:** + +[USB](usb.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [DeviceEvent](#deviceevent) ([in] struct [USBDeviceInfo](_u_s_b_device_info.md) info) | 设备状态改变事件。 | +| [PortChangedEvent](#portchangedevent) ([in] struct [PortInfo](_port_info.md) info) | 端口改变事件。 | + + +## **成员函数说明** + + +### DeviceEvent() + + +``` +IUsbdSubscriber::DeviceEvent ([in] struct USBDeviceInfo info) +``` + +**描述:** + +设备状态改变事件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| UsbInfo | USB设备信息。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 + + +### PortChangedEvent() + + +``` +IUsbdSubscriber::PortChangedEvent ([in] struct PortInfo info) +``` + +**描述:** + +端口改变事件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| info | 端口信息。 | + +**返回:** + +0 表示操作成功。 + +非零值 表示操作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md index 9471fe3dcd50cd9a9eb64b937221e654fb0d024a..d6309d369b6fc7b664bc41c488f4a06ece3d08af 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md @@ -3,52 +3,49 @@ ## **概述** -**所属模块:** +声明用户认证驱动的API接口。 -[HdfUserAuth](_hdf_user_auth.md) +**Since:** +3.2 -## **汇总** +**Version:** +1.0 -### Public 成员函数 +**所属模块:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [Init](#init) () | 初始化用户认证驱动缓存信息,用于用户认证框架进程启动时初始化信息。 [更多...](#init) | -| [AddExecutor](#addexecutor) ([in] struct [ExecutorRegisterInfo](_executor_register_info.md) info, [out] unsigned long index, [out] unsigned char[] publicKey, [out] unsigned long[] templateIds) | 添加认证执行器来获取认证能力,用于各认证基础服务如口令认证服务等将认证能力对接到用户认证框架。 [更多...](#addexecutor) | -| [DeleteExecutor](#deleteexecutor) ([in] unsigned long index) | 删除执行器,用于清理失效的执行器信息。 [更多...](#deleteexecutor) | -| [OpenSession](#opensession) ([in] int userId, [out] unsigned char[] challenge) | 开启一个认证凭据管理会话,用于在请求管理用户认证凭据前获取有效挑战值。 [更多...](#opensession) | -| [CloseSession](#closesession) ([in] int userId) | 关闭认证凭据管理会话,完成用户认证凭据管理请求处理后,调用该接口使原挑战值失效。 [更多...](#closesession) | -| [BeginEnrollment](#beginenrollment) ([in] int userId, [in] unsigned char[] authToken, [in] struct [EnrollParam](_enroll_param.md) param, [out] struct [ScheduleInfo](_schedule_info.md) info) | 开始注册用户认证凭据。当注册凭据类型为口令且该用户已经注册了口令凭据时,将会更新口令凭据。 [更多...](#beginenrollment) | -| [UpdateEnrollmentResult](#updateenrollmentresult) ([in] int userId, [in] unsigned char[] scheduleResult, [out] unsigned long credentialId, [out] struct [CredentialInfo](_credential_info.md) oldInfo) | 更新用户凭据注册结果,完成凭据注册。 [更多...](#updateenrollmentresult) | -| [CancelEnrollment](#cancelenrollment) ([in] int userId) | 取消注册请求。 [更多...](#cancelenrollment) | -| [DeleteCredential](#deletecredential) ([in] int userId, [in] unsigned long credentialId, [in] unsigned char[] authToken, [out] struct [CredentialInfo](_credential_info.md) info) | 删除用户凭据信息。 [更多...](#deletecredential) | -| [GetCredential](#getcredential) ([in] int userId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [out] struct [CredentialInfo](_credential_info.md)[] infos) | 查询用户凭据信息。 [更多...](#getcredential) | -| [GetUserInfo](#getuserinfo) ([in] int userId, [out] unsigned long secureUid, [out] enum PinSubType pinSubType, [out] struct [EnrolledInfo](_enrolled_info.md)[] infos) | 查询用户认证相关信息。 [更多...](#getuserinfo) | -| [DeleteUser](#deleteuser) ([in] int userId, [in] unsigned char[] authToken, [out] struct [CredentialInfo](_credential_info.md)[] deletedInfos) | 删除用户口令认证凭据,在用户IAM系统内删除该用户,该请求由用户触发。 [更多...](#deleteuser) | -| [EnforceDeleteUser](#enforcedeleteuser) ([in] int userId, [out] struct [CredentialInfo](_credential_info.md)[] deletedInfos) | 强制删除用户,该请求由系统内管理用户的模块触发。 [更多...](#enforcedeleteuser) | -| [BeginAuthentication](#beginauthentication) ([in] unsigned long contextId, [in] struct [AuthSolution](_auth_solution.md) param, [out] struct [ScheduleInfo](_schedule_info.md)[] scheduleInfos) | 开始认证用户,并生成认证方案。 [更多...](#beginauthentication) | -| [UpdateAuthenticationResult](#updateauthenticationresult) ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct [AuthResultInfo](_auth_result_info.md) info) | 更新认证结果,评估认证方案的认证结果。 [更多...](#updateauthenticationresult) | -| [CancelAuthentication](#cancelauthentication) ([in] unsigned long contextId) | 取消用户认证请求。 [更多...](#cancelauthentication) | -| [BeginIdentification](#beginidentification) ([in] unsigned long contextId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [in] unsigned char[] challenge, [in] unsigned int executorSensorHint, [out] struct [ScheduleInfo](_schedule_info.md) scheduleInfo) | 开始用户身份识别,并生成识别方案。 [更多...](#beginidentification) | -| [UpdateIdentificationResult](#updateidentificationresult) ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct [IdentifyResultInfo](_identify_result_info.md) info) | 更新用户身份识别结果,生成身份识别方案的结果。 [更多...](#updateidentificationresult) | -| [CancelIdentification](#cancelidentification) ([in] unsigned long contextId) | 取消用户身份识别请求。 [更多...](#cancelidentification) | -| [GetAuthTrustLevel](#getauthtrustlevel) ([in] GetUserInfoint userId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [out] unsigned int authTrustLevel) | 获取当前认证类型的认证结果可信等级。 [更多...](#getauthtrustlevel) | -| [GetValidSolution](#getvalidsolution) ([in] int userId, [in] enum [AuthType](_hdf_face_auth.md#authtype)[] authTypes, [in] unsigned int authTrustLevel, [out] enum [AuthType](_hdf_face_auth.md#authtype)[] validTypes) | 获取指定认证结果可信等级下有效的认证方式。 [更多...](#getvalidsolution) | - - -## **详细描述** +[HdfUserAuth](_hdf_user_auth.md) -声明用户认证驱动的API接口。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [Init](#init)() | 初始化用户认证驱动缓存信息,用于用户认证框架进程启动时初始化信息。 | +| [AddExecutor](#addexecutor)([in] struct ExecutorRegisterInfo info, [out] unsigned long index, [out] unsigned char[] publicKey, [out] unsigned long[] templateIds) | 添加认证执行器来获取认证能力,用于各认证基础服务如口令认证服务等将认证能力对接到用户认证框架。 | +| [DeleteExecutor](#deleteexecutor)([in] unsigned long index) | 删除执行器,用于清理失效的执行器信息。 | +| [OpenSession](#opensession)([in] int userId, [out] unsigned char[] challenge) | 开启一个认证凭据管理会话,用于在请求管理用户认证凭据前获取有效挑战值。 | +| [CloseSession](#closesession)([in] int userId) | 关闭认证凭据管理会话,完成用户认证凭据管理请求处理后,调用该接口使原挑战值失效。 | +| [BeginEnrollment](#beginenrollment)([in] int userId, [in] unsigned char[] authToken, [in] struct EnrollParam param, [out] struct ScheduleInfo info) | 开始注册用户认证凭据。当注册凭据类型为口令且该用户已经注册了口令凭据时,将会更新口令凭据。 | +| [UpdateEnrollmentResult](#updateenrollmentresult)([in] int userId, [in] unsigned char[] scheduleResult, [out] unsigned long credentialId, [out] struct CredentialInfo oldInfo) | 更新用户凭据注册结果,完成凭据注册。 | +| [CancelEnrollment](#cancelenrollment)([in] int userId) | 取消注册请求。 | +| [DeleteCredential](#deletecredential)([in] int userId, [in] unsigned long credentialId, [in] unsigned char[] authToken, [out] struct CredentialInfo info) | 删除用户凭据信息。 | +| [GetCredential](#getcredential)([in] int userId, [in] enum AuthType authType, [out] struct CredentialInfo[] infos) | 查询用户凭据信息。 | +| [GetUserInfo](#getuserinfo) ([in] int userId, [out] unsigned long secureUid, [out] enum PinSubType pinSubType, [out] struct EnrolledInfo[] infos) | 查询用户认证相关信息。 | +| [DeleteUser](#deleteuser)([in] int userId, [in] unsigned char[] authToken, [out] struct CredentialInfo[] deletedInfos) | 删除用户口令认证凭据,在用户IAM系统内删除该用户,该请求由用户触发。 | +| [EnforceDeleteUser](#enforcedeleteuser)([in] int userId, [out] struct CredentialInfo[] deletedInfos) | 强制删除用户,该请求由系统内管理用户的模块触发。 | +| [BeginAuthentication](#beginauthentication)([in] unsigned long contextId, [in] struct AuthSolution param, [out] struct ScheduleInfo[] scheduleInfos) | 开始认证用户,并生成认证方案。 | +| [UpdateAuthenticationResult](#updateauthenticationresult)([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct AuthResultInfo info) | 更新认证结果,评估认证方案的认证结果。 | +| [CancelAuthentication](#cancelauthentication)([in] unsigned long contextId) | 取消用户认证请求。 | +| [BeginIdentification](#beginidentification)([in] unsigned long contextId, [in] enum AuthType authType, [in] unsigned char[] challenge, [in] unsigned int executorSensorHint, [out] struct ScheduleInfo scheduleInfo) | 开始用户身份识别,并生成识别方案。 | +| [UpdateIdentificationResult](#updateidentificationresult)([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct IdentifyResultInfo info) | 更新用户身份识别结果,生成身份识别方案的结果。 | +| [CancelIdentification](#cancelidentification)([in] unsigned long contextId) | 取消用户身份识别请求。 | +| [GetAuthTrustLevel](#getauthtrustlevel)([in] GetUserInfoint userId, [in] enum AuthType authType, [out] unsigned int authTrustLevel) | 获取当前认证类型的认证结果可信等级。 | +| [GetValidSolution](#getvalidsolution)([in] int userId, [in] enum AuthType[] authTypes, [in] unsigned int authTrustLevel, [out] enum AuthType[] validTypes) | 获取指定认证结果可信等级下有效的认证方式。 | ## **成员函数说明** @@ -429,7 +426,7 @@ IUserAuthInterface::GetUserInfo([in] int userId, [out] unsigned long secureUid, | -------- | -------- | | userId | 用户ID。 | | secureUid | 安全用户ID。 | -| pinSubType | 口令认证子类型,请参考[PinSubType](_hdf_user_auth.md#pinsubtype)。 | +| pinSubType | 口令认证子类型[PinSubType](_hdf_user_auth.md#pinsubtype)。 | | infos | 注册信息[EnrolledInfo](_enrolled_info.md)。 | **返回:** diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_vibrator_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_vibrator_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..f0e739cef3f20c790d87d3462e5e245689530ba8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_vibrator_interface.md @@ -0,0 +1,169 @@ +# IVibratorInterface + + +## **概述** + +Vibrator模块向上层服务提供统一的接口。 + +上层服务开发人员可根据Vibrator模块提供的统一接口,用于控制马达执行单次或周期性振动。 + +**Since:** + +3.2 + +**Version:** + +1.1 + +**相关模块:** + +[Vibrator](vibrator.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [StartOnce](#startonce) ([in] unsigned int duration) | 控制马达以执行给定持续时间的单次振动。 | +| [Start](#start) ([in] String effectType) | 控制马达以预置效果执行周期性振动。 | +| [Stop](#stop) ([in] enum [HdfVibratorMode](vibrator.md#hdfvibratormode) mode) | 停止马达振动。 | +| [GetVibratorInfo](#getvibratorinfo) ([out] struct [HdfVibratorInfo](_hdf_vibrator_info.md)[] vibratorInfo) | 获取有关系统中支持设置振幅和频率的所有马达信息。 | +| [EnableVibratorModulation](#enablevibratormodulation) ([in] unsigned int duration, [in] int intensity, [in] int frequency) | 根据传入的振动效果启动马达。 | + + +## **成员函数说明** + + +### EnableVibratorModulation() + + +``` +IVibratorInterface::EnableVibratorModulation ([in] unsigned int duration, [in] int intensity, [in] int frequency ) +``` + +**描述:** + +根据传入的振动效果启动马达。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| duration | 表示马达振动的持续时间,以毫秒为单位。 | +| intensity | 表示振动周期内的马达振幅。 | +| frequency | 表示振动周期内的马达频率。 | + +**返回:** + +如果操作成功,则返回0。 + +如果不支持振动周期设置,则返回-1。 + +如果不支持振幅设置,则返回-2。 + +如果不支持频率设置,则返回-3。 + + +### GetVibratorInfo() + + +``` +IVibratorInterface::GetVibratorInfo ([out] struct HdfVibratorInfo[] vibratorInfo) +``` + +**描述:** + +获取有关系统中支持设置振幅和频率的所有马达信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| vibratorInfo | 表示指向马达信息的指针,详见[HdfVibratorInfo](_hdf_vibrator_info.md)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Start() + + +``` +IVibratorInterface::Start ([in] String effectType) +``` + +**描述:** + +控制马达以预置效果执行周期性振动。 + +单次振动与周期振动相互排斥。在执行周期性振动之前,需退出单次振动。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| effectType | 表示马达振动的预设效果类型。建议最大长度为64字节。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### StartOnce() + + +``` +IVibratorInterface::StartOnce ([in] unsigned int duration) +``` + +**描述:** + +控制马达以执行给定持续时间的单次振动。 + +单次振动与周期振动相互排斥。在执行单次振动之前,需退出周期性振动。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| duration | 表示单次振动的持续时间,以毫秒为单位。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Stop() + + +``` +IVibratorInterface::Stop ([in] enum HdfVibratorMode mode) +``` + +**描述:** + +停止马达振动。 + +马达启动前,必须在任何模式下停止振动。此功能用在振动过程之后。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| mode | 表示振动模式,可以是单次或周期性的,详见[HdfVibratorMode](vibrator.md#hdfvibratormode)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..3fe5e85f25ae6014d60ece20c979fe605223f74c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_callback.md @@ -0,0 +1,99 @@ +# IWlanCallback + + +## **概述** + +定义WLAN模块的回调函数。 + +当WLAN模块发生重启,扫描热点结束,收到Netlink消息后,调用回调函数,处理对应的结果信息。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [ResetDriverResult](#resetdriverresult) ([in] unsigned int event, [in] int code, [in] String ifName) | 重启WLAN驱动的结果处理回调方法。 | +| [ScanResult](#scanresult) ([in] unsigned int event, [in] struct [HdfWifiScanResult](_hdf_wifi_scan_result.md) scanResult, [in] String ifName) | 扫描结果的回调方法。 | +| [WifiNetlinkMessage](#wifinetlinkmessage) ([in] unsigned char[] recvMsg) | Netlink消息的回调方法。 | + + +## **成员函数说明** + + +### ResetDriverResult() + + +``` +IWlanCallback::ResetDriverResult ([in] unsigned int event, [in] int code, [in] String ifName ) +``` + +**描述:** + +重启WLAN驱动的结果处理回调方法。 + +当重启WLAN驱动后,调用此接口处理驱动重启后的返回结果。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 重启驱动的事件ID。 | +| code | 重启驱动后返回的结果数据。 | +| ifName | 网卡名称。 | + + +### ScanResult() + + +``` +IWlanCallback::ScanResult ([in] unsigned int event, [in] struct HdfWifiScanResult scanResult, [in] String ifName ) +``` + +**描述:** + +扫描结果的回调方法。 + +当扫描结束后,将通过此方法处理返回的扫描结果数据。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| event | 扫描结果的事件ID。 | +| scanResult | 扫描结果数据。 | +| ifName | 网卡名称。 | + + +### WifiNetlinkMessage() + + +``` +IWlanCallback::WifiNetlinkMessage ([in] unsigned char[] recvMsg) +``` + +**描述:** + +Netlink消息的回调方法。 + +当收到Netlink消息后,将通过此方法处理收到的消息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| recvMsg | 收到的Netlink消息。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..33df7f747fb979dce5515f83a1de25e930e4a3fd --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_wlan_interface.md @@ -0,0 +1,801 @@ +# IWlanInterface + + +## **概述** + +WLAN模块向上层WLAN服务提供了统一接口。 + +上层服务调用相关的接口,可以建立/关闭WLAN热点,扫描/关联/去关联WLAN热点,设置国家码,管理网络设备等。 + +**Since:** + +3.2 + +**Version:** + +1.0 + +**相关模块:** + +[WLAN](wlan.md) + + +## **汇总** + + +### Public 成员函数 + + | 名称 | 描述 | +| -------- | -------- | +| [Start](#start) () | 创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 | +| [Stop](#stop) () | 销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 | +| [CreateFeature](#createfeature) ([in] int type, [out] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 根据输入类型创建对应的feature对象。 | +| [DestroyFeature](#destroyfeature) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 销毁feature对象。 | +| [GetAsscociatedStas](#getasscociatedstas) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] struct [HdfStaInfo](_hdf_sta_info.md)[] staInfo, [out] unsigned int num) | 获取与AP连接的所有STA的信息(目前只包含MAC地址)。 | +| [GetChipId](#getchipid) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char chipId) | 获得当前驱动的芯片ID。 | +| [GetDeviceMacAddress](#getdevicemacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char[] mac, [in] unsigned char len) | 获取设备的MAC地址。 | +| [GetFeatureByIfName](#getfeaturebyifname) ([in] String ifName, [out] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature) | 通过网卡名称获取对应的feature对象。 | +| [GetFeatureType](#getfeaturetype) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] int featureType) | 获取feature对象的类型。 | +| [GetFreqsWithBand](#getfreqswithband) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] struct [HdfWifiInfo](_hdf_wifi_info.md) wifiInfo, [out] int[] freq) | 获取指定频段(2.4G或者5G)下支持的频率。 | +| [GetIfNamesByChipId](#getifnamesbychipid) ([in] unsigned char chipId, [out] String ifName, [out] unsigned int num) | 通过芯片ID获得当前芯片所有的网卡名称。 | +| [GetNetworkIfaceName](#getnetworkifacename) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] String ifName) | 根据feature对象获取网卡名称。 | +| [GetSupportCombo](#getsupportcombo) ([out] unsigned long combo) | 获取多网卡共存情况。 | +| [GetSupportFeature](#getsupportfeature) ([out] unsigned char[] supType) | 获取该设备支持的WLAN特性(不考虑当前的使用状态)。 | +| [RegisterEventCallback](#registereventcallback) ([in] [IWlanCallback](interface_i_wlan_callback.md) cbFunc, [in] String ifName) | 注册IWiFi的回调函数,监听异步事件。 | +| [UnregisterEventCallback](#unregistereventcallback) ([in] [IWlanCallback](interface_i_wlan_callback.md) cbFunc, [in] String ifName) | 去注册IWiFi的回调函数。 | +| [ResetDriver](#resetdriver) ([in] unsigned char chipId, [in] String ifName) | 重启指定芯片ID的WLAN驱动程序。 | +| [SetCountryCode](#setcountrycode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] String code, [in] unsigned int len) | 设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 | +| [SetMacAddress](#setmacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char[] mac) | 根据传入参数设置对应网卡的MAC地址。 | +| [SetScanningMacAddress](#setscanningmacaddress) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char[] scanMac) | 设置扫描单个MAC地址。 | +| [SetTxPower](#settxpower) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] int power) | 设置发射功率。 | +| [GetNetDevInfo](#getnetdevinfo) ([out] struct [HdfNetDeviceInfoResult](_hdf_net_device_info_result.md) netDeviceInfoResult) | 获取网络设备信息(设备索引、网卡名字、MAC等信息)。 | +| [StartScan](#startscan) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] struct [HdfWifiScan](_hdf_wifi_scan.md) scan) | 启动扫描。 | +| [GetPowerMode](#getpowermode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [out] unsigned char mode) | 获取正在使用的功率模式。 | +| [SetPowerMode](#setpowermode) ([in] struct [HdfFeatureInfo](_hdf_feature_info.md) ifeature, [in] unsigned char mode) | 设置功率模式。 | +| [StartChannelMeas](#startchannelmeas) ([in] String ifName, [in] struct [MeasChannelParam](_meas_channel_param.md) measChannelParam) | 启动信道测量。 | +| [GetChannelMeasResult](#getchannelmeasresult) ([in] String ifName, [out] struct [MeasChannelResult](_meas_channel_result.md) measChannelResult) | 获取信道测量结果。 | +| [SetProjectionScreenParam](#setprojectionscreenparam) ([in] String ifName, [in] struct [ProjectionScreenCmdParam](_projection_screen_cmd_param.md) param) | 设置投屏参数。 | +| [WifiSendCmdIoctl](#wifisendcmdioctl) ([in] String ifName, [in] int cmdId, [in] byte[] paramBuf) | 向驱动发送IO控制命令。 | +| [GetStaInfo](#getstainfo) ([in] String ifName, [out] struct [WifiStationInfo](_wifi_station_info.md) info, [in] unsigned char[] mac) | 获取指定网卡的STA的信息。 | + + +## **成员函数说明** + + +### CreateFeature() + + +``` +IWlanInterface::CreateFeature ([in] int type, [out] struct HdfFeatureInfo ifeature ) +``` + +**描述:** + +根据输入类型创建对应的feature对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| type | 创建的feature类型。 | +| ifeature | 获取创建的feature对象。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### DestroyFeature() + + +``` +IWlanInterface::DestroyFeature ([in] struct HdfFeatureInfo ifeature) +``` + +**描述:** + +销毁feature对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | 销毁的feature对象。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetAsscociatedStas() + + +``` +IWlanInterface::GetAsscociatedStas ([in] struct HdfFeatureInfo ifeature, [out] struct HdfStaInfo[] staInfo, [out] unsigned int num ) +``` + +**描述:** + +获取与AP连接的所有STA的信息(目前只包含MAC地址)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| staInfo | 保存与AP连接的STA的基本信息。 | +| num | 实际连接的STA的个数。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetChannelMeasResult() + + +``` +IWlanInterface::GetChannelMeasResult ([in] String ifName, [out] struct MeasChannelResult measChannelResult ) +``` + +**描述:** + +获取信道测量结果。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| measChannelResult | 信道测量结果(信道号、信道负载、信道噪声)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetChipId() + + +``` +IWlanInterface::GetChipId ([in] struct HdfFeatureInfo ifeature, [out] unsigned char chipId ) +``` + +**描述:** + +获得当前驱动的芯片ID。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| chipId | 获得的芯片ID。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetDeviceMacAddress() + + +``` +IWlanInterface::GetDeviceMacAddress ([in] struct HdfFeatureInfo ifeature, [out] unsigned char[] mac, [in] unsigned char len ) +``` + +**描述:** + +获取设备的MAC地址。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| mac | 获得的MAC地址。 | +| len | mac数组的长度。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetFeatureByIfName() + + +``` +IWlanInterface::GetFeatureByIfName ([in] String ifName, [out] struct HdfFeatureInfo ifeature ) +``` + +**描述:** + +通过网卡名称获取对应的feature对象。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| ifeature | 获取该网卡的feature对象。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetFeatureType() + + +``` +IWlanInterface::GetFeatureType ([in] struct HdfFeatureInfo ifeature, [out] int featureType ) +``` + +**描述:** + +获取feature对象的类型。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| featureType | feature对象的类型。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetFreqsWithBand() + + +``` +IWlanInterface::GetFreqsWithBand ([in] struct HdfFeatureInfo ifeature, [in] struct HdfWifiInfo wifiInfo, [out] int[] freq ) +``` + +**描述:** + +获取指定频段(2.4G或者5G)下支持的频率。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| wifiInfo | 频段信息。 | +| freq | 保存支持的频率。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetIfNamesByChipId() + + +``` +IWlanInterface::GetIfNamesByChipId ([in] unsigned char chipId, [out] String ifName, [out] unsigned int num ) +``` + +**描述:** + +通过芯片ID获得当前芯片所有的网卡名称。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| chipId | 需要获取网卡名称的芯片ID。 | +| ifNames | 网卡名称。 | +| num | 网卡的数量。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetNetDevInfo() + + +``` +IWlanInterface::GetNetDevInfo ([out] struct HdfNetDeviceInfoResult netDeviceInfoResult) +``` + +**描述:** + +获取网络设备信息(设备索引、网卡名字、MAC等信息)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| netDeviceInfoResult | 输出参数,得到的网络设备信息。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetNetworkIfaceName() + + +``` +IWlanInterface::GetNetworkIfaceName ([in] struct HdfFeatureInfo ifeature, [out] String ifName ) +``` + +**描述:** + +根据feature对象获取网卡名称。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| ifName | 网卡名称。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetPowerMode() + + +``` +IWlanInterface::GetPowerMode ([in] struct HdfFeatureInfo ifeature, [out] unsigned char mode ) +``` + +**描述:** + +获取正在使用的功率模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| mode | 功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetStaInfo() + + +``` +IWlanInterface::GetStaInfo ([in] String ifName, [out] struct WifiStationInfo info, [in] unsigned char[] mac ) +``` + +**描述:** + +获取指定网卡的STA的信息。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| info | 获取的STA的信息,详情请参考[WifiStationInfo](_wifi_station_info.md)。 | +| mac | STA的MAC地址。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetSupportCombo() + + +``` +IWlanInterface::GetSupportCombo ([out] unsigned long combo) +``` + +**描述:** + +获取多网卡共存情况。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| combo | 基于芯片的能力保存当前所有支持的多网卡共存情况(比如支持AP、STA、P2P等不同组合的共存)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### GetSupportFeature() + + +``` +IWlanInterface::GetSupportFeature ([out] unsigned char[] supType) +``` + +**描述:** + +获取该设备支持的WLAN特性(不考虑当前的使用状态)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| supType | 保存当前设备支持的特性。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### RegisterEventCallback() + + +``` +IWlanInterface::RegisterEventCallback ([in] IWlanCallback cbFunc, [in] String ifName ) +``` + +**描述:** + +注册IWiFi的回调函数,监听异步事件。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cbFunc | 注册的回调函数。 | +| ifName | 网卡名称。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### ResetDriver() + + +``` +IWlanInterface::ResetDriver ([in] unsigned char chipId, [in] String ifName ) +``` + +**描述:** + +重启指定芯片ID的WLAN驱动程序。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| chipId | 需要进行重启驱动的芯片ID。 | +| ifName | 网卡名称。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetCountryCode() + + +``` +IWlanInterface::SetCountryCode ([in] struct HdfFeatureInfo ifeature, [in] String code, [in] unsigned int len ) +``` + +**描述:** + +设置国家码(表示AP射频所在的国家,规定了AP射频特性,包括AP的发送功率、支持的信道等。其目的是为了使AP的射频特性符合不同国家或区域的法律法规要求)。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| code | 设置的国家码。 | +| len | 国家码长度。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetMacAddress() + + +``` +IWlanInterface::SetMacAddress ([in] struct HdfFeatureInfo ifeature, [in] unsigned char[] mac ) +``` + +**描述:** + +根据传入参数设置对应网卡的MAC地址。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| mac | 设置的MAC地址。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetPowerMode() + + +``` +IWlanInterface::SetPowerMode ([in] struct HdfFeatureInfo ifeature, [in] unsigned char mode ) +``` + +**描述:** + +设置功率模式。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| mode | 功率模式,包括睡眠模式(待机状态运行)、一般模式(正常额定功率运行)、穿墙模式(最大功率运行,提高信号强度和覆盖面积)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetProjectionScreenParam() + + +``` +IWlanInterface::SetProjectionScreenParam ([in] String ifName, [in] struct ProjectionScreenCmdParam param ) +``` + +**描述:** + +设置投屏参数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| param | 投屏参数。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetScanningMacAddress() + + +``` +IWlanInterface::SetScanningMacAddress ([in] struct HdfFeatureInfo ifeature, [in] unsigned char[] scanMac ) +``` + +**描述:** + +设置扫描单个MAC地址。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| scanMac | 设置STA扫描的MAC地址。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### SetTxPower() + + +``` +IWlanInterface::SetTxPower ([in] struct HdfFeatureInfo ifeature, [in] int power ) +``` + +**描述:** + +设置发射功率。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| power | 设置的发射功率。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Start() + + +``` +IWlanInterface::Start () +``` + +**描述:** + +创建HAL和驱动之间的通道及获取驱动网卡信息,该函数调用在创建IWiFi实体后进行。 + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### StartChannelMeas() + + +``` +IWlanInterface::StartChannelMeas ([in] String ifName, [in] struct MeasChannelParam measChannelParam ) +``` + +**描述:** + +启动信道测量。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| measChannelParam | 信道测量参数(信道号、测量时间)。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### StartScan() + + +``` +IWlanInterface::StartScan ([in] struct HdfFeatureInfo ifeature, [in] struct HdfWifiScan scan ) +``` + +**描述:** + +启动扫描。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifeature | feature对象。 | +| scan | 扫描参数。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### Stop() + + +``` +IWlanInterface::Stop () +``` + +**描述:** + +销毁HAL和驱动之间的通道,该函数调用在销毁IWiFi实体前进行。 + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### UnregisterEventCallback() + + +``` +IWlanInterface::UnregisterEventCallback ([in] IWlanCallback cbFunc, [in] String ifName ) +``` + +**描述:** + +去注册IWiFi的回调函数。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| cbFunc | 去注册的回调函数。 | +| ifName | 网卡名称。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 + + +### WifiSendCmdIoctl() + + +``` +IWlanInterface::WifiSendCmdIoctl ([in] String ifName, [in] int cmdId, [in] byte[] paramBuf ) +``` + +**描述:** + +向驱动发送IO控制命令。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| ifName | 网卡名称。 | +| cmdId | 命令ID。 | +| paramBuf | 命令内容。 | + +**返回:** + +如果操作成功,则返回0。 + +如果操作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md index f2ec31e36bd23413a8d772d66f0b89eb8cb6f72b..dd911a53c9d501fcae7e23004f394a8e35ce17bf 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md @@ -3,40 +3,37 @@ ## **概述** -**所属模块:** - -[HdfPinAuth](_hdf_pin_auth.md) - +定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 -## **汇总** +**Since:** +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [GetTemplateInfo](interface_i_executor.md#gettemplateinfo) ([in] unsigned long templateId, [out] struct [TemplateInfo](_template_info.md) templateInfo) | 获取凭据模版信息。 [更多...](interface_i_executor.md#gettemplateinfo) | -| [Cancel](interface_i_executor.md#cancel) ([in] unsigned long scheduleId) | 取消操作请求。 [更多...](interface_i_executor.md#cancel) | -| [GetExecutorInfo](#getexecutorinfo) ([out] struct [ExecutorInfo](_executor_info.md) executorInfo) | 获取执行器信息,口令认证服务将执行器注册到用户认证框架时需要通过该接口获取对应信息。 [更多...](#getexecutorinfo) | -| [OnRegisterFinish](#onregisterfinish) ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完成执行器注册,对口令模版信息进行对账,用于删除无效的口令模板及相关信息。 [更多...](#onregisterfinish) | -| [OnSetData](interface_i_executor.md#onsetdata) ([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data) | 设置口令数据,口令认证驱动处理注册或认证口令请求时,如果口令数据由口令认证服务获取,需要通过该接口将口令数据传给口令认证驱动。 [更多...](interface_i_executor.md#onsetdata) | -| [Enroll](#enroll) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | 注册口令。 [更多...](#enroll) | -| [Authenticate](#authenticate) ([in] unsigned long scheduleId, [in] unsigned long templateId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | 认证口令。 [ERROR:Invalid link:zh-cn_topic_0000001304382272.xml#xref15713627408,link:zh-cn_topic_0000001304382272.xml](zh-cn_topic_0000001304382272.xml) | -| [Delete](#delete) ([in] unsigned long templateId) | 删除口令。 [更多...](#delete) | -| [SendCommand](#sendcommand) ([in] int commandId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | 发送口令认证功能相关操作命令。 [更多...](#sendcommand) | +1.0 +**所属模块:** -## **详细描述** +[HdfPinAuth](_hdf_pin_auth.md) -定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [GetTemplateInfo](#gettemplateinfo)([in] unsigned long templateId, [out] struct TemplateInfo templateInfo) | 获取凭据模版信息。 | +| [Cancel](#cancel)([in] unsigned long scheduleId) | 取消操作请求。 | +| [GetExecutorInfo](#getexecutorinfo) ([out] struct ExecutorInfo executorInfo) | 获取执行器信息,口令认证服务将执行器注册到用户认证框架时需要通过该接口获取对应信息。 | +| [OnRegisterFinish](#onregisterfinish) ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完成执行器注册,对口令模版信息进行对账,用于删除无效的口令模板及相关信息。 | +| [OnSetData](#onsetdata)([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data) | 设置口令数据,口令认证驱动处理注册或认证口令请求时,如果口令数据由口令认证服务获取,需要通过该接口将口令数据传给口令认证驱动。 | +| [Enroll](#enroll) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 注册口令。 | +| [Authenticate](#authenticate) ([in] unsigned long scheduleId, [in] unsigned long templateId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 认证口令。 | +| [Delete](#delete) ([in] unsigned long templateId) | 删除口令。 | +| [SendCommand](#sendcommand) ([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 发送口令认证功能相关操作命令。 | ## **成员函数说明** @@ -259,7 +256,7 @@ IExecutor::SendCommand ([in] int commandId, [in] unsigned char[] extraInfo, [in] | 名称 | 描述 | | -------- | -------- | -| commandId | 操作命令ID[CommandId](_hdf_pin_auth.md#commandid)。 | +| commandId | 操作命令ID。 | | extraInfo | 其他相关信息,用于支持信息扩展。 | | callbackObj | 回调对象[IExecutorCallback](interface_pin_i_executor_callback.md)。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md index afa114d1d6713248b831ebbca7933c13e947da39..e0d8afed7239953c8881233d67d6edb244c075a1 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md @@ -3,33 +3,30 @@ ## **概述** -**所属模块:** - -[HdfPinAuth](_hdf_pin_auth.md) +定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 +**Since:** -## **汇总** - +3.2 -### Public 成员函数 +**Version:** - | Public 成员函数 | 描述 | -| -------- | -------- | -| [OnResult](interface_i_executor_callback.md#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义操作结果回调函数。 [更多...](interface_i_executor_callback.md#onresult) | -| [OnGetData](#ongetdata) ([in] unsigned long scheduleId, [in] unsigned char[] salt, [in] unsigned long authSubType) | 定义请求获取口令数据回调函数。 [更多...](#ongetdata) | +1.0 +**所属模块:** -## **详细描述** +[HdfPinAuth](_hdf_pin_auth.md) -定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_i_executor.md)。 -**Since:** +## **汇总** -3.2 -**Version:** +### Public 成员函数 -1.0 + | 名称 | 描述 | +| -------- | -------- | +| [OnResult](#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义操作结果回调函数。 | +| [OnGetData](#ongetdata) ([in] unsigned long scheduleId, [in] unsigned char[] salt, [in] unsigned long authSubType) | 定义请求获取口令数据回调函数。 | ## **成员函数说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md b/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md deleted file mode 100644 index 0a593960df15b13fa7993604729fe44d422f52a7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# ioffline_stream_operator.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | 离线流的操作类。 | - - -## **详细描述** - -离线流的操作接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md b/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md deleted file mode 100644 index a051ce63222611aef21f4be9f21e1c972b6468ba..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# istream_operator.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | 流的操作类。 | - - -## **详细描述** - -流的操作接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md deleted file mode 100644 index 79f5e3d8b480e208e732160c760498ea84515517..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# istream_operator_callback.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | 流的操作回调类。 | - - -## **详细描述** - -[IStreamOperator](istream__operator_8h.md) 相关的回调,这些回调均由调用者实现。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/light.md b/zh-cn/device-dev/reference/hdi-apis/light.md new file mode 100644 index 0000000000000000000000000000000000000000..dd499b06f0a262abb527523c1179f53b245a78c7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/light.md @@ -0,0 +1,97 @@ +# Light + + +## **概述** + +灯驱动对灯服务提供通用的接口能力。 + +灯模块为灯服务提供通用的接口去访问灯驱动,服务获取灯驱动对象或代理后,可以通过调用的APIs接口获取相关的灯信息。 例如打开或关闭灯、根据灯类型ID设置灯闪烁模式。 + +**Since**: + +3.1 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [ILightInterface.idl](_i_light_interface_8idl.md) | 定义灯模块的通用接口能力,包括获取灯类型ID、打开或关闭灯光、设置灯的亮度和闪烁模式。 | +| [LightTypes.idl](_light_types_8idl.md) | 定义灯的数据结构,包括灯类型ID、灯的基本信息、灯的模式、灯的闪烁参数、灯的颜色模式和灯的效果参数。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ILightInterface](interface_i_light_interface.md) | 提供灯模块基本操作接口。 | +| [HdfLightInfo](_hdf_light_info.md) | 定义灯的基本信息。 | +| [HdfLightFlashEffect](_hdf_light_flash_effect.md) | 定义灯的闪烁参数。 | +| [RGBColor](_r_g_b_color.md) | 定义灯的RGB模式。 | +| [WRGBColor](_w_r_g_b_color.md) | 定义灯的WRGB模式。 | +| [ColorValue](union_color_value.md) | 定义灯的颜色模式。 | +| [HdfLightColor](_hdf_light_color.md) | 定义亮灯参数。 | +| [HdfLightEffect](_hdf_light_effect.md) | 定义灯的效果参数。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfLightId](#hdflightid) { HDF_LIGHT_ID_BATTERY = 1, HDF_LIGHT_ID_NOTIFICATIONS = 2, HDF_LIGHT_ID_ATTENTION = 3, HDF_LIGHT_ID_BUTT = 4 } | 枚举灯类型。 | +| [HdfLightFlashMode](#hdflightflashmode) { HDF_LIGHT_FLASH_NONE = 0, HDF_LIGHT_FLASH_TIMED = 1, HDF_LIGHT_FLASH_GRADIENT = 2, HDF_LIGHT_FLASH_BUTT = 2 } | 枚举灯的模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.light.v1_0 | 灯模块接口的包路径。 | + + +## **枚举类型说明** + + +### HdfLightFlashMode + + +``` +enum HdfLightFlashMode +``` + +**描述:** + +枚举灯的模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_LIGHT_FLASH_NONE | 常亮模式。 | +| HDF_LIGHT_FLASH_TIMED | 闪烁模式。 | +| HDF_LIGHT_FLASH_GRADIENT | 渐变。 | +| HDF_LIGHT_FLASH_BUTT | 无效模式。 | + + +### HdfLightId + + +``` +enum HdfLightId +``` + +**描述:** + +枚举灯类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_LIGHT_ID_BATTERY | 电源指示灯。 | +| HDF_LIGHT_ID_NOTIFICATIONS | 通知灯。 | +| HDF_LIGHT_ID_ATTENTION | 报警灯。 | +| HDF_LIGHT_ID_BUTT | 无效ID。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md b/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md deleted file mode 100644 index 55be372ba23701d13dd838bfbc217c0e0e10523b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md +++ /dev/null @@ -1,33 +0,0 @@ -# light_type.h - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### 类 - -| 类 | 描述 | -| -------- | -------- | -| LightFlashEffect | 定义闪烁参数。 [更多...](_light_flash_effect.md) | -| LightEffect | 定义灯的效果参数。 [更多...](_light_effect.md) | -| LightInfo | 定义灯的基本信息。 [更多...](_light_info.md) | - - -## **详细描述** - -声明light模块的通用API,可用于获取灯ID、打开或关闭灯、并设置灯光亮度和闪烁模式。 - -**Since:** - -3.1 - -**Version:** - -1.0 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md deleted file mode 100644 index 989dc4180adaaf06f1dd227e2976a82aaf775830..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md +++ /dev/null @@ -1,40 +0,0 @@ -# light_if.h - - -## **概述** - -**所属模块:** - -[Light](_light.md) - - -## **汇总** - - -### 类 - -| 类 | 描述 | -| -------- | -------- | -| [LightInterface](_light_interface.md) | 定义可以在灯上执行的基本操作。 [更多...](_light_interface.md) | - - -### 函数 - -| 函数 | 描述 | -| -------- | -------- | -| [NewLightInterfaceInstance](_light.md#newlightinterfaceinstance) (void) | 创建LightInterface实例。 [更多...](_light.md#newlightinterfaceinstance) | -| [FreeLightInterfaceInstance](_light.md#freelightinterfaceinstance) (void) | 释放LightInterface实例和相关资源。 [更多...](_light.md#freelightinterfaceinstance) | - - -## **详细描述** - -声明light模块的通用API,可用于获取灯ID、打开或关闭灯、并设置灯光亮度和闪烁模式。 - -**Since:** - -3.1 - -**Version:** - -1.0 - diff --git a/zh-cn/device-dev/reference/hdi-apis/modulelist.md b/zh-cn/device-dev/reference/hdi-apis/modulelist.md new file mode 100644 index 0000000000000000000000000000000000000000..a0969df08272de3d04f006ea7643d30eec42deed --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/modulelist.md @@ -0,0 +1,39 @@ +# 模块 + + + +- **[Audio](_audio.md)** + +- **[Battery](battery.md)** + +- **[Camera](camera.md)** + +- **[Codec](codec.md)** + +- **[Display](_display.md)** + +- **[HdfFaceAuth](_hdf_face_auth.md)** + +- **[HdfPinAuth](_hdf_pin_auth.md)** + +- **[HdfUserAuth](_hdf_user_auth.md)** + +- **[HdiActivityRecognition](activity_recognition.md)** + +- **[Input](input.md)** + +- **[Light](light.md)** + +- **[Motion](motion.md)** + +- **[Power](power.md)** + +- **[Sensor](sensor.md)** + +- **[Thermal](thermal.md)** + +- **[USB](usb.md)** + +- **[Vibrator](vibrator.md)** + +- **[WLAN](wlan.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/motion.md b/zh-cn/device-dev/reference/hdi-apis/motion.md new file mode 100644 index 0000000000000000000000000000000000000000..4662cf421979b9d24c5be1ca2143d2c649104b93 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/motion.md @@ -0,0 +1,75 @@ +# Motion + + +## **概述** + +手势识别设备驱动对硬件服务提供通用的接口能力。 + +模块提供硬件服务对手势识别驱动模块访问统一接口,服务获取驱动对象或者代理后,通过其提供的各类方法,实现使能手势识别/ 去使能手势识别、订阅/取消订阅手势识别数据。 + +**Since**: + +3.2 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [IMotionCallback.idl](_i_motion_callback_8idl.md) | 定义上报手势识别数据回调函数接口。 | +| [IMotionInterface.idl](_i_motion_interface_8idl.md) | 定义使能/去使能手势识别、订阅/取消订阅手势识别数据的接口。 | +| [MotionTypes.idl](_motion_types_8idl.md) | 定义手势识别模块用到的数据结构,包括手势识别类型、上报的手势识别数据结构。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IMotionCallback](interface_i_motion_callback.md) | 定义上报手势识别数据回调函数。 | +| [IMotionInterface](interface_i_motion_interface.md) | 提供Motion设备基本控制操作接口。 | +| [HdfMotionEvent](_hdf_motion_event.md) | 上报手势识别数据结构。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfMotionTypeTag](#hdfmotiontypetag) {   HDF_MOTION_TYPE_PICKUP = 0, HDF_MOTION_TYPE_FLIP, HDF_MOTION_CLOSE_TO_EAR, HDF_MOTION_TYPE_SHAKE,   HDF_MOTION_TYPE_ROTATION, HDF_MOTION_TYPE_POCKET_MODE, HDF_MOTION_TYPE_LEAVE_EAR, HDF_MOTION_TYPE_WRIST_UP,   HDF_MOTION_TYPE_WRIST_DOWN, HDF_MOTION_TYPE_MAX } | 枚举手势识别类型。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.motion.v1_0 | 手势识别模块接口的包路径。 | + + +## **枚举类型说明** + + +### HdfMotionTypeTag + + +``` +enum HdfMotionTypeTag +``` + +**描述:** + +枚举手势识别类型。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_MOTION_TYPE_PICKUP | 拿起类型。 | +| HDF_MOTION_TYPE_FLIP | 翻转类型。 | +| HDF_MOTION_CLOSE_TO_EAR | 靠近耳朵类型。 | +| HDF_MOTION_TYPE_SHAKE | 摇一摇类型。 | +| HDF_MOTION_TYPE_ROTATION | 旋转屏类型。 | +| HDF_MOTION_TYPE_POCKET_MODE | 口袋模式类型。 | +| HDF_MOTION_TYPE_LEAVE_EAR | 拿离耳朵类型。 | +| HDF_MOTION_TYPE_WRIST_UP | 腕朝上类型。 | +| HDF_MOTION_TYPE_WRIST_DOWN | 腕朝下类型。 | +| HDF_MOTION_TYPE_MAX | 最大手势识别类型。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md index b642de475903f6710b7d62886606ef708b62023e..c521e57491dce8ea817583370c6219278cfe6051 100644 --- a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md @@ -3,6 +3,12 @@ ## **概述** +定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 + +**Since:** + +3.2 + **所属模块:** [HdfPinAuth](_hdf_pin_auth.md) @@ -13,22 +19,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IExecutor](interface_pin_i_executor.md) | 定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 [更多...](interface_pin_i_executor.md) | +| [IExecutor](interface_pin_i_executor.md) | 定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.pin_auth.v1_0 | 口令认证接口的包路径 | - - -## **详细描述** - -定义执行器标准API接口。接口可用于获取执行器信息,获取凭据模版信息,注册口令,认证口令,删除口令等。 - -**Since:** - -3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md index 39df7ba9021fa902cc6948b9cb567fe9de3ab613..a8a0b816d93ea68433e534748afc275f544773b6 100644 --- a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md +++ b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md @@ -3,6 +3,16 @@ ## **概述** +定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 + +**Since:** + +3.2 + +**Version:** + +1.0 + **所属模块:** [HdfPinAuth](_hdf_pin_auth.md) @@ -13,26 +23,13 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 [更多...](interface_pin_i_executor_callback.md) | +| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异步API接口回调,用于返回异步接口的请求处理结果和信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | | package ohos.hdi.pin_auth.v1_0 | 口令认证接口的包路径 | - - -## **详细描述** - -定义异步API接口回调,用于返回异步接口的请求处理结果和获取信息。使用细节见[IExecutor](interface_pin_i_executor.md)。 - -**Since:** - -3.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/power.md b/zh-cn/device-dev/reference/hdi-apis/power.md index 2ce105c12d28d9579ab2b3ad6eefbf186588e312..4383da36d209e4552fbf70c1e62d023c3c4adcd3 100644 --- a/zh-cn/device-dev/reference/hdi-apis/power.md +++ b/zh-cn/device-dev/reference/hdi-apis/power.md @@ -1,12 +1,27 @@ # Power +## **概述** + +提供休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 + +电源模块为电源服务提供的休眠/唤醒操作、订阅休眠/唤醒状态和运行锁管理的接口。 服务获取此模块的对象或代理后,可以调用相关的接口对设备进行休眠/唤醒、订阅休眠/唤醒状态和管理运行锁。 + +**Since**: + +3.1 + +**Version**: + +1.0 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md) | 休眠/唤醒状态的回调。 | | [IPowerInterface.idl](_i_power_interface_8idl.md) | 休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 | @@ -15,41 +30,26 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | 休眠/唤醒状态的回调。 [更多...](interface_i_power_hdi_callback.md) | -| [IPowerInterface](interface_i_power_interface.md) | 休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 [更多...](interface_i_power_interface.md) | +| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | 休眠/唤醒状态的回调。 | +| [IPowerInterface](interface_i_power_interface.md) | 休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 | ### 枚举 - | 枚举 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [PowerHdfCmd](#powerhdfcmd) {   CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND,   CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电源命令的参数。 [更多...](#powerhdfcmd) | -| [PowerHdfCallbackCmd](#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电源状态回调的参数。 [更多...](#powerhdfcallbackcmd) | -| [PowerHdfState](#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电源的状态。 [更多...](#powerhdfstate) | +| [PowerHdfCmd](#powerhdfcmd) {   CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND,   CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电源命令的参数。 | +| [PowerHdfCallbackCmd](#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电源状态回调的参数。 | +| [PowerHdfState](#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电源的状态。 | -### 变量 +### 关键字 - | 变量 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| package ohos.hdi.power.v1_0 | 电源管理接口的包路径。 | - - -## **详细描述** - -提供休眠/唤醒操作、订阅休眠/唤醒状态、运行锁管理的接口。 - -电源模块为电源服务提供的休眠/唤醒操作、订阅休眠/唤醒状态和运行锁管理的接口。 服务获取此模块的对象或代理后,可以调用相关的接口对设备进行休眠/唤醒、订阅休眠/唤醒状态和管理运行锁。 - -**Since:** - -3.1 - -**Version:** - -1.0 +| package ohos.hdi.power.v1_0 | 电源模块接口的包路径。 | ## **枚举类型说明** diff --git a/zh-cn/device-dev/reference/hdi-apis/sensor.md b/zh-cn/device-dev/reference/hdi-apis/sensor.md new file mode 100644 index 0000000000000000000000000000000000000000..5c37da3a27dd00fe925aba5de15f35a8a52d1a88 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/sensor.md @@ -0,0 +1,145 @@ +# Sensor + + +## **概述** + +传感器设备驱动对传感器服务提供通用的接口能力。 + +模块提供传感器服务对传感器驱动访问统一接口,服务获取驱动对象或者代理后,通过其提供的各类方法,以传感器ID区分访问不同类型传感器设备,实现获取传感器设备信息、订阅/取消订阅传感器数据、 使能/去使能传感器、设置传感器模式、设置传感器精度、量程等可选配置等。 + +**Since**: + +2.2 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [ISensorCallback.idl](_i_sensor_callback_8idl.md) | Sensor模块为Sensor服务提供数据上报的回调函数。 | +| [ISensorInterface.idl](_i_sensor_interface_8idl.md) | Sensor模块对外通用的接口声明文件,提供获取传感器设备信息、订阅/取消订阅传感器数据、使能/去使能传感器、设置传感器模式、设置传感器精度,量程等可选配置接口定义。 | +| [SensorTypes.idl](_sensor_types_8idl.md) | 定义传感器模块所使用的传感器类型,传感器信息,传感器数据结构等数据类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [ISensorCallback](interface_i_sensor_callback.md) | 定义用于上报传感器数据的回调函数。 | +| [ISensorInterface](interface_i_sensor_interface.md) | 提供Sensor设备基本控制操作接口。 | +| [HdfSensorInformation](_hdf_sensor_information.md) | 定义传感器的基本信息。 | +| [HdfSensorEvents](_hdf_sensor_events.md) | 定义传感器上报的数据。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfSensorTypeTag](#hdfsensortypetag) {   HDF_SENSOR_TYPE_NONE = 0, HDF_SENSOR_TYPE_ACCELEROMETER = 1, HDF_SENSOR_TYPE_GYROSCOPE = 2, HDF_SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3,   HDF_SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, HDF_SENSOR_TYPE_AMBIENT_LIGHT = 5, HDF_SENSOR_TYPE_MAGNETIC_FIELD = 6, HDF_SENSOR_TYPE_CAPACITIVE = 7,   HDF_SENSOR_TYPE_BAROMETER = 8, HDF_SENSOR_TYPE_TEMPERATURE = 9, HDF_SENSOR_TYPE_HALL = 10, HDF_SENSOR_TYPE_GESTURE = 11,   HDF_SENSOR_TYPE_PROXIMITY = 12, HDF_SENSOR_TYPE_HUMIDITY = 13, HDF_SENSOR_TYPE_MEDICAL_BEGIN = 128, HDF_SENSOR_TYPE_MEDICAL_END = 160,   HDF_SENSOR_TYPE_PHYSICAL_MAX = 255, HDF_SENSOR_TYPE_ORIENTATION = 256, HDF_SENSOR_TYPE_GRAVITY = 257, HDF_SENSOR_TYPE_LINEAR_ACCELERATION = 258,   HDF_SENSOR_TYPE_ROTATION_VECTOR = 259, HDF_SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, HDF_SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, HDF_SENSOR_TYPE_GAME_ROTATION_VECTOR = 262,   HDF_SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, HDF_SENSOR_TYPE_SIGNIFICANT_MOTION = 264, HDF_SENSOR_TYPE_PEDOMETER_DETECTION = 265, HDF_SENSOR_TYPE_PEDOMETER = 266,   HDF_SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, HDF_SENSOR_TYPE_HEART_RATE = 278, HDF_SENSOR_TYPE_DEVICE_ORIENTATION = 279, HDF_SENSOR_TYPE_WEAR_DETECTION = 280,   HDF_SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, HDF_SENSOR_TYPE_MAX } | 定义传感器类型标识。 | +| [HdfSensorGroupType](#hdfsensorgrouptype) { HDF_TRADITIONAL_SENSOR_TYPE = 0, HDF_MEDICAL_SENSOR_TYPE = 1, HDF_SENSOR_GROUP_TYPE_MAX } | 枚举传感器的硬件服务组。 | +| [HdfSensorModeType](#hdfsensormodetype) {   SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3,   SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | 传感器的工作模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.sensor.v1_0 | Sensor模块接口的包路径。 | + + +## **枚举类型说明** + + +### HdfSensorGroupType + + +``` +enum HdfSensorGroupType +``` + +**描述:** + +枚举传感器的硬件服务组。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_TRADITIONAL_SENSOR_TYPE | 传统传感器类型,传感器ID枚举值范围不在128-160之间。 | +| HDF_MEDICAL_SENSOR_TYPE | 医疗传感器类型,传感器ID枚举值范围在128-160之间。 | +| HDF_SENSOR_GROUP_TYPE_MAX | 最大传感器类型。 | + + +### HdfSensorModeType + + +``` +enum HdfSensorModeType +``` + +**描述:** + +传感器的工作模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| SENSOR_MODE_DEFAULT | 传感器数据默认上报模式。 | +| SENSOR_MODE_REALTIME | 传感器数据持续上报模式。 | +| SENSOR_MODE_ON_CHANGE | 传感器数据变更时上报模式。 | +| SENSOR_MODE_ONE_SHOT | 传感器一次数据上报模式。 | +| SENSOR_MODE_FIFO_MODE | 传感器数据缓存模式。 | +| SENSOR_MODE_MAX | 传感器最大类型标识。 | + + +### HdfSensorTypeTag + + +``` +enum HdfSensorTypeTag +``` + +**描述:** + +定义传感器类型标识。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_SENSOR_TYPE_NONE | 空传感器类型,用于测试。 | +| HDF_SENSOR_TYPE_ACCELEROMETER | 加速度传感器。 | +| HDF_SENSOR_TYPE_GYROSCOPE | 陀螺仪传感器。 | +| HDF_SENSOR_TYPE_PHOTOPLETHYSMOGRAPH | 心率传感器。 | +| HDF_SENSOR_TYPE_ELECTROCARDIOGRAPH | 心电传感器。 | +| HDF_SENSOR_TYPE_AMBIENT_LIGHT | 环境光传感器。 | +| HDF_SENSOR_TYPE_MAGNETIC_FIELD | 地磁传感器。 | +| HDF_SENSOR_TYPE_CAPACITIVE | 电容传感器。 | +| HDF_SENSOR_TYPE_BAROMETER | 气压计传感器。 | +| HDF_SENSOR_TYPE_TEMPERATURE | 温度传感器。 | +| HDF_SENSOR_TYPE_HALL | 霍尔传感器。 | +| HDF_SENSOR_TYPE_GESTURE | 手势传感器。 | +| HDF_SENSOR_TYPE_PROXIMITY | 接近光传感器。 | +| HDF_SENSOR_TYPE_HUMIDITY | 湿度传感器。 | +| HDF_SENSOR_TYPE_MEDICAL_BEGIN | 医疗传感器ID枚举值范围的开始。 | +| HDF_SENSOR_TYPE_MEDICAL_END | 医疗传感器ID枚举值范围的结束。 | +| HDF_SENSOR_TYPE_PHYSICAL_MAX | 物理传感器最大类型。 | +| HDF_SENSOR_TYPE_ORIENTATION | 方向传感器。 | +| HDF_SENSOR_TYPE_GRAVITY | 重力传感器。 | +| HDF_SENSOR_TYPE_LINEAR_ACCELERATION | 线性加速度传感器。 | +| HDF_SENSOR_TYPE_ROTATION_VECTOR | 旋转矢量传感器。 | +| HDF_SENSOR_TYPE_AMBIENT_TEMPERATURE | 环境温度传感器。 | +| HDF_SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | 未校准磁场传感器。 | +| HDF_SENSOR_TYPE_GAME_ROTATION_VECTOR | 游戏旋转矢量传感器。 | +| HDF_SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | 未校准陀螺仪传感器。 | +| HDF_SENSOR_TYPE_SIGNIFICANT_MOTION | 大幅度动作传感器。 | +| HDF_SENSOR_TYPE_PEDOMETER_DETECTION | 计步器检测传感器。 | +| HDF_SENSOR_TYPE_PEDOMETER | 计步器传感器。 | +| HDF_SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | 地磁旋转矢量传感器。 | +| HDF_SENSOR_TYPE_HEART_RATE | 心率传感器。 | +| HDF_SENSOR_TYPE_DEVICE_ORIENTATION | 设备方向传感器。 | +| HDF_SENSOR_TYPE_WEAR_DETECTION | 佩戴检测传感器。 | +| HDF_SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | 未校准加速度传感器。 | +| HDF_SENSOR_TYPE_MAX | 传感器类型最大个数标识。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md deleted file mode 100644 index 886db580b0e774b24cce3e329d712189beaaaa9d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md +++ /dev/null @@ -1,39 +0,0 @@ -# sensor_if.h - - -## **概述** - -**所属模块:** - -[Sensor](_sensor.md) - - -## **汇总** - - -### 类 - -| 类 | 描述 | -| -------- | -------- | -| [SensorInterface](_sensor_interface.md) | 提供sensor设备基本控制操作接口。 [更多...](_sensor_interface.md) | - - -### 函数 - -| 函数 | 描述 | -| -------- | -------- | -| [NewSensorInterfaceInstance](_sensor.md#newsensorinterfaceinstance) (void) | 创建传感器接口实例。 [更多...](_sensor.md#newsensorinterfaceinstance) | -| [FreeSensorInterfaceInstance](_sensor.md#freesensorinterfaceinstance) (void) | 释放传感器接口实例。 [更多...](_sensor.md#freesensorinterfaceinstance) | - - -## **详细描述** - -Sensor模块对外通用的接口声明文件,提供获取传感器设备信息、订阅/取消订阅传感器数据、 使能/去使能传感器、设置传感器模式、设置传感器精度,量程等可选配置接口定义。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md deleted file mode 100644 index 35adb8935df3946a74ce804b53a713680154aedc..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md +++ /dev/null @@ -1,59 +0,0 @@ -# sensor_type.h - - -## **概述** - -**所属模块:** - -[Sensor](_sensor.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [SensorInformation](_sensor_information.md) | 定义传感器基本信息。 [更多...](_sensor_information.md) | -| [SensorEvents](_sensor_events.md) | 上报传感器数据结构。 [更多...](_sensor_events.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| [SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen)   32 | Sensor名称的最大长度 | -| [SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen)   16 | Sensor版本号的最大长度 | - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| ([RecordDataCallback](_sensor.md#recorddatacallback)) (const struct [SensorEvents](_sensor_events.md) \*) | 传感器上报数据回调函数的定义,传感器服务用户在订阅传感器时, 需要注册上报数据回调函数,传感器使能后,传感器服务用户可以接受到传感器数据,详见[SensorInterface](_sensor_interface.md)。 [更多...](_sensor.md#recorddatacallback) | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [SensorStatus](_sensor.md#sensorstatus) { SENSOR_SUCCESS = 0, SENSOR_FAILURE = -1, SENSOR_NOT_SUPPORT = -2, SENSOR_INVALID_PARAM = -3,   SENSOR_INVALID_SERVICE = -4, SENSOR_NULL_PTR = -5 } | 定义传感器模块返回值类型。 [更多...](_sensor.md#sensorstatus) | -| [SensorTypeTag](_sensor.md#sensortypetag) { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_ACCELEROMETER = 1, SENSOR_TYPE_GYROSCOPE = 2, SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3,   SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, SENSOR_TYPE_AMBIENT_LIGHT = 5, SENSOR_TYPE_MAGNETIC_FIELD = 6, SENSOR_TYPE_CAPACITIVE = 7,   SENSOR_TYPE_BAROMETER = 8, SENSOR_TYPE_TEMPERATURE = 9, SENSOR_TYPE_HALL = 10, SENSOR_TYPE_GESTURE = 11,   SENSOR_TYPE_PROXIMITY = 12, SENSOR_TYPE_HUMIDITY = 13, SENSOR_TYPE_MEDICAL_BEGIN = 128, SENSOR_TYPE_MEDICAL_END = 160,   SENSOR_TYPE_PHYSICAL_MAX = 255, SENSOR_TYPE_ORIENTATION = 256, SENSOR_TYPE_GRAVITY = 257, SENSOR_TYPE_LINEAR_ACCELERATION = 258,   SENSOR_TYPE_ROTATION_VECTOR = 259, SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, SENSOR_TYPE_GAME_ROTATION_VECTOR = 262,   SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, SENSOR_TYPE_SIGNIFICANT_MOTION = 264, SENSOR_TYPE_PEDOMETER_DETECTION = 265, SENSOR_TYPE_PEDOMETER = 266,   SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, SENSOR_TYPE_HEART_RATE = 278, SENSOR_TYPE_DEVICE_ORIENTATION = 279, SENSOR_TYPE_WEAR_DETECTION = 280,   SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, SENSOR_TYPE_MAX } | 定义传感器类型标识。 [更多...](_sensor.md#sensortypetag) | -| [SensorAccuracyType](_sensor.md#sensoraccuracytype) { SENSOR_NO_ACCURACY = 0, SENSOR_LOW_ACCURACY = 1, SENSOR_MEDIUM_ACCURACY = 2, SENSOR_HIGH_ACCURACY = 3,   SENSOR_MAX_ACCURACY } | 传感器的精度类型。 [更多...](_sensor.md#sensoraccuracytype) | -| [SensorRangeType](_sensor.md#sensorrangetype) { SENSOR_RANGE_LEVEL1 = 0, SENSOR_RANGE_LEVEL2 = 1, SENSOR_RANGE_LEVEL3 = 2, SENSOR_RANGE_LEVEL_MAX } | 传感器的量程级别。 [更多...](_sensor.md#sensorrangetype) | -| [SensorModeType](_sensor.md#sensormodetype) { SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3,   SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | 传感器的工作模式。 [更多...](_sensor.md#sensormodetype) | -| [SensorGroupType](_sensor.md#sensorgrouptype) { TRADITIONAL_SENSOR_TYPE = 0, MEDICAL_SENSOR_TYPE = 1, SENSOR_GROUP_TYPE_MAX } | 枚举传感器的硬件服务组。 [更多...](_sensor.md#sensorgrouptype) | - - -## **详细描述** - -定义传感器模块所使用的传感器类型,传感器信息,传感器数据结构等数据类型。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/thermal.md b/zh-cn/device-dev/reference/hdi-apis/thermal.md index d639a37e380cc8615bd0440eee3909523152865b..72a5d3edf656d93a1cb5587840d022fc181f7e3d 100644 --- a/zh-cn/device-dev/reference/hdi-apis/thermal.md +++ b/zh-cn/device-dev/reference/hdi-apis/thermal.md @@ -1,12 +1,27 @@ # Thermal +## **概述** + +提供设备温度管理、控制及订阅接口。 + +热模块为热服务提供的设备温度管理、控制及订阅接口。服务获取此模块的对象或代理后,可以调用相关的接口管理、控制和订阅设备温度。 + +**Since**: + +3.1 + +**Version**: + +1.0 + + ## **汇总** ### 文件 - | 文件 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [IThermalCallback.idl](_i_thermal_callback_8idl.md) | 设备发热状态的回调。 | | [IThermalInterface.idl](_i_thermal_interface_8idl.md) | 设备温度管理、控制及订阅接口。 | @@ -15,31 +30,16 @@ ### 类 - | 类 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备发热状态的回调。 [更多...](interface_i_thermal_callback.md) | -| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管理、控制及订阅接口。 [更多...](interface_i_thermal_interface.md) | -| [ThermalZoneInfo](_thermal_zone_info.md) | 设备发热的信息。 [更多...](_thermal_zone_info.md) | -| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备发热的信息列表。 [更多...](_hdf_thermal_callback_info.md) | +| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备发热状态的回调。 | +| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管理、控制及订阅接口。 | +| [ThermalZoneInfo](_thermal_zone_info.md) | 设备发热的信息。 | +| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备发热的信息列表。 | -### 变量 +### 关键字 - | 变量 名称 | 描述 | + | 名称 | 描述 | | -------- | -------- | -| package ohos.hdi.thermal.v1_0 | 设备温度管理接口的包路径 | - - -## **详细描述** - -提供设备温度管理、控制及订阅接口。 - -热模块为热服务提供的设备温度管理、控制及订阅接口。 服务获取此模块的对象或代理后,可以调用相关的接口管理、控制和订阅设备温度。 - -**Since:** - -3.1 - -**Version:** - -1.0 +| package ohos.hdi.thermal.v1_0 | Thermal模块接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/total.md b/zh-cn/device-dev/reference/hdi-apis/total.md new file mode 100644 index 0000000000000000000000000000000000000000..bac50766065bf942c00fe3d98e89e1772b2b5087 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/total.md @@ -0,0 +1,7 @@ +# 头文件和结构体 + + + +- **[头文件](files.md)** + +- **[结构体](annotated.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/types_8h.md b/zh-cn/device-dev/reference/hdi-apis/types_8h.md deleted file mode 100644 index d464901d79c2444c7a1e1910b598dbe89cd1b8a0..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/types_8h.md +++ /dev/null @@ -1,61 +0,0 @@ -# types.h - - -## **概述** - -**所属模块:** - -[Camera](_camera.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) | 流信息,用于创建流时传入相关的配置参数。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_info.md) | -| [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | 流的属性。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | -| [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) | 捕获请求的相关信息。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_info.md) | -| [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | 捕获结束相关信息,用于捕获结束回调 **OnCaptureEnded**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | -| [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | 流错误信息,用于回调 **OnCaptureError**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| **OHOS::Camera::CameraAbility** = CameraMetadata | Camera设备能力集合。 | -| **OHOS::Camera::CameraSetting** = CameraMetadata | Camera设置参数,包括sensor帧率,3A相关参数等。 | -| **OHOS::Camera::MetaType** = int32_t | 整型。 | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [OHOS::Camera::CamRetCode](_camera.md#camretcode) : int32_t {   OHOS::Camera::NO_ERROR = 0, OHOS::Camera::CAMERA_BUSY = -1, OHOS::Camera::INSUFFICIENT_RESOURCES = -2, OHOS::Camera::INVALID_ARGUMENT = -3,   OHOS::Camera::METHOD_NOT_SUPPORTED = -4, OHOS::Camera::CAMERA_CLOSED = -5, OHOS::Camera::DEVICE_ERROR = -6 } | HDI接口的返回值。 [更多...](_camera.md#camretcode) | -| [OHOS::Camera::ResultCallbackMode](_camera.md#resultcallbackmode) : int32_t { OHOS::Camera::PER_FRAME, OHOS::Camera::ON_CHANGED } | metadata的上报模式。 [更多...](_camera.md#resultcallbackmode) | -| [OHOS::Camera::OperationMode](_camera.md#operationmode) : int32_t { OHOS::Camera::NORMAL = 0 } | 流的使用模式。 [更多...](_camera.md#operationmode) | -| [OHOS::Camera::StreamIntent](_camera.md#streamintent) : int32_t {   OHOS::Camera::PREVIEW = 0, OHOS::Camera::VIDEO = 1, OHOS::Camera::STILL_CAPTURE = 2, OHOS::Camera::POST_VIEW = 3,   OHOS::Camera::ANALYZE = 4, OHOS::Camera::CUSTOM = 5 } | 流的类型。 [更多...](_camera.md#streamintent) | -| [OHOS::Camera::EncodeType](_camera.md#encodetype) : int32_t { OHOS::Camera::ENCODE_TYPE_NULL = 0, OHOS::Camera::ENCODE_TYPE_H264 = 1, OHOS::Camera::ENCODE_TYPE_H265 = 2, OHOS::Camera::ENCODE_TYPE_JPEG = 3 } | 流数据的编码类型。 [更多...](_camera.md#encodetype) | -| [OHOS::Camera::StreamSupportType](_camera.md#streamsupporttype) : int32_t { OHOS::Camera::DYNAMIC_SUPPORTED, OHOS::Camera::RE_CONFIGURED_REQUIRED, OHOS::Camera::NOT_SUPPORTED } | 动态配置流的切换方式,使用场景参考 [IsStreamsSupported](_camera.md#isstreamssupported) 。 [更多...](_camera.md#streamsupporttype) | -| [OHOS::Camera::CameraStatus](_camera.md#camerastatus) { OHOS::Camera::UN_AVAILABLE = 0, OHOS::Camera::AVAILABLE = 1 } | Camera设备状态。 [更多...](_camera.md#camerastatus) | -| [OHOS::Camera::FlashlightStatus](_camera.md#flashlightstatus) : uint32_t { OHOS::Camera::FLASHLIGHT_OFF = 0, OHOS::Camera::FLASHLIGHT_ON = 1, OHOS::Camera::FLASHLIGHT_UNAVAILABLE = 2 } | 闪光灯状态。 [更多...](_camera.md#flashlightstatus) | -| [OHOS::Camera::CameraEvent](_camera.md#cameraevent): uint32_t { OHOS::Camera::CAMERA_EVENT_DEVICE_ADD = 0, OHOS::Camera::CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 [更多...](_camera.md#cameraevent) | -| [OHOS::Camera::ErrorType](_camera.md#errortype) : uint32_t { OHOS::Camera::FATAL_ERROR = 0, OHOS::Camera::REQUEST_TIMEOUT = 1 } | 设备错误类型,用于设备错误回调 **OnError**。 [更多...](_camera.md#errortype) | -| [OHOS::Camera::StreamError](_camera.md#streamerror) { OHOS::Camera::UNKNOWN_ERROR = 0, OHOS::Camera::BUFFER_LOST = 1 } | 流错误类型,用于流错误类型 **CaptureErrorInfo**。 [更多...](_camera.md#streamerror) | - - -## **详细描述** - -Camera模块HDI接口使用的数据类型。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md b/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md index 8de76492ce9026d0aea6c5a71bd5ca2ad479d361..f9291a99bb1b489827b8e47ed1a33301215de8df 100644 --- a/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md +++ b/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md @@ -3,7 +3,9 @@ ## **概述** -**所属模块:** +音频场景描述。 + +**相关模块:** [Audio](_audio.md) @@ -13,12 +15,7 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [id](_audio.md#id) | 音频场景的ID。 | | [desc](_audio.md#desc-35) | 以字符串命名的音频场景。 | - - -## **详细描述** - -音频场景描述。 diff --git a/zh-cn/device-dev/reference/hdi-apis/union_color_value.md b/zh-cn/device-dev/reference/hdi-apis/union_color_value.md new file mode 100644 index 0000000000000000000000000000000000000000..49a63ccebf1a51b82141b05378791a5aa7030268 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/union_color_value.md @@ -0,0 +1,50 @@ +# ColorValue + + +## **概述** + +定义灯的颜色模式。 + +参数包括RGB模式和WRGB模式。 + +**相关模块:** + +[Light](light.md) + + +## **汇总** + + +### Public 属性 + + | 名称 | 描述 | +| -------- | -------- | +| [wrgbColor](#wrgbcolor) | WRGB模式 | +| [rgbColor](#rgbcolor) | RGB模式 | + + +## **类成员变量说明** + + +### rgbColor + + +``` +struct RGBColor ColorValue::rgbColor +``` + +**描述:** + +RGB模式, 详见[RGBColor](_r_g_b_color.md)。 + + +### wrgbColor + + +``` +struct WRGBColor ColorValue::wrgbColor +``` + +**描述:** + +WRGB模式, 详见[WRGBColor](_w_r_g_b_color.md)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md index 3e1b3f060202249675ae58d842207e63f25152dd..015901e57a6474e086908bec3f88c427c14db67e 100644 --- a/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md +++ b/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md @@ -3,9 +3,11 @@ ## **概述** -**所属模块:** +定义音视频编解码能力。 + +**相关模块:** -[Codec](_codec.md) +[Codec](codec.md) ## **汇总** @@ -13,17 +15,12 @@ ### Public 属性 - | Public 属性 | 描述 | + | 名称 | 描述 | | -------- | -------- | | [video](#video) | 视频编解码能力 | | [audio](#audio) | 音频编解码能力 | -## **详细描述** - -定义音视频编解码能力。 - - ## **类成员变量说明** @@ -36,7 +33,7 @@ AudioPortCap PortCap::audio **描述:** -音频编解码能力 +音频编解码能力。 ### video @@ -48,4 +45,4 @@ VideoPortCap PortCap::video **描述:** -视频编解码能力 +视频编解码能力。 diff --git a/zh-cn/device-dev/reference/hdi-apis/usb.md b/zh-cn/device-dev/reference/hdi-apis/usb.md new file mode 100644 index 0000000000000000000000000000000000000000..494b00f32ef88eed39019685303d6435bbf0ffc9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/usb.md @@ -0,0 +1,50 @@ +# USB + + +## **概述** + +提供统一的USB驱动标准接口,实现USB驱动接入。 + +上层USB服务开发人员可以根据USB驱动模块提供的标准接口获取如下功能:打开/关闭设备,获取设备描述符,获取文件描述符,打开/关闭接口,批量读取/写入数据, 设置/获取设备功能,绑定/解绑订阅者等。 + +**Since**: + +3.2 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [IUsbdBulkCallback.idl](_i_usbd_bulk_callback_8idl.md) | USB驱动批量传输读/写数据的回调。 | +| [IUsbdSubscriber.idl](_i_usbd_subscriber_8idl.md) | USB驱动的订阅函数。 | +| [IUsbInterface.idl](_i_usb_interface_8idl.md) | 声明标准的USB驱动接口函数。 | +| [UsbTypes.idl](_usb_types_8idl.md) | USB驱动相关的数据类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IUsbdBulkCallback](interface_i_usbd_bulk_callback.md) | USB驱动的回调函数。 | +| [IUsbdSubscriber](interface_i_usbd_subscriber.md) | 定义USB驱动的订阅类相关函数。 | +| [IUsbInterface](interface_i_usb_interface.md) | 定义USB驱动基本的操作功能。 | +| [PortInfo](_port_info.md) | USB设备端口信息。 | +| [UsbDev](_usb_dev.md) | USB设备地址信息。 | +| [UsbPipe](_usb_pipe.md) | USB设备管道信息。 | +| [UsbCtrlTransfer](_usb_ctrl_transfer.md) | USB设备控制传输信息。 | +| [USBDeviceInfo](_u_s_b_device_info.md) | USB设备信息。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.usb.v1_0 | USB驱动接口的包路径。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md b/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md deleted file mode 100644 index 4d075be4d50a0065bee81aa13f8f93b56c68876c..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md +++ /dev/null @@ -1,32 +0,0 @@ -# usb_info.h - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信息。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | -| [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | USB设备信息类。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | - - -## **详细描述** - -USB驱动订阅模块使用的数据类型。 - -**Since:** - -3.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md deleted file mode 100644 index e8ca6691a0b58d02be9447301431287af1273c80..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# usbd_client.h - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | USB驱动类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | - - -## **详细描述** - -声明标准USB驱动接口函数。 - -**Since:** - -3.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md deleted file mode 100644 index 5bddc2d6b20509f2b5d0cfd6b7be46ee5503f7b7..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md +++ /dev/null @@ -1,31 +0,0 @@ -# usbd_subscriber.h - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | USB订阅类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | - - -## **详细描述** - -USB驱动订阅模块。 - -**Since:** - -3.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md deleted file mode 100644 index a8a3c6bdb08dc9fa640877e6569b59c5af4b287f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md +++ /dev/null @@ -1,67 +0,0 @@ -# usbd_type.h - - -## **概述** - -**所属模块:** - -[USB](_u_s_b.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | USB设备。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | -| [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | 管道信息。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | -| [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | USB控制传输。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | -| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信息。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| [USB_MAX_INTERFACES](_u_s_b.md#usbmaxinterfaces)   32 | USB设备最大接口数量。 | - -### 静态常量 - - | 静态常量 | 描述 | -| -------- | -------- | -| [USB_ENDPOINT_DIR_MASK](_u_s_b.md#usb\_endpoint\_dir\_mask)   0x80 | 从地址中提取USB Endpoint方向的位掩码。 | -| [USB_ENDPOINT_DIR_IN](_u_s_b.md#usb\_endpoint\_dir\_in)   0x80 | USB Endpoint从设备到主机的数据方向。 | -| [USB_ENDPOINT_DIR_OUT](_u_s_b.md#usb\_endpoint\_dir\_out)   0 | USB Endpoint从主机到设备的数据方向。 | - - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| ([UsbdRequestCallback](_u_s_b.md#usbdrequestcallback)) (uint8_t \*requestArg) | 请求回调函数。 | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [UsbdBulkCbCmd](_u_s_b.md#usbdbulkcbcmd) { CMD_USBD_BULK_CALLBACK_READ, CMD_USBD_BULK_CALLBACK_WRITE } | 批量回调命令字。 [更多...](_u_s_b.md#usbdbulkcbcmd) | -| [UsbdDeviceAction](_u_s_b.md#usbddeviceaction) { ACT_DEVUP = 0, ACT_DEVDOWN, ACT_UPDEVICE, ACT_DOWNDEVICE } | 主机端和设备端插拔事件。 [更多...](_u_s_b.md#usbddeviceaction) | - - -## **详细描述** - -USB驱动模块接口定义中使用的自定义数据类型。 - -USB驱动模块接口定义中使用的自定义数据类型, 包括分发的命令字、数据方向等。 - -**Since:** - -3.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/vibrator.md b/zh-cn/device-dev/reference/hdi-apis/vibrator.md new file mode 100644 index 0000000000000000000000000000000000000000..2d6e1c4eb804fe204f991cb2644e6ef13612028c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/vibrator.md @@ -0,0 +1,70 @@ +# Vibrator + + +## **概述** + +马达驱动对马达服务提供通用的接口能力。 + +模块提供马达服务对马达驱动访问的统一接口,服务获取驱动对象或者代理后,控制马达的单次振动、周期性振动、停止振动、设置马达振幅与频率。 + +**Since**: + +3.2 + +**Version**: + +1.1 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [IVibratorInterface.idl](_i_vibrator_interface_8idl.md) | 定义马达的通用API,可用于控制马达执行单次或周期性振动、设置马达振幅与频率。 | +| [VibratorTypes.idl](_vibrator_types_8idl.md) | 定义马达数据结构,包括马达振动模式和马达参数。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IVibratorInterface](interface_i_vibrator_interface.md) | Vibrator模块向上层服务提供统一的接口。 | +| [HdfVibratorInfo](_hdf_vibrator_info.md) | 定义马达参数。 | + + +### 枚举 + + | 名称 | 描述 | +| -------- | -------- | +| [HdfVibratorMode](#hdfvibratormode) { HDF_VIBRATOR_MODE_ONCE, HDF_VIBRATOR_MODE_PRESET, HDF_VIBRATOR_MODE_BUTT } | 枚举马达的振动模式。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.vibrator.v1_1 | 马达模块接口的包路径。 | + + +## **枚举类型说明** + + +### HdfVibratorMode + + +``` +enum HdfVibratorMode +``` + +**描述:** + +枚举马达的振动模式。 + + | 枚举值 | 描述 | +| -------- | -------- | +| HDF_VIBRATOR_MODE_ONCE | 表示给定持续时间内的单次振动。 | +| HDF_VIBRATOR_MODE_PRESET | 表示具有预置效果的周期性振动。 | +| HDF_VIBRATOR_MODE_BUTT | 表示效果模式无效。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md deleted file mode 100644 index 29b0c3a7c21a41ed4c0ae62ab3d56da43c59c3ea..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md +++ /dev/null @@ -1,39 +0,0 @@ -# vibrator_if.h - - -## **概述** - -**所属模块:** - -[Vibrator](_vibrator.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [VibratorInterface](_vibrator_interface.md) | 提供Vibrator设备基本控制操作接口。 | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [NewVibratorInterfaceInstance](_vibrator.md#newvibratorinterfaceinstance) (void) | 创建一个VibratorInterface实例。 [更多...](_vibrator.md#newvibratorinterfaceinstance) | -| [FreeVibratorInterfaceInstance](_vibrator.md#freevibratorinterfaceinstance) (void) | 释放VibratorInterface实例以及相关资源。 [更多...](_vibrator.md#freevibratorinterfaceinstance) | - - -## **详细描述** - -定义马达数据结构,包括马达模式和效果振动。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md deleted file mode 100644 index 1abb949a8c7e380abacb367d82feffd85471982d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md +++ /dev/null @@ -1,33 +0,0 @@ -# vibrator_type.h - - -## **概述** - -**所属模块:** - -[Vibrator](_vibrator.md) - - -## **汇总** - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [VibratorMode](_vibrator.md#vibratormode) { VIBRATOR_MODE_ONCE = 0, VIBRATOR_MODE_PRESET = 1, VIBRATOR_MODE_BUTT } | 枚举马达振动模式。 [更多...](_vibrator.md#vibratormode) | -| [VibratorStatus](_vibrator.md#vibratorstatus) { VIBRATOR_SUCCESS = 0, VIBRATOR_NOT_PERIOD = -1,  VIBRATOR_NOT_INTENSITY  = -2,  VIBRATOR_NOT_FREQUENCY= -3} | 枚举马达振动模式。[更多...](_vibrator.md#vibratorstatus) | -| [VibratorInfo](_vibrator.md#vibratorinfo) { isSupportIntensity, isSupportFrequency, intensityMaxValue, intensityMinValue, frequencyMaxValue, frequencyMinValue} | 定义马达参数。[更多...](_vibrator.md#vibratorinfo) | - - -## **详细描述** - -定义马达数据结构,包括马达模式和效果振动。 - -**Since:** - -2.2 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md deleted file mode 100644 index ce0a6c3e0386722de46f68519df51ef20ba04ce5..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md +++ /dev/null @@ -1,46 +0,0 @@ -# wifi_hal.h - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [IWiFi](_i_wi_fi.md) | HAL对WLAN服务提供的基本能力。 [更多...](_i_wi_fi.md) | - - -### 类型定义 - - | 类型定义 | 描述 | -| -------- | -------- | -| ([CallbackFunc](_w_l_a_n.md#callbackfunc)) (uint32_t event, void \*data, const char \*ifName) | 定义IWiFi回调函数的原型,监听异步事件。 [更多...](_w_l_a_n.md#callbackfunc) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [WifiConstruct](_w_l_a_n.md#wificonstruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)中能力接口。 [更多...](_w_l_a_n.md#wificonstruct) | -| [WifiDestruct](_w_l_a_n.md#wifidestruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 销毁IWiFi结构体并释放相关资源。 [更多...](_w_l_a_n.md#wifidestruct) | - - -## **详细描述** - -提供给WLAN服务的WLAN基本能力接口。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md deleted file mode 100644 index 5070b56b1ba8a62600a9a0486c7125d2ed457e9d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md +++ /dev/null @@ -1,39 +0,0 @@ -# wifi_hal_ap_feature.h - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [StaInfo](_sta_info.md) | 描述与AP连接的STA的基本信息 [更多...](_sta_info.md) | -| [IWiFiAp](_i_wi_fi_ap.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,并包含AP模式下获取连接STA的信息和设置国家码的功能。 [更多...](_i_wi_fi_ap.md) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [InitApFeature](_w_l_a_n.md#initapfeature) (struct [IWiFiAp](_i_wi_fi_ap.md) \*\*fe) | 初始化AP特性。WLAN服务在创建AP类型的特性[FeatureType](_w_l_a_n.md#featuretype)时调用。 [更多...](_w_l_a_n.md#initapfeature) | - - -## **详细描述** - -提供WLAN的AP特性能力(获取与AP连接的STA的基本信息、设置国家码)。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md deleted file mode 100644 index 2507aeda6f531039f93e9db3bcb511b06f6622f3..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md +++ /dev/null @@ -1,54 +0,0 @@ -# wifi_hal_base_feature.h - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [IWiFiBaseFeature](_i_wi_fi_base_feature.md) | WLAN基本特性操作接口,包括获取网卡名称,设置MAC地址,设置发射功率等公共能力接口。 [更多...](_i_wi_fi_base_feature.md) | - - -### 宏定义 - - | 宏定义 | 描述 | -| -------- | -------- | -| [IFNAME_MAX_LEN](_w_l_a_n.md#ga63637ece87095ff8d153f650434ecf97)   16 | 网卡名称最大长度。 | -| [WIFI_MAC_ADDR_LENGTH](_w_l_a_n.md#ga27ea7645cf89c113dae48346e19a676f)   6 | WLAN的MAC地址长度。 | -| [ERR_UNAUTH_ACCESS](_w_l_a_n.md#gadfe9ac5a374d348cd8f77a84cd5ab94e)   (-6) | 定义访问失败错误码。 | - - -### 枚举 - - | 枚举 | 描述 | -| -------- | -------- | -| [FeatureType](_w_l_a_n.md#featuretype) {   PROTOCOL_80211_IFTYPE_UNSPECIFIED, PROTOCOL_80211_IFTYPE_ADHOC, PROTOCOL_80211_IFTYPE_STATION, PROTOCOL_80211_IFTYPE_AP,   PROTOCOL_80211_IFTYPE_AP_VLAN, PROTOCOL_80211_IFTYPE_WDS, PROTOCOL_80211_IFTYPE_MONITOR, PROTOCOL_80211_IFTYPE_MESH_POINT,   PROTOCOL_80211_IFTYPE_P2P_CLIENT, PROTOCOL_80211_IFTYPE_P2P_GO, PROTOCOL_80211_IFTYPE_P2P_DEVICE, PROTOCOL_80211_IFTYPE_NUM } | 枚举WLAN相关特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 [更多...](_w_l_a_n.md#featuretype) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [InitBaseFeature](_w_l_a_n.md#initbasefeature) (struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*fe) | WLAN服务创建任何类型的特性{\@Link FeatureType}时,都需要调用此函数。 [更多...](_w_l_a_n.md#initbasefeature) | - - -## **详细描述** - -提供WLAN基本特性能力。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md deleted file mode 100644 index 66cf5f1a520a17a27b8806a589916e124d362d23..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md +++ /dev/null @@ -1,38 +0,0 @@ -# wifi_hal_sta_feature.h - - -## **概述** - -**所属模块:** - -[WLAN](_w_l_a_n.md) - - -## **汇总** - - -### 类 - - | 类 | 描述 | -| -------- | -------- | -| [IWiFiSta](_i_wi_fi_sta.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,额外包含设置扫描单个MAC地址功能。 [更多...](_i_wi_fi_sta.md) | - - -### 函数 - - | 函数 | 描述 | -| -------- | -------- | -| [InitStaFeature](_w_l_a_n.md#initstafeature) (struct [IWiFiSta](_i_wi_fi_sta.md) \*\*fe) | 初始化STA特性。WLAN服务在创建STA类型的特性[FeatureType](_w_l_a_n.md#featuretype)时调用。 [更多...](_w_l_a_n.md#initstafeature) | - - -## **详细描述** - -提供WLAN的STA特性能力。 - -**Since:** - -1.0 - -**Version:** - -1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wlan.md b/zh-cn/device-dev/reference/hdi-apis/wlan.md new file mode 100644 index 0000000000000000000000000000000000000000..b2bba7253d37b14588ca2b44988dd6a0612e6800 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/wlan.md @@ -0,0 +1,55 @@ +# WLAN + + +## **概述** + +WLAN模块向上层WLAN服务提供了统一接口。 + +上层WLAN服务开发人员可根据WLAN模块提供的向上统一接口获取如下能力:建立/关闭WLAN热点,扫描/关联WLAN热点,WLAN平台芯片管理,网络数据缓冲的申请、释放、移动等操作,网络设备管理,电源管理等。 + +**Since**: + +3.2 + +**Version**: + +1.0 + + +## **汇总** + + +### 文件 + + | 名称 | 描述 | +| -------- | -------- | +| [IWlanCallback.idl](_i_wlan_callback_8idl.md) | WLAN模块为WLAN服务提供的重启驱动、扫描结果、Netlink消息处理的回调。 | +| [IWlanInterface.idl](_i_wlan_interface_8idl.md) | 建立/关闭WLAN热点,扫描/关联/去关联WLAN热点,设置国家码,管理网络设备等操作的接口。 | +| [WlanTypes.idl](_wlan_types_8idl.md) | WLAN模块相关的数据类型。 | + + +### 类 + + | 名称 | 描述 | +| -------- | -------- | +| [IWlanCallback](interface_i_wlan_callback.md) | 定义WLAN模块的回调函数。 | +| [IWlanInterface](interface_i_wlan_interface.md) | WLAN模块向上层WLAN服务提供了统一接口。 | +| [HdfFeatureInfo](_hdf_feature_info.md) | feature对象信息。 | +| [HdfStaInfo](_hdf_sta_info.md) | STA的信息。 | +| [HdfWifiDriverScanSsid](_hdf_wifi_driver_scan_ssid.md) | WiFi扫描参数SSID信息。 | +| [HdfWifiScan](_hdf_wifi_scan.md) | WiFi扫描参数。 | +| [HdfNetDeviceInfo](_hdf_net_device_info.md) | 网络设备信息。 | +| [HdfNetDeviceInfoResult](_hdf_net_device_info_result.md) | 网络设备信息集合。 | +| [HdfWifiScanResult](_hdf_wifi_scan_result.md) | WiFi扫描结果。 | +| [HdfWifiInfo](_hdf_wifi_info.md) | WiFi频段信息。 | +| [MeasChannelParam](_meas_channel_param.md) | 信道测量参数。 | +| [MeasChannelResult](_meas_channel_result.md) | 信道测量结果。 | +| [ProjectionScreenCmdParam](_projection_screen_cmd_param.md) | 投屏参数。 | +| [WifiStationInfo](_wifi_station_info.md) | STA的信息。 | + + +### 关键字 + + | 名称 | 描述 | +| -------- | -------- | +| package ohos.hdi.wlan.v1_0 | WLAN模块接口的包路径。 | diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_1.png b/zh-cn/device-dev/subsystems/figures/ABStartup_1.png new file mode 100644 index 0000000000000000000000000000000000000000..d6805478550aa33c3b1a403a4a8af67189c92239 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_1.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_2.png b/zh-cn/device-dev/subsystems/figures/ABStartup_2.png new file mode 100644 index 0000000000000000000000000000000000000000..4853f09f0ac40b1d28c676c1aa2331ce0c996aa1 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_2.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_3.png b/zh-cn/device-dev/subsystems/figures/ABStartup_3.png new file mode 100644 index 0000000000000000000000000000000000000000..fa2eb6b2105468f816d4a75200eb4f6c64fe3a2b Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_3.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_4.png b/zh-cn/device-dev/subsystems/figures/ABStartup_4.png new file mode 100644 index 0000000000000000000000000000000000000000..f23ea49d9fa04eb907047f43be9e9490be834089 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_4.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_5.png b/zh-cn/device-dev/subsystems/figures/ABStartup_5.png new file mode 100644 index 0000000000000000000000000000000000000000..a0f6292a2bcc9d91171428cc70a262ed740182d1 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_5.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_6.png b/zh-cn/device-dev/subsystems/figures/ABStartup_6.png new file mode 100644 index 0000000000000000000000000000000000000000..7e6b11e268374f2f5c091f3b821f0e84f31f1e53 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_6.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_7.png b/zh-cn/device-dev/subsystems/figures/ABStartup_7.png new file mode 100644 index 0000000000000000000000000000000000000000..21e20faa1c8d32758c1360d8c718d1c6198e7f63 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_7.png differ diff --git a/zh-cn/device-dev/subsystems/figures/ABStartup_8.png b/zh-cn/device-dev/subsystems/figures/ABStartup_8.png new file mode 100644 index 0000000000000000000000000000000000000000..ec4873a2e91327170a4ab0273c2f78ececae7804 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/ABStartup_8.png differ diff --git a/zh-cn/device-dev/subsystems/figures/HiTraceMeter.png b/zh-cn/device-dev/subsystems/figures/HiTraceMeter.png new file mode 100644 index 0000000000000000000000000000000000000000..15e6c6bc750993801d814bfba775a8f4a0141590 Binary files /dev/null and b/zh-cn/device-dev/subsystems/figures/HiTraceMeter.png differ diff --git a/zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md b/zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md index cd87caab277a0f14c98e8e5642c37a179b4f79b8..69e3b2dc032c90905ea40f8475c3bb6acf56f545 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md @@ -3,13 +3,18 @@ ## 概述 ### 基本概念 - begetctl介绍 + 具体参考[begetctl命令](#table14737791480)。 - bootchart 插件 + bootchart是一个用于linux启动过程性能分析的开源工具软件,在系统中自动收集CPU占用率、磁盘吞吐率、进程等信息,并以图形方式显示分析结果,可用作指导优化系统启动过程。begetctl命令参考:[begetctl命令](#table14737791480)。 + - bootevent 插件 + + bootevent是一个记录init进程及各个服务的启动关键事件的插件,记录内容包括事件名称,关联事件的服务的启动时间,事件发生时间。导出文件支持tracing解析,可用作指导优化系统启动过程。 ### 约束与限制 -bootchart 只支持标准系统, begetctl 支持小型系统和标准系统。 +bootchart和bootevent只支持标准系统, begetctl 支持小型系统和标准系统。 ## 开发指导 ### 参数说明 @@ -54,8 +59,13 @@ bootchart 只支持标准系统, begetctl 支持小型系统和标准系统。 | modulectl uninstall moduleName | 卸载动态插件,例如:
modulectl uninstall bootchart | 无 | | modulectl install moduleName | 安装动态插件,例如:
modulectl install bootchart | 无 | | modulectl list | 动态插件列表,例如:
begetctl modulectl list | 无 | +| bootevent disable | 关闭bootevent插件功能,例如:
bootevent disable | 无 | +| bootevent enable | 开启bootevent插件功能,例如:
begetctl 关闭bootevent插件功能 | 无 | +| dump_service parameter_service trigger | 命令行展示所有trigger信息,例如:
begetctl dump_service parameter_service trigger | 无 | +| dump_service all | 命令行展示所有服务的信息,例如:
begetctl dump_service all | 无 | +| dump_service serviceName | 命令行展示单个服务信息,例如:
begetctl dump_service param_watcher | 无 | +| dump api | 命令行展示init接口信息,例如:
begetctl dump api | 无 | -## 开发指导 ### 接口说明 @@ -137,7 +147,7 @@ bootchart 只支持标准系统, begetctl 支持小型系统和标准系统。 ``` ### 开发实例 - +#### bootchart 使用示例 预制条件: 1. 准备bootchart测试环境:linux操作系统下安装python及pycairo pip install pycairo 2. 在linux解压bootchart-master.tar @@ -162,4 +172,31 @@ bootchart 只支持标准系统, begetctl 支持小型系统和标准系统。 ``` 预期结果: -
        在bootchart-master目录下生成bootchart.pdf。 \ No newline at end of file +
        在bootchart-master目录下生成bootchart.pdf。 +#### bootevent 使用示例 +1. 在服务的cfg文件中配置bootevent事件,支持配置一个或多个bootevent事件。 + + 配置单个bootevent事件: + ```json + bootevents : "bootevent.xxxbootevent", + ``` + 配置多个bootevent事件: + ```json + bootevents : ["bootevent.xxxbootevent1", "bootevent.xxxbootevent2.xxx"], + ``` +> **注意:** 配置的bootevent事件必须以“bootevent.”开始。 +2. 服务代码中发送bootevent事件。 + + 服务自身代码中调用init提供的SetParameter接口发送bootevent事件,例如发送上一步骤中设置的XXXbootevent1事件: + ```c + SetParameter("bootevent.XXXbootevent1", "true"); + ``` +3. 命令行启用bootevent功能。 + + - 执行begetctl bootevent enable命令后再次启动系统,bootevent功能开启。 + - 执行begetctl bootevent disable命令后再次启动系统,bootevent功能关闭。 +4. 导出文件支持trace分析。 + + - 导出的bootevent文件目录:/data/service/el0/startup/init/。 + - 导出文件命名规则:“时间戳.bootevent”。 + - 导出的bootevent信息文件可以通过trace分析工具进行可视化展示。 \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-boot-init-service.md b/zh-cn/device-dev/subsystems/subsys-boot-init-service.md index f7dbca859906cce7d5b07b46912fa7415d1f69f0..3fe50696d25a41524f8ab1fdc0f483193728787d 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-init-service.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-init-service.md @@ -89,6 +89,19 @@ "secon" : "u:r:distributedsche:s0" // 服务的SELinux标签, "u:r:distributedsche:s0"为要设置的SELinux标签信息 } ``` + +- 添加selinux标签 + + 服务配置selinux策略,需要通过"secon"为服务添加selinux标签。例如为watchdog_service添加selinux标签,如下: + + ``` + "services" : [{ + "name" : "watchdog_service", + "secon" : "u:r:watchdog_service:s0" + }] + ``` + 对应的需要在selinux中定义此标签,定义方法与配置文件参照selinux指导文档 + - init FD代持(仅标准系统以上提供) FD代持是按需启动的一个辅助扩展机制,按需启动进程可以保持退出前的fd状态句柄不丢失。按需启动进程退出前可将fd发送给init代持,再次启动后再从init获取fd。 diff --git a/zh-cn/device-dev/subsystems/subsys-boot-overview.md b/zh-cn/device-dev/subsystems/subsys-boot-overview.md index 69fd385b94244c0c8e92c289d419ce4db1267e49..c8d02992b4cb304d3a1266712e7abccbf63d89b7 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-overview.md @@ -341,6 +341,134 @@ 有些开发板没有采用ramdisk启动引导,直接通过内核挂载system.img。此场景需要修改productdefine中的产品配置文件,通过"enable_ramdisk"开关关闭ramdisk生成,init也不会从ramdisk里二次启动到system。 -此场景的主要启动过程与上述流程类似,只是有ramdisk时,init会把system.img挂载到/usr目录,然后chroot到/usr下,并且执行/etc/init.cfg入口脚本文件;而没有ramdisk时,没有chroot过程,切init执行的入口启动脚本是init.without_two_stages.cfg文件。 +此场景的主要启动过程与上述流程类似,只是有ramdisk时,init会把system.img挂载到/usr目录,然后chroot到/usr下;而没有ramdisk时,没有chroot过程,但是都会读取init.cfg文件从而执行脚本。 对于无ramdisk的启动加载,即system as root. 在bootloader阶段将根文件系统所在的块设备通过bootargs传给内核,如root=/dev/mmcblk0p5,rootfstype=ext4。内核在初始化根文件系统时,解析bootargs中root,完成根文件系统的挂载。 + + +### A/B分区启动 + +OpenHarmony现支持A/B双分区启动(主备系统分区),即在设备的存储介质上同时存放两套系统分区A和B,启动时根据当前的活动分区标记(我们称之为active partition slot)来决定加载哪一套系统分区。目前支持A/B启动的分区有system分区和chipset分区。 + +- bootslots + + bootslots是指当前支持的启动分区个数,当前bootslots的值被设置为2,表示支持A/B双系统分区启动,如果该值为1,则表示不支持A/B分区启动,仅可从默认系统分区启动。 + + init启动的第一阶段将会读取bootslots值,根据该值判断当前系统是否支持A/B分区,若不支持,则按照默认fstab挂载系统分区;若支持,则继续判断本次启动需要挂载哪一套系统分区。init获取bootslots的主要接口如下: + ``` + int GetBootSlots(void) + { + int bootSlots = GetSlotInfoFromParameter("bootslots"); + BEGET_CHECK_RETURN_VALUE(bootSlots <= 0, bootSlots); + BEGET_LOGI("No valid slot value found from parameter, try to get it from cmdline"); + return GetSlotInfoFromCmdLine("bootslots"); + } + ``` + 在系统正常启动后,用户可以在控制台通过系统参数ohos.boot.bootslots来获取bootslots的值,以查看当前系统是否支持A/B分区启动。获取该系统参数的具体命令如下: + ``` + param get ohos.boot.bootslots + ``` + +- currentslot + + currentslot是指当前启动的系统分区,比如A分区或B分区。currentslot的值使用数字表示,比如数字1表示当前启动A分区,数字2表示当前启动B分区。 + + init在启动的第一阶段通过bootslots判断系统是否支持A/B分区,若不支持,将不再获取currentslot值,直接启动默认系统分区;若支持,将会继续获取currentslot值,根据该值判断当前启动的系统分区为A分区或B分区。init获取currentslot的主要接口如下: + ``` + int GetCurrentSlot(void) + { + // get current slot from parameter + int currentSlot = GetSlotInfoFromParameter("currentslot"); + BEGET_CHECK_RETURN_VALUE(currentSlot <= 0, currentSlot); + BEGET_LOGI("No valid slot value found from parameter, try to get it from cmdline"); + + // get current slot from cmdline + currentSlot = GetSlotInfoFromCmdLine("currentslot"); + BEGET_CHECK_RETURN_VALUE(currentSlot <= 0, currentSlot); + BEGET_LOGI("No valid slot value found from cmdline, try to get it from misc"); + + // get current slot from misc + return GetSlotInfoFromMisc(MISC_PARTITION_ACTIVE_SLOT_OFFSET, MISC_PARTITION_ACTIVE_SLOT_SIZE); + } + ``` + +- A/B分区启动流程 + + 1. 获取当前启动的A/B分区信息,即currentslot信息。 + 2. 以原始fstab为基础构造新的分区挂载配置,为支持A/B启动的分区(目前支持的分区有system分区和chipset分区)添加对应的"_a"或"_b"后缀。 + 3. 按照构造后的分区挂载配置挂载带有相应后缀的分区并切换到启动的第二阶段,启动第二阶段将在具体的A分区或B分区中进行,涉及A/B分区启动部分至此结束。 + + 调整分区挂载配置的主要接口如下: + ``` + static void AdjustPartitionNameByPartitionSlot(FstabItem *item) + { + BEGET_CHECK_ONLY_RETURN(strstr(item->deviceName, "/system") != NULL || + strstr(item->deviceName, "/chipset") != NULL); + char buffer[MAX_BUFFER_LEN] = {0}; + int slot = GetCurrentSlot(); + BEGET_ERROR_CHECK(slot > 0 && slot <= MAX_SLOT, slot = 1, "slot value %d is invalid, set default value", slot); + BEGET_INFO_CHECK(slot > 1, return, "default partition doesn't need to add suffix"); + BEGET_ERROR_CHECK(sprintf_s(buffer, sizeof(buffer), "%s_%c", item->deviceName, 'a' + slot - 1) > 0, + return, "Failed to format partition name suffix, use default partition name"); + free(item->deviceName); + item->deviceName = strdup(buffer); + BEGET_LOGI("partition name with slot suffix: %s", item->deviceName); + } + ``` + +- A/B分区挂载与启动实例 + + 下面以rk3568平台为例,演示系统从默认分区启动到支持A/B分区启动的过程。 + + 1. 烧写原始镜像并查看各分区设备信息 + + ![原始分区](figures/ABStartup_1.png) + + 使用原始镜像构造A/B分区镜像,测试A/B分区启动功能 + - 复制system、vendor镜像并添加_b后缀。 + - 在分区表(parameter.txt)中添加system_b、vendor_b分区。 + + 2. 烧写A/B分区镜像 + + - 在rk3568烧写工具中导入配置,选择带有system_b和vendor_b分区的parameter.txt。 + - 按照新的分区表配置选择镜像(注意新增的system_b和vendor_b镜像),选择完成后烧写。 + + 3. 启动完成后 + + 1. 执行cat /proc/cmdline,能够找到bootslot=2,说明当前系统支持A/B分区启动。 + + ![cmdline](figures/ABStartup_2.png) + 2. 执行param get ohos.boot.bootslot,得到的结果是2,说明bootslot信息被成功写到了parameter中。 + + 3. 执行ls -l /dev/block/by-name,能够找到system_b、vendor_b,说明新增的B分区设备节点创建成功。 + + ![设备信息](figures/ABStartup_3.png) + + 4. 执行df -h 查看当前系统挂载分区。 + + ![分区信息](figures/ABStartup_4.png) + + 可以看到根文件系统(一个 ” / ” 表示)挂载的是mmcblk0p6,从上一张图中可以找到对应mmcblk0p6的是system;也可以看到/vendor中挂载的是mmcblk0p7,从上一张图中可以找到对应mmcblk0p7的是vendor。也就是说,现在挂载的是默认分区(就是原来的没有后缀的system和vendor分区,可以理解为默认分区就是A分区)。 + + 接下来,我们将尝试B分区启动。 + + 1)执行partitionslot setactive 2,将活动分区slot设置为2,也就是B分区的slot。 + + ![设置slot](figures/ABStartup_5.png) + + 2)执行partitionslot getslot,查看刚刚设置的slot值是否设置成功。 + + ![查看slot](figures/ABStartup_6.png) + + current slot: 2表示活动分区slot被成功设置为2 + + 3)重启设备后,执行df -h,查看当前系统挂载分区 + 发现当前根文件系统挂载的是mmcblk0p11,/vendor挂载的是mmcblk0p12。 + + ![挂载信息](figures/ABStartup_7.png) + + 4)再次执行ls -l /dev/block/by-name。 + + ![新增设备信息](figures/ABStartup_8.png) + + 找到mmcblk0p11对应的是system_b,mmcblk0p12对应的是vendor_b,也就是说,本次启动系统已经成功从B分区挂载启动。 diff --git a/zh-cn/device-dev/subsystems/subsys-build-all.md b/zh-cn/device-dev/subsystems/subsys-build-all.md index 21fafa4d6f941cc48eb601f742cd9488c2165c91..602e4e7f22a9f27c59250b2830b3be3be47abd0a 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-all.md +++ b/zh-cn/device-dev/subsystems/subsys-build-all.md @@ -74,7 +74,9 @@ OpenHarmony编译子系统是以GN和Ninja构建为基座,对构建和配置 - 安装方式二:apt-get和pip3 install命令安装 ```shell apt-get update -y - apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9.2 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev + apt-get install -y + # 如果是ubuntu20.04系统请直接安装python3.9,如果是ubuntu18.04请改为安装python3.8 + apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales doxygen apt-get install -y libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev # python需要安装以下模块,repo文件在上一章节约束与限制的源码获取中得到。 @@ -92,7 +94,7 @@ OpenHarmony编译子系统是以GN和Ninja构建为基座,对构建和配置 # export PATH=~/.local/bin:$PATH ``` - ![icon-note.gif](public_sys-resources/icon-note.gif)**注意**:上述安装ohos-build的过程中会安装编译工具hb,但有时会出现hb安装不成功的情况,若安装不成功,则按照[hb安装](../../device-dev/quick-start/quickstart-pkg-install_tool.md#安装hb)重新安装。 + ![icon-note.gif](../public_sys-resources/icon-note.gif)**注意**:上述安装ohos-build的过程中会安装编译工具hb,但有时会出现hb安装不成功的情况,若安装不成功,则按照[hb安装](../../device-dev/quick-start/quickstart-pkg-install_tool.md#安装hb)重新安装。 ## 配置规则 diff --git a/zh-cn/device-dev/subsystems/subsys-build-module.md b/zh-cn/device-dev/subsystems/subsys-build-module.md index 060c3e8cd1de8b643d28172f663400a785f2512e..07c0b3022f064ca92c99795b200684f510ac7514 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-module.md +++ b/zh-cn/device-dev/subsystems/subsys-build-module.md @@ -25,7 +25,7 @@ ohos_resources #其他常用模板 #配置文件 -ohos_prebuild_etc +ohos_prebuilt_etc #sa配置 ohos_sa_profile diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md b/zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md index 59f3e29fcc1a8725ac1df9c58e897e88277e5f47..b53bc41d2d1bf2f3ec39e65317ae996b9776bb52 100755 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @@ -53,7 +53,7 @@ HiLog是OpenHarmony日志系统,提供给系统框架、服务、以及应用 ``` #undef LOG_DOMAIN #undef LOG_TAG - #define LOG_DOMAIN 0 // 标识业务领域,范围0x0~0xFFFFF + #define LOG_DOMAIN 0xD003200 // 标识业务领域,范围0xD000000~0xD0FFFFF #define LOG_TAG "MY_TAG" ``` @@ -82,7 +82,7 @@ HiLog是OpenHarmony日志系统,提供给系统框架、服务、以及应用 ``` class MyClass { - static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "MY_TAG"}; + static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD003200, "MY_TAG"}; ...... } ``` @@ -91,7 +91,7 @@ HiLog是OpenHarmony日志系统,提供给系统框架、服务、以及应用 ``` using namespace OHOS::HiviewDFX; - static constexpr HiLogLabel LABEL = {LOG_CORE, 0, "MY_TAG"}; + static constexpr HiLogLabel LABEL = {LOG_CORE, 0xD003200, "MY_TAG"}; ``` 打印日志: diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md index 11ec506b37867823f6c4e73dae4b7444dba48fe5..43eb7d21472cf8206f517711046af4786a327516 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -76,7 +76,7 @@ HiTraceMeter主要提供抓取用户态和内核态Trace数据的命令行工具 - ![输入图片说明](../../figures/Hitrace.png) +![输入图片说明](figures/HiTraceMeter.png) @@ -108,8 +108,8 @@ C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开 | Sync trace | 功能描述 |参数说明 | | :----------------------------------------------------------- | ------------- |------------- | -| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | 启动同步trace |label: Trace category。 | -| void FinishTrace(uint64_t label); | 关闭同步trace |value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。 | +| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | 启动同步trace |label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。 | +| void FinishTrace(uint64_t label); | 关闭同步trace |label: Trace category。 | 同步接口StartTrace和FinishTrace必须配对使用,FinishTrace和前面最近的StartTrace进行匹配。StartTrace和FinishTrace函数对可以嵌套模式使用,跟踪数据解析时使用栈式数据结构进行匹配。接口中的limit参数用于限流,使用默认值即可。 @@ -118,9 +118,8 @@ C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开 | Async trace | 功能描述 |参数说明 | | ------------------------------------------------------------ | ------------- |------------- | -| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | 开启异步trace | label: Trace category。 | -| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | 关闭异步trace | value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。| -| | | taskId:异步Trace中用来表示关联的ID。 | +| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | 开启异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | +| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | 关闭异步trace | label: Trace category。
value: Trace携带的信息,表明当前的某种状态,例如内存大小,队列长短等。
taskId:异步Trace中用来表示关联的ID。 | @@ -130,8 +129,7 @@ C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开 | Counter Trace | 功能描述 |参数说明 | | ------------------------------------------------------------ | --------- |--------- | -| void CountTrace(uint64_t label, const std::string& name, int64_t); | 计数trace |label: Trace category。。 | -| | |name: Trace的名称,IDE中会以此字段展示这段Trace。 | +| void CountTrace(uint64_t label, const std::string& name, int64_t); | 计数trace |label: Trace category。
name: Trace的名称,IDE中会以此字段展示这段Trace。 | ## 开发步骤 @@ -142,7 +140,7 @@ C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开 ``` 2. 头文件依赖添加。 - ``` + ```cpp #include "hitrace_meter.h"//接口函数定义头文件 ``` @@ -150,39 +148,39 @@ C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开 ```cpp - #include "hitrace_meter.h" // 包含hitrace_meter.h - using namespace std; + #include "hitrace_meter.h" // 包含hitrace_meter.h + using namespace std; - int main() - { - uint64_t label = BYTRACE_TAG_OHOS; - sleep(1); - CountTrace(label, "count number", 2000); // 整数跟踪 - - StartTrace(label, "func1Trace", -1); // func1Start的跟踪起始点 - sleep(1); - StartTrace(label, "func2Trace", -1); // func2Start的跟踪起始点 - sleep(2); - FinishTrace(label); // func2Trace的结束点 - sleep(1); - FinishTrace(label); // func1Trace的结束点 - - sleep(1); - CountTrace(label, "count number", 3000); // 整数跟踪 - - StartAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的开始点 - sleep(1); - StartAsyncTrace(label, "asyncTrace2", 3456); // 异步asyncTrace2的开始点 - StartAsyncTrace(label, "asyncTrace3", 5678); // 异步asyncTrace3的开始点 - sleep(1); - FinishAsyncTrace(label, "asyncTrace3", 5678); // 异步asyncTrace3的结束点 - sleep(1); - FinishAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的结束点 - sleep(1); - FinishAsyncTrace(label, "asyncTrace2", 3456); // 异步asyncTrace2的结束点 - - return 0; - } + int main() + { + uint64_t label = BYTRACE_TAG_OHOS; + sleep(1); + CountTrace(label, "count number", 2000); // 整数跟踪 + + StartTrace(label, "func1Trace", -1); // func1Start的跟踪起始点 + sleep(1); + StartTrace(label, "func2Trace", -1); // func2Start的跟踪起始点 + sleep(2); + FinishTrace(label); // func2Trace的结束点 + sleep(1); + FinishTrace(label); // func1Trace的结束点 + + sleep(1); + CountTrace(label, "count number", 3000); // 整数跟踪 + + StartAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的开始点 + sleep(1); + StartAsyncTrace(label, "asyncTrace2", 3456); // 异步asyncTrace2的开始点 + StartAsyncTrace(label, "asyncTrace3", 5678); // 异步asyncTrace3的开始点 + sleep(1); + FinishAsyncTrace(label, "asyncTrace3", 5678); // 异步asyncTrace3的结束点 + sleep(1); + FinishAsyncTrace(label, "asyncTrace1", 1234); // 异步asyncTrace1的结束点 + sleep(1); + FinishAsyncTrace(label, "asyncTrace2", 3456); // 异步asyncTrace2的结束点 + + return 0; + } ``` diff --git a/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md b/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md index 3a5ef5ef0458f5862de677e1d67c2295b20a5752..f5fbe44ae9d0121ac77eec21f7d8e66b4e2756ad 100644 --- a/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md @@ -230,29 +230,6 @@ hdc_std list targets -v hdc_std start ``` -客户端远程访问服务器 - -1 **kill** - 关闭sever。 - -2 **-s [ip:]port -m** - 启动server。 - - 使用方法: - -``` -hdc_std -s severIP:8710 -m -``` - -3 **-s [ip:]port command** - 指定server执行指令。 - - 使用方法: - -``` -hdc_std -s severIP:8710 list targets -``` - ## 网络相关的命令 @@ -541,3 +518,24 @@ hdc_std -s severIP:8710 list targets - **解决方法** hdc_std.exe不需要安装,直接放到磁盘上就能使用,也可以添加到环境变量中。通过打开cmd执行hdc_std命令直接使用。 + + +### hdc client如何远程访问hdc server + +- **使用场景** + + 本地client指定远程server上的设备,执行hdc命令。 + +- **连接步骤** + 1. 关闭本地sever: + ``` + hdc_std kill + ``` + 2. **-s [ip:]port -m** 启动远程server: + ``` + hdc_std -s severIP:8710 -m + ``` + 3. **-s [ip:]port command** 指定server执行指令: + ``` + hdc_std -s severIP:8710 list targets + ``` diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 1fe6576b25b528ca3483740deb6463590ebf4154..f26f2863bbd04c491f1e4ab3b90d6057e057cf9f 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -465,7 +465,7 @@ - [DFX概述](subsystems/subsys-dfx-overview.md) - [HiLog开发指导](subsystems/subsys-dfx-hilog-rich.md) - [HiLog_Lite开发指导](subsystems/subsys-dfx-hilog-lite.md) - - [HiTrace开发指导](subsystems/subsys-dfx-hitrace.md) + - [HiTraceChain开发指导](subsystems/subsys-dfx-hitracechain.md) - [HiCollie开发指导](subsystems/subsys-dfx-hicollie.md) - HiSysEvent开发指导 - [HiSysEvent打点配置指导](subsystems/subsys-dfx-hisysevent-logging-config.md) @@ -539,23 +539,25 @@ - [启动恢复常见问题](faqs/faqs-startup.md) - [系统应用常见问题](faqs/faqs-system-applications.md) - HDI接口参考 - - 模块 + - 模块 - [Audio](reference/hdi-apis/_audio.md) - [Battery](reference/hdi-apis/battery.md) - - [Camera](reference/hdi-apis/_camera.md) - - [Codec](reference/hdi-apis/_codec.md) + - [Camera](reference/hdi-apis/camera.md) + - [Codec](reference/hdi-apis/codec.md) - [Display](reference/hdi-apis/_display.md) - [HdfFaceAuth](reference/hdi-apis/_hdf_face_auth.md) - - [Input](reference/hdi-apis/_input.md) - - [Light](reference/hdi-apis/_light.md) - [HdfPinAuth](reference/hdi-apis/_hdf_pin_auth.md) + - [HdfUserAuth](reference/hdi-apis/_hdf_user_auth.md) + - [HdiActivityRecognition](reference/hdi-apis/activity_recognition.md) + - [Input](reference/hdi-apis/input.md) + - [Light](reference/hdi-apis/light.md) + - [Motion](reference/hdi-apis/motion.md) - [Power](reference/hdi-apis/power.md) - - [Sensor](reference/hdi-apis/_sensor.md) + - [Sensor](reference/hdi-apis/sensor.md) - [Thermal](reference/hdi-apis/thermal.md) - - [USB](reference/hdi-apis/_u_s_b.md) - - [HdfUserAuth](reference/hdi-apis/_hdf_user_auth.md) - - [Vibrator](reference/hdi-apis/_vibrator.md) - - [WLAN](reference/hdi-apis/_w_l_a_n.md) + - [USB](reference/hdi-apis/usb.md) + - [Vibrator](reference/hdi-apis/vibrator.md) + - [WLAN](reference/hdi-apis/wlan.md) - 头文件和结构体 - 头文件 - [audio_adapter.h](reference/hdi-apis/audio__adapter_8h.md) @@ -567,65 +569,74 @@ - [audio_scene.h](reference/hdi-apis/audio__scene_8h.md) - [audio_types.h](reference/hdi-apis/audio__types_8h.md) - [audio_volume.h](reference/hdi-apis/audio__volume_8h.md) - - [codec_callback_if.h](reference/hdi-apis/codec__callback__if_8h.md) - - [codec_common_type.h](reference/hdi-apis/codec__common__type_8h.md) - - [codec_component_if.h](reference/hdi-apis/codec__component__if_8h.md) - - [codec_component_manager.h](reference/hdi-apis/codec__component__manager_8h.md) - - [codec_component_type.h](reference/hdi-apis/codec__component__type_8h.md) + - [codec_callback_if.h](reference/hdi-apis/codec_callback_if_h.md) + - [codec_common_type.h](reference/hdi-apis/codec_common_type_h.md) + - [codec_component_if.h](reference/hdi-apis/codec_component_if_h.md) + - [codec_component_manager.h](reference/hdi-apis/codec__component__manager_h.md) + - [codec_component_type.h](reference/hdi-apis/codec__component__type_h.md) - [display_device.h](reference/hdi-apis/display__device_8h.md) - [display_gfx.h](reference/hdi-apis/display__gfx_8h.md) - [display_gralloc.h](reference/hdi-apis/display__gralloc_8h.md) - [display_layer.h](reference/hdi-apis/display__layer_8h.md) - [display_type.h](reference/hdi-apis/display__type_8h.md) - - [icamera_device_callback.h](reference/hdi-apis/icamera__device__callback_8h.md) - - [icamera_device.h](reference/hdi-apis/icamera__device_8h.md) - - [icamera_host_callback.h](reference/hdi-apis/icamera__host__callback_8h.md) - - [icamera_host.h](reference/hdi-apis/icamera__host_8h.md) + - [display_vgu.h](reference/hdi-apis/display__vgu_8h.md) - [input_controller.h](reference/hdi-apis/input__controller_8h.md) - [input_manager.h](reference/hdi-apis/input__manager_8h.md) - [input_reporter.h](reference/hdi-apis/input__reporter_8h.md) - [input_type.h](reference/hdi-apis/input__type_8h.md) - - [ioffline_stream_operator.h](reference/hdi-apis/ioffline__stream__operator_8h.md) - - [istream_operator_callback.h](reference/hdi-apis/istream__operator__callback_8h.md) - - [istream_operator.h](reference/hdi-apis/istream__operator_8h.md) - - [light_if.h](reference/hdi-apis/light__if_8h.md) - - [light_type.h](reference/hdi-apis/light_8typeh.md) - - [sensor_if.h](reference/hdi-apis/sensor__if_8h.md) - - [sensor_type.h](reference/hdi-apis/sensor__type_8h.md) - - [types.h](reference/hdi-apis/types_8h.md) - - [usb_info.h](reference/hdi-apis/usb__info_8h.md) - - [usbd_client.h](reference/hdi-apis/usbd__client_8h.md) - - [usbd_subscriber.h](reference/hdi-apis/usbd__subscriber_8h.md) - - [usbd_type.h](reference/hdi-apis/usbd__type_8h.md) - - [vibrator_if.h](reference/hdi-apis/vibrator__if_8h.md) - - [vibrator_type.h](reference/hdi-apis/vibrator__type_8h.md) - - [wifi_hal_ap_feature.h](reference/hdi-apis/wifi__hal__ap__feature_8h.md) - - [wifi_hal_base_feature.h](reference/hdi-apis/wifi__hal__base__feature_8h.md) - - [wifi_hal_sta_feature.h](reference/hdi-apis/wifi__hal__sta__feature_8h.md) - - [wifi_hal.h](reference/hdi-apis/wifi__hal_8h.md) + - [ActivityRecognitionTypes.idl](reference/hdi-apis/activity_recognition_types_idl.md) + - [Types.idl](reference/hdi-apis/battery_types_idl.md) - [IExecutor.idl](reference/hdi-apis/face__auth_2_i_executor_8idl.md) - [IExecutorCallback.idl](reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md) - [FaceAuthTypes.idl](reference/hdi-apis/_face_auth_types_8idl.md) - [PinAuthTypes.idl](reference/hdi-apis/_pin_auth_types_8idl.md) - - [IBatteryCallback.idl](reference/hdi-apis/_i_battery_callback_8idl.md) - - [IBatteryInterface.idl](reference/hdi-apis/_i_battery_interface_8idl.md) - [IExecutor.idl](reference/hdi-apis/pin__auth_2_i_executor_8idl.md) - [IExecutorCallback.idl](reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md) - [IFaceAuthInterface.idl](reference/hdi-apis/_i_face_auth_interface_8idl.md) - [IPinAuthInterface.idl](reference/hdi-apis/_i_pin_auth_interface_8idl.md) + - [IUserAuthInterface.idl](reference/hdi-apis/_i_user_auth_interface_8idl.md) + - [UserAuthTypes.idl](reference/hdi-apis/_user_auth_types_8idl.md) + - [IActivityChangedCallback.idl](reference/hdi-apis/_i_activity_changed_callback_8idl.md) + - [IActivityInterface.idl](reference/hdi-apis/_i_activity_interface_8idl.md) + - [IBatteryCallback.idl](reference/hdi-apis/_i_battery_callback_8idl.md) + - [IBatteryInterface.idl](reference/hdi-apis/_i_battery_interface_8idl.md) + - [ICameraDevice.idl](reference/hdi-apis/_i_camera_device_8idl.md) + - [ICameraDeviceCallback.idl](reference/hdi-apis/_i_camera_device_callback_8idl.md) + - [ICameraHostCallback.idl](reference/hdi-apis/_i_camera_host_callback_8idl.md) + - [ICameraHost.idl](reference/hdi-apis/_i_camera_host_8idl.md) + - [ILightInterface.idl](reference/hdi-apis/_i_light_interface_8idl.md) + - [IMotionCallback.idl](reference/hdi-apis/_i_motion_callback_8idl.md) + - [IMotionInterface.idl](reference/hdi-apis/_i_motion_interface_8idl.md) + - [IOfflineStreamOperator.idl](reference/hdi-apis/_i_offline_stream_operator_8idl.md) - [IPowerHdiCallback.idl](reference/hdi-apis/_i_power_hdi_callback_8idl.md) - [IPowerInterface.idl](reference/hdi-apis/_i_power_interface_8idl.md) - - [IThermalInterface.idl](reference/hdi-apis/_i_thermal_interface_8idl.md) + - [ISensorCallback.idl](reference/hdi-apis/_i_sensor_callback_8idl.md) + - [ISensorInterface.idl](reference/hdi-apis/_i_sensor_interface_8idl.md) + - [IStreamOperator.idl](reference/hdi-apis/_i_stream_operator_8idl.md) + - [IStreamOperatorCallback.idl](reference/hdi-apis/_i_stream_operator_callback_8idl.md) - [IThermalCallback.idl](reference/hdi-apis/_i_thermal_callback_8idl.md) - - [IUserAuthInterface.idl](reference/hdi-apis/_i_user_auth_interface_8idl.md) + - [IThermalInterface.idl](reference/hdi-apis/_i_thermal_interface_8idl.md) + - [IUsbdBulkCallback.idl](reference/hdi-apis/_i_usbd_bulk_callback_8idl.md) + - [IUsbInterface.idl](reference/hdi-apis/_i_usb_interface_8idl.md) + - [IUsbdSubscriber.idl](reference/hdi-apis/_i_usbd_subscriber_8idl.md) + - [IVibratorInterface.idl](reference/hdi-apis/_i_vibrator_interface_8idl.md) + - [IWlanCallback.idl](reference/hdi-apis/_i_wlan_callback_8idl.md) + - [IWlanInterface.idl](reference/hdi-apis/_i_wlan_interface_8idl.md) + - [LightTypes.idl](reference/hdi-apis/_light_types_8idl.md) + - [MotionTypes.idl](reference/hdi-apis/_motion_types_8idl.md) - [PowerTypes.idl](reference/hdi-apis/_power_types_8idl.md) + - [SensorTypes.idl](reference/hdi-apis/_sensor_types_8idl.md) - [ThermalTypes.idl](reference/hdi-apis/_thermal_types_8idl.md) - - [Types.idl](reference/hdi-apis/_types_8idl.md) - - [UserAuthTypes.idl](reference/hdi-apis/_user_auth_types_8idl.md) + - [Types.idl](reference/hdi-apis/camera_2v1__0_2_types_8idl.md) + - [UsbTypes.idl](reference/hdi-apis/_usb_types_8idl.md) + - [VibratorTypes.idl](reference/hdi-apis/_vibrator_types_8idl.md) + - [WlanTypes.idl](reference/hdi-apis/_wlan_types_8idl.md) - 结构体 - - [attribute](reference/hdi-apis/____attribute____.md) - - [Alignment](reference/hdi-apis/_alignment.md) + - [YUVDescInfo](reference/hdi-apis/_yun_desc_info_.md) + - [ExtDataHandle](reference/hdi-apis/_ext_data_handle.md) + - [ActRecognitionEvent](reference/hdi-apis/_act_recognition_event.md) - [AllocInfo](reference/hdi-apis/_alloc_info.md) + - [Alignment](reference/hdi-apis/_alignment.md) - [AudioAdapter](reference/hdi-apis/_audio_adapter.md) - [AudioAdapterDescriptor](reference/hdi-apis/_audio_adapter_descriptor.md) - [AudioAttribute](reference/hdi-apis/_audio_attribute.md) @@ -637,7 +648,7 @@ - [AudioMixExtInfo](reference/hdi-apis/_audio_mix_ext_info.md) - [AudioMmapBufferDescripter](reference/hdi-apis/_audio_mmap_buffer_descripter.md) - [AudioPort](reference/hdi-apis/_audio_port.md) - - [AudioPortCap](reference/hdi-apis/_audio_port_cap.md) + - [AudioPortCap](reference/hdi-apis/audio_portcap.md) - [AudioPortCapability](reference/hdi-apis/_audio_port_capability.md) - [AudioRender](reference/hdi-apis/_audio_render.md) - [AudioRoute](reference/hdi-apis/_audio_route.md) @@ -652,12 +663,16 @@ - [AudioVolume](reference/hdi-apis/_audio_volume.md) - [AuthResultInfo](reference/hdi-apis/_auth_result_info.md) - [AuthSolution](reference/hdi-apis/_auth_solution.md) - - [BatteryInfo](reference/hdi-apis/_battery_info.md) - [BufferData](reference/hdi-apis/_buffer_data.md) + - [BatteryInfo](reference/hdi-apis/_battery_info.md) + - [CaptureEndedInfo](reference/hdi-apis/_capture_ended_info.md) + - [CaptureErrorInfo](reference/hdi-apis/_capture_error_info.md) + - [CaptureInfo](reference/hdi-apis/_capture_info.md) - [CodecCallbackType](reference/hdi-apis/_codec_callback_type.md) - [CodecCompCapability](reference/hdi-apis/_codec_comp_capability.md) - [CodecComponentManager](reference/hdi-apis/_codec_component_manager.md) - [CodecComponentType](reference/hdi-apis/_codec_component_type.md) + - [ColorValue](reference/hdi-apis/union_color_value.md) - [CompVerInfo](reference/hdi-apis/_comp_ver_info.md) - [CredentialInfo](reference/hdi-apis/_credential_info.md) - [DeviceFuncs](reference/hdi-apis/_device_funcs.md) @@ -676,11 +691,33 @@ - [GfxFuncs](reference/hdi-apis/_gfx_funcs.md) - [GfxOpt](reference/hdi-apis/_gfx_opt.md) - [GrallocFuncs](reference/hdi-apis/_gralloc_funcs.md) + - [HdfFeatureInfo](reference/hdi-apis/_hdf_feature_info.md) + - [HdfLightColor](reference/hdi-apis/_hdf_light_color.md) + - [HdfLightEffect](reference/hdi-apis/_hdf_light_effect.md) + - [HdfLightFlashEffect](reference/hdi-apis/_hdf_light_flash_effect.md) + - [HdfLightInfo](reference/hdi-apis/_hdf_light_info.md) + - [HdfMotionEvent](reference/hdi-apis/_hdf_motion_event.md) + - [HdfNetDeviceInfo](reference/hdi-apis/_hdf_net_device_info.md) + - [HdfNetDeviceInfoResult](reference/hdi-apis/_hdf_net_device_info_result.md) + - [HdfSensorEvents](reference/hdi-apis/_hdf_sensor_events.md) + - [HdfSensorInformation](reference/hdi-apis/_hdf_sensor_information.md) + - [HdfStaInfo](reference/hdi-apis/_hdf_sta_info.md) - [HdfThermalCallbackInfo](reference/hdi-apis/_hdf_thermal_callback_info.md) + - [HdfVibratorInfo](reference/hdi-apis/_hdf_vibrator_info.md) + - [HdfWifiDriverScanSsid](reference/hdi-apis/_hdf_wifi_driver_scan_ssid.md) + - [HdfWifiInfo](reference/hdi-apis/_hdf_wifi_info.md) + - [HdfWifiScan](reference/hdi-apis/_hdf_wifi_scan.md) + - [HdfWifiScanResult](reference/hdi-apis/_hdf_wifi_scan_result.md) - [HDRCapability](reference/hdi-apis/_h_d_r_capability.md) - [HDRMetaData](reference/hdi-apis/_h_d_r_meta_data.md) + - [IActivityChangedCallback](reference/hdi-apis/interface_i_activity_changed_callback.md) + - [IActivityInterface](reference/hdi-apis/interface_i_activity_interface.md) - [IBatteryCallback](reference/hdi-apis/interface_i_battery_callback.md) - [IBatteryInterface](reference/hdi-apis/interface_i_battery_interface.md) + - [ICameraDevice](reference/hdi-apis/interface_i_camera_device.md) + - [ICameraDeviceCallback](reference/hdi-apis/interface_i_camera_device_callback.md) + - [ICameraHost](reference/hdi-apis/interface_i_camera_host.md) + - [ICameraHostCallback](reference/hdi-apis/interface_i_camera_host_callback.md) - [ICircle](reference/hdi-apis/_i_circle.md) - [IdentifyResultInfo](reference/hdi-apis/_identify_result_info.md) - [IExecutor](reference/hdi-apis/interface_i_executor.md) @@ -688,80 +725,95 @@ - [IExecutorCallback](reference/hdi-apis/interface_i_executor_callback.md) - [IExecutorCallback](reference/hdi-apis/interface_pin_i_executor_callback.md) - [IFaceAuthInterface](reference/hdi-apis/interface_i_face_auth_interface.md) - - [IInputInterface](reference/hdi-apis/_i_input_interface.md) - [ILine](reference/hdi-apis/_i_line.md) + - [IInputInterface](reference/hdi-apis/_i_input_interface.md) + - [ILightInterface](reference/hdi-apis/interface_i_light_interface.md) + - [IMotionCallback](reference/hdi-apis/interface_i_motion_callback.md) + - [IMotionInterface](reference/hdi-apis/interface_i_motion_interface.md) - [InputController](reference/hdi-apis/_input_controller.md) - [InputDevAbility](reference/hdi-apis/_input_dev_ability.md) - - [InputDevAttr](reference/hdi-apis/_input_dev_attr.md) + - [InputDevAttr](reference/hdi-apis/_input_dev_attr.md) - [InputDevDesc](reference/hdi-apis/_input_dev_desc.md) + - [InputDeviceInfo](reference/hdi-apis/_input_device_info.md) - [InputDevIdentify](reference/hdi-apis/_input_dev_identify.md) - - [InputDeviceInfo](reference/hdi-apis/_device_info.md) - - [InputDimensionInfo](reference/hdi-apis/_input_dimension_info.md) - - [InputEventCb](reference/hdi-apis/_input_report_event_cb.md) - - [InputEventPackage](reference/hdi-apis/_event_package.md) + - [InputDimensionInfo](reference/hdi-apis/_input_dimension_info.md) + - [InputEventCb](reference/hdi-apis/_input_event_cb.md) + - [InputEventPackage](reference/hdi-apis/_input_event_package.md) + - [IPowerHdiCallback](reference/hdi-apis/interface_i_power_hdi_callback.md) - [InputExtraCmd](reference/hdi-apis/_input_extra_cmd.md) - [InputHostCb](reference/hdi-apis/_input_host_cb.md) - - [InputHotPlugEvent](reference/hdi-apis/_input_hotplug_event.md) + - [InputHotPlugEvent](reference/hdi-apis/_input_hot_plug_event.md) - [InputManager](reference/hdi-apis/_input_manager.md) - [InputReporter](reference/hdi-apis/_input_reporter.md) + - [IOfflineStreamOperator](reference/hdi-apis/interface_i_offline_stream_operator.md) - [IPinAuthInterface](reference/hdi-apis/interface_i_pin_auth_interface.md) - - [IPowerHdiCallback](reference/hdi-apis/interface_i_power_hdi_callback.md) - [IPowerInterface](reference/hdi-apis/interface_i_power_interface.md) - [IRect](reference/hdi-apis/_i_rect.md) + - [ISensorCallback](reference/hdi-apis/interface_i_sensor_callback.md) + - [ISensorInterface](reference/hdi-apis/interface_i_sensor_interface.md) + - [IStreamOperator](reference/hdi-apis/interface_i_stream_operator.md) + - [IStreamOperatorCallback](reference/hdi-apis/interface_i_stream_operator_callback.md) - [ISurface](reference/hdi-apis/_i_surface.md) - [IThermalCallback](reference/hdi-apis/interface_i_thermal_callback.md) - [IThermalInterface](reference/hdi-apis/interface_i_thermal_interface.md) + - [IUsbdBulkCallback](reference/hdi-apis/interface_i_usbd_bulk_callback.md) + - [IUsbdSubscriber](reference/hdi-apis/interface_i_usbd_subscriber.md) + - [IUsbInterface](reference/hdi-apis/interface_i_usb_interface.md) - [IUserAuthInterface](reference/hdi-apis/interface_i_user_auth_interface.md) - - [IWiFi](reference/hdi-apis/_i_wi_fi.md) - - [IWiFiAp](reference/hdi-apis/_i_wi_fi_ap.md) - - [IWiFiBaseFeature](reference/hdi-apis/_i_wi_fi_base_feature.md) - - [IWiFiSta](reference/hdi-apis/_i_wi_fi_sta.md) + - [IVibratorInterface](reference/hdi-apis/interface_i_vibrator_interface.md) + - [IWlanCallback](reference/hdi-apis/interface_i_wlan_callback.md) + - [IWlanInterface](reference/hdi-apis/interface_i_wlan_interface.md) - [LayerAlpha](reference/hdi-apis/_layer_alpha.md) - [LayerBuffer](reference/hdi-apis/_layer_buffer.md) - [LayerFuncs](reference/hdi-apis/_layer_funcs.md) - [LayerInfo](reference/hdi-apis/_layer_info.md) - - [LightEffect](reference/hdi-apis/_light_effect.md) - - [LightFlashEffect](reference/hdi-apis/_light_flash_effect.md) - - [LightInfo](reference/hdi-apis/_light_info.md) - - [LightInterface](reference/hdi-apis/_light_interface.md) - - [OHOS::Camera::CaptureEndedInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) - - [OHOS::Camera::CaptureErrorInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md) - - [OHOS::Camera::CaptureInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md) - - [OHOS::Camera::ICameraDevice](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md) - - [OHOS::Camera::ICameraDeviceCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) - - [OHOS::Camera::ICameraHost](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md) - - [OHOS::Camera::ICameraHostCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) - - [OHOS::Camera::IOfflineStreamOperator](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) - - [OHOS::Camera::IStreamOperator](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) - - [OHOS::Camera::IStreamOperatorCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) - - [OHOS::Camera::StreamAttribute](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md) - - [OHOS::Camera::StreamInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md) - - [OHOS::USB::UsbCtrlTransfer](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) - - [OHOS::USB::UsbdClient](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) - - [OHOS::USB::UsbDev](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) - - [OHOS::USB::USBDeviceInfo](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) - - [OHOS::USB::UsbdSubscriber](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) - - [OHOS::USB::UsbInfo](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) - - [OHOS::USB::UsbPipe](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) + - [MeasChannelParam](reference/hdi-apis/_meas_channel_param.md) + - [MeasChannelResult](reference/hdi-apis/_meas_channel_result.md) - [OmxCodecBuffer](reference/hdi-apis/_omx_codec_buffer.md) - [PortCap](reference/hdi-apis/union_port_cap.md) + - [PortInfo](reference/hdi-apis/_port_info.md) - [PresentTimestamp](reference/hdi-apis/_present_timestamp.md) - [PropertyObject](reference/hdi-apis/_property_object.md) + - [ProjectionScreenCmdParam](reference/hdi-apis/_projection_screen_cmd_param.md) - [RangeValue](reference/hdi-apis/_range_value.md) - [Rect](reference/hdi-apis/_rect.md) - [Rectangle](reference/hdi-apis/_rectangle.md) + - [RGBColor](reference/hdi-apis/_r_g_b_color.md) - [ScheduleInfo](reference/hdi-apis/_schedule_info.md) - - [SensorEvents](reference/hdi-apis/_sensor_events.md) - - [SensorInformation](reference/hdi-apis/_sensor_information.md) - - [SensorInterface](reference/hdi-apis/_sensor_interface.md) - - [StaInfo](reference/hdi-apis/_sta_info.md) + - [StreamAttribute](reference/hdi-apis/_stream_attribute.md) + - [StreamInfo](reference/hdi-apis/_stream_info.md) - [SupportBufferType](reference/hdi-apis/_support_buffer_type.md) - [TemplateInfo](reference/hdi-apis/_template_info.md) - [ThermalZoneInfo](reference/hdi-apis/_thermal_zone_info.md) + - [UsbCtrlTransfer](reference/hdi-apis/_usb_ctrl_transfer.md) + - [UsbDev](reference/hdi-apis/_usb_dev.md) + - [USBDeviceInfo](reference/hdi-apis/_u_s_b_device_info.md) + - [UsbPipe](reference/hdi-apis/_usb_pipe.md) - [UseBufferType](reference/hdi-apis/_use_buffer_type.md) - [VerifyAllocInfo](reference/hdi-apis/_verify_alloc_info.md) - - [VibratorInterface](reference/hdi-apis/_vibrator_interface.md) + - [VGUBuffer](reference/hdi-apis/_v_g_u_buffer.md) + - [VGUColorStop](reference/hdi-apis/_v_g_u_color_stop.md) + - [VGUConic](reference/hdi-apis/_v_g_u_conic.md) + - [VGUFillAttr](reference/hdi-apis/_v_g_u_fill_attr.md) + - [VGUFuncs](reference/hdi-apis/_v_g_u_funcs.md) + - [VGUGradient](reference/hdi-apis/_v_g_u_gradient.md) + - [VGUImage](reference/hdi-apis/_v_g_u_image.md) + - [VGULinear](reference/hdi-apis/_v_g_u_linear.md) + - [VGUMaskLayer](reference/hdi-apis/_v_g_u_mask_layer.md) + - [VGUMatrix3](reference/hdi-apis/_v_g_u_matrix3.md) + - [VGUPaintStyle](reference/hdi-apis/_v_g_u_paint_style.md) + - [VGUPath](reference/hdi-apis/_v_g_u_path.md) + - [VGUPattern](reference/hdi-apis/_v_g_u_pattern.md) + - [VGUPoint](reference/hdi-apis/_v_g_u_point.md) + - [VGURadial](reference/hdi-apis/_v_g_u_radial.md) + - [VGURect](reference/hdi-apis/_v_g_u_rect.md) + - [VGUSolid](reference/hdi-apis/_v_g_u_solid.md) + - [VGUStrokeAttr](reference/hdi-apis/_v_g_u_stroke_attr.md) + - [VGUSurface](reference/hdi-apis/_v_g_u_surface.md) - [VideoPortCap](reference/hdi-apis/_video_port_cap.md) + - [WifiStationInfo](reference/hdi-apis/_wifi_station_info.md) + - [WRGBColor](reference/hdi-apis/_w_r_g_b_color.md) + - CMSIS API参考 - [CMSIS](reference/kernel/cmsis/_c_m_s_i_s-_r_t_o_s.md) diff --git a/zh-cn/figures/Hitrace.png b/zh-cn/figures/Hitrace.png deleted file mode 100644 index 258d0c9d7b5b95b9d10072b9771bc6f761be3c7b..0000000000000000000000000000000000000000 Binary files a/zh-cn/figures/Hitrace.png and /dev/null differ diff --git a/zh-cn/figures/hitrace.png b/zh-cn/figures/hitrace.png deleted file mode 100644 index e9f5ac4d22acc96f6bb0d163405367c50689b90e..0000000000000000000000000000000000000000 Binary files a/zh-cn/figures/hitrace.png and /dev/null differ diff --git a/zh-cn/readme/figures/build_framework_ZN.PNG b/zh-cn/readme/figures/build_framework_ZN.PNG new file mode 100644 index 0000000000000000000000000000000000000000..03f4d6f6cffc9d3552f86f197230d01a50e2860e Binary files /dev/null and b/zh-cn/readme/figures/build_framework_ZN.PNG differ diff --git a/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md b/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md new file mode 100644 index 0000000000000000000000000000000000000000..4c7289ed1c70c6171775bf34f9701689e94e5792 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md @@ -0,0 +1,21 @@ +# 3.1 release相对于3.1 beta变更详细说明 + +### 针对color.json中颜色值,增加合法性校验 + +针对color.json中颜色值,增加合法性校验,其校验规则如下: + +- 使用十六进制颜色码,格式如下: + - #rgb:red(0-f) green(0-f) blue(0-f) + - #argb:transparency(0-f) red(0-f) green(0-f) blue(0-f) + - #rrggbb: red(00-ff) green(00-ff) blue(00-ff) + - #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff) +- 使用$引用应用中已定义的资源,格式如下: + - $color:xxx + +**变更影响** + +不符合上述校验规则,将在编译时报错。 + +**关键的接口/组件变更** + +无 \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.1-Release/readme.md b/zh-cn/release-notes/api-change/v3.1-Release/readme.md index ca69ac422e485e04f319ae9dcddabf66012a99dd..6c1ca7ef961568d5b08f3d6b8eb91f83b3dc47db 100644 --- a/zh-cn/release-notes/api-change/v3.1-Release/readme.md +++ b/zh-cn/release-notes/api-change/v3.1-Release/readme.md @@ -4,7 +4,7 @@ - [JS API差异报告](js-apidiff-v3.1-release.md) - [Native API差异报告](native-apidiff-v3.1-release.md) +- [3.1 release相对于3.1 beta变更详细说明](changelog-v3.1-release.md) 此外,本次还发布了OpenHarmony 3.2 Canary (API Version 9 Canary)版本: [JS API差异报告(API Version 9 Canary)](js-apidiff-v3.2-canary.md) - diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md b/zh-cn/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md index 97cc21a129800e7f6018318d098ceeb4657e37d2..b218e9aecd626766f51f3e1a2b5249f0b53a6762 100644 --- a/zh-cn/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md +++ b/zh-cn/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md @@ -39,7 +39,7 @@ OpenHarmony应用沙箱组件 ![](figures/compile-change1-2.png) -**变更2:**自定义组件Struct的成员属性不能和内置属性方法名重名。 +**变更2**:自定义组件Struct的成员属性不能和内置属性方法名重名。 **变更影响** diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md b/zh-cn/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md new file mode 100644 index 0000000000000000000000000000000000000000..48b3fb3ed9d96a59e63451b2aa1010d5298c3cda --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md @@ -0,0 +1,195 @@ +# 3.2 beta3相对于3.2 beta2变更详细说明 + +## 包管理子系统 + +Beta3版本上增加了预置应用特权管控能力,可以分为两部分:预置应用权限管控和预置应用的配置方法。 +应用特权是指应用所具备的一些高等级的特殊能力,比如限制应用不可被卸载、应用内数据不可被删除等。 +OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单独配置的应用特权。OpenHarmony支持在不同产品上对预置应用进行差异化配置,设备厂商可根据需要对预置应用进行配置。此外,OpenHarmony根据GetCfgDirList获得系统支持的预置目录,如system、chipset、sys_prod、chip_prod;并且按照返回的顺序越靠后优先级越高,如chip_prod的优先级高于system的优先级。 + +### 预置应用安装方式变更 + +当前预置应用的安装方式由自动扫描目录/system/app下面的hap安装,变更为通过白名单配置方式安装。在install_list.json中配置app-dir的hap才会被自动安装,并成为预置应用。 + +**变更影响** + +不涉及js及native接口,对开发应用无影响。 + +**关键的接口/组件变更** + +无 + +**适配指导** + +在[/system/etc/app/install_list.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list.json)文件中配置相关字段,app_dir表示hap所在的目录,removable表示hap安装后是否可卸载。如下所示: + +```json +{ + "install_list" : [ + { + "app_dir" : "/system/app/com.ohos.systemui", + "removable" : false + }, + { + "app_dir" : "/system/app/demo.hap", + "removable" : true + } + ] +} +``` + +### 通用应用特权管控变更 + +通用的应用特权是指应用在不同设备类型上都可以获得的特权,可分为以下几种: +| 权限 | 描述 | +| ---------------- | ------------------------------------------------------------ | +| AllowAppDataNotCleared | 是否允许应用数据被删除 | +| AllowAppMultiProcess | 是否允许应用多进程 | +| AllowAppDesktopIconHide | 是否允许隐藏桌面图标 | +| AllowAbilityPriorityQueried | 是否允许Ability配置查询优先级 | +| AllowAbilityExcludeFromMissions | 是否允许Ability不在任务栈中显示 | +| AllowAppUsePrivilegeExtension | 是否允许应用使用ServiceExtension、DataExtension | +| AllowFormVisibleNotify | 是否允许桌面卡片可见 | + +上述特权之前通过config.json或者module.json进行配置,并结合是否为预置应用和系统应用进行区分,本次变更为根据签名证书和预置白名单的方式进行配置,其它方式均无效。 + +**变更影响** + +不涉及js及native接口,如果开发的应用中使用上述特权,那就需要应用开发者申请对应的特权,申请及配置方式可参考[应用配置指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md)。 + +**关键的接口/组件变更** + +无 + +**适配指导** + +可参考[应用配置指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md) + +```json +{ + "version-name": "1.0.0", + ... + "bundle-info": { + "developer-id": "OpenHarmony", + ... + }, + "issuer": "pki_internal", + "app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // 应用的数据不允许被删除且允许隐藏桌面图标 +} +``` + +### 产品化应用特权管控变更 +除了通用应用特权外,设备厂商还可以为各类设备额外定义允许配置的特权项,包括: + +| 权限 | 类型 | 默认值 | 描述 | +| --------------------- | -------- | ------ | ------------------------------------------------- | +| removable | bool | true | 是否允许应用被卸载,仅预置应用生效 | +| keepAlive | bool | false | 是否允许应用常驻 | +| singleton | bool | false | 是否允许应用安装到单用户下(U0) | +| allowCommonEvent | string[] | - | 是否允许静态广播拉起 | +| associatedWakeUp | bool | false | 是否允许FA模型应用被关联唤醒 | +| runningResourcesApply | bool | false | 是否允许应用运行资源申请(CPU、事件通知、蓝牙等) | + +上述特权之前通过config.json或者module.json进行配置,并结合是否为预置应用和系统应用进行区分,本次变更为根据预置白名单[install_list_capability.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json)的方式进行配置,其它方式均无效。 + +**变更影响** + +不涉及js及native接口,如果开发的应用中使用上述特权,那就需要应用开发者申请对应的特权,可参考[配置方式](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md#%E9%85%8D%E7%BD%AE%E6%96%B9%E5%BC%8F-1)。 + +**关键的接口/组件变更** + +无 + +**适配指导** + +可参考[配置方式](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md#%E9%85%8D%E7%BD%AE%E6%96%B9%E5%BC%8F-1) + +```json +{ + "install_list": [ + { + "bundleName": "com.example.kikakeyboard", + "singleton": true, // 应用安装到单用户下 + "keepAlive": true, // 应用常驻 + "runningResourcesApply": true, // 运行资源申请(CPU、事件通知、蓝牙等) + "associatedWakeUp": true, // FA模型应用被关联唤醒 + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // 当配置的证书指纹和hap的证书指纹一致才生效 + "allowCommonEvent": ["usual.event.SCREEN_ON", "usual.event.THERMAL_LEVEL_CHANGED"] + } +} +``` + +### 预授权白名单增加指纹信息校验 + +预授权文件[install_list_permissions.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json)在开发板上的路径由system/etc/permission变更为system/etc/app/。新增字段app_signature,表示hap的指纹信息,可以配置多个指纹信息。在授权时,指纹信息匹配成功才能授权。 + +**变更影响** + +不涉及js及native接口,如果开发的应用中使用了预授权能力,需要在预授权文件中增加指纹信息,未配置会导致预授权失败。 + +**关键的接口/组件变更** + +无 + +**适配指导** +可参考: +```json +{ +[ + { + "bundleName" : "com.ohos.screenshot", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : true + }, + { + "name" : "ohos.permission.READ_MEDIA", + "userCancellable" : true + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "userCancellable" : true + } + ] + } +} +``` + +## ArkUI子系统 + +### 修复FA模型下编译构建release hap模式的公共模块变量共享问题 + +两个页面依赖同一个文件的对象(foodData)时,当页面A修改了这个对象,当页面B读取这个对象时,获取到的是页面A修改后的值,从而实现了公共模块对象共享。 + +**变更影响** + +FA模型下的公共模块变量共享之前是作为需求交付的,在中间某个版本开始,编译release的hap该功能缺失,编译debug的hap一直是正常的,在830版本修复了编译release hap模式下的公共模块变量共享功能。 + +不影响应用编译,无需适配接口。 + +**关键的接口/组件变更** + +无 + +## 全球化子系统 + +### 针对color.json中颜色值,增加合法性校验 + +针对color.json中颜色值,增加合法性校验,其校验规则如下: + +- 使用十六进制颜色码,格式如下: + - #rgb:red(0-f) green(0-f) blue(0-f) + - #argb:transparency(0-f) red(0-f) green(0-f) blue(0-f) + - #rrggbb: red(00-ff) green(00-ff) blue(00-ff) + - #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff) +- 使用$引用应用中已定义的资源,格式如下: + - $color:xxx + +**变更影响** + +不符合上述校验规则,将在编译时报错。 + +**关键的接口/组件变更** + +无 \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/readme.md b/zh-cn/release-notes/api-change/v3.2-beta3/readme.md index d7d625cedc1f45a4dde5a863423d719e9e25edd3..c2f939199d3257e650eb48736ec275e72a3fad6c 100644 --- a/zh-cn/release-notes/api-change/v3.2-beta3/readme.md +++ b/zh-cn/release-notes/api-change/v3.2-beta3/readme.md @@ -30,3 +30,4 @@ - [升级服务](js-apidiff-update.md) - [Web](js-apidiff-web.md) - [窗口管理](js-apidiff-window.md) +- [3.2 beta3相对于3.2 beta2变更详细说明](changelog-v3.2-beta3.md) diff --git a/zh-cn/website.md b/zh-cn/website.md index dd1f69e29f2ade64a53ceab0c95904cfb789e054..50ce7f0dfc23de70e0de59450db04c3bdfdf2fd7 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -59,6 +59,7 @@ - [升级服务](release-notes/api-change/v3.2-beta3/js-apidiff-update.md) - [Web](release-notes/api-change/v3.2-beta3/js-apidiff-web.md) - [窗口管理](release-notes/api-change/v3.2-beta3/js-apidiff-window.md) + - [3.2 beta3相对于3.2 beta2变更详细说明](release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md) - OpenHarmony 3.2 Beta2 - JS API差异报告 - [元能力](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md) @@ -154,6 +155,7 @@ - [资源调度](release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler_api-9-canary.md) - [窗口管理](release-notes/api-change/v3.1-Release/js-apidiff-window_api-9-canary.md) - [Native API差异报告](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md) + - [3.1 release相对于3.1 beta变更详细说明](release-notes/api-change/v3.1-Release/changelog-v3.1-release.md) - OpenHarmony 3.1 Beta - [JS API差异报告](release-notes/api-change/v3.1-beta/js-apidiff-v3.1-beta.md) - [Native API差异报告](release-notes/api-change/v3.1-beta/native-apidiff-v3.1-beta.md)