diff --git a/CODEOWNERS b/CODEOWNERS index 6a8730751d65c0cd83e109d7a4edffce37b988ec..cd5e192f6dfec673acfd1a1c594cb33b3a173978 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -231,7 +231,7 @@ zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-camera.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-image.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-media.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-i18n.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-intl.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @HelloCrease @@ -366,6 +366,7 @@ zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease zh-cn/application-dev/website.md @zengyawen zh-cn/application-dev/faqs/ @zengyawen zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @qinxiaowang zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen -zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen \ No newline at end of file +zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen +zh-cn/application-dev/file-management/ @qinxiaowang \ No newline at end of file diff --git a/en/application-dev/ability/ability-brief.md b/en/application-dev/ability/ability-brief.md index 0d2303bf4f84c2ddc6f34a13d28b02a3762893b0..f0eb1ad833dfd7e21d275d48d40715221c542a50 100644 --- a/en/application-dev/ability/ability-brief.md +++ b/en/application-dev/ability/ability-brief.md @@ -5,7 +5,7 @@ An ability is the abstraction of a functionality that an application can provide The ability framework model has two forms: - FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there is Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. -- Stage model, which is introduced since API version 9. In the stage model, there is `Ability` and `ExtensionAbility`. `ExtensionAbility` is further extended to `ServiceExtensionAbility`, `FormExtensionAbility`, `DataShareExtensionAbility`, and more. +- Stage model, which is introduced since API version 9. In the stage model, there is `PageAbility` and `ExtensionAbility`. `ExtensionAbility` is further extended to `ServiceExtensionAbility`, `FormExtensionAbility`, `DataShareExtensionAbility`, and more. The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models. diff --git a/en/application-dev/ability/fa-brief.md b/en/application-dev/ability/fa-brief.md index b89c15504376f326629dd2b3dd537e1633d986d0..598ff0f5a79488925cc63d5b29afb0eaa86877aa 100644 --- a/en/application-dev/ability/fa-brief.md +++ b/en/application-dev/ability/fa-brief.md @@ -12,6 +12,7 @@ The Feature Ability (FA) model applies to application development using API vers ## Lifecycle Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and acts as a touchpoint for interacting with users. + **The following figure shows the lifecycle of the Page ability.** ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) @@ -26,3 +27,9 @@ Currently, the **app.js** file provides only the **onCreate** and **onDestroy** An application exclusively uses an independent process, and an ability exclusively uses an independent thread. When an ability is started for the first time, an application process as well as a thread for this ability is created. After the application is started, other abilities in the application are started, and a thread is created for every of these started abilities. Each ability is bound to an independent JSRuntime instance. In this way, abilities are isolated from each other. ![fa-threading-model](figures/fa-threading-model.png) + +## Application Package Structure + +For details about the project directory structure of the FA model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section4154183910141). + +For details about how to configure the application package structure of the FA model, see [Application Package Structure Configuration File](../quick-start/package-structure.md). diff --git a/en/application-dev/ability/figures/favsstage.png b/en/application-dev/ability/figures/favsstage.png index 45f6b0ef255b01730dc42023430391e1141291c2..13b1766da57d89f206068dbb03741ba1f0ae96ff 100644 Binary files a/en/application-dev/ability/figures/favsstage.png and b/en/application-dev/ability/figures/favsstage.png differ diff --git a/en/application-dev/ability/figures/lifecycle.png b/en/application-dev/ability/figures/lifecycle.png index 694238d99c7e70d16d6bd1a37c86bcd599a9b2f3..345dd474c68069251a2c4ce8c9e8d792dbe029ef 100644 Binary files a/en/application-dev/ability/figures/lifecycle.png and b/en/application-dev/ability/figures/lifecycle.png differ diff --git a/en/application-dev/ability/figures/stageabilitylifecyclecallback.png b/en/application-dev/ability/figures/stageabilitylifecyclecallback.png index 9e17ed71f1dc9d118a490109c1e5181d738e63db..8dbfac680bc9ce6e0509ebc19bfc0ca035187c90 100644 Binary files a/en/application-dev/ability/figures/stageabilitylifecyclecallback.png and b/en/application-dev/ability/figures/stageabilitylifecyclecallback.png differ diff --git a/en/application-dev/ability/stage-brief.md b/en/application-dev/ability/stage-brief.md index 0b4bfe8e3ec2943528e3bd2e8b640dea4ffbd070..427495774aa06066f6fd38c972ef59eafb102cf3 100644 --- a/en/application-dev/ability/stage-brief.md +++ b/en/application-dev/ability/stage-brief.md @@ -49,6 +49,8 @@ The ability and ability stage lifecycles are the rudiments of the basic process To implement device-specific tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes. +There are two lifecycle states related to **WindowStage** in **Ability**: **onWindowStageCreate** and **onWindowStageDestroy**. They are valid only for devices with the window display capability. **onWindowStageCreate** is invoked when a window stage is created, where you can call **loadContent** to set pages to be loaded for the ability. **onWindowStageDestroy** is invoked when the window stage is destroyed, where you can release resources. + ## Ability Instances and Missions @@ -58,7 +60,7 @@ Abilities can be started in any of the following modes: + **Standard**: Each time **startAbility** is called, an instance of the specified ability type is created in the application process. **Ability2** in the figure below is started in standard mode. -+ **Specified**: Before creating an **AbilityRecord**, you can create a key for the instance. Each time **startAbility** is called, the system asks the application which ability instance (corresponding to a key) will be used. **Ability3** in the figure below is started in specified mode. ++ **Specified**: Before creating an **Ability** instance, you can create a key for the instance. Each time **startAbility** is called, the system asks the application which ability instance (corresponding to a key) will be used. **Ability3** in the figure below is started in specified mode. Each ability instance corresponds to a mission in **Launcher Recent**. @@ -92,6 +94,12 @@ All OpenHarmony applications are designed to meet the single-process model. In t - Render process: created for the WebView and used to load the WebView rendering library. - The following figure shows the process model of an application. +The following figure shows the process model of an application. + +![stageprocessmodel](figures/stageprocessmodel.png) + +## Application Package Structure + +For details about the project directory structure of the stage model, see [OpenHarmony Project Overview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section56487581904). - ![stageprocessmodel](figures/stageprocessmodel.png) +For details about how to configure the application package structure of the stage model, see [Application Package Structure Configuration File (Stage Model)](../quick-start/stage-structure.md). 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/faqs/faqs-data-management.md b/en/application-dev/faqs/faqs-data-management.md index 839514879b8198273bc86680614b6b2054f662e2..a35f335d1db6f89033e4deb839cf9b7af0f544a2 100644 --- a/en/application-dev/faqs/faqs-data-management.md +++ b/en/application-dev/faqs/faqs-data-management.md @@ -1,4 +1,4 @@ -# Device Management Development +# Data Management Development diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index dc2f0ef50ad05bc74b3e7ba301c421dfc3dae741..116af9c40bdb3c13cc278a13bb7ae5b08330095f 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -381,6 +381,53 @@ context.getDisplayOrientation().then((data) => { }); ``` +## Context.getExternalCacheDir + +getExternalCacheDir(callback: AsyncCallback\): void + +Obtains the external cache directory of the application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | Yes | Callback used to return the absolute path of the cache directory.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getExternalCacheDir() +``` + +## Context.getExternalCacheDir + +getExternalCacheDir(): Promise\; + +Obtains the external cache directory of the application. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| ---------------- | ---------------- | +| Promise\ | Promise used to return the absolute path of the cache directory.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getExternalCacheDir().then((data) => { + console.info("=======================>getExternalCacheDirCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + ## Context.setDisplayOrientation7+ setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\): void 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-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md index 98529f06257e7d2dfe3e9a395fd176dd413bb347..8c85faa1eee7abbbc888e11cd5c12f2a308905c7 100644 --- a/en/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -68,7 +68,7 @@ This is a system API. **Example** ``` -let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} +let keyOptions = {preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0} let callback = function(keyOptions) { console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) 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/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index eb52d85a2c418842f2cb2d581fb0583917b68622..9d8332040bdcfece8717aacd79ea2eb579686cdd 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -75,7 +75,7 @@ Obtains detailed information about a system error code. callbackWrapper(original: Function): (err: Object, value: Object )=>void -Calls back an asynchronous function. In the callback, the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved), and the second parameter indicates the resolved value. +Wraps an asynchronous function (or a function that returns a promise) into an error-first callback, which means that **(err, value) => ...** is used as the last parameter of the callback. In the callback, the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved), and the second parameter indicates the resolved value. **System capability**: SystemCapability.Utils.Lang @@ -110,9 +110,10 @@ Calls back an asynchronous function. In the callback, the first parameter indica promiseWrapper(original: (err: Object, value: Object) => void): Object > **NOTE** +> > This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead. -Processes an asynchronous function and returns a promise version. +Wraps a function that follows the error-first callback paradigm into a promise. **System capability**: SystemCapability.Utils.Lang diff --git a/en/application-dev/security/Readme-EN.md b/en/application-dev/security/Readme-EN.md index b2d2dd285383d23e61b3c9bdbfb06a167cdd1b2c..c7c051cfe4cc83e8c1b59f8517401e2a4207d59f 100644 --- a/en/application-dev/security/Readme-EN.md +++ b/en/application-dev/security/Readme-EN.md @@ -2,7 +2,7 @@ - Access Control - [Access Control (Permission) Overview](accesstoken-overview.md) - - [Access Control (Permission) Development](accesstoken-guidelines.md) + - [Guide for Requesting Permissions from User](accesstoken-guidelines.md) - [Application Permission List](permission-list.md) - User Authentication - [User Authentication Overview](userauth-overview.md) diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index 4349c32625fd1d28c230f6d60c2120641a6c7f33..71caf0a817d7115f6ce59359ff7d979a975f2406 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -1,4 +1,4 @@ -# Access Control (Permission) Development +# Guide for Requesting Permissions from User ## When to Use @@ -13,14 +13,14 @@ In this example, the app requires the **ohos.permission.PERMISSION1** and **ohos > In this scenario, the required permissions include a **user_grant** permission. You can check whether the caller has the required permission through permission verification. > > If the permission verification result indicates that the app has not obtained that permission, dynamic user authorization is required. -> + ## Available APIs -The table below lists only the API used in this guide. For more information, see the [API Reference](../reference/apis/js-apis-abilityAccessCtrl.md). +The table below lists only the API used in this guide. For more information, see [Ability Access control](../reference/apis/js-apis-ability-context.md). | API | Description | | ------------------------------------------------------------ | --------------------------------------------------- | -| verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStatus> | Verifies whether an app has the specified permission. This API uses a promise to return the result.| +| requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; | Requests permissions from the user by displaying a dialog box. This API uses an asynchronous callback to return the result.| ## Declaring Permissions @@ -88,10 +88,10 @@ For the apps based on the stage model, declare the required permissions in the * "name" : "ohos.permission.PERMISSION1", "reason": "$string:reason", "usedScene": { - "abilities": [ - "FormAbility" - ], - "when":"inuse" + "abilities": [ + "FormAbility" + ], + "when":"inuse" } }, { @@ -101,7 +101,7 @@ For the apps based on the stage model, declare the required permissions in the * "abilities": [ "FormAbility" ], - "when":"always" + "when":"always" } } ] @@ -137,22 +137,22 @@ If the verification result indicates that the app has the permission, the app ca > **CAUTION** > -> The permissions authorized by user are not permanent, because the user may revoke the authorization at any time. Therefore, even if the user has granted the requested permission to an app, the app's permission must be verified before the app calls an API protected by the permission. +> The permission authorized by a user is not permanent, because the user may revoke the authorization at any time. Each time before the API protected by the permission is called, call **requestPermissionsFromUser()** to request the permission. ## Example -The procedure is as follows: +The procedure for requesting user authorization is as follows: 1. Obtain the ability context. -2. Call **requestPermissionsFromUser** to verify whether the app has required permissions. -3. Proceed based on the permission verification result. +2. Call **requestPermissionsFromUser()** to request user authorization. The API determines whether to display a dialog box to request user authorization based on whether the app has the permission. +3. Check whether the app has the permission based on the return value. If the app has the permission, the API can be invoked. ```js - // OnWindowStageCreate lifecycle of the ability + // OnWindowStageCreate of the ability onWindowStageCreate() { var context = this.context let array:Array = ["ohos.permission.PERMISSION2"]; - // requestPermissionsFromUser determines whether to invoke a pop-up window based on the permission authorization status. + // requestPermissionsFromUser determines whether to display a dialog box based on the permission authorization status. context.requestPermissionsFromUser(array).then(function(data) { console.log("data type:" + typeof(data)); console.log("data:" + data); @@ -165,4 +165,4 @@ The procedure is as follows: ``` > **NOTE**
-> For details about how to use **requestPermissionsFromUser**, see [API Reference](../reference/apis/js-apis-ability-context.md). +> For details about the APIs, see [AbilityContext](../reference/apis/js-apis-ability-context.md). 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/Readme-EN.md b/en/device-dev/driver/Readme-EN.md index 20f72079db50e75be15aa62d6a150fda60b9aaf6..3ee388ec4c5a5d7eaa3300995f53044b9f0d15e8 100644 --- a/en/device-dev/driver/Readme-EN.md +++ b/en/device-dev/driver/Readme-EN.md @@ -45,6 +45,7 @@ - Peripheral Driver Usage - [Audio](driver-peripherals-audio-des.md) - [Camera](driver-peripherals-camera-des.md) + - [Codec](driver-peripherals-codec-des.md) - [Facial Authentication](driver-peripherals-face_auth-des.md) - [Fingerprint Authentication](driver-peripherals-fingerprint_auth-des.md) - [LCD](driver-peripherals-lcd-des.md) diff --git a/en/device-dev/driver/driver-peripherals-codec-des.md b/en/device-dev/driver/driver-peripherals-codec-des.md new file mode 100644 index 0000000000000000000000000000000000000000..fcc4ccf2c47a05a71e06bce9f5e695586024a12c --- /dev/null +++ b/en/device-dev/driver/driver-peripherals-codec-des.md @@ -0,0 +1,761 @@ +# Codec + +## Overview +### Function + +The OpenHarmony codec Hardware Device Interface (HDI) driver framework implements the video hardware codec driver based on OpenMAX. It provides APIs for the upper-layer media services to obtain component encoding and decoding capabilities, create a component, set parameters, transfer data, and destroy a component. The codec driver can encode video data in YUV or RGB format to H.264 or H.265 format, and decode raw stream data from H.264 or H.265 format to YUV or RGB format. This document describes the codec functionality developed based on the OpenHarmony Hardware Driver Foundation (HDF). + +The codec HDI driver framework is implemented based on the HDF. The figure below shows the codec HDI driver framework. + +**Figure 1** Codec HDI driver framework + +![image](figures/Codec_architecture.png "Codec HDI driver framework") + +- Codec HDI Callback Remote Service: an anonymous callback service used to process callbacks. +- Codec HDI: provides standard APIs based on OpenMAX. The upper layer services call the APIs to implement hardware encoding and decoding. +- Codec HDI Adapter: HDI implementation layer, which implements HDI APIs and interacts with OpenMAX Integration layer (IL). +- OpenMAX IL interface: provides OpenMAX IL APIs to directly interact with the codec HDI driver. +- Vendor Impl: vendor adaptation layer, which is the OpenMAX implementation layer adapted by each vendor. +- Codec Hardware: hardware decoding device. + +### Basic Concepts +Before you get started, understand the following concepts: + +- Sampling rate + + The number of samples taken from continuous signals every second to form discrete signals, in Hz. + +- OpenMAX IL + + A standardized media component interface to enable applications and media frameworks to interact with multimedia codecs and supported components in a unified manner. + +- Frame rate + + Number of frames of images transmitted per second, or the number of times that a GPU can refresh images per second. A higher frame rate indicates smoother motion, while a lower frame rate means choppier motion and blurry footage. + +- Bit rate + + Number of bits transmitted or processed per unit of time, generally in kbit/s. A higher bit rate indicates clearer image, while a lower bit rate means blurry image with artifacts. + +- Component + + An OpenMAX IL component, which is an abstraction of modules in video streams. The components in this document refer to codec components for video encoding and decoding. + +### Constraints + +The codec HDI applies only to the standard system. + +For more details, see [OpenMAX IL](https://www.khronos.org/api/openmax/il). + +## Development Guidelines + +### When to Use +The codec module implements hardware encoding and decoding of video data. It converts raw stream data such as H.264 data into YUV or RGB data, and converts YUV or RGB data into data formats such as H.264. + +### Available APIs + +- codec_component_manager.h + + | API | Description | + | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------| + | int32_t (*CreateComponent)(struct CodecComponentType **component, uint32_t *componentId, char *compName, int64_t appData, struct CodecCallbackType *callbacks) | Creates a codec component instance. | + | int32_t (*DestroyComponent)(uint32_t componentId) | Destroys a component instance. | + +- codec_component _if.h + + | API | Description | + | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | + | int32_t (*SendCommand)(struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen) | Sends commands to a component. | + | int32_t (*GetParameter)(struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) | Obtains component parameter settings. | + | int32_t (*SetParameter)(struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen) | Sets component parameters. | + | int32_t (*GetState)(struct CodecComponentType *self, enum OMX_STATETYPE *state) | Obtains the component status. | + | int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) | Specifies the buffer of a component port. | + | int32_t (*FreeBuffer)(struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer) | Releases the buffer. | + | int32_t (*EmptyThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) | Empties this buffer. | + | int32_t (*FillThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) | Fills this buffer. | + +- codec_callback_if.h + + | API | Description | + | ---------------------------------------------------------------------------------------------------------------- |----------------------------------- | + | int32_t (*EventHandler)(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) | Reports an event. | + | int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer) | Reports an event indicating that the encoding or decoding in the input buffer is complete.| + | int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer) | Reports an event indicating that the output buffer is filled. | + +For more information, see [codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec). + +### Development Procedure +The codec HDI driver development procedure is as follows: + +#### Registering and Initializing the Driver +Define the **HdfDriverEntry** structure (which defines the driver initialization method) and fill in the **g_codecComponentDriverEntry** structure to implement the **Bind()**, **Init()**, and **Release()** pointers. + +```c +struct HdfDriverEntry g_codecComponentDriverEntry = { + .moduleVersion = 1, + .moduleName = "codec_hdi_omx_server", + .Bind = HdfCodecComponentTypeDriverBind, + .Init = HdfCodecComponentTypeDriverInit, + .Release = HdfCodecComponentTypeDriverRelease, +}; +HDF_INIT(g_codecComponentDriverEntry); // Register HdfDriverEntry of the codec HDI with the HDF. +``` + +- **HdfCodecComponentTypeDriverBind**: binds the device in the HDF to **CodecComponentTypeHost** and registers the codec service with the HDF. + + ```c + int32_t HdfCodecComponentTypeDriverBind(struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfCodecComponentTypeDriverBind enter."); + struct HdfCodecComponentTypeHost *omxcomponenttypeHost = + (struct HdfCodecComponentTypeHost *)OsalMemAlloc(sizeof(struct HdfCodecComponentTypeHost)); + if (omxcomponenttypeHost == NULL) { + HDF_LOGE("HdfCodecComponentTypeDriverBind OsalMemAlloc HdfCodecComponentTypeHost failed!"); + return HDF_FAILURE; + } + int ret = HdfDeviceObjectSetInterfaceDesc(deviceObject, COMPONENT_MANAGER_SERVICE_DESC); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Failed to set interface desc"); + return ret; + } + + omxcomponenttypeHost->ioservice.Dispatch = CodecComponentTypeDriverDispatch; + omxcomponenttypeHost->ioservice.Open = NULL; + omxcomponenttypeHost->ioservice.Release = NULL; + omxcomponenttypeHost->service = CodecComponentManagerSerivceGet(); + if (omxcomponenttypeHost->service == NULL) { + OsalMemFree(omxcomponenttypeHost); + return HDF_FAILURE; + } + + deviceObject->service = &omxcomponenttypeHost->ioservice; + return HDF_SUCCESS; + } + ``` + +- **HdfCodecComponentTypeDriverInit**: loads the attribute configuration from the HDF configuration source (HCS). + + ```c + int32_t HdfCodecComponentTypeDriverInit(struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfCodecComponentTypeDriverInit enter."); + if (deviceObject == NULL) { + return HDF_FAILURE; + } + InitDataNode(deviceObject->property); + if (LoadCapabilityData() != HDF_SUCCESS) { + ClearCapabilityData(); + } + return HDF_SUCCESS; + } + ``` + +- **HdfCodecComponentTypeDriverRelease**: releases the driver instance. + + ```c + void HdfCodecComponentTypeDriverRelease(struct HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfCodecComponentTypeDriverRelease enter."); + struct HdfCodecComponentTypeHost *omxcomponenttypeHost = + CONTAINER_OF(deviceObject->service, struct HdfCodecComponentTypeHost, ioservice); + OmxComponentManagerSeriveRelease(omxcomponenttypeHost->service); + OsalMemFree(omxcomponenttypeHost); + ClearCapabilityData(); + } + ``` + +#### Driver HCS +The HCS consists of the following: + +- Device configuration +- Configuration of the supported components + +The HCS includes the driver node, loading sequence, and service name. For details about the HCS syntax, see [Configuration Management](driver-hdf-manage.md). + +Configuration file Path of the standard system: +vendor/hihope/rk3568/hdf_config/uhdf/ + +1. Device configuration + + Add the **codec_omx_service** configuration to **codec_host** in **device_info.hcs**. The following is an example: + ```c + codec :: host { + hostName = "codec_host"; + priority = 50; + gid = ["codec_host", "uhdf_driver", "vendor_mpp_driver"]; + codec_omx_device :: device { + device0 :: deviceNode { + policy = 2; // Automatic loading, not lazy loading. + priority = 100; // Priority. + moduleName = "libcodec_hdi_omx_server.z.so"; // Dynamic library of the driver. + serviceName = "codec_hdi_omx_service"; // Service name of the driver. + deviceMatchAttr = "codec_component_capabilities"; //Attribute configuration. + } + } + } + ``` + +2. Configuration of supported components + + Add the component configuration to the **media_codec\codec_component_capabilities.hcs file**. The following is an example: + ```c + /* node name explanation -- HDF_video_hw_enc_avc_rk: + ** + ** HDF____________video__________________hw____________________enc____________avc_______rk + ** | | | | | | + ** HDF or OMX video or audio hardware or software encoder or decoder mime vendor + */ + HDF_video_hw_enc_avc_rk { + role = 1; // Role of the AvCodec. + type = 1; // Codec type. + name = "OMX.rk.video_encoder.avc"; // Component name. + supportProfiles = [1, 32768, 2, 32768, 8, 32768]; // Supported profiles. + maxInst = 4; // Maximum number of instances. + isSoftwareCodec = false; // Whether it is software codec. + processModeMask = []; // Codec processing mode. + capsMask = [0x01]; // Codec playback capabilities. + minBitRate = 1; // Minimum bit rate. + maxBitRate = 40000000; // Maximum bit rate. + minWidth = 176; // Minimum video width. + minHeight = 144;; // Minimum video height. + maxWidth = 1920; // Maximum video width. + maxHeight = 1088; // Maximum video height. + widthAlignment = 16; // Horizontal alignment. + heightAlignment = 8; // Vertical alignment. + minBlockCount = 0xFFFFFFFF; + maxBlockCount = 0xFFFFFFFF; + minBlocksPerSecond = 0xFFFFFFFF; + maxBlocksPerSecond = 0xFFFFFFFF; + blockSizeWidth = 0xFFFFFFFF; + blockSizeHeight = 0xFFFFFFFF; + supportPixelFmts = [28, 24, 30, 22, 7, 3, 14, 13, 20, 26, 27, 12]; // List of supported colors. + measuredFrameRate = [320, 240, 165, 165, 720, 480, 149, 149, 1280, 720, 73, 73, 1920, 1080, 18, 18]; + bitRateMode = [1, 2]; // Bit rate mode. + minFrameRate = 0; // Frame rate. + maxFrameRate = 0; + } + ``` + +### Development Example +After completing codec module driver adaptation, use the HDI APIs provided by the codec module for further development. The codec HDI provides the following features: + +1. Provides codec HDI APIs for video services to implement encoding and decoding of video services. +2. Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem. + +The development procedure is as follows: + +1. Initialize the driver, including initializing the instances, callbacks, and component. +2. Set codec parameters and information such as the video width, height, and bit rate. +3. Apply for input and output buffers. +4. Flip codec buffers, enable the component to enter the **OMX_Executing** state, and process the callbacks. +5. Deinitialize the interface instance, destroy the buffers, close the component, and releases all interface objects. + +#### Initializing the Driver +Initialize the interface instance and callbacks, and create a component. +```cpp +// Initialize the codec HDI ComponentManager instance. +omxMgr_ = GetCodecComponentManager(); + +// Initialize the callback. +callback_ = CodecCallbackTypeStubGetInstance(); +if (!omxMgr_ || !callback_) { + FUNC_EXIT_ERR(); + return false; +} +// Set the callback pointers. +callback_->EventHandler = &OMXCore::OnEvent; +callback_->EmptyBufferDone = &OMXCore::OnEmptyBufferDone; +callback_->FillBufferDone = &OMXCore::OnFillBufferDone; + +// Create a component instance. +uint32_t err = HDF_SUCCESS; +if (codec == codecMime::AVC) { + err = omxMgr_->CreateComponent(&client_, &componentId_, const_cast(DECODER_AVC), (int64_t)this, + callback_); +} else { + err = omxMgr_->CreateComponent(&client_, &componentId_, const_cast(DECODER_HEVC), (int64_t)this, + callback_); +} +``` + +#### Setting Codec Parameters and Configuration +Set the width and height of the input and output data, input data format, and output data format. +```cpp +// Set the width and height of the input image. +OMX_PARAM_PORTDEFINITIONTYPE param; +InitParam(param); +param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT; +auto err = client_->GetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed PortIndex::PORT_INDEX_INPUT, index is OMX_IndexParamPortDefinition", __func__); + return false; +} +HDF_LOGI("PortIndex::PORT_INDEX_INPUT: eCompressionFormat = %{public}d, eColorFormat = %{public}d ", + param.format.video.eCompressionFormat, param.format.video.eColorFormat); +param.format.video.nFrameWidth = width_; +param.format.video.nFrameHeight = height_; +param.format.video.nStride = width_; +param.format.video.nSliceHeight = height_; +err = client_->SetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed with PortIndex::PORT_INDEX_INPUT, index is OMX_IndexParamPortDefinition", __func__); + return false; +} +// Set the output width, height, and format. +InitParam(param); +param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT; +err = client_->GetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed with PortIndex::PORT_INDEX_OUTPUT, index is OMX_IndexParamPortDefinition", __func__); + return false; +} +HDF_LOGI("PortIndex::PORT_INDEX_OUTPUT eCompressionFormat = %{public}d, eColorFormat=%{public}d", + param.format.video.eCompressionFormat, param.format.video.eColorFormat); +param.format.video.nFrameWidth = width_; +param.format.video.nFrameHeight = height_; +param.format.video.nStride = width_; +param.format.video.nSliceHeight = height_; +param.format.video.eColorFormat = AV_COLOR_FORMAT; // Set the output data format to YUV420SP. +err = client_->SetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed with PortIndex::PORT_INDEX_OUTPUT, index is OMX_IndexParamPortDefinition", + __func__); + return false; +} +// Set the input data format to H.264/H.265. +OMX_VIDEO_PARAM_PORTFORMATTYPE param; +InitParam(param); +param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT; +auto err = client_->GetParameter(client_, OMX_IndexParamVideoPortFormat, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed with PortIndex::PORT_INDEX_INPUT", __func__); + return false; +} +HDF_LOGI("set Format PortIndex::PORT_INDEX_INPUT eCompressionFormat = %{public}d, eColorFormat=%{public}d", + param.eCompressionFormat, param.eColorFormat); +param.xFramerate = FRAME; // Set the frame rate to 30. +if (codecMime_ == codecMime::AVC) { + param.eCompressionFormat = OMX_VIDEO_CodingAVC; // H264 +} else { + param.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingHEVC; // H265 +} + +err = client_->SetParameter(client_, OMX_IndexParamVideoPortFormat, (int8_t *)¶m, sizeof(param)); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed with PortIndex::PORT_INDEX_INPUT", __func__); + return false; +} +``` + +#### Applying for Input and Output Buffers +Perform the following steps: + +1. Use **UseBuffer()** to apply for input and output buffers and save the buffer IDs. The buffer IDs can be used for subsequent buffer flipping. +2. Check whether the corresponding port is enabled. If not, enable the port first. +3. Use **SendCommand()** to change the component status to OMX_StateIdle, and wait until the operation result is obtained. +```cpp +// Apply for the input buffer. +auto ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT); +if (!ret) { + HDF_LOGE("%{public}s UseBufferOnPort PortIndex::PORT_INDEX_INPUT error", __func__); + return false; +} +// Apply for the output buffer. +ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT); +if (!ret) { + HDF_LOGE("%{public}s UseBufferOnPort PortIndex::PORT_INDEX_OUTPUT error", __func__); + return false; +} +// Enable the component to enter the OMX_StateIdle state. +auto err = client_->SendCommand(client_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed to SendCommand with OMX_CommandStateSet:OMX_StateIdle", __func__); + return false; +} +HDF_LOGI("Wait for OMX_StateIdle status"); +this->WaitForStatusChanged(); +``` + +Implement **UseBufferOnPort** as follows: + +```cpp +bool CodecHdiDecode::UseBufferOnPort(enum PortIndex portIndex) +{ + HDF_LOGI("%{public}s enter, portIndex = %{public}d", __func__, portIndex); + int bufferSize = 0; + int bufferCount = 0; + bool bPortEnable = false; + // Obtain parameters of the port buffer. + OMX_PARAM_PORTDEFINITIONTYPE param; + InitParam(param); + param.nPortIndex = (OMX_U32)portIndex; + auto err = client_->GetParameter(client_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param)); + if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed to GetParameter with OMX_IndexParamPortDefinition : portIndex[%{public}d]", + __func__, portIndex); + return false; + } + bufferSize = param.nBufferSize; + bufferCount = param.nBufferCountActual; + bPortEnable = param.bEnabled; + HDF_LOGI("buffer index [%{public}d], buffer size [%{public}d], " + "buffer count [%{public}d], portEnable[%{public}d], err [%{public}d]", + portIndex, bufferSize, bufferCount, bPortEnable, err); + { + OMX_PARAM_BUFFERSUPPLIERTYPE param; + InitParam(param); + param.nPortIndex = (uint32_t)portIndex; + auto err = client_->GetParameter(client_, OMX_IndexParamCompBufferSupplier, (int8_t *)¶m, sizeof(param)); + HDF_LOGI("param.eBufferSupplier[%{public}d] isSupply [%{public}d], err [%{public}d]", param.eBufferSupplier, + this->isSupply_, err); + } + // Set the port buffer. + UseBufferOnPort(portIndex, bufferCount, bufferSize); + // Check whether the port is available. + if (!bPortEnable) { + auto err = client_->SendCommand(client_, OMX_CommandPortEnable, (uint32_t)portIndex, NULL, 0); + if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s SendCommand OMX_CommandPortEnable::PortIndex::PORT_INDEX_INPUT error", __func__); + return false; + } + } + return true; +} + +bool CodecHdiDecode::UseBufferOnPort(enum PortIndex portIndex, int bufferCount, int bufferSize) +{ + for (int i = 0; i < bufferCount; i++) { + OmxCodecBuffer *omxBuffer = new OmxCodecBuffer(); + memset_s(omxBuffer, sizeof(OmxCodecBuffer), 0, sizeof(OmxCodecBuffer)); + omxBuffer->size = sizeof(OmxCodecBuffer); + omxBuffer->version.s.nVersionMajor = 1; + omxBuffer->bufferType = BUFFER_TYPE_AVSHARE_MEM_FD; + int fd = AshmemCreate(0, bufferSize); + shared_ptr sharedMem = make_shared(fd, bufferSize); + omxBuffer->bufferLen = FD_SIZE; + omxBuffer->buffer = (uint8_t *)(unsigned long)fd; + omxBuffer->allocLen = bufferSize; + omxBuffer->fenceFd = -1; + + if (portIndex == PortIndex::PORT_INDEX_INPUT) { + omxBuffer->type = READ_ONLY_TYPE; // ReadOnly + sharedMem->MapReadAndWriteAshmem(); + } else { + omxBuffer->type = READ_WRITE_TYPE; + sharedMem->MapReadOnlyAshmem(); + } + auto err = client_->UseBuffer(client_, (uint32_t)portIndex, omxBuffer); + if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed to UseBuffer with portIndex[%{public}d]", __func__, portIndex); + sharedMem->UnmapAshmem(); + sharedMem->CloseAshmem(); + sharedMem = nullptr; + return false; + } + omxBuffer->bufferLen = 0; + HDF_LOGI("UseBuffer returned bufferID [%{public}d]", omxBuffer->bufferId); + + BufferInfo *bufferInfo = new BufferInfo; + bufferInfo->omxBuffer = omxBuffer; + bufferInfo->avSharedPtr = sharedMem; + bufferInfo->portIndex = portIndex; + omxBuffers_.insert(std::make_pair(omxBuffer->bufferId, std::move(bufferInfo))); + if (portIndex == PortIndex::PORT_INDEX_INPUT) { + unUsedInBuffers_.push_back(omxBuffer->bufferId); + } else { + unUsedOutBuffers_.push_back(omxBuffer->bufferId); + } + int fdret = (int)omxBuffer->buffer; + HDF_LOGI("{bufferID = %{public}d, srcfd = %{public}d, retfd = %{public}d}", omxBuffer->bufferId, fd, fdret); + } + return true; +} +``` + +#### Codec Buffer Flipping +Set the component to the **OMX_StateExecuting** state, fill the input buffer, read data from the output buffer, and flip the buffers. + +```cpp +// Set the component to the OMX_StateExecuting state and start buffer flipping. +HDF_LOGI("...command to OMX_StateExecuting...."); +auto err = client_->SendCommand(client_, OMX_CommandStateSet, OMX_StateExecuting, NULL, 0); +if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s failed to SendCommand with OMX_CommandStateSet:OMX_StateIdle", __func__); + return; +} +// Set the output buffer. +for (auto bufferId : unUsedOutBuffers_) { + HDF_LOGI("fill bufferid [%{public}d]", bufferId); + auto iter = omxBuffers_.find(bufferId); + if (iter != omxBuffers_.end()) { + BufferInfo *bufferInfo = iter->second; + auto err = client_->FillThisBuffer(client_, bufferInfo->pOmxBuffer); + if (err != HDF_SUCCESS) { + HDF_LOGE("FillThisBuffer error"); + FUNC_EXIT_ERR(); + return; + } + } +} +// Fill the input buffer. +bool bEndOfFile = false; +while (!bEndOfFile) { + int bufferID = GetFreeBufferId(); + if (this->exit_) { + break; + } + if (bufferID < 0) { + usleep(10000); + continue; + } + auto iter = omxBuffers_.find(bufferID); + if (iter == omxBuffers_.end()) { + continue; + } + BufferInfo *bufferInfo = iter->second; + void *sharedAddr = (void *)bufferInfo->avSharedPtr->ReadFromAshmem(0, 0); + bool bEOS = (size_t)this->ReadOnePacket(fpIn_, (char *)sharedAddr, bufferInfo->omxBuffer->filledLen); + HDF_LOGI("read data size is %{public}d", bufferInfo->omxBuffer->filledLen); + bufferInfo->omxBuffer->offset = 0; + if (bEOS) { + bufferInfo->omxBuffer->flag = OMX_BUFFERFLAG_EOS; + bEndOfFile = true; + } + auto err = client_->EmptyThisBuffer(client_, bufferInfo->omxBuffer); + if (err != HDF_SUCCESS) { + HDF_LOGE("%{public}s EmptyThisBuffer error", __func__); + return; + } +} +// Wait. +while (!this->exit_) { + usleep(10000); + continue; +} +// Enable the component to enter the OMX_StateIdle state after decoding. +client_->SendCommand(client_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0); +``` + +Automatic framing is not supported in rk OMX decoding. Therefore, you need to manually divide data into frames. Currently, data is divided into frames from code 0x000001 or 0x00000001 and sent to the server for processing. The sample code is as follows: + +```cpp +// Read a file by frame. +bool OMXCore::ReadOnePacket(FILE* fp, char* buf, uint32_t& nFilled) +{ + // Read four bytes first. + size_t t = fread(buf, 1, 4, fp); + if (t < 4) { + // The file reading ends. + return true; + } + size_t filled = 0; + filled = 4; + + bool bRet = true; + while (!feof(fp)) { + fread(buf + filled, 1, 1, fp); + if (buf[filled] == 1) { + // Check the start code. + if ((buf[filled - 1] == 0) && + (buf[filled - 2] == 0) && + (buf[filled - 3] == 0)) { + fseek(fp, -4, SEEK_CUR); + filled -= 3; + bRet = false; + break; + } else if ((buf[filled - 1] == 0) && + (buf[filled - 2] == 0)) { + fseek(fp, -3, SEEK_CUR); + filled -= 2; + bRet = false; + break; + } + } + filled++; + } + nFilled = filled; + return bRet; +} +``` + +The codec HDI provides the following callbacks: + +- **EventHandler**: Called when a command is executed. For example, when the command for changing the component state from **OMX_StateIdle** to **OMX_StateExecuting** is executed, this callback is invoked to return the result. +- **EmptyBufferDone**: Called when the input data is consumed. If the client needs to fill in data to encode or decode, call **EmptyThisBuffer()**. +- **FillBufferDone**: Called when the output data is filled. If the client needs to read the encoded or decoded data, call **FillThisBuffer()**. + +```cpp +// EmptyBufferDone example +int32_t OMXCore::OnEmptyBufferDone(struct CodecCallbackType *self, int8_t *pAppData, uint32_t pAppDataLen, + const struct OmxCodecBuffer *pBuffer) +{ + HDF_LOGI("onEmptyBufferDone: pBuffer.bufferID [%{public}d]", pBuffer->bufferId); + g_core->OnEmptyBufferDone(pBuffer); + return HDF_SUCCESS; +} +int32_t OMXCore::OnEmptyBufferDone(const struct OmxCodecBuffer *pBuffer) +{ + unique_lock ulk(mLockInputBuffers_); + unUsedInBuffers_.push_back(pBuffer->bufferId); + return HDF_SUCCESS; +} +// FillBufferDone example +int32_t OMXCore::OnFillBufferDone(struct CodecCallbackType *self, int8_t *pAppData, uint32_t pAppDataLen, + struct OmxCodecBuffer *pBuffer) +{ + HDF_LOGI("onFillBufferDone: pBuffer.bufferID [%{public}d]", pBuffer->bufferId); + g_core->OnFillBufferDone(pBuffer); + return HDF_SUCCESS; +} +int32_t OMXCore::onFillBufferDone(struct OmxCodecBuffer* pBuffer) +{ + // Locate the buffer based on the buffer ID. + if (bExit_) { + return HDF_SUCCESS; + } + + auto iter = omxBuffers_.find(pBuffer->bufferId); + if (iter == omxBuffers_.end() || !iter->second) { + return HDF_SUCCESS; + } + // Obtain the output data. + BufferInfo *pBufferInfo = iter->second; + const void *addr = pBufferInfo->avSharedPtr->ReadFromAshmem(pBuffer->filledLen, pBuffer->offset); + // Decode the data and save it to a file. + fwrite(addr, 1, pBuffer->filledLen, fpOut_.get()); + fflush(fpOut_.get()); + // Reset the buffer data. + pBuffer->offset = 0; + pBuffer->filledLen = 0; + if (pBuffer->flag == OMX_BUFFERFLAG_EOS) { + // End + bExit_ = true; + HDF_LOGI("OnFillBufferDone the END coming"); + return HDF_SUCCESS; + } + // Call FillThisBuffer() again. + auto err = client_->FillThisBuffer(client_, pBufferInfo->pOmxBuffer); + if (err != HDF_SUCCESS) { + HDF_LOGE("FillThisBuffer error"); + return HDF_SUCCESS; + } + return HDF_SUCCESS; +} + +// EventHandler example +int32_t CodecHdiDecode::OnEvent(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) +{ + HDF_LOGI("onEvent: appData[0x%{public}p], eEvent [%{public}d], " + "nData1[%{public}d]", + info->appData, event, info->data1); + switch (event) { + case OMX_EventCmdComplete: { + OMX_COMMANDTYPE cmd = (OMX_COMMANDTYPE)info->data1; + if (OMX_CommandStateSet == cmd) { + HDF_LOGI("OMX_CommandStateSet reached, status is %{public}d", info->data2); + g_core->onStatusChanged(); + } + break; + } + default: + break; + } + return HDF_SUCCESS; +} +``` + +#### Destroying a Component +Change the component state to IDLE, release the input and output buffers, change the component state to **OMX_StateLoaded**, and call **DestoryComponent** to destroy the component. + +##### Example of Releasing Buffers + +```cpp +// Change the component state to OMX_StateLoaded. +client_->SendCommand(client_, OMX_CommandStateSet, OMX_StateLoaded, nullptr, 0); + +// Release all buffers in use. +auto iter = omxBuffers_.begin(); +while (iter != omxBuffers_.end()) { + BufferInfo *bufferInfo = iter->second; + client_->FreeBuffer(client_, (uint32_t)bufferInfo->portIndex, bufferInfo->omxBuffer); + delete bufferInfo; + iter++; +} +omxBuffers_.clear(); +unUsedInBuffers_.clear(); +unUsedOutBuffers_.clear(); + +enum OMX_STATETYPE status; +client_->GetState(client_, &status); +// After the buffers are released, the component enters the OMX_StateLoaded state. +if (status != OMX_StateLoaded) { + HDF_LOGI("Wait for OMX_StateLoaded status"); + this->WaitForStatusChanged(); +} else { + HDF_LOGI(" status is %{public}d", status); +} +``` + +##### Example of Destroying a Component Instance + +```cpp +// Destroy a component instance. +void OMXCore::Release() { + omxMgr_->DestoryComponent(client_); + client_ = nullptr; + CodecComponentManagerRelease(); +} +``` + +# FAQs + +## Green Screens Displayed During the Decoding Process + +**Symptom** + +Green screens are displayed during the decoding process. + +**Possible Causes** + +OpenMAX does not support framing. + +**Solution** + +Transfer data frame by frame when **EmptyThisBuffer** is called. + +## Only Green Screen Displayed During the Decoding Process + +**Symptom** + +Decoding fails, and all the frames decoded cannot be played. + +**Possible Causes** + +For the data in AVCC format, the first frame to be processed must be extra_data. + +**Solution** + +Write sps and pps to the buffer in extra_data format, and set the buffer flag to **OMX_BUFFERFLAG_EXTRADATA**. + +## Failed to Play the Encoded Video + +**Symptom** + +After the generated video stream (H.264 stream) is written to a file, the video stream cannot be played by FFplay. + +**Possible Causes** + +- The **xFramerate** parameter of the output port is incorrectly set. +- The **OMX_VIDEO_PARAM_AVCTYPE** parameter is correctly set. + + +**Solution** + +View the **codec_host** log generated during encoding, search for "encode params init settings", and check for incorrect parameters. If **framerate** is **0**, **xFramerate** is incorrectly set. In this case, move the framerate leftwards by 16 bits. + +Check the value of **OMX_VIDEO_PARAM_AVCTYPE**, and set it correctly. + + +# Reference + +For more information, see [Codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec). diff --git a/en/device-dev/driver/driver-peripherals-external-des.md b/en/device-dev/driver/driver-peripherals-external-des.md index 076457e26061280a71859a37dfe6c120beb1f61c..8c17105189ef7fef5ad99f01fa8222ea95570b80 100644 --- a/en/device-dev/driver/driver-peripherals-external-des.md +++ b/en/device-dev/driver/driver-peripherals-external-des.md @@ -111,12 +111,12 @@ The WLAN module provides the following types of APIs: | API| Description| | -------- | -------- | - | int32_t (\*init)(struct NetDevice \*netDev) | Initializes a network device. | - | struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev) | Obtains the state of a network device. | + | int32_t (\*init)(struct NetDevice \*netDev) | Initializes a network device.| + | struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev) | Obtains the state of a network device.| | int32_t (\*setMacAddr)(struct NetDevice \*netDev, void \*addr) | Sets the MAC address.| - | void (\*deInit)(struct NetDevice \*netDev) | Deinitializes a network device. | - | int32_t (\*open)(struct NetDevice \*netDev) | Opens a network device. | - | int32_t (\*stop)(struct NetDevice \*netDev) | Stops a network device. | + | void (\*deInit)(struct NetDevice \*netDev) | Deinitializes a network device.| + | int32_t (\*open)(struct NetDevice \*netDev) | Opens a network device.| + | int32_t (\*stop)(struct NetDevice \*netDev) | Stops a network device.| - The WLAN Driver module provides APIs that you can directly use to create or release a **WifiModule**, connect to or disconnect from a WLAN hotspot, request or release a **NetBuf**, and convert between the **pbuf** structure of Lightweight IP (lwIP) and a **NetBuf**. @@ -231,21 +231,21 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial #include "wifi_module.h" #include "hi_wifi_api.h" #include "hi_types_base.h" - + #define HDF_LOG_TAG Hi3881Driver - + /* Functions for initializing and deinitializing a WLAN chip. */ int32_t InitHi3881Chip(struct HdfWlanDevice *device); int32_t DeinitHi3881Chip(struct HdfWlanDevice *device); /* Functions for initializing and deinitializing a WLAN chip driver. */ int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice); int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice); - + /* Initialize mac80211 by hooking the functions of the chip. */ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver); - + static const char* const HI3881_DRIVER_NAME = "hisi"; - + /* Hook the functions of the WLAN chip driver, mac80211, and chip. */ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex) { @@ -265,7 +265,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial OsalMemFree(specificDriver); return NULL; } - + if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) { HDF_LOGE("%s fail: strcpy_s fail!", __func__); OsalMemFree(specificDriver); @@ -273,12 +273,12 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } specificDriver->init = Hi3881Init; specificDriver->deinit = Hi3881Deinit; - + HiMac80211Init(specificDriver); - + return specificDriver; } - + /* Release the WLAN chip driver. */ static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver) { @@ -291,12 +291,12 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } OsalMemFree(chipDriver); } - + static uint8_t GetHi3881GetMaxIFCount(struct HdfChipDriverFactory *factory) { (void)factory; return 1; } - + /* Register WLAN chip functions. */ static int32_t HDFWlanRegHisiDriverFactory(void) { @@ -318,16 +318,16 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial HDF_LOGE("%s fail: driverMgr is NULL!", __func__); return HDF_FAILURE; } - + return HDF_SUCCESS; } - + static int32_t HdfWlanHisiChipDriverInit(struct HdfDeviceObject *device) { (void)device; return HDFWlanRegHisiDriverFactory(); } - + struct HdfDriverEntry g_hdfHisiChipEntry = { .moduleVersion = 1, .Bind = HdfWlanHisiDriverBind, @@ -335,7 +335,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial .Release = HdfWlanHisiChipRelease, .moduleName = "HDF_WLAN_CHIPS" }; - + HDF_INIT(g_hdfHisiChipEntry); ``` @@ -352,9 +352,9 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial #include "wal_cfg80211.h" #include "net_adapter.h" #include "hdf_wlan_utils.h" - + #define HDF_LOG_TAG Hi3881Driver - + /* Initialize the WLAN chip. */ int32_t InitHi3881Chip(struct HdfWlanDevice *device) { @@ -365,7 +365,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial HDF_LOGE("%s:NULL ptr!", __func__); return HI_FAIL; } - + do { if (ret != HI_SUCCESS) { if (device->reset != NULL && device->reset->Reset != NULL) { @@ -375,14 +375,14 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } ret = hi_wifi_init(maxPortCount, device->bus); } while (ret != 0 && --maxRetryCount > 0); - + if (ret != 0) { HDF_LOGE("%s:Init hi3881 driver failed!", __func__); return ret; } return HI_SUCCESS; } - + /* Deinitializing the WLAN chip. */ int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) { @@ -393,7 +393,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } return ret; } - + /* Initializing the WLAN chip driver. */ int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) { @@ -426,7 +426,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } return ret; } - + /* Deinitializing the WLAN chip driver. */ int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) { @@ -439,6 +439,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial } return wal_deinit_drv_wlan_netdev(netDevice); } + ``` During the chip initialization process, call **NetDeviceInit()** to initialize a network device, call **NetDeviceAdd()** to add the network device to a protocol stack, and hook function pointers of **netdev**. @@ -452,38 +453,38 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial oam_error_log0(0, OAM_SF_ANY, "{netdev is null!}"); return HI_ERR_CODE_PTR_NULL; } - - do { - /* Initialize the network device. */ - ret = wal_init_netdev(type, netdev); - if (ret != HI_SUCCESS) { - break; - } - - ret = wal_init_netif(type, netdev); - if (ret != HI_SUCCESS) { - break; - } - ac_mode_str = "11bgn"; - if (mode == WAL_PHY_MODE_11G) { - ac_mode_str = "11bg"; - } else if (mode == WAL_PHY_MODE_11B) { - ac_mode_str = "11b"; - } - - ret = wal_ioctl_set_mode(netdev, ac_mode_str); - } while (false); - - if (ret != HI_SUCCESS) { - wal_deinit_wlan_vap(netdev); - oal_net_unregister_netdev(netdev); - oal_net_clear_netdev(netdev); - return HI_FAIL; - } - - return HI_SUCCESS; + + do { + /* Initialize the network device. */ + ret = wal_init_netdev(type, netdev); + if (ret != HI_SUCCESS) { + break; + } + + ret = wal_init_netif(type, netdev); + if (ret != HI_SUCCESS) { + break; + } + ac_mode_str = "11bgn"; + if (mode == WAL_PHY_MODE_11G) { + ac_mode_str = "11bg"; + } else if (mode == WAL_PHY_MODE_11B) { + ac_mode_str = "11b"; + } + + ret = wal_ioctl_set_mode(netdev, ac_mode_str); + } while (false); + + if (ret != HI_SUCCESS) { + wal_deinit_wlan_vap(netdev); + oal_net_unregister_netdev(netdev); + oal_net_clear_netdev(netdev); + return HI_FAIL; + } + + return HI_SUCCESS; } - + /* Hook function pointers of netdev. For details, see NetDeviceInterFace. */ oal_net_device_ops_stru g_wal_net_dev_ops = { @@ -504,19 +505,18 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial #endif .specialEtherTypeProcess = SpecialEtherTypeProcess, }; - + hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev) { /* Add the network device to the protocol stack. */ hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); - + ... + return HI_SUCCESS; } ``` - - 3. Bind the commands to be delivered, including setting the MAC address and transmit power, implement STA connection and scan, start APs, and setting the country code. ```c @@ -580,7 +580,7 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial 4. Invoke the event reporting APIs. - The WLAN framework provides the event reporting APIs. For example, call **HdfWiFiEventNewSta AP** to report information about the newly associated STA. For details, see **hdf_wifi_event.c**. + The WLAN framework provides the event reporting APIs. For details, see hdf_wifi_event.c. For example, call **HdfWiFiEventNewSta AP** to report information about the newly associated STA. ```c hi_u32 oal_cfg80211_new_sta(oal_net_device_stru *net_device, const hi_u8 *mac_addr, hi_u8 addr_len, @@ -678,7 +678,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of exit 0 ``` - - Create a **udhcpd.conf** file (used to start the **udhcpd**) and copy the following content to the file: + - Create a **udhcpd.conf** file (used to start the **udhcpd**) and copy the following content to the file. In the following, **opt dns** *x.x.x.x* *x.x.x.x* indicates two DNS servers configured. You can configure DNS servers as required. ```text start 192.168.12.2 @@ -692,7 +692,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of offer_time 60 #default: 60 (1 minute) min_lease 60 #defult: 60 lease_file /vendor/etc/udhcpd.leases - opt dns 10.221.0.11 8.8.8.8 + opt dns x.x.x.x x.x.x.x option subnet 255.255.255.0 opt router 192.168.12.1 ``` @@ -734,7 +734,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of 4. On the mobile phone, select the network named **test** in the available Wi-Fi list and enter the password. - The network name and password are configured in the **hostapd.conf** file. You can see the network name in the connected Wi-Fi list if the connection is successful. + The network name and password are configured in the **hostapd.conf** file. You can see that network name in the connected Wi-Fi list if the connection is successful. 5. Ping the test terminal from the development board. @@ -742,7 +742,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of busybox ping xxx.xxx.xxx.xxx ``` - In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the basic features of the WLAN driver are implemented successfully. + In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. - Verify basic STA features. @@ -771,7 +771,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of busybox ping xxx.xxx.xxx.xxx ``` - In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the basic features of the WLAN driver are implemented successfully. + In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. 3. Verify the unit test cases. @@ -862,69 +862,69 @@ Develop test cases in the WLAN module unit test to verify the basic features of The sample code is as follows: - ```c - #include "wifi_hal.h" - #include "wifi_hal_sta_feature.h" - #include "wifi_hal_ap_feature.h" - #include "wifi_hal_cmd.h" - #include "wifi_hal_event.h" - - #define MAC_LEN 6 - #define HDF_SUCCESS 0 - #define HDF_FAILURE (-1) - - static int32_t hal_main() - { - int32_t ret; - struct IWiFi *wifi; - - /* Create an IWiFi instance. */ - ret = WifiConstruct(&wifi); - if (ret != HDF_SUCCESS || wifi == NULL) { - return HDF_FAILURE; - } - - /* Create a channel between the HAL and the driver and obtain the driver NIC information. */ - ret = wifi->start(wifi); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - - /* Create an apFeature instance. */ - ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - - /* Obtain the MAC address of the device. */ - unsigned char mac[MAC_LEN] = {0}; - ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - - /* Destroy the apFeature instance. */ - ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - - /* Destroy the channel between the HAL and the driver. */ - ret = wifi->stop(wifi); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - - /* Destroy the IWiFi instance. */ - ret = WifiDestruct(&wifi); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - return ret; - } - ``` + ```c + #include "wifi_hal.h" + #include "wifi_hal_sta_feature.h" + #include "wifi_hal_ap_feature.h" + #include "wifi_hal_cmd.h" + #include "wifi_hal_event.h" + #define MAC_LEN 6 + #define HDF_SUCCESS 0 + #define HDF_FAILURE (-1) + ``` + + + static int32_t hal_main() + { + int32_t ret; + struct IWiFi *wifi; + /* Create an IWiFi instance. */ + ret = WifiConstruct(&wifi); + if (ret != HDF_SUCCESS || wifi == NULL) { + return HDF_FAILURE; + } + + /* Create a channel between the HAL and the driver and obtain the driver NIC information. */ + ret = wifi->start(wifi); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + + /* Create an apFeature instance. */ + ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + + /* Obtain the MAC address of the device. */ + unsigned char mac[MAC_LEN] = {0}; + ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + + /* Destroy the apFeature instance. */ + ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + + /* Destroy the channel between the HAL and the driver. */ + ret = wifi->stop(wifi); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + + /* Destroy the IWiFi instance. */ + ret = WifiDestruct(&wifi); + if (ret != HDF_SUCCESS) { + return HDF_FAILURE; + } + return ret; + } + ``` 4. Verify the test cases. 1. Push the test cases to the development board. @@ -944,7 +944,11 @@ Develop test cases in the WLAN module unit test to verify the basic features of ./ Test case name. ``` + + 3. Check the test case execution result. + + ## Reference @@ -958,11 +962,11 @@ Develop test cases in the WLAN module unit test to verify the basic features of - Code paths: - - Adaptation of WLAN FlowCtl component on LiteOS: + - Adaptation of WLAN FlowCtl component on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network/wifi** - - Adaptation of HDF network model on LiteOS: + - Adaptation of HDF network model on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network** @@ -974,7 +978,9 @@ Develop test cases in the WLAN module unit test to verify the basic features of **//drivers/hdf_core/framework/model/network/wifi** - - External APIs of the WLAN module:**//drivers/hdf_core/framework/include/wifi** + - External APIs of the WLAN module: + + **//drivers/hdf_core/framework/include/wifi** - HDF network model APIs: @@ -984,6 +990,6 @@ Develop test cases in the WLAN module unit test to verify the basic features of **//drivers/peripheral/wlan** - - External APIs of the WLAN HDI: + - External APIs of the WLAN HDI: **//out/{product_name}/gen/drivers/interface/wlan/v1_0** 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/driver/figures/Codec_architecture.png b/en/device-dev/driver/figures/Codec_architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..8307f28f93b5af2f471e96f58c6208a4ce005efa Binary files /dev/null and b/en/device-dev/driver/figures/Codec_architecture.png differ diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index f3f6df0eb652d6fd93e8d4dae2ebf9ae58c816e8..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) @@ -103,9 +89,10 @@ - [DFX Overview](subsys-dfx-overview.md) - [HiLog Development](subsys-dfx-hilog-rich.md) - [HiLog\_Lite Development](subsys-dfx-hilog-lite.md) - - [HiTrace Development](subsys-dfx-hitrace.md) + - [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/en/device-dev/subsystems/subsys-dfx-hitrace.md b/en/device-dev/subsystems/subsys-dfx-hitracechain.md similarity index 90% rename from en/device-dev/subsystems/subsys-dfx-hitrace.md rename to en/device-dev/subsystems/subsys-dfx-hitracechain.md index 4cc3bd9bb90269b74e103659360807d709cfb55b..6639011302e78ba1e9931b24362c5790c24dd4a3 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitrace.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -1,18 +1,20 @@ -# HiTrace Development +# HiTraceChain Development ## Overview -HiTrace tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. +HiTraceChain tracks the call chain with the same **traceid** throughout the inter-device, inter-process, and inter-thread service processes. It associates and displays the call relationship and various output information during the entire process, helping you analyze and locate faults and optimize the system. ## Use Cases -HiTrace can be used for the following purposes: +HiTraceChain can be used for the following purposes: + +- Associates and reports service process information \(such as logs and events\) on the device. + +- Displays and analyzes reported information on the cloud to facilitate fault location. -- Associates and reports service process information \(such as logs and events\) on the device. -- Displays and analyzes reported information on the cloud to facilitate fault location. - Works with the IDE to debug the detailed service process and time consumption distribution for system optimization. - **Figure 1** Use cases of HiTrace + **Figure 1** Use cases of HiTraceChain ![](figure/use-cases-of-hitrace.png "use-cases-of-hitrace") @@ -33,9 +35,9 @@ HiTrace can be used for the following purposes: ## Available APIs -HiTrace provides C++ and C APIs. The upper-layer services mainly use HiTrace to start and stop call chain tracing. +HiTraceChain provides C++ and C APIs. The upper-layer services mainly use HiTraceChain to start and stop call chain tracing. -HiTrace is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTrace sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTrace obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTrace clears **traceid** from the TLS of the calling thread. +HiTraceChain is implemented at layer C. It works by transferring **traceid** throughout the service calling process. Before service processing, HiTraceChain sets **traceid** in the thread local storage \(TLS\) of the calling thread. During service processing, HiTraceChain obtains **traceid** from the contextual TLS of the calling thread and automatically adds it to the log and event information. After service processing is complete, HiTraceChain clears **traceid** from the TLS of the calling thread. ### Java, C++, and C APIs @@ -56,7 +58,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

API

-

HiTrace

+

HiTraceChain

@@ -67,42 +69,42 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

HiTraceId Begin(const std::string& name, int flags)

-

HiTraceIdStruct HiTraceBegin(const char* name, int flags)

+

HiTraceIdStruct HiTraceChainBegin(const char* name, int flags)

void End(const HiTraceId& id)

-

void HiTraceEnd(const HiTraceIdStruct* pId)

+

void HiTraceChainEnd(const HiTraceIdStruct* pId)

HiTraceId GetId();

-

HiTraceIdStruct HiTraceGetId()

+

HiTraceIdStruct HiTraceChainGetId()

void SetId(const HiTraceId& id)

-

void HiTraceSetId(const HiTraceIdStruct* pId)

+

void HiTraceChainSetId(const HiTraceIdStruct* pId)

void ClearId()

-

void HiTraceClearId()

+

void HiTraceChainClearId()

HiTraceId CreateSpan()

-

HiTraceIdStruct HiTraceCreateSpan()

+

HiTraceIdStruct HiTraceChainCreateSpan()

void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

void HiTraceTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

+

void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

void HiTraceTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

+

void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct* pId, const char* fmt, ...)

HiTraceId

@@ -122,72 +124,72 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

HiTraceId();

-

void HiTraceInitId(HiTraceIdStruct* pId)

+

void HiTraceChainInitId(HiTraceIdStruct* pId)

HiTraceId(const uint8_t* pIdArray, int len)

-

HiTraceIdStruct HiTraceBytesToId(const uint8_t* pIdArray, int len)

+

HiTraceIdStruct HiTraceChainBytesToId(const uint8_t* pIdArray, int len)

bool IsValid()

-

int HiTraceIsValid(const HiTraceIdStruct* pId)

+

int HiTraceChainIsValid(const HiTraceIdStruct* pId)

bool IsFlagEnabled(HiTraceFlag flag)

-

int HiTraceIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag)

+

int HiTraceChainIsFlagEnabled(const HiTraceIdStruct* pId, HiTraceFlag flag)

void EnableFlag(HiTraceFlag flag)

-

void HiTraceEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag)

+

void HiTraceChainEnableFlag(HiTraceIdStruct* pId, HiTraceFlag flag)

int GetFlags()

-

int HiTraceGetFlags(const HiTraceIdStruct* pId)

+

int HiTraceChainGetFlags(const HiTraceIdStruct* pId)

void SetFlags(int flags)

-

void HiTraceSetFlags(HiTraceIdStruct* pId, int flags)

+

void HiTraceChainSetFlags(HiTraceIdStruct* pId, int flags)

uint64_t GetChainId()

-

uint64_t HiTraceGetChainId(const HiTraceIdStruct* pId)

+

uint64_t HiTraceChainGetChainId(const HiTraceIdStruct* pId)

void SetChainId(uint64_t chainId)

-

void HiTraceSetChainId(HiTraceIdStruct* pId, uint64_t chainId)

+

void HiTraceChainSetChainId(HiTraceIdStruct* pId, uint64_t chainId)

uint64_t GetSpanId()

-

uint64_t HiTraceGetSpanId(const HiTraceIdStruct* pId)

+

uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct* pId)

void SetSpanId(uint64_t spanId)

-

void HiTraceSetSpanId(HiTraceIdStruct* pId, uint64_t spanId)

+

void HiTraceChainSetSpanId(HiTraceIdStruct* pId, uint64_t spanId)

uint64_t GetParentSpanId()

-

uint64_t HiTraceGetParentSpanId(const HiTraceIdStruct* pId)

+

uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct* pId)

void SetParentSpanId(uint64_t parentSpanId)

-

void HiTraceSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId)

+

void HiTraceChainSetParentSpanId(HiTraceIdStruct* pId, uint64_t parentSpanId)

int ToBytes(uint8_t* pIdArray, int len)

-

int HiTraceIdToBytes(const HiTraceIdStruct* pId, uint8_t* pIdArray, int len)

+

int HiTraceChainIdToBytes(const HiTraceIdStruct* pId, uint8_t* pIdArray, int len)

@@ -206,7 +208,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug -

HiTrace

+

HiTraceChain

@@ -217,7 +219,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

HiTraceId Begin(const std::string& name, int flags)

-

Starts HiTrace, generates a HiTraceId object, and sets it in the TLS of the calling thread.

+

Starts HiTraceChain, generates a HiTraceId object, and sets it in the TLS of the calling thread.

Input arguments:

  • name: Indicates the name of the service process.
  • flags: Indicates tracing flags, which can be used in combination.
    • HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.
    • HITRACE_FLAG_DONOT_CREATE_SPAN: Do not create a span. By default, a span is created.
    • HITRACE_FLAG_TP_INFO: Outputs the tracepoint information. By default, the information is not output.
    • HITRACE_FLAG_NO_BE_INFO: Do not output the start and end information. By default, the information is output.
    • HITRACE_FLAG_DONOT_ENABLE_LOG: Do not associate logs for output. By default, logs are associated for output.
    • HITRACE_FLAG_FAULT_TRIGGER: Triggers tracing by fault. By default, tracing is triggered normally.
    • HITRACE_FLAG_D2D_TP_INFO: Outputs the device-to-device tracepoint information. By default, the information is not output.
    • HITRCE_FLAG_DEFAULT: Indicates the default flag.
  • Output arguments: none
  • Return value: Returns a valid HiTraceId object if call chain tracing is triggered successfully; returns an invalid object otherwise.
@@ -226,7 +228,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

void End(const HiTraceId& id)

-

Stops HiTrace based on the HiTraceId object returned by the Begin API, and clears the HiTraceId object in the TLS of the calling thread.

+

Stops HiTraceChain based on the HiTraceId object returned by the Begin API, and clears the HiTraceId object in the TLS of the calling thread.

Input arguments:

  • id: Indicates the HiTraceId object.

Output arguments: none

@@ -268,7 +270,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

Outputs HiTrace call chain information based on the information type. The information includes the timestamp and HiTraceId object information of the span.

+

Outputs HiTraceChain call chain information based on the information type. The information includes the timestamp and HiTraceId object information of the span.

Input arguments:

  • type: Indicates the information type. The options are as follows:
    • HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
    • HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
    • HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
    • HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
    • HITRACE_TP_GENERAL: Indicates the common output information.
  • id: Indicates the ID of the current span.
  • fmt: Indicates the string describing the format variable parameter.
  • args: Indicates the variable parameter.
@@ -278,7 +280,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug

void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)

-

Outputs HiTrace call chain information based on the communication mode and information type. The information includes the timestamp and HiTraceId object information of the span.

+

Outputs HiTraceChain call chain information based on the communication mode and information type. The information includes the timestamp and HiTraceId object information of the span.

Input arguments:

  • mode: Indicates the communication mode. The options are as follows:
    • HITRACE_CM_DEFAULT: default communication mode used when no communication mode is specified
    • HITRACE_CM_THREAD: inter-thread communication
    • HITRACE_CM_PROCESS: inter-process communication
    • HITRACE_CM_DEVICE: inter-device communication
  • type: Indicates the information type. The options are as follows:
    • HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
    • HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
    • HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
    • HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
    • HITRACE_TP_GENERAL: Indicates the common output information.
    @@ -428,7 +430,7 @@ HiTrace is implemented at layer C. It works by transferring **traceid** throug ## Call Chain Processing -Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTrace** requires transfer of **traceid** in the communication mechanism. +Inter-device, inter-process, and inter-thread calls are implemented through the communication mechanism. **HiTraceChain** requires transfer of **traceid** in the communication mechanism. Some built-in communication mechanisms \(such as ZIDL\) of OpenHarmony already support the transfer of **traceid**. @@ -475,25 +477,25 @@ The process is as follows: 1. Develop the source code. - Include the **hitrace** header file in the class definition header file or class implementation source file. For example: + Include the **hitracechain** header file in the class definition header file or class implementation source file. For example: ``` - #include "hitrace/trace.h" + #include "hitrace/tracechain.h" ``` Add the code to start and stop call chain tracing in the class implementation source file. ``` using namespace OHOS::HiviewDFX; - HiTraceId traceId = HiTrace::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); ... - HiTrace::End(traceId); + HiTraceChain::End(traceId); ``` 2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. ``` - external_deps = [ "hiviewdfx:libhitrace" ] + external_deps = [ "hiviewdfx:libhitracechain" ] ``` @@ -501,24 +503,24 @@ The process is as follows: 1. Develop the source code. - Include the **hitrace** header file in the source file. + Include the **hitracechain** header file in the source file. ``` - #include "hitrace/trace.h" + #include "hitrace/tracechain.h" ``` Add the code to start and stop call chain tracing in the class implementation source file. ``` - HiTraceIdStruct traceId = HiTraceBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); ... - HiTraceEnd(traceId); + HiTraceChainEnd(traceId); ``` 2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. ``` - external_deps = [ "hiviewdfx:libhitrace" ] + external_deps = [ "hiviewdfx:libhitracechain" ] ``` diff --git a/en/device-dev/subsystems/subsys-dfx-overview.md b/en/device-dev/subsystems/subsys-dfx-overview.md index 17f65f4ffd4ef6a59f363fcf80419e6fc2cf9cbe..246375d40c696fc92a4d4a733543c0b3fd231169 100644 --- a/en/device-dev/subsystems/subsys-dfx-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-overview.md @@ -6,7 +6,7 @@ The DFX subsystem provides the following functions: - HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MB\). -- HiTrace: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- HiTraceChain: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiCollie: implements thread suspension detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiSysEvent: implements system event logging. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiChecker: implements defect scanning. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). @@ -35,3 +35,4 @@ Event logging means to collect and log events reported during system running. Th **System event** A system event is an indication of the system status at a given time point during system running. You can use these events to analyze the status change of the system. + 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/OpenHarmony-Overview_zh.md b/zh-cn/OpenHarmony-Overview_zh.md index d1e7d2846472ee5b603c6b576560b8ba4afe2ac9..14634f537ded05f47c83f59e063732217cf860d2 100644 --- a/zh-cn/OpenHarmony-Overview_zh.md +++ b/zh-cn/OpenHarmony-Overview_zh.md @@ -156,7 +156,7 @@ OpenHarmony支持如下几种系统类型: ## 快速入门 -- [设备开发快速入门](device-dev/quick-start/quickstart-ide-lite-overview.md) +- [设备开发快速入门](device-dev/quick-start/quickstart-overview.md) - [应用开发快速入门](application-dev/quick-start/start-overview.md) 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 08d96de0527fc1fd41f05b2b4c48a3d96fdf5a48..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) @@ -26,6 +26,7 @@ - [安全](security/Readme-CN.md) - [网络与连接](connectivity/Readme-CN.md) - [数据管理](database/Readme-CN.md) + - [文件管理](file-management/Readme-CN.md) - [电话服务](telephony/Readme-CN.md) - [任务管理](task-management/Readme-CN.md) - [设备管理](device/Readme-CN.md) diff --git a/zh-cn/application-dev/ability/context-userguide.md b/zh-cn/application-dev/ability/context-userguide.md index 3d99a6fc7e033afb86457f8f4985941e7925394a..5db42e2462f957d5ae454dae2890e1d5d980dc65 100644 --- a/zh-cn/application-dev/ability/context-userguide.md +++ b/zh-cn/application-dev/ability/context-userguide.md @@ -10,7 +10,7 @@ 只有app/Context中的方法属于FA模型对应的Context。该模式下,应用级别的Context和Ability级别的Context都是该类型的实例,如果在应用级别的Context里面调用了Ability级别的方法,会产生错误。所以开发者需要注意Context实例所代表的实际含义。 - Stage模型 - 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/ApplicationContext、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext等Context。这些Context的介绍及使用方式将会在[Stage模型和Context详细介绍](#stage模型和context详细介绍)中进行说明。 + 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/ApplicationContext、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext等Context。这些Context的介绍及使用方式将会在[Stage模型的Context详细介绍](#stage模型的context详细介绍)中进行说明。 ![contextIntroduction](figures/contextIntroduction.png) @@ -54,7 +54,7 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise; 示例: ```javascript import featureAbility from '@ohos.ability.featureAbility' -import bundle from '../@ohos.bundle'; +import bundle from '@ohos.bundle'; export default { onCreate() { @@ -71,13 +71,13 @@ export default { } ``` -## Stage模型和Context详细介绍 +## Stage模型的Context详细介绍 ​ Stage模型有如下几类Context: ### application/Context -​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir、area等,还有应用的一些基本方法:createBundleContext等。 +​ application/Context是基类Context。里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir、area等,还有应用的一些基本方法:createModuleContext等。 **d.ts声明** diff --git a/zh-cn/application-dev/ability/continuationmanager.md b/zh-cn/application-dev/ability/continuationmanager.md index 10396fd4bce36a115ce74e0bba512c9b7489a183..d82b77dbdf811b3fdc37a6a021b2416c0e0d8f9c 100644 --- a/zh-cn/application-dev/ability/continuationmanager.md +++ b/zh-cn/application-dev/ability/continuationmanager.md @@ -12,20 +12,20 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ## 接口说明 | 接口名 | 接口描述 | | ---------------------------------------------------------------------------------------------- | ----------- | -| register(callback: AsyncCallback\): void | 注册流转管理服务,并获取对应的注册token,无过滤条件(AsyncCallback)。 | -| register(options: ContinuationExtraParams, callback: AsyncCallback\): void | 注册流转管理服务,并获取对应的注册token(AsyncCallback)。 | -| register(options?: ContinuationExtraParams): Promise\ | 连接流转管理服务,并获取对应的注册token(Promise)。 | +| registerContinuation(callback: AsyncCallback\): void | 注册流转管理服务,并获取对应的注册token,无过滤条件(AsyncCallback)。 | +| registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\): void | 注册流转管理服务,并获取对应的注册token(AsyncCallback)。 | +| registerContinuation(options?: ContinuationExtraParams): Promise\ | 连接流转管理服务,并获取对应的注册token(Promise)。 | | on(type: "deviceConnect", token: number, callback: Callback\>): void | 监听设备连接状态(Callback)。 | | on(type: "deviceDisconnect", token: number, callback: Callback\>): void | 监听设备断开状态(Callback)。 | | off(type: "deviceConnect", token: number): void | 取消监听设备连接状态。 | | off(type: "deviceDisconnect", token: number): void | 取消监听设备断开状态。 | -| startDeviceManager(token: number, callback: AsyncCallback\): void | 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件(AsyncCallback)。 | -| startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | 拉起设备选择模块,可显示组网内可选择设备列表信息(AsyncCallback)。 | -| startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | 拉起设备选择模块,可显示组网内可选择设备列表信息(Promise)。 | -| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | 通知设备选择模块,更新当前的流转状态(AsyncCallback)。 | -| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\ | 通知设备选择模块,更新当前的流转状态(Promise)。 | -| unregister(token: number, callback: AsyncCallback\): void | 取消注册流转管理服务,传入注册时获取的token进行取消注册(AsyncCallback)。 | -| unregister(token: number): Promise\ | 取消注册流转管理服务,传入注册时获取的token进行取消注册(Promise)。 | +| startContinuationDeviceManager(token: number, callback: AsyncCallback\): void | 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件(AsyncCallback)。 | +| startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | 拉起设备选择模块,可显示组网内可选择设备列表信息(AsyncCallback)。 | +| startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | 拉起设备选择模块,可显示组网内可选择设备列表信息(Promise)。 | +| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | 通知设备选择模块,更新当前的流转状态(AsyncCallback)。 | +| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\ | 通知设备选择模块,更新当前的流转状态(Promise)。 | +| unregisterContinuation(token: number, callback: AsyncCallback\): void | 取消注册流转管理服务,传入注册时获取的token进行取消注册(AsyncCallback)。 | +| unregisterContinuation(token: number): Promise\ | 取消注册流转管理服务,传入注册时获取的token进行取消注册(Promise)。 | ## 开发步骤 1. 导入continuationManager模块。 @@ -138,13 +138,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ```ts let token: number = -1; // 用于保存注册成功并返回的token,后续使用其完成监听设备连接/断开状态、拉起设备选择模块以及更新流转状态的动作 - - continuationManager.register().then((data) => { - console.info('register finished, ' + JSON.stringify(data)); - token = data; // 获取到对应的注册token,并赋值给token变量 - }).catch((err) => { - console.error('register failed, cause: ' + JSON.stringify(err)); - }); + try { + continuationManager.registerContinuation().then((data) => { + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; // 获取到对应的注册token,并赋值给token变量 + }).catch((err) => { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } ``` 4. 监听设备状态。 @@ -154,28 +157,32 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 ```ts let remoteDeviceId: string = ""; // 用于保存用户选择的远端设备信息,后续使用其完成跨端迁移或多端协同操作 - // 参数token为注册token - continuationManager.on("deviceConnect", token, (continuationResults) => { - console.info('registerDeviceConnectCallback len: ' + continuationResults.length); - if (continuationResults.length <= 0) { - console.info('no selected device'); - return; - } - remoteDeviceId = continuationResults[0].id; // 将选择的第一个远端设备deviceId赋值给remoteDeviceId变量 - - // 将remoteDeviceId参数传给want - let want = { - deviceId: remoteDeviceId, - bundleName: 'ohos.samples.continuationmanager', - abilityName: 'MainAbility' - }; - // 发起多端协同操作,需申请ohos.permission.DISTRIBUTED_DATASYNC权限 - globalThis.abilityContext.startAbility(want).then((data) => { - console.info('StartRemoteAbility finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err)); + try { + // 参数token为注册token + continuationManager.on("deviceConnect", token, (continuationResults) => { + console.info('registerDeviceConnectCallback len: ' + continuationResults.length); + if (continuationResults.length <= 0) { + console.info('no selected device'); + return; + } + remoteDeviceId = continuationResults[0].id; // 将选择的第一个远端设备deviceId赋值给remoteDeviceId变量 + + // 将remoteDeviceId参数传给want + let want = { + deviceId: remoteDeviceId, + bundleName: 'ohos.samples.continuationmanager', + abilityName: 'MainAbility' + }; + // 发起多端协同操作,需申请ohos.permission.DISTRIBUTED_DATASYNC权限 + globalThis.abilityContext.startAbility(want).then((data) => { + console.info('StartRemoteAbility finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err)); + }); }); - }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` 上述多端协同操作为Stage平台的跨设备拉起,FA平台详情见[PageAbility开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/fa-pageability.md)。 @@ -187,35 +194,43 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED; // 参数token为注册token,参数remoteDeviceId为获取到的remoteDeviceId - continuationManager.updateConnectStatus(token, remoteDeviceId, deviceConnectStatus).then((data) => { - console.info('updateConnectStatus finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); - }); + try { + continuationManager.updateContinuationState(token, remoteDeviceId, deviceConnectStatus).then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } ``` 监听设备断开状态,方便用户终止跨端迁移或多端协同操作,代码示例如下: ```ts - // 参数token为注册token - continuationManager.on("deviceDisconnect", token, (deviceIds) => { - console.info('onDeviceDisconnect len: ' + deviceIds.length); - if (deviceIds.length <= 0) { - console.info('no unselected device'); - return; - } + try { + // 参数token为注册token + continuationManager.on("deviceDisconnect", token, (deviceIds) => { + console.info('onDeviceDisconnect len: ' + deviceIds.length); + if (deviceIds.length <= 0) { + console.info('no unselected device'); + return; + } - // 更新设备流转状态 - let unselectedDeviceId: string = deviceIds[0]; // 将取消选择的第一个远端设备deviceId赋值给unselectedDeviceId变量 - let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // 设备断开状态 + // 更新设备流转状态 + let unselectedDeviceId: string = deviceIds[0]; // 将取消选择的第一个远端设备deviceId赋值给unselectedDeviceId变量 + let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // 设备断开状态 - // 参数token为注册token,参数unselectedDeviceId为获取到的unselectedDeviceId - continuationManager.updateConnectStatus(token, unselectedDeviceId, deviceConnectStatus).then((data) => { - console.info('updateConnectStatus finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); + // 参数token为注册token,参数unselectedDeviceId为获取到的unselectedDeviceId + continuationManager.updateContinuationState(token, unselectedDeviceId, deviceConnectStatus).then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); }); - }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } ``` 5. 拉起设备选择模块,可显示组网内可选择设备列表信息,供用户选择。 @@ -229,12 +244,16 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE // 设备选择模块单选模式 }; - // 参数token为注册token - continuationManager.startDeviceManager(token, continuationExtraParams).then((data) => { - console.info('startDeviceManager finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); - }); + try { + // 参数token为注册token + continuationManager.startContinuationDeviceManager(token, continuationExtraParams).then((data) => { + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } ``` 6. 当用户不打算再进行跨端迁移或多端协同操作时,可以传入注册时获取的token进行取消注册。 @@ -242,10 +261,14 @@ continuationManager作为流转能力的入口,主要用于拉起系统中的 取消注册流转管理服务的代码示例如下: ```ts - // 参数token为注册token - continuationManager.unregister(token).then((data) => { - console.info('unregister finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('unregister failed, cause: ' + JSON.stringify(err)); - }); + try { + // 参数token为注册token + continuationManager.unregisterContinuation(token).then((data) => { + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/ability/figures/contextIntroduction.png b/zh-cn/application-dev/ability/figures/contextIntroduction.png index 13ead57e71d75174e44b30799696252fdf198ab7..df5f7b1936617af892d7d6729deee2239232c1cf 100644 Binary files a/zh-cn/application-dev/ability/figures/contextIntroduction.png and b/zh-cn/application-dev/ability/figures/contextIntroduction.png differ diff --git a/zh-cn/application-dev/ability/stage-brief.md b/zh-cn/application-dev/ability/stage-brief.md index c4b1a09320f88b41ebe5f541efada4aaa9ced7cb..858dc74a03b441bf7a4f48aef1cd55c8648c2f85 100644 --- a/zh-cn/application-dev/ability/stage-brief.md +++ b/zh-cn/application-dev/ability/stage-brief.md @@ -60,7 +60,7 @@ + **Standard**:每次startAbility调用,都会在应用进程中创建一个该类型的实例,如下图Ability2的两个实例; -+ **Specified**:允许开发者在系统创建AbilityRecord之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。 ++ **Specified**:允许开发者在系统创建Ability实例之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。 ​ 每个Ability实例都对应了一个Launcher Recent中看到的Mission(任务)。 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/file-management/Readme-CN.md b/zh-cn/application-dev/file-management/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..5177e924c050d43e6efc42c0fc50f98b10b59eed --- /dev/null +++ b/zh-cn/application-dev/file-management/Readme-CN.md @@ -0,0 +1,6 @@ +# 文件管理 +- 媒体库管理 + - [媒体库开发概述](medialibrary-overview.md) + - [媒体资源使用指导](medialibrary-resource-guidelines.md) + - [文件路径使用指导](medialibrary-filepath-guidelines.md) + - [相册资源使用指导](medialibrary-album-guidelines.md) \ No newline at end of file diff --git a/zh-cn/application-dev/file-management/medialibrary-album-guidelines.md b/zh-cn/application-dev/file-management/medialibrary-album-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..4265b41dd33be1e9155b605f38ad76a3dfc17970 --- /dev/null +++ b/zh-cn/application-dev/file-management/medialibrary-album-guidelines.md @@ -0,0 +1,94 @@ +# 相册资源使用指导 + +mediaLibrary提供相册相关的接口,供开发者创建、删除相册,获取相册中的图片资源等。 + +> **说明:** +> +> 在进行功能开发前,请开发者查阅[媒体库开发概述](medialibrary-overview.md),了解如何获取媒体库实例和如何申请媒体库功能开发相关权限。 + +为了保证应用的运行效率,大部分MediaLibrary调用都是异步的,对于异步调用的API均提供了callback和Promise两种方式,以下示例均采用Promise函数,更多方式可以查阅[API参考](../reference/apis/js-apis-medialibrary.md)。 + +## 获取相册中的图片/视频 + +获取相册中的图片、视频有两种方式: + +一是通过[MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1)指定相册以获取媒体资源,参考[获取指定相册的媒体资源](medialibrary-resource-guidelines#指定相册); + +二是通过[Album.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-3)使用相册Album实例获取媒体资源,参考[获取相册中的图片或视频](medialibrary-resource-guidelines#获取相册中的图片或视频)。 + +## 创建相册 + +通过[MediaLibrary.createAsset](../reference/apis/js-apis-medialibrary.md#createasset8-1)可以创建媒体资源,可以通过创建图片或视频文件时设置的相对路径,创建出相册。相对路径的命名即为相册名称。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA”。 + +下面以创建相册myAlbum为例。 + +**开发步骤** + +1. 调用getPublicDirectory获取文件公共路径。 + + 获取文件公共路径的更多指导可参考[获取文件保存的公共目录](medialibrary-filepath-guidelines.md#获取文件保存的公共目录)。 + +2. 调用createAsset新建图片,并设置相对路径为path+'myAlbum/'。 + + 即在创建相册的同时,往里面放了一张图片。 + +```ts +async function example() { + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const path = await media.getPublicDirectory(DIR_IMAGE) + //myAlbum为新建文件保存路径,也是新建相册的名称 + media.createAsset(mediaType, 'test.jpg', path + 'myAlbum/', (err, fileAsset) => { + if (fileAsset != undefined) { + console.info('createAlbum successfully, message = ' + fileAsset); + } else { + console.info('createAlbum failed, message = ' + err); + } + }); +} +``` + +## 重命名相册 + +重命名修改的是相册的FileAsset.albumName属性,即相册名称。修改后再通过[Album.commitModify](../reference/apis/js-apis-medialibrary.md#commitmodify8-3)更新到数据库中。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA”。 + +下面以重命名相册为“newAlbum“为例。 + +**开发步骤** + +1. 建立检索条件,用于获取目标相册。 +2. 调用getAlbums获取相册列表。 +3. 将相册重命名为“newAlbum“。 +4. 调用Album.commitModify将更新的相册属性修改到数据库中。 + +```ts +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let albumList = await media.getAlbums(AlbumNoArgsfetchOp); + let album = albumList[0]; + album.albumName = 'newAlbum'; + //回调返回空 + album.commitModify().then(function() { + console.info("albumRename successfully"); + }).catch(function(err){ + console.info("albumRename failed with error:"+ err); + }); +} +``` diff --git a/zh-cn/application-dev/file-management/medialibrary-filepath-guidelines.md b/zh-cn/application-dev/file-management/medialibrary-filepath-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..2298af3b425f4d1382654817a8507a2a402f9be4 --- /dev/null +++ b/zh-cn/application-dev/file-management/medialibrary-filepath-guidelines.md @@ -0,0 +1,244 @@ +# 文件路径使用指导 + +Openharmony上用户数据统一由媒体库进行管理,用户数据用户数据可以通过mediaLibrary提供的接口能力进行访问和操作。 + +> **说明:** +> +> 在进行功能开发前,请开发者查阅[媒体库开发概述](medialibrary-overview.md),了解如何获取媒体库实例和如何申请媒体库功能开发相关权限。 + +为了保证应用的运行效率,大部分MediaLibrary调用都是异步的,对于异步调用的API均提供了callback和Promise两种方式,以下示例均采用Promise函数,更多方式可以查阅[API参考](../reference/apis/js-apis-medialibrary.md)。 + +## 公共目录路径支持的文件格式 + +在使用文件路径进行开发之前,需要了解各公共目录路径支持的文件格式说明。 +> **注意:**
    +> 下表仅表示系统能识别的文件类型,在具体的开发中,开发者需要关注对应接口支持的文件格式。
    如image编码功能只支持.jpeg和.webp,解码功能只支持.jpg .png .gif .bmp .webp RAW。 + +| 目录路径 | 目录类型 | 媒体类型 | 说明 | 支持的文件格式 | +| ---------- | ------------- | ------------- | -------------- | ------------------------------------------------------------ | +| Camera/ | DIR_CAMERA | VIDEO amd IMAGE | 相机拍摄图片与录像的存放路径,目录与子目录下可以存放视频,图片类型文件。 | .bmp / .bm / .gif / .jpg /. jpeg / .jpe / .png / .webp / .raw / .svg / .heif / .mp4 / .3gp / .mpg / .mov / .webm / .mkv | +| Videos/ | DIR_VIDEO | VIDEO | 视频专有目录,目录与子目录下只可以存放视频类型文件。| .mp4 / .3gp / .mpg / .mov / .webm / .mkv | +| Pictures/ | DIR_IMAGE | IMAGE | 图片专有目录,目录与子目录下只可以存放图片类型文件。 | .bmp / .bm / .gif / .jpg /. jpeg / .jpe / .png / .webp / .raw / .svg / .heif | +| Audios/ | DIR_AUDIO | AUDIO |音频专有目录,目录与子目录下只可以存放音频类型文件。| .aac/.mp3/.flac/.wav/.ogg | +| Documents/ | DIR_DOCUMENTS | FILE |文档类型目录,目录与子目录下只可以存放音频,图片,视频以外类型文件。| - | +| Download/ | DIR_DOWNLOAD | ALLTYPE |下载文件存放目录,目录与子目录下文件类型不受限制。| - | + +## 获取文件保存的公共目录 + +不同类型的文件会保存到不同的公共目录下,可以通过接口[getPublicDirectory](../reference/apis/js-apis-medialibrary.md#getpublicdirectory8-1)来获取公共目录路径。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读权限“ohos.permission.READ_MEDIA。 + +下面以获取Camera文件保存的公共目录为例。 + +```ts +async function example(){ + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; + const dicResult = await media.getPublicDirectory(DIR_CAMERA); + if (dicResult == 'Camera/') { + console.info('mediaLibraryTest : getPublicDirectory passed'); + } else { + console.info('mediaLibraryTest : getPublicDirectory failed'); + } +} +``` + +## 沙箱与公共路径间文件的复制 + +OpenHarmony提供应用沙箱机制,增加目录可见性数据访问防线,减少了应用数据和用户隐私信息泄露,建立了更加严格安全的应用沙盒隔离能力。 + +放在公共路径下的文件,用户可以通过系统应用“文件管理”、“图库”访问,但应用沙箱内的文件,只有应用本身可以访问。 + +### 复制文件 + +通过接口[mediaLibrary.FileAsset.open](../reference/apis/js-apis-medialibrary.md#open8-1)可以打开公共路径文件。 + +通过接口[fileio.open](../reference/apis/js-apis-fileio.md#fileioopen7)可以打开沙箱路径文件,沙箱路径必须通过应用上下文context进行访问。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA。 +- 除了@ohos.multimedia.mediaLibrary外,还需要导入模块[@ohos.fileio](../reference/apis/js-apis-fileio.md)。 + +**开发步骤** + +1. 调用[context.filesDir](../reference/apis/js-apis-Context.md#contextgetfilesdir)获取应用沙箱路径。 +2. 调用MediaLibrary.getFileAssets和FetchFileResult.getFirstObject获取公共目录中的FileAsset实例。 +3. 调用fileio.open打开沙箱路径文件。 +4. 调用fileAsset.open打开公共路径文件。 +5. 调用fileio.copyfile复制文件。 +6. 调用fileAsset.close和fileio.close关闭文件。 + +**示例1 将公共路径文件复制到沙箱路径下** + +```ts +async function copyPublic2Sandbox() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let sandboxDirPath = globalThis.context.filesDir; + let fileKeyObj = mediaLibrary.FileKey + let fileAssetFetchOp = { + selections: fileKeyObj.DISPLAY_NAME + '= ?' , + selectionArgs: ['testFile.txt'], + }; + let fetchResult = await media.getFileAssets(fileAssetFetchOp); + let fileAsset = await fetchResult.getFirstObject(); + + let fdPub = await fileAsset.open('rw'); + let fdSand = await fileio.open(sandboxDirPath + '/testFile.txt', 0o2 | 0o100, 0o666); + await fileio.copyFile(fdPub, fdSand); + + await fileAsset.close(fdPub); + await fileio.close(fdSand); + + let content_sand = await fileio.readText(sandboxDirPath + '/testFile.txt'); + console.log('content read from sandbox file: ', content_sand) +} +``` + +**示例2 将应用沙箱路径文件复制到公共路径** + +```ts +async function copySandbox2Public() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let sandboxDirPath = globalThis.context.filesDir; + + let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS; + const publicDirPath = await media.getPublicDirectory(DIR_DOCUMENTS); + try { + let fileAsset = await media.createAsset(mediaLibrary.MediaType.FILE, 'testFile02.txt', publicDirPath); + console.info('createFile successfully, message = ' + fileAsset); + } catch (err) { + console.info('createFile failed, message = ' + err); + } + try { + let fileKeyObj = mediaLibrary.FileKey + let fileAssetFetchOp = { + selections: fileKeyObj.DISPLAY_NAME + '= ?' , + selectionArgs: ['testFile02.txt'], + }; + let fetchResult = await media.getFileAssets(fileAssetFetchOp); + var fileAsset = await fetchResult.getFirstObject(); + } catch (err) { + console.info('file asset get failed, message = ', err) + } + var fdPub = await fileAsset.open('rw'); + var fdSand = await fileio.open(sandboxDirPath + 'testFile.txt', 0o2); + await fileio.copyFile(fdSand, fdPub); + await fileio.close(fdPub); + await fileio.close(fdSand); + let fdPubRead = await fileAsset.open('rw'); + try { + var arrayBuffer = new ArrayBuffer(4096); + await fileio.read(fdPubRead, arrayBuffer); + var content_pub = String.fromCharCode(new Uint8Array(arrayBuffer)); + fileAsset.close(fdPubRead); + } catch (err) { + console.log('read text failed, message = ', err); + } + console.log('content read from public file: ', content_pub); +} +``` + +### 读写文件内容 + +通过[mediaLibrary](../reference/apis/js-apis-medialibrary.md)的接口FileAsset.open和FileAsset.close可以打开和关闭文件。通过[fileio](../reference/apis/js-apis-fileio.md)的接口fileio.read和fileio.write可以读写文件。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA。 +- 除了@ohos.multimedia.mediaLibrary外,还需要导入模块[@ohos.fileio](../reference/apis/js-apis-fileio.md)。 + +**开发步骤** + +1. 创建用于读写示例的文件。 + + ```ts + async function example() { + let mediaType = mediaLibrary.MediaType.FILE; + let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const path = await media.getPublicDirectory(DIR_DOCUMENTS); + media.createAsset(mediaType, "testFile.text", path).then (function (asset) { + console.info("createAsset successfully:"+ JSON.stringify(asset)); + }).catch(function(err){ + console.info("createAsset failed with error:"+ err); + }); + } + ``` + +2. 使用open打开文件。 + +3. 使用fileio.write写入文件,以string形式传入写入数据。 + +4. 使用fileio.read读取文件,以 ArrayBuffer 形式保存读取结果。 + +5. 将ArrayBuffer转化为string,以string形式得到文件内容。 + +6. 使用close关闭文件。 + +**示例1 打开现有文件、向文件中写入** + +```ts +async function writeOnlyPromise() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let fileKeyObj = mediaLibrary.FileKey + let fileAssetFetchOp = { + selections: fileKeyObj.DISPLAY_NAME + '= ?' , + selectionArgs: ['testFile.txt'], + }; + let fetchResult = await media.getFileAssets(fileAssetFetchOp); + let fileAsset = await fetchResult.getFirstObject(); + console.info('fileAssetName: ', fileAsset.displayName); + + try { + let fd = await fileAsset.open('w'); + console.info('file descriptor: ', fd); + await fileio.write(fd, "Write file test content."); + await fileAsset.close(fd); + } catch (err) { + console.info('write file failed, message = ', err); + } +} +``` + +**示例2 打开现有文件,读取文件内容** + +```ts +async function readOnlyPromise() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let fileKeyObj = mediaLibrary.FileKey + let fileAssetFetchOp = { + selections: fileKeyObj.DISPLAY_NAME + '= ?' , + selectionArgs: ['testFile.txt'], + }; + let fetchResult = await media.getFileAssets(fileAssetFetchOp); + let fileAsset = await fetchResult.getFirstObject(); + console.info('fileAssetName: ', fileAsset.displayName); + + try { + let fd = await fileAsset.open('r'); + let arrayBuffer = new ArrayBuffer(4096); + await fileio.read(fd, arrayBuffer); + let fileContent = String.fromCharCode(...new Uint8Array(arrayBuffer)); + globalThis.fileContent = fileContent + globalThis.fileName = fileAsset.displayName; + console.info('file content: ', fileContent); + await fileAsset.close(fd); + } catch (err) { + console.info('read file failed, message = ', err); + } +} +``` + diff --git a/zh-cn/application-dev/file-management/medialibrary-overview.md b/zh-cn/application-dev/file-management/medialibrary-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..cde6847318650e674b34d24916fc5d2077ff4619 --- /dev/null +++ b/zh-cn/application-dev/file-management/medialibrary-overview.md @@ -0,0 +1,126 @@ +# 媒体库开发概述 + +MediaLibrary提供媒体库相关能力,帮助开发者更方便地访问和修改媒体文件,具体分为: + +- [媒体资源(音频、视频、图片文件等)相关](medialibrary-resource-guidelines.md),包括: + - 查询指定媒体资源 + - 获取图片/视频 + - 获取图片/视频缩略图 + - 创建媒体资源 + - 重命名媒体资源 + - 将媒体资源放入回收站 +- [文件路径相关](medialibrary-filepath-guidelines.md),包括: + - 获取文件保存的公共目录 + - 沙箱与公共路径间文件的复制 + - 读写文件内容 +- [相册相关](medialibrary-album-guidelines.md),包括: + - 获取相册中的图片/视频 + - 创建相册 + - 重命名相册 + +> **说明:**
    +> 本开发指导基于API Version 9,仅适用于Stage模型。 + +应用需要先获取媒体库实例,才能访问和修改用户等个人媒体数据信息。媒体库涉及用户个人数据信息,所以应用需要向用户申请媒体库读写操作权限才能保证功能的正常运行。 + +开发者在使用MediaLibrary进行功能开发前,请先掌握以下内容: + +- [获取媒体库实例](#获取媒体库实例) +- [申请媒体库功能相关权限](#申请媒体库功能相关权限) + +## 获取媒体库实例 + +应用需要使用应用上下文Context通过接口[getMediaLibrary](../reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary8),获取媒体库实例,用于访问和修改用户等个人媒体数据信息(如音频、视频、图片、文档等)。 + +**开发步骤** + +1. 导入mediaLibrary模块以使用媒体库相关接口。 +2. 通过getContext获取应用上下文。 +3. 获取媒体库实例。 + +```ts +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; + +const context = getContext(this); +var media = mediaLibrary.getMediaLibrary(context); +``` + +## 申请媒体库功能相关权限 + +媒体库的读写操作需要相应权限,在申请权限前,请保证符合[权限使用的基本原则](../security/accesstoken-overview.md#权限使用的基本原则)。涉及的权限如下表。 + +| 权限名 | 说明 | 授权方式 | +| ------------------------------ | ------------------------------------------ | ---------- | +| ohos.permission.READ_MEDIA | 允许应用读取用户外部存储中的媒体文件信息。 | user_grant | +| ohos.permission.WRITE_MEDIA | 允许应用读写用户外部存储中的媒体文件信息。 | user_grant | +| ohos.permission.MEDIA_LOCATION | 允许应用访问用户媒体文件中的地理位置信息。 | user_grant | + +以上权限的授权方式均为user_grant(用户授权),即开发者在module.json5文件中配置对应的权限后,需要使用接口[Context.requestPermissionsFromUser](../reference/apis/js-apis-ability-context.md#abilitycontextrequestpermissionsfromuser)去校验当前用户是否已授权。如果是,应用可以直接访问/操作目标对象;否则需要弹框向用户申请授权。 + +> **说明:**
    即使用户曾经授予权限,应用在调用受此权限保护的接口前,也应该先检查是否有权限。不能把之前授予的状态持久化,因为用户在动态授予后还可以通过“设置”取消应用的权限。 + +**开发步骤** + +1. 在配置文件module.json5中声明权限。在配置文件的“module”标签内,增加“requestPermissions”标签,标签内容请根据实际情况填写。标签说明可参考[访问控制(权限)开发指导](../security/accesstoken-guidelines.md)。 + + ```json + { + "module": { + "requestPermissions": [ + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } + } + ] + } + } + ``` + +2. 调用requestPermissionsFromUser进行权限校验,可以选择需要动态申请获取的权限。 + + ```ts + import Ability from '@ohos.application.Ability' + + export default class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + var permissions=['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA'] + var permissionRequestResult; + this.context.requestPermissionsFromUser(permissions,(err,result) => { + if(err){ + console.log('requestPermissionsFromUserError: ' + JSON.stringify(err)); + }else{ + permissionRequestResult=result; + console.log('permissionRequestResult: ' + JSON.stringify(permissionRequestResult)); + } + }); + } + } + ``` + + \ No newline at end of file diff --git a/zh-cn/application-dev/file-management/medialibrary-resource-guidelines.md b/zh-cn/application-dev/file-management/medialibrary-resource-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..5f84cb935ca2ac52820d38f2a65a0d7a0725e6a5 --- /dev/null +++ b/zh-cn/application-dev/file-management/medialibrary-resource-guidelines.md @@ -0,0 +1,386 @@ +# 媒体资源使用指导 + +应用可以通过mediaLibrary的接口,进行媒体资源(音频、视频、图片文件等)相关操作。 + +> **说明:** +> +> 在进行功能开发前,请开发者查阅[媒体库开发概述](medialibrary-overview.md),了解如何获取媒体库实例和如何申请媒体库功能开发相关权限。 + +为了保证应用的运行效率,大部分MediaLibrary调用都是异步的,对于异步调用的API均提供了callback和Promise两种方式,以下示例均采用Promise函数,更多方式可以查阅[API参考](../reference/apis/js-apis-medialibrary.md)。 + +## 获取媒体资源 + +开发者可以根据特定的条件查询媒体资源,如指定类型、指定日期、指定相册等。 + +应用通过调用[MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1)获取媒体资源,并传入MediaFetchOptions对象指定检索条件。MediaFetchOptions.selections为检索条件,使用FileKey中的枚举值作为检索条件的列名;MediaFetchOptions.selectionArgs对应selections中检索条件列的值;除此之外,可以使用order(结果排序方式)、uri(文件URI)、networkId(注册设备网络ID)作为检索条件。 + +如果只想获取某个位置的对象(如第一个、最后一个、指定索引等),可以通过[FetchFileResult](../reference/apis/js-apis-medialibrary.md#fetchfileresult7)中的接口获取对应位置的媒体资源对象。本小节均采用getNextObject循环获取检索结果中的所有媒体资源。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读权限“ohos.permission.READ_MEDIA”。 + +### 指定媒体类型 + +下面以查询图片类型的媒体资源为例。 + +**开发步骤** + +selections: FileKey.MEDIA_TYPE,根据媒体类型检索。 + +selectionArgs: MediaType.IMAGE,媒体类型为图片。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.IMAGE + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + for (let i = 0; i < fetchFileResult.getCount(); i++) { + fetchFileResult.getNextObject((err, fileAsset) => { + if (err) { + console.error('Failed '); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + }) + } +} +``` + +### 指定日期 + +下面以查询指定添加日期的媒体资源为例。实际开发中可以设置添加日期、修改日期、拍摄日期。 + +selections: FileKey.DATE_ADDED,根据文件添加日期检索。 + +selectionArgs:2022-8-5,具体添加时间的字符串。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let option = { + selections: fileKeyObj.DATE_ADDED + '= ?', + selectionArgs: ['2022-8-5'], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + for (let i = 0; i < fetchFileResult.getCount(); i++) { + fetchFileResult.getNextObject((err, fileAsset) => { + if (err) { + console.error('Failed '); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + }) + } +} +``` + +### 按指定顺序排列 + +下面以查询图片并按文件添加日期降序排列为例。实际开发中可以设置升序(AESC)和降序(DESC)。 + +order: FileKey.DATE_ADDED,根据文件添加日期排序;并设置排列顺序为DESC降序。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.IMAGE + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + for (let i = 0; i < fetchFileResult.getCount(); i++) { + fetchFileResult.getNextObject((err, fileAsset) => { + if (err) { + console.error('Failed '); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + }) + } +} +``` + +### 指定相册 + +下面以指定相册myAlbum为例。 + +selections: FileKey.ALBUM_NAME,根据相册名称检索。 + +selectionArgs:'myAlbum',具体相册名称。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.IMAGE + let option = { + selections: fileKeyObj.ALBUM_NAME + '= ?', + selectionArgs: ['myAlbum'], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + for (let i = 0; i < fetchFileResult.getCount(); i++) { + fetchFileResult.getNextObject((err, fileAsset) => { + if (err) { + console.error('Failed '); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + }) + } +} +``` + +## 获取相册中的图片或视频 + +获取相册的媒体资源有两种方式,一是通过[MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1)指定相册以获取媒体资源,参考[获取指定相册的媒体资源](#指定相册);二是通过[Album.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-3)使用相册Album实例获取媒体资源。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读权限“ohos.permission.READ_MEDIA”。 + +**开发步骤** + +下面以获取相册名称为“新建相册1”的视频为例。 + +1. 建立检索条件,用于获取目的相册实例。 + + ```ts + let fileKeyObj = mediaLibrary.FileKey; + let AlbumNoArgsFetchOp = { + selections: fileKeyObj.ALBUM_NAME + '= ?', + selectionArgs: ['新建相册1'] + } + ``` + +2. 建立检索条件,用于获取目的相册下的视频资源。 + + ```ts + let fileKeyObj = mediaLibrary.FileKey; + let imageType = mediaLibrary.MediaType.VIDEO; + let imagesFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + } + ``` + +3. 通过Album.getFileAssets获取对应的资源。 + +以下为**完整示例**。 + +```ts +async function getCameraImagePromise() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let fileKeyObj = mediaLibrary.FileKey; + let imageType = mediaLibrary.MediaType.IMAGE; + let imagesFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + } + let AlbumNoArgsFetchOp = { + selections: fileKeyObj.ALBUM_NAME + '= ?', + selectionArgs: ['新建相册1'] + } + + let albumList = await media.getAlbums(AlbumNoArgsFetchOp); + if (albumList.length > 0) { + const album = albumList[0]; + let fetchFileResult = await album.getFileAssets(imagesFetchOp); + let count = fetchFileResult.getCount(); + console.info("get mediaLibrary IMAGE number", count); + } else { + console.info('getAlbum list is: 0'); + } +} +``` + +## 获取图片/视频缩略图 + +通过接口[FileAsset.getThumbnail](../reference/apis/js-apis-medialibrary.md#getthumbnail8-2),传入缩略图尺寸,可以获取图片/视频缩略图。缩略图常用于UI界面展示。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读权限“ohos.permission.READ_MEDIA”。 + +### 获取某张图片的缩略图 + +当需要在相册展示图片/视频、编辑预览,应用需要获取某张图片的缩略图。 + +下面以获取相册第一张图片的缩略图为例,缩略图尺寸为720*720。 + +**开发步骤** + +1. 建立检索条件,用于获取目的相册下的图片资源。 +2. 调用getFileAssets获取目标图片资源。 +3. 调用getFirstObject获取第一张图片。 +4. 调用getThumbnail获取相册中图片的缩略图。 + +```ts +async function getFirstThumbnailPromise() { + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + let fileKeyObj = mediaLibrary.FileKey; + let imageType = mediaLibrary.MediaType.IMAGE; + let imagesFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + } + + let size = { width: 720, height: 720 }; + const fetchFileResult = await media.getFileAssets(imagesFetchOp); + if (fetchFileResult != undefined) { + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size).then((pixelMap) => { + pixelMap.getImageInfo().then((info) => { + console.info('get Thumbnail info: ' + "width: " + info.size.width + " height: " + info.size.height); + }).catch((err) => { + console.info("getImageInfo failed with error:" + err); + }); + }).catch((err) => { + console.info("getImageInfo failed with error:" + err); + }); + } else { + console.info("get image failed with error"); + } +} +``` + +## 创建媒体资源 + +通过接口[MediaLibrary.createAsset](../reference/apis/js-apis-medialibrary.md#createasset8-1)可以创建媒体资源。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA”。 +- [获取公共目录路径](medialibrary-filepath-guidelines.md)。 + +下面以创建文件类型(MediaType.FILE)的文件为例。 + +```ts +async function example() { + let mediaType = mediaLibrary.MediaType.FILE; + let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const path = await media.getPublicDirectory(DIR_DOCUMENTS); + media.createAsset(mediaType, "testFile.text", path).then ((asset) => { + console.info("createAsset successfully:"+ JSON.stringify(asset)); + }).catch((err) => { + console.info("createAsset failed with error:"+ err); + }); +} +``` + +## 将文件放入回收站 + +通过[FileAsset.trash](../reference/apis/js-apis-medialibrary.md#trash8)可以将文件放入回收站。 + +放入回收站的文件将会保存30天,在此期间,开发者可以将trash的入参isTrash设置为false将其恢复为正常文件;应用用户也可以通过系统应用“文件管理”或“图库”恢复文件。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA”。 + +下面以将文件检索结果中第一个文件放入回收站为例。 + +**开发步骤** + +1. 建立检索条件,用于获取目的相册下的图片资源。 +2. 调用getFileAssets获取目标图片资源。 +3. 调用getFirstObject获取第一张图片,即要放入回收站的图片对象。 +4. 调用trash将文件放入回收站。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.FILE + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + let asset = await fetchFileResult.getFirstObject(); + if (asset == undefined) { + console.error('asset not exist') + return + } + //回调为空 + asset.trash(true).then(() => { + console.info("trash successfully"); + }).catch((err) => { + console.info("trash failed with error:"+ err); + }); +} +``` + +## 重命名媒体资源 + +重命名修改的是文件的FileAsset.displayName属性,即文件的显示文件名,包含文件后缀。 + +修改后再通过[FileAsset.commitModify](../reference/apis/js-apis-medialibrary.md#commitmodify8-1)更新到数据库中。 + +在删除文件之前,需要先获取文件对象,可以通过[FetchFileResult](../reference/apis/js-apis-medialibrary.md#fetchfileresult7)中的接口获取对应位置的文件。 + +**前提条件** + +- 获取媒体库mediaLibrary实例。 +- 申请媒体库读写权限“ohos.permission.WRITE_MEDIA”。 + +下面以将文件检索结果中第一个文件重命名为“newtitle.text”为例。 + +**开发步骤** + +1. 建立检索条件,用于获取目的相册下的图片资源。 +2. 调用getFileAssets获取目标图片资源。 +3. 调用getFirstObject获取第一张图片,即要重命名的图片对象。 +4. 将图片重命名为“newImage.jpg“。 +5. 调用FileAsset.commitModify将更新的图片属性修改到数据库中。 + +```ts +async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.FILE + let option = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + const context = getContext(this); + var media = mediaLibrary.getMediaLibrary(context); + const fetchFileResult = await media.getFileAssets(option); + let asset = await fetchFileResult.getFirstObject(); + if (asset == undefined) { + console.error('asset not exist') + return + } + asset.displayName = 'newImage.jpg'; + //回调为空 + asset.commitModify((err) => { + if (err) { + console.error('fileRename Failed '); + return; + } + console.log('fileRename successful.'); + }) +} +``` diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/design-principles.md b/zh-cn/application-dev/key-features/multi-device-app-dev/design-principles.md index 1079073aa98e16ab58cc454254b6de20b2f19c91..9b2af2b3c312ec3c47d1d2abf9b165f97eaa52a5 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/design-principles.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/design-principles.md @@ -1,6 +1,5 @@ # 设计原则和要点 - ## 设计原则 当为多种不同的设备开发应用时,有如下设计原则: @@ -21,14 +20,12 @@ 在硬件能力、交互方式、使用场景差异较大的设备上,除了考虑布局位置、内容宽度、横向组件数量,还需支持不同的输入方式、考虑功能架构的调整,避免出现输入不识别、功能不可用、使用困难的问题。 - ## 设计要点 很多用户的多设备体验以默认设备为核心或从默认设备往外延伸,因此,围绕全场景体验的OpenHarmony UX设计,将优先确保用户在不同的设备上获得跟使用默认设备类似的体验,同时充分利用设备的优势使体验最大化。 在进行OpenHarmony的多设备应用设计时,需考虑应用以下内容: - ### 自适应应用架构 使用自适应应用架构,可以确保应用在不同终端上,以最佳的导航形式来访问应用。OpenHarmony 在开发SDK上提供了便利,开发者可以通过简单配置轻松完成,无需从0开始构建。 @@ -37,8 +34,7 @@ ![一多-1-1](figures/一多-1-1.png) -更多应用架构的设计内容,详见:[应用架构](architecture-design.md)。 - +更多应用架构的设计内容,详见:应用架构下的[应用导航结构设计要求](navigation-design.md)和[应用页面结构设计](page-design.md)。 ### 响应式界面布局 @@ -56,15 +52,13 @@ OpenHarmony 提供了多种布局能力,开发者通过组合运用使内容 ![概述-界面布局-歌单详情高保真](figures/概述-界面布局-歌单详情高保真.png) -更多界面布局的设计内容,详见:[界面布局](interface-layout-design.md)。 - +更多界面布局的设计内容,详见:[界面布局](interface-layout-design-intro.md)。 ### 交互归一 交互归一描述了在多种交互任务或场景下,应用在触屏上和其它常用的输入方式(例如鼠标、触摸板、键盘)上分别对应的正确的交互规则。设计师和开发者应保证在当前输入方式下应用能够以正确的、符合用户习惯的交互规则进行响应。通常情况下,系统已经做好了这些事情,开发者只需正确调用。如果您的操作比较特别,您需要考虑多端上的交互归一,以确保用户体验的一致。 -更多交互归一的设计内容,详见:[人机交互](man-machine-interaction.md)。 - +更多交互归一的设计内容,详见:[人机交互](interaction-basics.md)。 ### 视觉参数化 @@ -72,8 +66,7 @@ OpenHarmony 提供了多种布局能力,开发者通过组合运用使内容 ![画板copy](figures/画板copy.png) -更多视觉参数化的设计内容,详见:[视觉风格](visual-style.md)。 - +更多视觉参数化的设计内容,详见:[视觉风格](visual-basics.md)。 ### 多态控件 @@ -81,7 +74,6 @@ OpenHarmony 提供了多种布局能力,开发者通过组合运用使内容 OpenHarmony默认提供支持多设备的控件,开发者可以直接使用并对不同状态进行自定义。例如平板可以连接蓝牙键盘和鼠标来做文字编辑工作,此时控件需要同时满足键盘和鼠标交互,需要支持获焦态和悬停态。 - ### 针对性优化 在上述设计内容以外,在具体设备上,推荐针对性地进行特殊的操作和布局优化,使之符合当前设备的使用习惯。 diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001381220169.png b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001381220169.png index 49846845ca794c645a7ee12af2808bb08f4b5ffa..710140939944b033c8450706e636730f1c0ad2f0 100644 Binary files a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001381220169.png and b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001381220169.png differ diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/navigation-design.md b/zh-cn/application-dev/key-features/multi-device-app-dev/navigation-design.md index 7bec736913b899523468cad314227f917c734231..41dcdb3b7203b3d1def7415f72b0db6589ef0c49 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/navigation-design.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/navigation-design.md @@ -8,15 +8,15 @@ 导航需要遵循以下原则: -- **一致:**导航操作的结果应该与用户的期望保持一致。相同或类似的场景使用用户熟悉的界面布局和控件,在多设备上确保一致的应用架构和导航行为,让用户无论在什么页面,都知道如何导航。例如二级界面使用左上角的返回按钮来返回界面的上一个层级。 +- **一致:** 导航操作的结果应该与用户的期望保持一致。相同或类似的场景使用用户熟悉的界面布局和控件,在多设备上确保一致的应用架构和导航行为,让用户无论在什么页面,都知道如何导航。例如二级界面使用左上角的返回按钮来返回界面的上一个层级。 -- **清晰:**导航应该提供清晰的路径。用户使用的时候,逻辑关系简单且容易理解,能够知道当前处在界面的什么位置,操作后将会跳转到什么位置,不会迷失方向。例如使用底部页签,让用户在平级页面之间进行切换。 +- **清晰:** 导航应该提供清晰的路径。用户使用的时候,逻辑关系简单且容易理解,能够知道当前处在界面的什么位置,操作后将会跳转到什么位置,不会迷失方向。例如使用底部页签,让用户在平级页面之间进行切换。 导航要避免以下设计: -- **层级过深:**导航层级建议在三层以内。对于太深的层次,会带来操作效率的问题。如果确实需要深层级设计,建议使用面包屑设计或增加一键回到首页的功能。 +- **层级过深:** 导航层级建议在三层以内。对于太深的层次,会带来操作效率的问题。如果确实需要深层级设计,建议使用面包屑设计或增加一键回到首页的功能。 -- **导航复杂:**在侧边导航中,使用底部页签,会让操作变得复杂,建议仅使用侧边导航。 +- **导航复杂:** 在侧边导航中,使用底部页签,会让操作变得复杂,建议仅使用侧边导航。 ## 导航的分类 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/stage-structure.md b/zh-cn/application-dev/quick-start/stage-structure.md index 2614a8cea2e065b64afd51e4535ff7ff007302dd..dbdb68f9ae500bd586ec8fc85f20159cf1bcf8b6 100755 --- a/zh-cn/application-dev/quick-start/stage-structure.md +++ b/zh-cn/application-dev/quick-start/stage-structure.md @@ -12,7 +12,7 @@ | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | ---------- | -| app | 标识应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 否 | +| app | 标识应用的全局配置信息。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 否 | | module | 标识HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象内部结构](#module对象内部结构)。 | 对象 | 否 | ### app对象内部结构 @@ -68,6 +68,7 @@ app.json示例: | keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。标签值为布尔类型,如果为true,应用将始终保持为运行状态,并且在系统启动的时候会被系统启动起来,应用进程退出后,系统也会重新启动该应用进程。 | 布尔值 | 可缺省,缺省值为false。 | | userDataClearable | 标识是否允许应用清除用户数据,仅支持系统应用配置,三方应用配置不生效,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为true。 | | accessible | 标识应用的安装目录是否是可访问的,仅支持系统应用配置,三方应用配置不生效。配置为true表示安装目录可以被三方应用访问,false表示不能被三方应用访问。 | 布尔值 | 可缺省,缺省值为false。 | +| multiProjects | 标识当前工程是否支持多工程。 | 布尔值 | 可缺省,缺省值为false。 | | 设备类型 | 该标签可以配置多个,表示具体设备上的特殊配置信息,具体的设备类型有:"tablet"、"tv"、"wearable"、"car",可能包含的字段有:minAPIVersion、distributedNotificationEnabled、keepAlive、removable。 | 对象 | 该标签可缺省,缺省值使用app下面相关的字段。 | ### module对象内部结构 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/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 4f6a8342035080d94594859718f56b28c7c84b5e..87e2bda0fe1883722417ab38523d266e87ef168e 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,4 +1,4 @@ -# 接口 +# 接口 - [开发说明](development-intro.md) - Ability框架 - FA模型 @@ -91,8 +91,10 @@ - bundle/[PackInfo (PackInfo)](js-apis-bundle-PackInfo.md) - UI界面 - [@ohos.animator (动画)](js-apis-animator.md) + - [@ohos.curves (插值计算)](js-apis-curve.md) + - [@ohos.matrix4 (矩阵变换)](js-apis-matrix4.md) - [@ohos.mediaquery (媒体查询)](js-apis-mediaquery.md) - - [@ohos.prompt (弹窗)](js-apis-prompt.md) + - [@ohos.promptAction (弹窗)](js-apis-promptAction.md) - [@ohos.router (页面路由)](js-apis-router.md) - [@ohos.uiAppearance(用户界面外观)](js-apis-uiappearance.md) - 图形图像 @@ -215,6 +217,7 @@ - [@ohos.geolocation (位置服务)](js-apis-geolocation.md) - [@ohos.multimodalInput.inputConsumer (组合按键)](js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越管理)](js-apis-cooperate.md) - [@ohos.multimodalInput.inputEvent (输入事件)](js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient (注入按键)](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (输入监听)](js-apis-inputmonitor.md) @@ -265,6 +268,7 @@ - 已停止维护的接口 - [@ohos.bytrace (性能打点)](js-apis-bytrace.md) - [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md) + - [@ohos.prompt (弹窗)](js-apis-prompt.md) - [@system.app (应用上下文)](js-apis-system-app.md) - [@system.battery (电量信息)](js-apis-system-battery.md) - [@system.bluetooth (蓝牙)](js-apis-system-bluetooth.md) diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png new file mode 100644 index 0000000000000000000000000000000000000000..36eab44e87c075e01baa66bfc48a86ba703b7835 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001118642902.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif new file mode 100644 index 0000000000000000000000000000000000000000..df8e47d8359338f9d0412cacfe12b847c28c2a84 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174104410.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png new file mode 100644 index 0000000000000000000000000000000000000000..1dc7d8d7beda862221b05a9247723a3f74bf323d Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001174422898.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png new file mode 100644 index 0000000000000000000000000000000000000000..747b8f915f2d40803ce6a7937de1add5deb8e640 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219662645.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png new file mode 100644 index 0000000000000000000000000000000000000000..605c0a1ddc0e2bace2e4c9a23fc2391af9ebf5bf Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219744181.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png new file mode 100644 index 0000000000000000000000000000000000000000..5c0ada67867ec3765eeb53af5c62369762d0bac4 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864131.png differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif new file mode 100644 index 0000000000000000000000000000000000000000..0befd736af77db15c203c4a5578929baf1d83e08 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001219864133.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c43bdf5b331963459154d4f0400fad7b17b34e8 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_00007.gif differ diff --git a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md index 49f936f59c1bc974156013c12425da01ceb79c64..e5f4ee612cd8a2d4f78186d9e441b74544de0b9a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @@ -49,3 +49,51 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil } }; ``` + +## EnterpriseAdminExtensionAbility.onBundleAdded + +onBundleAdded(bundleName: string): void + +应用安装事件回调。 + +**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| bundleName | string | 是 | 安装应用包名。 | + +**示例:** + +```ts +export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { + onBundleAdded(bundleName: string) { + console.log("added bundle name: " + bundleName); + } +}; +``` + +## EnterpriseAdminExtensionAbility.onBundleRemoved + +onBundleRemoved(bundleName: string): void + +应用卸载事件回调。 + +**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| bundleName | string | 是 | 卸载应用包名。 | + +**示例:** + +```ts +export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { + onBundleAdded(bundleName: string) { + console.log("removed bundle name: " + bundleName); + } +}; +``` 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..0915d3f045fecdc836105c146e7efb84be6d6f73 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -40,7 +40,7 @@ var AtManager = abilityAccessCtrl.createAtManager(); checkAccessToken(tokenID: number, permissionName: string): Promise<GrantStatus> -校验应用是否授予权限,使用Promise方式异步返回结果。 +校验应用是否授予权限。使用Promise异步回调。 **系统能力:** SystemCapability.Security.AccessToken @@ -57,10 +57,17 @@ checkAccessToken(tokenID: number, permissionName: string): Promise<GrantStatu | :------------ | :---------------------------------- | | Promise<GrantStatus> | Promise对象。返回授权状态结果。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | + **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -96,6 +103,13 @@ verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus | :------------ | :---------------------------------- | | [GrantStatus](#grantstatus) | 枚举实例,返回授权状态。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | + **示例:** ```js @@ -109,11 +123,11 @@ console.log(`data->${JSON.stringify(data)}`); grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise<void> -授予应用user grant权限,使用Promise方式异步返回结果。 +授予应用user grant权限。使用Promise异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -131,10 +145,20 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl | :------------ | :---------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100006 | The specified application does not support the permissions granted or ungranted as specified. | + **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -154,11 +178,11 @@ try { grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback<void>): void -授予应用user grant权限,使用callback回调异步返回结果。 +授予应用user grant权限。使用callback异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -169,12 +193,22 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl | tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | | permissionName | string | 是 | 被授予的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | -| callback | AsyncCallback<void> | 是 | 检查授予应用user grant权限的操作结果同步的回调。 | +| callback | AsyncCallback<void> | 是 | 授予应用user grant权限。当授予权限成功时,err为undefine;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100006 | The specified application does not support the permissions granted or ungranted as specified. | **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -196,11 +230,11 @@ try { revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise<void> -撤销应用user grant权限,使用Promise方式异步返回结果。 +撤销应用user grant权限。使用Promise异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -218,10 +252,20 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF | :------------ | :---------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100006 | The specified application does not support the permissions granted or ungranted as specified. | + **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -241,11 +285,11 @@ try { revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback<void>): void -撤销应用user grant权限,使用callback回调异步返回结果。 +撤销应用user grant权限。使用callback异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -256,12 +300,22 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF | tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | | permissionName | string | 是 | 被撤销的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | -| callback | AsyncCallback<void> | 是 | 检查撤销应用user grant权限的操作结果同步的回调。 | +| callback | AsyncCallback<void> | 是 | 撤销应用user grant权限。当撤销权限成功时,err为undefine;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100006 | The specified application does not support the permissions granted or ungranted as specified. | **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -283,11 +337,11 @@ try { getPermissionFlags(tokenID: number, permissionName: string): Promise<number> -获取指定应用的指定权限的flag,使用Promise方式异步返回结果。 +获取指定应用的指定权限的flag。使用Promise异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS or ohos.permission.GRANT_SENSITIVE_PERMISSIONS or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS or ohos.permission.GRANT_SENSITIVE_PERMISSIONS or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -304,10 +358,20 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g | :------------ | :---------------------------------- | | Promise<number> | Promise对象。返回查询结果。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100006 | The specified application does not support the permissions granted or ungranted as specified. | + **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; let AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -327,9 +391,9 @@ try { getVersion(): Promise<number> -获取当前权限管理的数据版本,使用Promise方式异步返回结果。 +获取当前权限管理的数据版本。使用Promise异步回调。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.Security.AccessToken @@ -353,11 +417,11 @@ promise.then(data => { on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<string>, callback: Callback<PermissionStateChangeInfo>): void; -订阅指定tokenId列表与权限列表的权限状态变更事件,使用callback回调异步返回结果。 +订阅指定tokenId列表与权限列表的权限状态变更事件。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -370,6 +434,15 @@ on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNa | permissionNameList | Array<string> | 否 | 订阅的权限名列表,为空时表示订阅所有的权限状态变化。 | | callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | 是 | 订阅指定tokenId与指定权限名状态变更事件的回调。| +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100004 | The listener interface is not used together. | +| 12100005 | The number of listeners exceeds the limit. | + **示例:** ```js @@ -393,9 +466,9 @@ off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionN 取消订阅指定tokenId列表与权限列表的权限状态变更事件,使用callback回调异步返回结果。 -此接口为系统接口。 +**系统接口:** 此接口为系统接口。 -**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS +**需要权限:** ohos.permission.GET_SENSITIVE_PERMISSIONS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -408,6 +481,14 @@ off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionN | permissionNameList | Array<string> | 否 | 订阅的权限名列表,为空时表示订阅所有的权限状态变化,必须与on的输入一致。 | | callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | 否 | 取消订阅指定tokenId与指定权限名状态变更事件的回调。| +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100004 | The listener interface is not used together. | + **示例:** ```js @@ -427,9 +508,9 @@ try { verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStatus> -校验应用是否授予权限,使用Promise方式异步返回结果。 +校验应用是否授予权限。使用Promise异步回调。 -> **说明:** 从API version 9开始不再维护,建议使用[checkAccessToken](#checkaccesstoken9)替代。 +> **说明:** 从API version 9开始不再维护,建议使用[checkAccessToken](#checkAccessToken9)替代。 **系统能力:** SystemCapability.Security.AccessToken @@ -449,7 +530,7 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat **示例:** ```js -import privacyManager from '@ohos.abilityAccessCtrl'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; // 可以通过getApplicationInfo获取accessTokenId @@ -472,7 +553,7 @@ promise.then(data => { ### PermissionStateChangeType9+ -表示权限状态变化操作类型的枚举。 +表示权限授权状态变化操作类型的枚举。 **系统接口:** 此接口为系统接口。 @@ -485,12 +566,14 @@ promise.then(data => { ### PermissionStateChangeInfo9+ +表示某次权限授权状态变化的详情。 + **系统接口:** 此接口为系统接口。 - **系统能力:** SystemCapability.Security.AccessToken +**系统能力:** 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-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index 54966570a6c4af2578a2dc3d250edd033c4cba16..6689361e739a8a6746f1a6fe98b7f19b70977cbb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -12,17 +12,16 @@ ```js import animator from '@ohos.animator'; ``` +## create9+ - -## createAnimator - -createAnimator(options: AnimatorOptions): AnimatorResult +create(options: AnimatorOptions): AnimatorResult 定义Animator类。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------------------- | ---- | ------- | | options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | @@ -34,73 +33,67 @@ createAnimator(options: AnimatorOptions): AnimatorResult **示例:** - ```html - -
    -
    -
    -
    - ``` - ```js - // js - export default { - data : { - divWidth: 200, - divHeight: 200, - animator: null - }, - onInit() { - var options = { - duration: 1500, - easing: 'friction', - fill: 'forwards', - iterations: 2, - begin: 200.0, - end: 400.0 - }; - this.animator = animator.createAnimator(options); - }, - Show() { - var options1 = { - duration: 2000, - easing: 'friction', - fill: 'forwards', - iterations: 1, - begin: 200.0, - end: 400.0 - }; - this.animator.update(options1); - var _this = this; - this.animator.onframe = function(value) { - _this.divWidth = value; - _this.divHeight = value; - }; - this.animator.play(); - } - } + var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, + }; + animator.create(options); ``` ## AnimatorResult 定义Animator结果接口。 -### update + -update(options: AnimatorOptions): void +### reset9+ + +reset(options: AnimatorOptions): void 更新当前动画器。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------------------------- | ---- | ------- | | options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.animator(动画)](../errorcodes/errorcode-animator.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + + **示例:** + ```js -animator.update(options); +var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, +}; +try { + animator.reset(options); +} catch(error) { + console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); +} ``` ### play @@ -112,6 +105,7 @@ play(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.play(); ``` @@ -125,6 +119,7 @@ finish(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.finish(); ``` @@ -138,6 +133,7 @@ pause(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.pause(); ``` @@ -151,6 +147,7 @@ cancel(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.cancel(); ``` @@ -164,6 +161,7 @@ reverse(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.reverse(); ``` @@ -177,11 +175,13 @@ onframe: (progress: number) => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | -------- | | progress | number | 是 | 动画的当前进度。 | **示例:** + ```js animator.onframe(); ``` @@ -195,6 +195,7 @@ onfinish: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.onfinish(); ``` @@ -202,12 +203,13 @@ animator.onfinish(); ### oncancel oncancel: () => void - +不再维护 动画被取消时回调。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.oncancel(); ``` @@ -221,10 +223,13 @@ onrepeat: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js animator.onrepeat(); ``` + + ## AnimatorOptions 定义动画选项。 @@ -241,3 +246,122 @@ animator.onrepeat(); | iterations | number | 是 | 动画播放次数,默认值1。设置为0时不播放,设置为-1时无限次播放。 | | begin | number | 是 | 动画插值起点,默认为0。 | | end | number | 是 | 动画插值终点,默认为1。 | + + +## 完整示例 + +```html + +
    +
    +
    +
    +``` + +```js +export default { + data: { + divWidth: 200, + divHeight: 200, + animator: null + }, + onInit() { + var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 2, + begin: 200.0, + end: 400.0 + }; + this.animator = animator.create(options); + }, + Show() { + var options1 = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 2, + begin: 0, + end: 400.0, + }; + try { + this.animator.reset(options1); + } catch(error) { + console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`); + } + var _this = this; + this.animator.onframe = function(value) { + _this.divWidth = value; + _this.divHeight = value; + }; + this.animator.play(); + } +} +``` + + ![zh-cn_image_00007](figures/zh-cn_image_00007.gif) + +## update(deprecated) + +update(options: AnimatorOptions): void + +更新当前动画器。 + +从API version9开始不再维护,建议使用[reset9+](#reset9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | + +**示例:** + +```js +animator.update(options); +``` + +## createAnimator(deprecated) + +createAnimator(options: AnimatorOptions): AnimatorResult + +定义Animator类。 + +从API version9开始不再维护,建议使用[create9+](#create9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ------------- | +| [AnimatorResult](#animatorresult) | Animator结果接口。 | + +**示例:** + +```js +var options = { + duration: 1500, + easing: 'friction', + delay: 0, + fill: 'forwards', + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0, +}; +this.animator = animator.createAnimator(options); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 2ecce44700157d0dd9c3b5f7aabd2eebfb42836b..cbe6af5410c204f20bcfbe623b95bf7d71be0117 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -36,12 +36,110 @@ createAppAccountManager(): AppAccountManager 管理应用帐号模块的实例。 -### addAccount +### createAccount9+ + +createAccount(name: string, callback: AsyncCallback<void>): void; + +将此应用的帐号名添加到帐号管理服务中,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| name | string | 是 | 要添加的应用帐号名称。 | +| callback | AsyncCallback<void> | 是 | 将此应用的帐号名添加到帐号管理服务回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.createAccount("WangWu", (err) => { + console.log("createAccount err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("createAccount err: " + JSON.stringify(err)); + } + ``` + +### createAccount9+ + +createAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void + +将此应用程序的帐号名和额外信息(能转换string类型的其它信息,如token)添加到帐号管理服务中,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| name | string | 是 | 要添加的应用帐号名称。 | +| extraInfo | string | 是 | 要添加的应用帐号的额外信息(能转换string类型的其它信息,如token等),额外信息不能是应用帐号的敏感信息(如应用账号密码)。 | +| callback | AsyncCallback<void> | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.createAccount("LiSi", "token101", (err) => { + console.log("createAccount err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("createAccount err: " + JSON.stringify(err)); + } + ``` + +### createAccount9+ + +createAccount(name: string, extraInfo?: string): Promise<void> + +将此应用的帐号名或额外信息(能转换成string类型的其它信息)添加到帐号管理服务中,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 要添加的应用帐号名称。 | +| extraInfo | string | 否 | 要添加的应用帐号的额外信息(能转换成string类型的其它信息),额外信息不能是应用帐号的敏感信息(如应用账号密码)。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.createAccount("LiSi", "token101").then(()=> { + console.log('createAccount Success'); + }).catch((err) => { + console.log("createAccount err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("createAccount err: " + JSON.stringify(err)); + } + ``` + +### addAccount(deprecated) addAccount(name: string, callback: AsyncCallback<void>): void 将此应用的帐号名添加到帐号管理服务中,使用callback回调异步返回结果。 +> **说明:** +> 从API version 9开始废弃, 建议使用[createAccount](#createaccount9)替代 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -60,12 +158,15 @@ addAccount(name: string, callback: AsyncCallback<void>): void }); ``` -### addAccount +### addAccount(deprecated) addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void 将此应用程序的帐号名和额外信息(能转换string类型的其它信息,如token)添加到帐号管理服务中,使用callback回调异步返回结果。 +> **说明:** > 从API version 9开始废弃, 建议使用[createAccount](#createaccount9-1)替代 +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -85,14 +186,15 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) }); ``` - - -### addAccount +### addAccount(deprecated) addAccount(name: string, extraInfo?: string): Promise<void> 将此应用的帐号名或额外信息(能转换成string类型的其它信息)添加到帐号管理服务中,使用Promise方式异步返回结果。 +> **说明:** > 从API version 9开始废弃, 建议使用[createAccount](#createaccount9-2)替代 +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -119,12 +221,105 @@ addAccount(name: string, extraInfo?: string): Promise<void> }); ``` -### addAccountImplicitly8+ +### createAccountImplicitly9+ + +createAccountImplicitly(owner: string, callback: AuthCallback): void + +根据指定的帐号所有者隐式地添加应用帐号,并使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ----------------------- | +| owner | string | 是 | 要添加的应用帐号所有者包名。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证回调,用于返回鉴权结果。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.createAccountImplicitly("com.example.ohos.accountjsdemo", { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + } catch (err) { + console.log("createAccountImplicitly err: " + JSON.stringify(err)); + } + ``` + +### createAccountImplicitly9+ + +createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, callback: AuthCallback): void + +根据指定的帐号所有者和可选项隐式地添加应用帐号,并使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ----------------------- | +| owner | string | 是 | 要添加的应用帐号所有者包名。 | +| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | 是 | 隐式创建账号的选项。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证回调,用于返回鉴权结果。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.createAccountImplicitly("com.example.ohos.accountjsdemo", { + requiredLabels: ["student"], authType: "getSocialData"}, { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + } catch (err) { + console.log("createAccountImplicitly err: " + JSON.stringify(err)); + } + + ``` + +### addAccountImplicitly(deprecated) addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void 根据指定的帐号所有者、鉴权类型和可选项隐式地添加应用帐号,并使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[createAccountImplicitly](#createaccountimplicitly9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -134,7 +329,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a | owner | string | 是 | 要添加的应用帐号所有者包名。 | | authType | string | 是 | 要添加的应用帐号鉴权类型。鉴权类型为自定义。 | | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。可选项可根据自己需要设置。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回鉴权结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回鉴权结果。 | **示例:** @@ -160,12 +355,81 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a }); ``` -### deleteAccount +### removeAccount9+ + +removeAccount(name: string, callback: AsyncCallback<void>): void + +从帐号管理服务中移除应用帐号,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------- | +| name | string | 是 | 要删除的应用帐号名称。 | +| callback | AsyncCallback<void> | 是 | 帐号管理服务中移除应用帐号的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.removeAccount("ZhaoLiu", (err) => { + console.log("removeAccount err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("removeAccount err: " + JSON.stringify(err)); + } + + ``` + +### removeAccount9+ + +deleteAccount(name: string): Promise<void> + +从帐号管理服务中移除应用帐号,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----------- | +| name | string | 是 | 要移除的应用帐号名称。 | + +**返回值:** + +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.deleteAccount("ZhaoLiu").then(() => { + console.log('removeAccount Success'); + }).catch((err) => { + console.log("removeAccount err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("removeAccount err: " + JSON.stringify(err)); + } + + ``` + +### deleteAccount(deprecated) deleteAccount(name: string, callback: AsyncCallback<void>): void 从帐号管理服务中删除应用帐号,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[removeAccount](#removeaccount9)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -184,12 +448,16 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void }); ``` -### deleteAccount +### deleteAccount(deprecated) deleteAccount(name: string): Promise<void> 从帐号管理服务中删除应用帐号,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[removeAccount](#removeaccount9)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -215,12 +483,84 @@ deleteAccount(name: string): Promise<void> }); ``` -### disableAppAccess +### setAppAccess9+ + +setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback: AsyncCallback<void>): void + +设置指定第三方应用帐号名称对指定包名称的第三方应用的访问权限,由isAccessible指明是允许访问还是禁止访问,callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | --------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| isAccessible | boolean | 是 | 访问控制,允许访问或禁止访问。 | +| callback | AsyncCallback<void> | 是 | 访问权限设置的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", true, (err) => { + console.log("enableAppAccess: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("enableAppAccess: " + JSON.stringify(err)); + } + + ``` + +### setAppAccess9+ + +setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise<void> + +设置指定第三方应用帐号名称对指定包名称的第三方应用的访问权限,由isAccessible指明是允许访问还是禁止访问,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| isAccessible | boolean | 是 | 访问控制,允许访问或禁止访问。 | + +**返回值:** + +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", true).then(() => { + console.log('setAppAccess Success'); + }).catch((err) => { + console.log("setAppAccess err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setAppAccess err: " + JSON.stringify(err)); + } + ``` + +### disableAppAccess(deprecated) disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 禁止指定第三方应用帐号名称对指定的第三方应用进行访问,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃。建议使用[setAppAccess](#setappaccess9)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -229,7 +569,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo | ---------- | ------------------------- | ---- | --------------------------------- | | name | string | 是 | 要禁用访问的第三方应用帐号名称。 | | bundleName | string | 是 | 第三方应用的包名。 | -| callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐号名称对指定包名称的第三方应用的回调进行访问。 | +| callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐号名称对指定包名称的第三方应用进行访问的回调。 | **示例:** @@ -240,12 +580,16 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo }); ``` -### disableAppAccess +### disableAppAccess(deprecated) disableAppAccess(name: string, bundleName: string): Promise<void> 禁止指定第三方应用帐号名称对指定包名称的第三方应用进行访问,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃。建议使用[setAppAccess](#setappaccess9-1)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -272,12 +616,16 @@ disableAppAccess(name: string, bundleName: string): Promise<void> }); ``` -### enableAppAccess +### enableAppAccess(deprecated) enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 允许指定第三方应用帐号名称对指定包名称的第三方应用进行访问,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃。建议使用[setAppAccess](#setappaccess9)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -286,7 +634,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi | ---------- | ------------------------- | ---- | --------------------------------- | | name | string | 是 | 应用帐号名称。 | | bundleName | string | 是 | 第三方应用的包名。 | -| callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐号名称对指定包名称的第三方应用的回调进行访问。 | +| callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐号名称对指定包名称的第三方应用进行访问的回调。 | **示例:** @@ -297,12 +645,16 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi }); ``` -### enableAppAccess +### enableAppAccess(deprecated) enableAppAccess(name: string, bundleName: string): Promise<void> 允许指定第三方应用帐号的名称对指定包名称的第三方应用进行访问,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃。建议使用[setAppAccess](#setappaccess9-1)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -329,22 +681,163 @@ enableAppAccess(name: string, bundleName: string): Promise<void> }); ``` -### checkAppAccountSyncEnable - -checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void +### checkAppAccess9+ -检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 +checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void -**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC +查看指定第三方应用帐号名称对指定包名称的第三方应用的访问权限,callback回调异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | ---- | --------------------- | -| name | string | 是 | 应用帐号名称。 | -| callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | --------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| callback | AsyncCallback<void> | 是 | 查看访问权限的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.checkAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { + console.log("checkAppAccess: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("checkAppAccess: " + JSON.stringify(err)); + } + + ``` + +### checkAppAccess9+ + +checkAppAccess(name: string, bundleName: string): Promise<void> + +查看指定第三方应用帐号名称对指定包名称的第三方应用的访问权限,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | + +**返回值:** + +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.checkAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { + console.log('checkAppAccess Success'); + }).catch((err) => { + console.log("checkAppAccess err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("checkAppAccess err: " + JSON.stringify(err)); + } + + ``` + +### checkDataSyncEnabled9+ + +checkDataSyncEnabled(name: string, callback: AsyncCallback<boolean>): void + +检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | --------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.checkDataSyncEnabled("ZhangSan", (err, result) => { + console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); + console.log('checkDataSyncEnabled result: ' + result); + }); + } catch (err) { + console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); + } + + ``` + +### checkDataSyncEnabled9+ + +checkDataSyncEnabled(name: string): Promise<boolean> + +检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ------- | +| name | string | 是 | 应用帐号名称。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :-------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.checkDataSyncEnabled("ZhangSan").then((data) => { + console.log('checkDataSyncEnabled, result: ' + data); + }).catch((err) => { + console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); + } + + ``` + +### checkAppAccountSyncEnable(deprecated) + +checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void + +检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃。建议使用[checkDataSyncEnabled](#checkdatasyncenabled9)替代。 +> +> 从 API version 7开始支持。 + +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | --------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步回调。 | **示例:** @@ -356,12 +849,16 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): }); ``` -### checkAppAccountSyncEnable +### checkAppAccountSyncEnable(deprecated) checkAppAccountSyncEnable(name: string): Promise<boolean> 检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃。建议使用[checkDataSyncEnabled](#checkdatasyncenabled9-1)替代。 +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -389,12 +886,88 @@ checkAppAccountSyncEnable(name: string): Promise<boolean> }); ``` -### setAccountCredential +### setCredential9+ + +setCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void + +设置此应用程序帐号的凭据,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | ------------- | +| name | string | 是 | 应用程序帐号名称。 | +| credentialType | string | 是 | 要设置的凭据类型。 | +| credential | string | 是 | 要设置的凭据。 | +| callback | AsyncCallback<void> | 是 | 设置此应用帐号的凭据回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setCredential("ZhangSan", "credentialType001", "credential001", (err) => { + console.log("setCredential err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setCredential err: " + JSON.stringify(err)); + } + ``` + +### setCredential9+ + +setCredential(name: string, credentialType: string, credential: string): Promise<void> + +设置此应用程序帐号的凭据,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ---------- | +| name | string | 是 | 应用帐号的名称。 | +| credentialType | string | 是 | 要设置的凭据的类型。 | +| credential | string | 是 | 要设置的凭据。 | + +**返回值:** + +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setCredential("ZhangSan", "credentialType001", "credential001").then(() => { + console.log('setCredential Success'); + }).catch((err) => { + console.log("setCredential err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setCredential err: " + JSON.stringify(err)); + } + + ``` + +### setAccountCredential(deprecated) setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void 设置此应用程序帐号的凭据,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[setCredential](#setcredential9)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -415,12 +988,16 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca }); ``` -### setAccountCredential +### setAccountCredential(deprecated) setAccountCredential(name: string, credentialType: string, credential: string): Promise<void> 设置此应用程序帐号的凭据,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[setCredential](#setcredential9-1)替代。 +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -448,12 +1025,17 @@ setAccountCredential(name: string, credentialType: string, credential: string): }); ``` -### setAccountExtraInfo +### setAccountExtraInfo(deprecated) setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void 设置此应用程序帐号的额外信息,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 7开始支持。 + + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -473,12 +1055,17 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback< }); ``` -### setAccountExtraInfo +### setAccountExtraInfo(deprecated) setAccountExtraInfo(name: string, extraInfo: string): Promise<void> 设置此应用程序帐号的额外信息,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 7开始支持。 + + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -504,13 +1091,86 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void> console.log("setAccountExtraInfo err: " + JSON.stringify(err)); }); ``` + +### setDataSyncEnabled9+ + +setDataSyncEnabled(name: string, isEnable: boolean, callback: AsyncCallback<void>): void + +设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------- | +| name | string | 是 | 应用帐号名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | +| callback | AsyncCallback<void> | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setDataSyncEnabled("ZhangSan", true, (err) => { + console.log("setDataSyncEnabled err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setDataSyncEnabled err: " + JSON.stringify(err)); + } + ``` + +### setDataSyncEnabled9+ + +setDataSyncEnabled(name: string, isEnable: boolean): Promise<void> + +设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------- | ---- | ----------- | +| name | string | 是 | 应用帐号名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | + +**返回值:** + +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager .setDataSyncEnabled("ZhangSan", true).then(() => { + console.log('setDataSyncEnabled Success'); + }).catch((err) => { + console.log("setDataSyncEnabled err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setDataSyncEnabled err: " + JSON.stringify(err)); + } + ``` -### setAppAccountSyncEnable +### setAppAccountSyncEnable(deprecated) setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void 设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[setDataSyncEnabled](#setdatasyncenabled9)替代。 +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -532,12 +1192,16 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback }); ``` -### setAppAccountSyncEnable +### setAppAccountSyncEnable(deprecated) setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> 设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[setDataSyncEnabled](#setdatasyncenabled9-1)替代。 +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC **系统能力:** SystemCapability.Account.AppAccount @@ -566,7 +1230,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> }); ``` -### setAssociatedData +### setCustomData9+ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void @@ -587,12 +1251,16 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => { - console.log("setAssociatedData err: " + JSON.stringify(err)); - }); + try { + appAccountManager.setCustomData("ZhangSan", "k001", "v001", (err) => { + console.log("setCustomData err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setCustomData err: " + JSON.stringify(err)); + } ``` -### setAssociatedData +### setCustomData9+ setAssociatedData(name: string, key: string, value: string): Promise<void> @@ -618,219 +1286,213 @@ setAssociatedData(name: string, key: string, value: string): Promise<void> ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { - console.log('setAssociatedData Success'); - }).catch((err) => { - console.log("setAssociatedData err: " + JSON.stringify(err)); - }); + try { + appAccountManager.setCustomData("ZhangSan", "k001", "v001").then(() => { + console.log('setCustomData Success'); + }).catch((err) => { + console.log("setCustomData err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("setCustomData err: " + JSON.stringify(err)); + } ``` -### getAccountCredential +### setAssociatedData(deprecated) -getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void +setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void -获取此应用帐号的凭据(如数字密码、人脸和PIN码等),使用callback回调异步返回结果。 +设置与此应用程序帐号关联的数据,使用callback回调异步返回结果。 -**系统能力:** SystemCapability.Account.AppAccount +> **说明:** 从API version 9开始废弃, 建议使用[setCustomData](#setcustomdata9)替代。 +> +> 从 API version 7开始支持。 -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | --------------------------- | ---- | -------------- | -| name | string | 是 | 应用帐号名称。 | -| credentialType | string | 是 | 获取此应用帐号的凭据的类型。 | -| callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | +**系统能力:** SystemCapability.Account.AppAccount -**示例:** +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ----------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | +| callback | AsyncCallback<void> | 是 | 设置与此应用帐号关联的数据的回调。 | + +**示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { - console.log("getAccountCredential err: " + JSON.stringify(err)); - console.log('getAccountCredential result: ' + result); + appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => { + console.log("setAssociatedData err: " + JSON.stringify(err)); }); ``` -### getAccountCredential +### setAssociatedData(deprecated) -getAccountCredential(name: string, credentialType: string): Promise<string> +setAssociatedData(name: string, key: string, value: string): Promise<void> + +设置与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[setCustomData](#setcustomdata9-1)替代。 +> +> 从 API version 7开始支持。 -获取此应用程序帐号的凭据,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------ | ---- | ---------- | -| name | string | 是 | 应用帐号名称。 | -| credentialType | string | 是 | 要获取的凭据的类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | **返回值:** -| 类型 | 说明 | -| :-------------------- | :-------------------- | -| Promise<string> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :-------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { - console.log('getAccountCredential, result: ' + data); + appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { + console.log('setAssociatedData Success'); }).catch((err) => { - console.log("getAccountCredential err: " + JSON.stringify(err)); + console.log("setAssociatedData err: " + JSON.stringify(err)); }); ``` -### getAccountExtraInfo +### getAllAccounts9+ -getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void +getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void -获取此应用帐号的额外信息(能转换成string类型的其它信息),使用callback回调异步返回结果。 +获取全部应用已授权帐号信息。 + +**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | --------------- | -| name | string | 是 | 应用帐号名称。 | -| callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 应用帐号信息列表。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { - console.log("getAccountExtraInfo err: " + JSON.stringify(err)); - console.log('getAccountExtraInfo result: ' + result); - }); + try { + appAccountManager.getAllAccounts((err, data)=>{ + console.debug("getAllAccounts err:" + JSON.stringify(err)); + console.debug("getAllAccounts data:" + JSON.stringify(data)); + }); + } catch (err) { + console.debug("getAllAccounts err:" + JSON.stringify(err)); + } ``` -### getAccountExtraInfo - -getAccountExtraInfo(name: string): Promise<string> +### getAllAccounts9+ -获取此应用程序帐号的额外信息,使用Promise方式异步返回结果。 +getAllAccounts(): Promise<Array<AppAccountInfo>> -**系统能力:** SystemCapability.Account.AppAccount +获取全部应用已授权帐号信息。 -**参数:** +**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ------- | -| name | string | 是 | 应用帐号名称。 | +**系统能力:** SystemCapability.Account.AppAccount **返回值:** -| 类型 | 说明 | -| :-------------------- | :-------------------- | -| Promise<string> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | +| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { - console.log('getAccountExtraInfo, result: ' + data); - }).catch((err) => { - console.log("getAccountExtraInfo err: " + JSON.stringify(err)); - }); + try { + appAccountManager.getAllAccounts().then((data) => { + console.log('getAllAccounts: ' + data); + }).catch((err) => { + console.log("getAllAccounts err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getAllAccounts err: " + JSON.stringify(err)); + } ``` -### getAssociatedData - -getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void - -获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。 - -**系统能力:** SystemCapability.Account.AppAccount - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | ----------------- | -| name | string | 是 | 应用帐号名称。 | -| key | string | 是 | 要获取的数据的键。 | -| callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | - -**示例:** +### getAllAccessibleAccounts(deprecated) - ```js - const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { - console.log("getAssociatedData err: " + JSON.stringify(err)); - console.log('getAssociatedData result: ' + result); - }); - ``` +getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void -### getAssociatedData +获取全部应用已授权帐号信息。 -getAssociatedData(name: string, key: string): Promise<string> +> **说明:** 从API version 9开始废弃, 建议使用[getAllAccounts](#getallaccounts9)替代。 +> +> 从 API version 7开始支持。 -获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 +**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | --------- | -| name | string | 是 | 应用帐号名称。 | -| key | string | 是 | 要获取的数据的键。 | - -**返回值:** - -| 类型 | 说明 | -| :-------------------- | :-------------------- | -| Promise<string> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 应用帐号信息列表。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { - console.log('getAssociatedData: ' + data); - }).catch((err) => { - console.log("getAssociatedData err: " + JSON.stringify(err)); + appAccountManager.getAllAccessibleAccounts((err, data)=>{ + console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); + console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data)); }); ``` -### getAssociatedDataSync9+ +### getAllAccessibleAccounts(deprecated) -getAssociatedDataSync(name: string, key: string): string; +getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> -获取与此应用程序帐号关联的数据,使用同步方式返回结果。 +获取全部应用已授权帐号信息。 -**系统能力:** SystemCapability.Account.AppAccount +> **说明:** 从API version 9开始废弃, 建议使用[getAllAccounts](#getallaccounts9-1)替代。 +> +> 从 API version 7开始支持。 -**参数:** +**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | --------- | -| name | string | 是 | 应用帐号名称。 | -| key | string | 是 | 要获取的数据的键。 | +**系统能力:** SystemCapability.Account.AppAccount **返回值:** -| 类型 | 说明 | -| :-------------------- | :-------------------- | -| string | 目标关联数据的取值。 | +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | +| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001"); - console.info("getAssociatedDataSync backData:" + JSON.stringify(backData)); + appAccountManager.getAllAccessibleAccounts().then((data) => { + console.log('getAllAccessibleAccounts: ' + data); + }).catch((err) => { + console.log("getAllAccessibleAccounts err: " + JSON.stringify(err)); + }); ``` -### getAllAccessibleAccounts +### getAccountsByOwner9+ -getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void +getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void -获取全部应用已授权帐号信息。 +获取指定应用全部帐号信息。 **需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 @@ -840,23 +1502,29 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>& | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | --------- | +| owner | string | 是 | 应用包名称。 | | callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 应用帐号信息列表。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAllAccessibleAccounts((err, data)=>{ - console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); - console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data)); - }); + const selfBundle = "com.example.actsgetallaaccounts"; + try { + appAccountManager.getAccountsByOwner(selfBundle, (err, data)=>{ + console.debug("getAccountsByOwner err:" + JSON.stringify(err)); + console.debug("getAccountsByOwner data:" + JSON.stringify(data)); + }); + } catch (err) { + console.debug("getAccountsByOwner err:" + JSON.stringify(err)); + } ``` -### getAllAccessibleAccounts +### getAccountsByOwner9+ -getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> +getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>> -获取全部应用已授权帐号信息。 +获取指定应用全部帐号信息。 **需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 @@ -864,6 +1532,12 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> **参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------ | +| owner | string | 是 | 应用包名称。 | + +**返回值:** + | 类型 | 说明 | | ---------------------------------------- | --------------------- | | Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise实例,用于获取异步返回结果。 | @@ -872,19 +1546,28 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.getAllAccessibleAccounts().then((data) => { - console.log('getAllAccessibleAccounts: ' + data); - }).catch((err) => { - console.log("getAllAccessibleAccounts err: " + JSON.stringify(err)); - }); + const selfBundle = "com.example.actsgetallaaccounts"; + try { + appAccountManager.getAccountsByOwner(selfBundle).then((data) => { + console.log('getAccountsByOwner: ' + data); + }).catch((err) => { + console.log("getAccountsByOwner err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getAccountsByOwner err: " + JSON.stringify(err)); + } ``` -### getAllAccounts +### getAllAccounts(deprecated) getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void 获取指定应用全部帐号信息。 +> **说明:** 从API version 9开始废弃, 建议使用[getAccountsByOwner]替代。 +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 **系统能力:** SystemCapability.Account.AppAccount @@ -907,12 +1590,16 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo }); ``` -### getAllAccounts +### getAllAccounts(deprecated) getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> 获取指定应用全部帐号信息。 +> **说明:** 从API version 9开始废弃, 建议使用[getAccountsByOwner](#getaccountsbyowner9-1)替代。 +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS,仅系统应用可用。 **系统能力:** SystemCapability.Account.AppAccount @@ -923,7 +1610,7 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> | ----- | ------ | ---- | ------ | | owner | string | 是 | 应用包名称。 | -**参数:** +**返回值:** | 类型 | 说明 | | ---------------------------------------- | --------------------- | @@ -941,89 +1628,567 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> }); ``` -### on('change') +### getCredential9+ -on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void +getCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void -订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。 +获取此应用帐号的凭据(如数字密码、人脸和PIN码等),使用callback回调异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------ | -| type | 'change' | 是 | 关于帐号更改事件,当帐号所有者更新帐号时,订阅者将收到通知。 | -| owners | Array<string> | 是 | 指示帐号的所有者。 | -| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 订阅指定帐号所有者的帐号变更事件的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | --------------------------- | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 获取此应用帐号的凭据的类型。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - function changeOnCallback(data){ - console.debug("receive change data:" + JSON.stringify(data)); - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); - } - catch(err){ - console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + try { + appAccountManager.getCredential("ZhangSan", "credentialType001", (err, result) => { + console.log("getCredential err: " + JSON.stringify(err)); + console.log('getCredential result: ' + result); + }); + } catch (err) { + console.log("getCredential err: " + JSON.stringify(err)); } ``` -### off('change') +### getCredential9+ -off(type: 'change', callback?: Callback>): void +getCredential(name: string, credentialType: string): Promise<string> -取消订阅帐号事件,使用callback回调异步返回结果。 +获取此应用程序帐号的凭据,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------- | ---- | ------------ | -| type | 'change' | 是 | 关于帐号更改事件。 | -| callback | Callback> | 否 | 取消订阅帐号事件的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ---------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - function changeOnCallback(data){ - console.debug("receive change data:" + JSON.stringify(data)); - appAccountManager.off('change', function(){ - console.debug("off finish"); - }) - } - try{ - appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); - } - catch(err){ - console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + try { + appAccountManager.getCredential("ZhangSan", "credentialType001").then((data) => { + console.log('getCredential, result: ' + data); + }).catch((err) => { + console.log("getCredential err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getCredential err: " + JSON.stringify(err)); } ``` -### authenticate8+ +### getAccountCredential(deprecated) -authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void +getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void -对应用帐户进行鉴权以获取OAuth令牌,使用callback回调异步返回结果。 +获取此应用帐号的凭据(如数字密码、人脸和PIN码等),使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[getCredential](#getcredential9)替代。 +> +> 从 API version 7开始支持。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------- | ---- | --------------- | -| name | string | 是 | 要鉴权的应用帐号名称。 | -| owner | string | 是 | 要鉴权的应用帐号所有者包名。 | -| authType | string | 是 | 鉴权类型。 | -| options | {[key: string]: any} | 是 | 鉴权所需的可选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回鉴权结果。 | - -**示例:** +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | --------------------------- | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 获取此应用帐号的凭据的类型。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { + console.log("getAccountCredential err: " + JSON.stringify(err)); + console.log('getAccountCredential result: ' + result); + }); + ``` + +### getAccountCredential(deprecated) + +getAccountCredential(name: string, credentialType: string): Promise<string> + +获取此应用程序帐号的凭据,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[getCredential](#getcredential9-1)替代。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | ---------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { + console.log('getAccountCredential, result: ' + data); + }).catch((err) => { + console.log("getAccountCredential err: " + JSON.stringify(err)); + }); + ``` + +### getAccountExtraInfo(deprecated) + +getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void + +获取此应用帐号的额外信息(能转换成string类型的其它信息),使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { + console.log("getAccountExtraInfo err: " + JSON.stringify(err)); + console.log('getAccountExtraInfo result: ' + result); + }); + ``` + +### getAccountExtraInfo(deprecated) + +getAccountExtraInfo(name: string): Promise<string> + +获取此应用程序帐号的额外信息,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ------- | +| name | string | 是 | 应用帐号名称。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { + console.log('getAccountExtraInfo, result: ' + data); + }).catch((err) => { + console.log("getAccountExtraInfo err: " + JSON.stringify(err)); + }); + ``` + +### getCustomData9+ + +getCustomData(name: string, key: string, callback: AsyncCallback<string>): void + +获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ----------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | +| callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getCustomData("ZhangSan", "k001", (err, result) => { + console.log("getCustomData err: " + JSON.stringify(err)); + console.log('getCustomData result: ' + result); + }); + } catch (err) { + console.log("getCustomData err: " + JSON.stringify(err)); + } + ``` + +### getCustomData9+ + +getCustomData(name: string, key: string): Promise<string> + +获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getCustomData("ZhangSan", "k001").then((data) => { + console.log('getCustomData: ' + data); + }).catch((err) => { + console.log("getCustomData err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getCustomData err: " + JSON.stringify(err)); + } + ``` + +### getAssociatedData(deprecated) + +getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void + +获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[getCustomData](#getcustomdata9)替代。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ----------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | +| callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { + console.log("getAssociatedData err: " + JSON.stringify(err)); + console.log('getAssociatedData result: ' + result); + }); + ``` + +### getAssociatedData(deprecated) + +getAssociatedData(name: string, key: string): Promise<string> + +获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[getCustomData](#getcustomdata9-1)替代。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { + console.log('getAssociatedData: ' + data); + }).catch((err) => { + console.log("getAssociatedData err: " + JSON.stringify(err)); + }); + ``` + +### getAssociatedDataSync9+ + +getAssociatedDataSync(name: string, key: string): string; + +获取与此应用程序帐号关联的数据,使用同步方式返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的键。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------- | +| string | 目标关联数据的取值。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001"); + console.info("getAssociatedDataSync backData:" + JSON.stringify(backData)); + } catch (err) { + console.error(`getAssociatedDataSync err, code is ${e.code}, message is ${e.message}`); + } + ``` + +### on('accountChange')9+ + +on(type: 'accountChange', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void + +订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | 'accountChange' | 是 | 关于帐号更改事件,当帐号所有者更新帐号时,订阅者将收到通知。 | +| owners | Array<string> | 是 | 指示帐号的所有者。 | +| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 订阅指定帐号所有者的帐号变更事件的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + function changeOnCallback(data){ + console.debug("receive change data:" + JSON.stringify(data)); + } + try{ + appAccountManager.on('accountChange', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + } + ``` + +### on('change')(deprecated) + +on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void + +订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[on('accountChange')](#onaccountchange9)替代。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | 'change' | 是 | 关于帐号更改事件,当帐号所有者更新帐号时,订阅者将收到通知。 | +| owners | Array<string> | 是 | 指示帐号的所有者。 | +| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | 是 | 订阅指定帐号所有者的帐号变更事件的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + function changeOnCallback(data){ + console.debug("receive change data:" + JSON.stringify(data)); + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + } + ``` + +### off('accountChange')9+ + +off(type: 'accountChange', callback?: Callback>): void + +取消订阅帐号事件,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | ------------ | +| type | 'accountChange' | 是 | 关于帐号更改事件。 | +| callback | Callback> | 否 | 取消订阅帐号事件的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + function changeOnCallback(data){ + console.debug("receive change data:" + JSON.stringify(data)); + appAccountManager.off('accountChange', function(){ + console.debug("off finish"); + }) + } + try{ + appAccountManager.on('accountChange', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + } + ``` + +### off('change')(deprecated) + +off(type: 'change', callback?: Callback>): void + +取消订阅帐号事件,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[off('accountChange')](#offaccountchange9)替代。 +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | ------------ | +| type | 'change' | 是 | 关于帐号更改事件。 | +| callback | Callback> | 否 | 取消订阅帐号事件的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + function changeOnCallback(data){ + console.debug("receive change data:" + JSON.stringify(data)); + appAccountManager.off('change', function(){ + console.debug("off finish"); + }) + } + try{ + appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); + } + catch(err){ + console.error("on accountOnOffDemo err:" + JSON.stringify(err)); + } + ``` + +### auth9+ + +auth(name: string, owner: string, authType: string, callback: AuthCallback): void + +对应用帐户进行鉴权以获取Auth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | --------------- | +| name | string | 是 | 要鉴权的应用帐号名称。 | +| owner | string | 是 | 要鉴权的应用帐号所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证器回调,用于返回鉴权结果。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.auth("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + } catch (err) { + console.log("auth err: " + JSON.stringify(err)); + } + ``` + +### auth9+ + +auth(name: string, owner: string, authType: string, options: {[key: string]: Object}, callback: AuthCallback): void + +对应用帐户进行鉴权以获取OAuth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | --------------- | +| name | string | 是 | 要鉴权的应用帐号名称。 | +| owner | string | 是 | 要鉴权的应用帐号所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| options | {[key: string]: Object} | 是 | 鉴权所需的可选项。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证器回调,用于返回鉴权结果。 | + +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility'; @@ -1033,26 +2198,148 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri console.log("result: " + JSON.stringify(result)); } - function onRequestRedirectedCallback(request) { - let abilityStartSetting = {want: request}; - featureAbility.startAbility(abilityStartSetting, (err)=>{ - console.log("startAbility err: " + JSON.stringify(err)); + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.auth("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + } catch (err) { + console.log("auth err: " + JSON.stringify(err)); + } + ``` + +### authenticate(deprecated) + +authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void + +对应用帐户进行鉴权以获取OAuth令牌,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[auth](#auth9)替代。 +> +> 从 API version 8开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | --------------- | +| name | string | 是 | 要鉴权的应用帐号名称。 | +| owner | string | 是 | 要鉴权的应用帐号所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| options | {[key: string]: any} | 是 | 鉴权所需的可选项。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回鉴权结果。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + ``` + +### getAuthToken9+ + +getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void + +获取指定应用帐号和鉴权类型的Auth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ----------- | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| callback | AsyncCallback<string> | 是 | 查询结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", (err, data) => { + console.log('getAuthToken err: ' + JSON.stringify(err)); + console.log('getAuthToken token: ' + data); }); + } catch (err) { + console.log('getAuthToken err: ' + JSON.stringify(err)); } + ``` + +### getAuthToken9+ + +getAuthToken(name: string, owner: string, authType: string): Promise<string> + +获取指定应用帐户和鉴权类型的Auth令牌,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ----------- | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | --------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** + ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, { - onResult: onResultCallback, - onRequestRedirected: onRequestRedirectedCallback - }); + try { + appAccountManager.getAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData").then((data) => { + console.log('getAuthToken token: ' + data); + }).catch((err) => { + console.log("getAuthToken err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getAuthToken err: " + JSON.stringify(err)); + } ``` -### getOAuthToken8+ +### getOAuthToken(deprecated) getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void 获取指定应用帐号和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthToken](#getauthtoken9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1074,12 +2361,16 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall }); ``` -### getOAuthToken8+ +### getOAuthToken(deprecated) getOAuthToken(name: string, owner: string, authType: string): Promise<string> 获取指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthToken](#getauthtoken9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1090,7 +2381,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& | owner | string | 是 | 应用帐号的所有者包名。 | | authType | string | 是 | 鉴权类型。 | -**参数:** +**返回值:** | 类型 | 说明 | | --------------------- | --------------------- | @@ -1107,12 +2398,83 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& }); ``` -### setOAuthToken8+ +### setAuthToken9+ + +setAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void + +设置指定应用帐号和鉴权类型的Auth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | Auth令牌。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx", (err) => { + console.log('setAuthToken err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('setAuthToken err: ' + JSON.stringify(err)); + } + ``` + +### setAuthToken9+ + +setAuthToken(name: string, authType: string, token: string): Promise<void> + +设置指定应用帐户和鉴权类型的Auth令牌,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | -------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | Auth令牌。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx").then(() => { + console.log('setAuthToken successfully'); + }).catch((err) => { + console.log('setAuthToken err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('setAuthToken err: ' + JSON.stringify(err)); + } + ``` + +### setOAuthToken(deprecated) setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void 设置指定应用帐号和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[setAuthToken](#setauthtoken9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1133,12 +2495,16 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall }); ``` -### setOAuthToken8+ +### setOAuthToken(deprecated) setOAuthToken(name: string, authType: string, token: string): Promise<void> 设置指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[setAuthToken](#setauthtoken9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1149,7 +2515,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> | authType | string | 是 | 鉴权类型。 | | token | string | 是 | OAuth令牌。 | -**参数:** +**返回值:** | 类型 | 说明 | | ------------------- | --------------------- | @@ -1166,12 +2532,85 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> }); ``` -### deleteOAuthToken8+ +### deleteAuthToken9+ + +deleteAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void + +删除指定应用帐户和鉴权类型的Auth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------ | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的Auth令牌。 | +| callback | AsyncCallback<void> | 是 | 删除结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.deleteAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx", (err) => { + console.log('deleteAuthToken err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('deleteAuthToken err: ' + JSON.stringify(err)); + } + ``` + +### deleteAuthToken9+ + +deleteAuthToken(name: string, owner: string, authType: string, token: string): Promise<void> + +删除指定应用帐户和鉴权类型的Auth令牌,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------ | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的Auth令牌。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.deleteAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx").then(() => { + console.log('deleteAuthToken successfully'); + }).catch((err) => { + console.log("deleteAuthToken err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("deleteAuthToken err: " + JSON.stringify(err)); + } + ``` + +### deleteOAuthToken(deprecated) deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void 删除指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[deleteAuthToken](#deleteauthtoken9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1193,12 +2632,16 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c }); ``` -### deleteOAuthToken8+ +### deleteOAuthToken(deprecated) deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void> 删除指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[setAuthToken](#setauthtoken9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1210,7 +2653,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): | authType | string | 是 | 鉴权类型。 | | token | string | 是 | 要删除的OAuth令牌。 | -**参数:** +**返回值:** | 类型 | 说明 | | ------------------- | --------------------- | @@ -1227,11 +2670,84 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): }); ``` -### setOAuthTokenVisibility8+ +### setAuthTokenVisibility9+ + +setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void + +设置指定鉴权类型的Auth令牌对特定应用的可见性,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。当设置成true可见,false不可见。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => { + console.log('setAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('setAuthTokenVisibility err: ' + JSON.stringify(err)); + } + ``` + +### setAuthTokenVisibility9+ + +setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> + +设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ------------ | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => { + console.log('setAuthTokenVisibility successfully'); + }).catch((err) => { + console.log('setAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('setAuthTokenVisibility err: ' + JSON.stringify(err)); + } + ``` + +### setOAuthTokenVisibility(deprecated) setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void -设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 +设置指定鉴权类型的Auth令牌对特定应用的可见性,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[setAuthTokenVisibility](#setauthtokenvisibility9)替代。 +> +> 从 API version 8开始支持。 **系统能力:** SystemCapability.Account.AppAccount @@ -1249,51 +2765,127 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => { - console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); - }); + appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => { + console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + ``` + +### setOAuthTokenVisibility(deprecated) + +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> + +设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃, 建议使用[setAuthTokenVisibility](#setauthtokenvisibility9-1)替代。 +> +> 从 API version 8开始支持。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ------------ | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => { + console.log('setOAuthTokenVisibility successfully'); + }).catch((err) => { + console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + ``` + +### checkAuthTokenVisibility9+ + +checkAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void + +检查指定鉴权类型的Auth令牌对特定应用的可见性,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ----------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 检查可见性的应用包名。 | +| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", (err, data) => { + console.log('checkAuthTokenVisibility err: ' + JSON.stringify(err)); + console.log('checkAuthTokenVisibility isVisible: ' + data); + }); + } catch (err) { + console.log('checkAuthTokenVisibility err: ' + JSON.stringify(err)); + } ``` -### setOAuthTokenVisibility8+ +### checkAuthTokenVisibility9+ -setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> +checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean> -设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 +检查指定鉴权类型的Auth令牌对特定应用的可见性,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------- | ---- | ------------ | -| name | string | 是 | 应用帐号的名称。 | -| authType | string | 是 | 鉴权类型。 | -| bundleName | string | 是 | 被设置可见性的应用包名。 | -| isVisible | boolean | 是 | 是否可见。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 用于检查可见性的应用包名。 | -**参数:** +**返回值:** -| 类型 | 说明 | -| ------------------- | --------------------- | -| Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ---------------------- | --------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => { - console.log('setOAuthTokenVisibility successfully'); - }).catch((err) => { - console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); - }); + try { + appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo").then((data) => { + console.log('checkAuthTokenVisibility isVisible: ' + data); + }).catch((err) => { + console.log('checkAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + } catch (err) { + console.log('checkAuthTokenVisibility err: ' + JSON.stringify(err)); + } ``` -### checkOAuthTokenVisibility8+ +### checkOAuthTokenVisibility(deprecated) checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[checkAuthTokenVisibility](#checkauthtokenvisibility9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1315,12 +2907,17 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca }); ``` -### checkOAuthTokenVisibility8+ + +### checkOAuthTokenVisibility(deprecated) checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean> 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[checkAuthTokenVisibility](#checkauthtokenvisibility9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1331,7 +2928,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P | authType | string | 是 | 鉴权类型。 | | bundleName | string | 是 | 用于检查可见性的应用包名。 | -**参数:** +**返回值:** | 类型 | 说明 | | ---------------------- | --------------------- | @@ -1348,12 +2945,82 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P }); ``` -### getAllOAuthTokens8+ +### getAllAuthTokens9+ + +getAllAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void + +获取指定应用对调用方全部可见的Auth令牌,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------- | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | +| callback | AsyncCallback<Array< [AuthTokenInfo](#authtokeninfo9)>> | 是 | 查询结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getAllAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { + console.log("getAllAuthTokens err: " + JSON.stringify(err)); + console.log('getAllAuthTokens data: ' + JSON.stringify(data)); + }); + } catch (err) { + console.log("getAllAuthTokens err: " + JSON.stringify(err)); + } + ``` + +### getAllAuthTokens9+ + +getAllAuthTokens(name: string, owner: string): Promise<Array<AuthTokenInfo>> + +获取指定应用帐户对调用方可见的全部Auth令牌,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------- | +| name | string | 是 | 应用帐号的名称。 | +| owner | string | 是 | 应用帐号的所有者包名。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | +| Promise<Array< [AuthTokenInfo](#authtokeninfo9)>> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getAllAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { + console.log('getAllAuthTokens data: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getAllAuthTokens err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getAllAuthTokens err: " + JSON.stringify(err)); + } + ``` + +### getAllOAuthTokens(deprecated) getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void 获取指定应用对调用方全部可见的OAuth令牌,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAllAuthTokens](#getallauthtokens9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1362,7 +3029,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& | -------- | ---------------------------------------- | ---- | ----------- | | name | string | 是 | 应用帐号的名称。 | | owner | string | 是 | 应用帐号的所有者包名。 | -| callback | AsyncCallback<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | 是 | 查询结果的回调。 | +| callback | AsyncCallback<Array< [OAuthTokenInfo](#oauthtokeninfodeprecated)>> | 是 | 查询结果的回调。 | **示例:** @@ -1374,12 +3041,16 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& }); ``` -### getAllOAuthTokens8+ +### getAllOAuthTokens(deprecated) getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>> 获取指定应用帐户对调用方可见的全部OAuth令牌,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAllAuthTokens](#getallauthtokens9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1389,11 +3060,11 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn | name | string | 是 | 应用帐号的名称。 | | owner | string | 是 | 应用帐号的所有者包名。 | -**参数:** +**返回值:** | 类型 | 说明 | | ---------------------------------------- | --------------------- | -| Promise<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | Promise实例,用于获取异步返回结果。 | +| Promise<Array< [OAuthTokenInfo](#oauthtokeninfodeprecated)>> | Promise实例,用于获取异步返回结果。 | **示例:** @@ -1406,12 +3077,82 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn }); ``` -### getOAuthList8+ +### getAuthList9+ + +getAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void + +获取指定应用帐户和鉴权类型的Auth令牌的授权列表,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 应用帐号的鉴权类型的Auth令牌的授权列表。 | +| callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getAuthList("com.example.ohos.accountjsdemo", "getSocialData", (err, data) => { + console.log('getAuthList err: ' + JSON.stringify(err)); + console.log('getAuthList data: ' + JSON.stringify(data)); + }); + } catch (err) { + console.log('getAuthList err: ' + JSON.stringify(err)); + } + ``` + +### getAuthList9+ + +getAuthList(name: string, authType: string): Promise<Array<string>> + +获取指定应用帐户和鉴权类型的Auth令牌的授权列表,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ----------------------- | +| name | string | 是 | 应用帐号的名称。 | +| authType | string | 是 | 应用帐号的鉴权类型的Auth令牌的授权列表。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | --------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.getAuthList("com.example.ohos.accountjsdemo", "getSocialData").then((data) => { + console.log('getAuthList data: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getAuthList err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("getAuthList err: " + JSON.stringify(err)); + } + ``` + +### getOAuthList(deprecated) getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthList](#getauthlist9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1432,12 +3173,16 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< }); ``` -### getOAuthList8+ +### getOAuthList(deprecated) getOAuthList(name: string, authType: string): Promise<Array<string>> 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthList](#getauthlist9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1447,7 +3192,7 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> | name | string | 是 | 应用帐号的名称。 | | authType | string | 是 | 应用帐号的鉴权类型的OAuth令牌的授权列表。 | -**参数:** +**返回值:** | 类型 | 说明 | | ---------------------------------- | --------------------- | @@ -1464,12 +3209,100 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> }); ``` -### getAuthenticatorCallback8+ +### getAuthCallback9+ + +getAuthCallback(sessionId: string, callback: AsyncCallback<AuthCallback>): void + +获取鉴权会话的认证器回调,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---------------------------------------- | ---- | -------- | +| sessionId | string | 是 | 鉴权会话的标识。 | +| callback | AsyncCallback<[AuthCallback](#authcallback9)> | 是 | 查询结果的回调。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + const appAccountManager = account_appAccount.createAppAccountManager(); + featureAbility.getWant((err, want) => { + var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; + try { + appAccountManager.getAuthCallback(sessionId, (err, callback) => { + if (err.code != account_appAccount.ResultCode.SUCCESS) { + console.log("getAuthCallback err: " + JSON.stringify(err)); + return; + } + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); + }); + } catch (err) { + console.log("getAuthCallback err: " + JSON.stringify(err)); + } + }); + ``` + +### getAuthCallback9+ + +getAuthCallback(sessionId: string): Promise<AuthCallback> + +获取鉴权会话的认证器回调,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | -------- | +| sessionId | string | 是 | 鉴权会话的标识。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------ | --------------------- | +| Promise<[AuthCallback](#authcallback9)> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + import featureAbility from '@ohos.ability.featureAbility'; + + const appAccountManager = account_appAccount.createAppAccountManager(); + featureAbility.getWant().then((want) => { + var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; + try { + appAccountManager.getAuthCallback(sessionId).then((callback) => { + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); + }).catch((err) => { + console.log("getAuthCallback err: " + JSON.stringify(err)); + }); + } + }).catch((err) => { + console.log("getWant err: " + JSON.stringify(err)); + }); + ``` + +### getAuthenticatorCallback(deprecated) getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void 获取鉴权会话的认证器回调,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthCallback](#getauthcallback9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1477,7 +3310,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic | 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------- | ---- | -------- | | sessionId | string | 是 | 鉴权会话的标识。 | -| callback | AsyncCallback<[AuthenticatorCallback](#authenticatorcallback8)> | 是 | 查询结果的回调。 | +| callback | AsyncCallback<[AuthenticatorCallback](#authenticatorcallbackdeprecated)> | 是 | 查询结果的回调。 | **示例:** @@ -1500,12 +3333,16 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic }); ``` -### getAuthenticatorCallback8+ +### getAuthenticatorCallback(deprecated) getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> 获取鉴权会话的认证器回调,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[getAuthCallback](#getauthcallback9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1514,11 +3351,11 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> | --------- | ------ | ---- | -------- | | sessionId | string | 是 | 鉴权会话的标识。 | -**参数:** +**返回值:** | 类型 | 说明 | | ------------------------------------ | --------------------- | -| Promise<[AuthenticatorCallback](#authenticatorcallback8)> | Promise实例,用于获取异步返回结果。 | +| Promise<[AuthenticatorCallback](#authenticatorcallbackdeprecated)> | Promise实例,用于获取异步返回结果。 | **示例:** @@ -1535,19 +3372,87 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; callback.onResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { - console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); + console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("getWant err: " + JSON.stringify(err)); + }); + ``` + +### queryAuthenticatorInfo9+ + +queryAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void + +获取指定应用帐号的认证器信息,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ----------- | +| owner | string | 是 | 应用帐号的所有者包名。 | +| callback | AsyncCallback<[AuthenticatorInfo](#authenticatorinfo8)> | 是 | 查询结果的回调。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.queryAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { + console.log("queryAuthenticatorInfo err: " + JSON.stringify(err)); + console.log('queryAuthenticatorInfo data: ' + JSON.stringify(data)); + }); + } catch (err) { + console.log("queryAuthenticatorInfo err: " + JSON.stringify(err)); + } + ``` + +### queryAuthenticatorInfo9+ + +queryAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> + +获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------- | +| owner | string | 是 | 应用帐号的所有者包名。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | --------------------- | +| Promise<[AuthenticatorInfo](#authenticatorinfo8)> | Promise实例,用于获取异步返回结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + try { + appAccountManager.queryAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { + console.log('queryAuthenticatorInfo: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("queryAuthenticatorInfo err: " + JSON.stringify(err)); }); - }).catch((err) => { - console.log("getWant err: " + JSON.stringify(err)); - }); + } catch (err) { + console.log("queryAuthenticatorInfo err: " + JSON.stringify(err)); + } ``` -### getAuthenticatorInfo8+ +### getAuthenticatorInfo(deprecated) getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void 获取指定应用帐号的认证器信息,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[queryAuthenticatorInfo](#queryauthenticatorinfo9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1567,12 +3472,16 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo }); ``` -### getAuthenticatorInfo8+ +### getAuthenticatorInfo(deprecated) getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> 获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[queryAuthenticatorInfo](#queryauthenticatorinfo9-1)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1581,7 +3490,7 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> | ----- | ------ | ---- | ----------- | | owner | string | 是 | 应用帐号的所有者包名。 | -**参数:** +**返回值:** | 类型 | 说明 | | -------------------------------- | --------------------- | @@ -1598,62 +3507,74 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> }); ``` -### checkAppAccess9+ +### checkAccountLabels9+ -checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void +checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void; -检查指定应用帐户对特定应用是否授权,使用callback回调异步返回结果。 +检查指定帐户是否具有特定的标签集合,使用callback回调异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ---------------------------- | ----- | ---------------- | -| name | string | 是 | 应用帐户的名称。 | -| bundleName | string | 是 | 被检查的应用包名。 | -| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ----- | --------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者。| +| labels | Array<string> | 是 | 标签数组。 | +| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => { - console.log('checkAppAccess: ' + JSON.stringify(data)); - console.log("checkAppAccess err: " + JSON.stringify(err)); - }); + var labels = ["student"]; + try { + appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => { + console.log('checkAccountLabels: ' + JSON.stringify(data)); + console.log("checkAccountLabels err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("checkAccountLabels err: " + JSON.stringify(err)); + } ``` -### checkAppAccess9+ +### checkAccountLabels9+ -checkAppAccess(name: string, bundleName: string): Promise<boolean> +checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean> -检查指定应用帐户对特定应用是否授权,使用Promise方式异步返回结果。 +检查指定帐户是否具有特定的标签集合,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Account.AppAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ----- | ---------------- | -| name | string | 是 | 应用帐户的名称。 | -| bundleName | string | 是 | 被检查的应用包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ----- | --------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者。| +| labels | Array<string> | 是 | 标签数组。 | -**参数:** +**返回值:** -| 类型 | 说明 | -| ---------------------- | --------------------------------- | +| 类型 | 说明 | +| ------------------- | -------------------------------- | | Promise<boolean> | Promise实例,用于获取异步返回结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo").then((data) => { - console.log('checkAppAccess: ' + JSON.stringify(data)); - }).catch((err) => { - console.log("checkAppAccess err: " + JSON.stringify(err)); - }); + var labels = ["student"]; + try { + appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => { + console.log('checkAccountLabels: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("checkAccountLabels err: " + JSON.stringify(err)); + }); + } catch (err) { + console.log("checkAccountLabels err: " + JSON.stringify(err)); + } ``` ### deleteAccountCredential9+ @@ -1676,10 +3597,14 @@ deleteAccountCredential(name: string, credentialType: string, callback: AsyncCal ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.deleteAccountCredential("zhangsan", "pin", (err, data) => { - console.log('deleteAccountCredential: ' + JSON.stringify(data)); + try { + appAccountManager.deleteAccountCredential("zhangsan", "pin", (err, data) => { + console.log('deleteAccountCredential: ' + JSON.stringify(data)); + console.log("deleteAccountCredential err: " + JSON.stringify(err)); + }); + } catch (err) { console.log("deleteAccountCredential err: " + JSON.stringify(err)); - }); + } ``` ### deleteAccountCredential9+ @@ -1697,7 +3622,7 @@ deleteAccountCredential(name: string, credentialType: string): Promise<void&g | name | string | 是 | 应用帐户的名称。 | | credentialType | string | 是 | 凭据类型。 | -**参数:** +**返回值:** | 类型 | 说明 | | ------------------- | -------------------------------- | @@ -1707,73 +3632,15 @@ deleteAccountCredential(name: string, credentialType: string): Promise<void&g ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.deleteAccountCredential("zhangsan", "pin").then((data) => { - console.log('deleteAccountCredential: ' + JSON.stringify(data)); - }).catch((err) => { + try { + appAccountManager.deleteAccountCredential("zhangsan", "pin").then((data) => { + console.log('deleteAccountCredential: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("deleteAccountCredential err: " + JSON.stringify(err)); + }); + } catch (err) { console.log("deleteAccountCredential err: " + JSON.stringify(err)); - }); - ``` - -### checkAccountLabels9+ - -checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void; - -检查指定帐户是否具有特定的标签集合,使用callback回调异步返回结果。 - -**系统能力:** SystemCapability.Account.AppAccount - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ----- | --------------- | -| name | string | 是 | 应用帐户的名称。 | -| owner | string | 是 | 应用帐户的所有者。| -| labels | Array<string> | 是 | 标签数组。 | -| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | - -**示例:** - - ```js - const appAccountManager = account_appAccount.createAppAccountManager(); - var labels = ["student"]; - appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => { - console.log('checkAccountLabels: ' + JSON.stringify(data)); - console.log("checkAccountLabels err: " + JSON.stringify(err)); - }); - ``` - -### checkAccountLabels9+ - -checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean> - -检查指定帐户是否具有特定的标签集合,使用Promise方式异步返回结果。 - -**系统能力:** SystemCapability.Account.AppAccount - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ----- | --------------- | -| name | string | 是 | 应用帐户的名称。 | -| owner | string | 是 | 应用帐户的所有者。| -| labels | Array<string> | 是 | 标签数组。 | - -**参数:** - -| 类型 | 说明 | -| ------------------- | -------------------------------- | -| Promise<boolean> | Promise实例,用于获取异步返回结果。 | - -**示例:** - - ```js - const appAccountManager = account_appAccount.createAppAccountManager(); - var labels = ["student"]; - appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => { - console.log('checkAccountLabels: ' + JSON.stringify(data)); - }).catch((err) => { - console.log("checkAccountLabels err: " + JSON.stringify(err)); - }); + } ``` ### selectAccountsByOptions9+ @@ -1798,10 +3665,14 @@ selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback& var options = { allowedOwners: ["com.example.ohos.accountjsdemo"] }; - appAccountManager.selectAccountsByOptions(options, (err, data) => { - console.log('selectAccountsByOptions: ' + JSON.stringify(data)); + try { + appAccountManager.selectAccountsByOptions(options, (err, data) => { + console.log('selectAccountsByOptions: ' + JSON.stringify(data)); + console.log("selectAccountsByOptions err: " + JSON.stringify(err)); + }); + } catch (err) { console.log("selectAccountsByOptions err: " + JSON.stringify(err)); - }); + } ``` ### selectAccountsByOptions9+ @@ -1818,7 +3689,7 @@ selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<App | -------------- | ------------------------- | ----- | --------------- | | options | [SelectAccountsOptions](#selectaccountsoptions9) | 是 | 选择帐户的选项。 | -**参数:** +**返回值:** | 类型 | 说明 | | ------------------- | -------------------------------- | @@ -1831,11 +3702,15 @@ selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<App var options = { allowedOwners: ["com.example.ohos.accountjsdemo"] }; - appAccountManager.selectAccountsByOptions(options).then((data) => { - console.log('selectAccountsByOptions: ' + JSON.stringify(data)); - }).catch((err) => { + try { + appAccountManager.selectAccountsByOptions(options).then((data) => { + console.log('selectAccountsByOptions: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("selectAccountsByOptions err: " + JSON.stringify(err)); + }); + } catch (err) { console.log("selectAccountsByOptions err: " + JSON.stringify(err)); - }); + } ``` ### verifyCredential9+ @@ -1852,21 +3727,25 @@ verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): | -------- | --------------------- | ----- | ----------------------- | | name | string | 是 | 应用帐户的名称。 | | owner | string | 是 | 应用帐户的所有者。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,返回验证结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,返回验证结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", { - onResult: (resultCode, result) => { - console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); - console.log("verifyCredential onResult, result:" + JSON.stringify(result)); - }, - onRequestRedirected: (request) => { - console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); - } - }); + try { + appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", { + onResult: (resultCode, result) => { + console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); + console.log("verifyCredential onResult, result:" + JSON.stringify(result)); + }, + onRequestRedirected: (request) => { + console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); + } + }); + } catch (err) { + console.log("verifyCredential err: " + JSON.stringify(err)); + } ``` ### verifyCredential9+ @@ -1884,7 +3763,7 @@ verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, | name | string | 是 | 应用帐户的名称。 | | owner | string | 是 | 应用帐户的所有者。 | | options | [VerifyCredentialOptions](#verifycredentialoptions9) | 是 | 验证凭据的选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,返回验证结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,返回验证结果。 | **示例:** @@ -1894,20 +3773,24 @@ verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, credentialType: "pin", credential: "123456" }; - appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", options, { - onResult: (resultCode, result) => { - console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); - console.log("verifyCredential onResult, result:" + JSON.stringify(result)); - }, - onRequestRedirected: (request) => { - console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); - } - }); + try { + appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", options, { + onResult: (resultCode, result) => { + console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); + console.log("verifyCredential onResult, result:" + JSON.stringify(result)); + }, + onRequestRedirected: (request) => { + console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); + } + }); + } catch (err) { + console.log("verifyCredential err: " + JSON.stringify(err)); + } ``` ### setAuthenticatorProperties9+ -setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void; +setAuthenticatorProperties(owner: string, callback: AuthCallback): void; 设置认证器属性,使用callback回调异步返回结果。 @@ -1918,27 +3801,30 @@ setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ----- | ----------------------- | | owner | string | 是 | 认证器的所有者。 | -| options | [SetPropertiesOptions](#setpropertiesoptions9) | 是 | 设置属性的选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,返回设置结果。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证器回调,返回设置结果。 | **示例:** ```js const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", { - onResult: (resultCode, result) => { - console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); - console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); - }, - onRequestRedirected: (request) => { - console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); - } - }); + try { + appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", { + onResult: (resultCode, result) => { + console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); + console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); + }, + onRequestRedirected: (request) => { + console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); + } + }); + } catch (err) { + console.log("setAuthenticatorProperties err: " + JSON.stringify(err)); + } ``` ### setAuthenticatorProperties9+ -setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void; +setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthCallback): void; 设置认证器属性,使用callback回调异步返回结果。 @@ -1950,7 +3836,7 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | -------- | --------------------- | ----- | ----------------------- | | owner | string | 是 | 认证器的所有者。 | | options | [SetPropertiesOptions](#setpropertiesoptions9) | 是 | 设置属性的选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,返回设置结果。 | +| callback | [AuthCallback](#authcallback9) | 是 | 认证器回调,返回设置结果。 | **示例:** @@ -1959,15 +3845,20 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac var options = { properties: {"prop1": "value1"} }; - appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", options, { - onResult: (resultCode, result) => { - console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); - console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); - }, - onRequestRedirected: (request) => { - console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); - } - }); + try { + appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", options, { + onResult: (resultCode, result) => { + console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); + console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); + }, + onRequestRedirected: (request) => { + console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); + } + }); + } catch (err) { + console.log("setAuthenticatorProperties err: " + JSON.stringify(err)); + } + ``` ## AppAccountInfo @@ -1981,17 +3872,33 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | owner | string | 是 | 应用帐号的所有者包名。 | | name | string | 是 | 应用帐号的名称。 | -## OAuthTokenInfo8+ +## AuthTokenInfo9+ + +表示Auth令牌信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| -------------------- | -------------- | ----- | ---------------- | +| authType9+ | string | 是 | 令牌的鉴权类型。 | +| token9+ | string | 是 | 令牌的取值。 | +| account9+ | [AppAccountInfo](#appaccountinfo) | 否 | 令牌所属的帐号信息。| + +## OAuthTokenInfo(deprecated) 表示OAuth令牌信息。 +> **说明:** 从API version 9开始废弃, 建议使用[AuthTokenInfo](#authtokeninfo9)替代。 +> +> 从 API version 8开始支持。 + **系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 | 参数名 | 类型 | 必填 | 说明 | | -------------------- | -------------- | ----- | ---------------- | | authType | string | 是 | 令牌的鉴权类型。 | | token | string | 是 | 令牌的取值。 | -| account9+ | AppAccountInfo | 否 | 令牌所属的帐号信息。| +| account9+ | [AppAccountInfo](#appaccountinfo) | 否 | 令牌所属的帐号信息。| ## AuthenticatorInfo8+ @@ -2005,6 +3912,48 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | iconId | number | 是 | 认证器的图标标识。 | | labelId | number | 是 | 认证器的标签标识。 | +## AuthResult9+ + +表示认证结果信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------- | +| account | [AppAccountInfo](#appaccountinfo) | 否 | 令牌所属的帐号信息。 | +| tokenInfo | [AuthTokenInfo](#authtokeninfo9) | 否 | 令牌信息。 | + +## AuthOptions9+ + +表示认证的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------- | +| parameters | {[key:string]: Object} | 否 | 自定义参数对象。 | + +## CreateAccountOptions9+ + +表示创建账号的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------- | +| customData | {[key:string]: Object} | 否 | 自定义数据。 | + +## CreateAccountImplicitlyOptions9+ + +表示隐式创建账号的选项。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ---------- | +| requiredLabels | {[key:string]: Object} | 否 | 必须的标签。 | +| authType | string | 否 | 鉴权类型。 | +| parameters | {[key:string]: Object} | 否 | 自定义参数对象。 | ## SelectAccountsOptions9+ 表示用于选择帐号的选项。 @@ -2049,8 +3998,10 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | 名称 | 默认值 | 说明 | | -------------------------------- | ---------------------- | ----------------------- | -| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作,隐式添加帐号。 | -| ACTION_AUTHENTICATE | "authenticate" | 表示操作,鉴权。 | +| ACTION_ADD_ACCOUNT_IMPLICITLY(deprecated) | "addAccountImplicitly" | 表示操作,隐式添加帐号。 | +| ACTION_AUTHENTICATE(deprecated) | "authenticate" | 表示操作,鉴权。 | +| ACTION_CREATE_ACCOUNT_IMPLICITLY9+ | "createAccountImplicitly" | 表示操作,隐式创建帐号。 | +| ACTION_AUTH9+ | "auth" | 表示操作,鉴权。 | | KEY_NAME | "name" | 表示键名,应用帐号名称。 | | KEY_OWNER | "owner" | 表示键名,应用帐号所有者。| | KEY_TOKEN | "token" | 表示键名,令牌。 | @@ -2091,10 +4042,103 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 | | ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 | -## AuthenticatorCallback8+ +## AuthCallback9+ + +认证回调接口。 + +### onResult9+ + +onResult: (code: number, result: {[key: string]: any}) => void + +通知请求结果。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------- | ---- | ------ | +| code | number | 是 | 鉴权结果码。 | +| result | {[key: string]: any} | 否 | 鉴权结果。 | + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + var sessionId = "1234"; + appAccountManager.getAuthCallback(sessionId).then((callback) => { + var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", + [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", + [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); + }).catch((err) => { + console.log("getAuthCallback err: " + JSON.stringify(err)); + }); + ``` + +### onRequestRedirected9+ + +onRequestRedirected: (request: Want) => void + +通知请求被跳转。 + +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---- | ---- | ---------- | +| request | Want | 是 | 用于跳转的请求信息。 | + +**示例:** + + ```js + class MyAuthenticator extends account_appAccount.Authenticator { + createAccountImplicitly(options, callback) { + callback.onRequestRedirected({ + bundleName: "com.example.ohos.accountjsdemo", + abilityName: "com.example.ohos.accountjsdemo.LoginAbility", + }); + } + + auth(name, authType, options, callback) { + var result = {[account_appAccount.Constants.KEY_NAME]: name, + [account_appAccount.Constants.KEY_AUTH_TYPE]: authType, + [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + callback.onResult(account_appAccount.ResultCode.SUCCESS, result); + } + } + ``` + +### onRequestContinued9+ + +onRequestContinued?: () => void + +通知请求被继续处理。 + +**系统能力:** SystemCapability.Account.AppAccount + +**示例:** + + ```js + const appAccountManager = account_appAccount.createAppAccountManager(); + var sessionId = "1234"; + appAccountManager.getAuthCallback(sessionId).then((callback) => { + callback.onRequestContinued(); + }).catch((err) => { + console.log("getAuthCallback err: " + JSON.stringify(err)); + }); + ``` + +## AuthenticatorCallback(deprecated) OAuth认证器回调接口。 +> **说明:** 从API version 9开始废弃。 +> +> 从 API version 8开始支持, 建议使用[AuthCallback](#authcallback9)替代。 + ### onResult8+ onResult: (code: number, result: {[key: string]: any}) => void @@ -2199,7 +4243,7 @@ addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: | authType | string | 是 | 应用帐号的鉴权类型。 | | callerBundleName | string | 是 | 鉴权请求方的包名。 | | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回鉴权结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回鉴权结果。 | ### authenticate8+ @@ -2217,7 +4261,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options: | authType | string | 是 | 应用帐号的鉴权类型。 | | callerBundleName | string | 是 | 鉴权请求方的包名。 | | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回鉴权结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回鉴权结果。 | ### verifyCredential9+ @@ -2233,7 +4277,7 @@ verifyCredential(name: string, options: VerifyCredentialOptions, callback: Authe | ---------------- | --------------------- | ---- | --------------- | | name | string | 是 | 应用帐号的名称。 | | options | [VerifyCredentialOptions](#verifycredentialoptions9) | 是 | 验证凭据的可选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回验证结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回验证结果。 | ### setProperties9+ @@ -2248,7 +4292,7 @@ setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): v | 接口名 | 类型 | 必填 | 说明 | | ---------------- | --------------------- | ---- | --------------- | | options | [SetPropertiesOptions](#setpropertiesoptions9) | 是 | 设置属性的可选项。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回设置结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回设置结果。 | ### checkAccountLabels9+ @@ -2264,7 +4308,7 @@ checkAccountLabels(name: string, labels: Array<string>, callback: Authenti | ---------------- | --------------------- | ---- | --------------- | | name | string | 是 | 应用帐号的名称。 | | labels | Array<string> | 是 | 标签数组。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回检查结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回检查结果。 | ### isAccountRemovable9+ @@ -2279,7 +4323,7 @@ isAccountRemovable(name: string, callback: AuthenticatorCallback): void; | 接口名 | 类型 | 必填 | 说明 | | ---------------- | --------------------- | ---- | --------------- | | name | string | 是 | 应用帐号的名称。 | -| callback | [AuthenticatorCallback](#authenticatorcallback8) | 是 | 认证器回调,用于返回判断结果。 | +| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | 是 | 认证器回调,用于返回判断结果。 | ### getRemoteObject9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index 8ce41e3e803fd73d9b122f760d6b0f2a21bf716d..e9447a2709bbd3d4933746be58d28380daab80b9 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -16,17 +16,17 @@ import ElementName from '@ohos.bundle'; import image from '@ohos.multimedia.image'; import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); - var id = missions[0].missionId; - - missionManager.getMissionSnapShot("", id, (error, snapshot) => { - console.log("getMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); - }) +missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.getMissionSnapShot("", id, (error, snapshot) => { + console.log("getMissionSnapShot is called, error.code = " + error.code); + console.log("bundleName = " + snapshot.ability.bundleName); }) +}) ``` ## MissionSnapshot diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md index 6e9cbe21f860a5189c93308e6818c9b43127450c..c4df381040d58b064fecda53f25b1ab2ada6c69d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -52,7 +52,7 @@ onAcceptWant(want: Want): string; | 类型 | 说明 | | -------- | -------- | - | string | 用户返回一个ability标识,如果之前启动过次标识的ability,不创建新的实例并拉回栈顶,否则创建新的实例并启动。 | + | string | 用户返回一个ability标识,如果之前启动过标识的ability,不创建新的实例并拉回栈顶,否则创建新的实例并启动。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index e897e24775313397b93afe4e78c932d866990c5a..79113c8c43330044a1074a869c63ca1a36c08238 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -7,6 +7,7 @@ - [AudioManager](#audiomanager):音频管理。 - [AudioRenderer](#audiorenderer8):音频渲染,用于播放PCM(Pulse Code Modulation)音频数据。 - [AudioCapturer](#audiocapturer8):音频采集,用于录制PCM音频数据。 +- [TonePlayer](#toneplayer9):用于管理和播放DTMF(Dual Tone Multi Frequency,双音多频)音调,如拨号音、通话回铃音等。 > **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -254,6 +255,78 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { }); ``` +## audio.createTonePlayer9+ + +createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback<TonePlayer>): void + +创建DTMF播放器。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | -------------- | +| options | [AudioRendererInfo](#audiorendererinfo8) | 是 | 配置音频渲染器信息。| +| callback | AsyncCallback<[TonePlayer](#toneplayer9)> | 是 | 回调函数,回调返回音频渲染器对象。| + +**示例:** + +```js +import audio from '@ohos.multimedia.audio'; + +var audioRendererInfo = { + "contentType": audio.ContentType.CONTENT_TYPE_MUSIC, + "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags": 0 +} +var tonePlayer; + +audio.createTonePlayer(audioRendererInfo, (err, data) => { + console.info(`callback call createTonePlayer: audioRendererInfo: ${audioRendererInfo}`); + if (err) { + console.error(`callback call createTonePlayer return error: ${err.message}`); + } else { + console.info(`callback call createTonePlayer return data: ${data}`); + tonePlayer = data; + } +}); +``` + +## audio.createTonePlayer9+ + +createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer> + +创建DTMF播放器。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------ | :---------------------------------------------| :--- | :----------- | +| options | [AudioRendererInfo](#audiorendererinfo8) | 是 | 配置音频渲染器信息。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------- | -------------------------------- | +| Promise<[TonePlayer](#toneplayer9)> | Promise对象,返回音频渲染器对象。 | + +**示例:** + +```js +import audio from '@ohos.multimedia.audio'; +async function createTonePlayer(){ + var audioRendererInfo = { + "contentType": audio.ContentType.CONTENT_TYPE_MUSIC, + "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags": 0 + } + let tonePlayer = await audio.createTonePlayer(this.audioRendererInfo); +} +``` + ## AudioVolumeType 枚举,音频流类型。 @@ -428,12 +501,13 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | -| ---------------------------------- | ------ | ---------- | -| STREAM_USAGE_UNKNOWN | 0 | 未知类型。 | -| STREAM_USAGE_MEDIA | 1 | 音频。 | -| STREAM_USAGE_VOICE_COMMUNICATION | 2 | 语音通信。 | -| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | 通知铃声。 | +| 名称 | 默认值 | 描述 | +| ------------------------------------------| ------ | ---------- | +| STREAM_USAGE_UNKNOWN | 0 | 未知类型。 | +| STREAM_USAGE_MEDIA | 1 | 音频。 | +| STREAM_USAGE_VOICE_COMMUNICATION | 2 | 语音通信。 | +| STREAM_USAGE_VOICE_ASSISTANT9+ | 3 | 语音播报。 | +| STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | 通知铃声。 | ## FocusType9+ @@ -712,11 +786,12 @@ getVolumeGroupInfos(); **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | -| :------------------------------ | :----- | :--------------------- | -| SOURCE_TYPE_INVALID | -1 | 无效的音频源。 | -| SOURCE_TYPE_MIC | 0 | Mic音频源。 | -| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | 语音通话场景的音频源。 | +| 名称 | 默认值 | 描述 | +| :------------------------------------------- | :----- | :--------------------- | +| SOURCE_TYPE_INVALID | -1 | 无效的音频源。 | +| SOURCE_TYPE_MIC | 0 | Mic音频源。 | +| SOURCE_TYPE_VOICE_RECOGNITION9+ | 1 | 语音识别源。 | +| SOURCE_TYPE_VOICE_COMMUNICATION | 7 | 语音通话场景的音频源。 | ## AudioScene8+ @@ -731,7 +806,6 @@ getVolumeGroupInfos(); | AUDIO_SCENE_PHONE_CALL | 2 | 电话模式。
    此接口为系统接口,三方应用不支持调用。 | | AUDIO_SCENE_VOICE_CHAT | 3 | 语音聊天模式。 | - ## AudioManager 管理音频音量和音频设备。在调用AudioManager的接口前,需要先通过[getAudioManager](#audiogetaudiomanager)创建实例。 @@ -3149,6 +3223,91 @@ audioManager.getRoutingManager((err,AudioRoutingManager)=>{ }); ``` +### selectInputDevice9+ + +selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void + +选择音频输入设备,当前只能选择一个输入设备,使用callback方式异步返回结果。 + +**系统接口:** 该接口为系统接口 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输入设备类。 | +| callback | AsyncCallback<void> | 是 | 回调,返回选择输入设备结果。 | + +**示例:** +```js +var audioManager = audio.getAudioManager(); +let inputAudioDeviceDescriptor = [{ + "deviceRole":audio.DeviceRole.INPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; +var audioRoutingManager; + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select input devices result callback: SUCCESS'); } + }); + }); +} +``` + +### selectInputDevice9+ + +selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void> + +**系统接口:** 该接口为系统接口 + +选择音频输入设备,当前只能选择一个输入设备,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输入设备类。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | --------------------------- | +| Promise<void> | Promise返回选择输入设备结果。 | + +**示例:** + +```js +var audioManager = audio.getAudioManager(); +let inputAudioDeviceDescriptor =[{ + "deviceRole":audio.DeviceRole.INPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; +var audioRoutingManager; + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => { + console.info('Select input devices result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }); + }); +} +``` + ### selectOutputDevice9+ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void @@ -5039,4 +5198,255 @@ audioCapturer.on('stateChange', (state) => { console.info('audio capturer state is: STATE_RUNNING'); } }); -``` \ No newline at end of file +``` + +## ToneType 9+ + +枚举,播放器的音调类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Tone + +| 名称 | 默认值 | 描述 | +| :------------------------------------------------ | :----- | :----------------------------| +| TONE_TYPE_DIAL_0 | 0 | 键0的DTMF音。 | +| TONE_TYPE_DIAL_1 | 1 | 键1的DTMF音。 | +| TONE_TYPE_DIAL_2 | 2 | 键2的DTMF音。 | +| TONE_TYPE_DIAL_3 | 3 | 键3的DTMF音。 | +| TONE_TYPE_DIAL_4 | 4 | 键4的DTMF音。 | +| TONE_TYPE_DIAL_5 | 5 | 键5的DTMF音。 | +| TONE_TYPE_DIAL_6 | 6 | 键6的DTMF音。 | +| TONE_TYPE_DIAL_7 | 7 | 键7的DTMF音。 | +| TONE_TYPE_DIAL_8 | 8 | 键8的DTMF音。 | +| TONE_TYPE_DIAL_9 | 9 | 键9的DTMF音。 | +| TONE_TYPE_DIAL_S | 10 | 键*的DTMF音。 | +| TONE_TYPE_DIAL_P | 11 | 键#的DTMF音。 | +| TONE_TYPE_DIAL_A | 12 | 键A的DTMF音。 | +| TONE_TYPE_DIAL_B | 13 | 键B的DTMF音。 | +| TONE_TYPE_DIAL_C | 14 | 键C的DTMF音。 | +| TONE_TYPE_DIAL_D | 15 | 键D的DTMF音。 | +| TONE_TYPE_COMMON_SUPERVISORY_DIAL | 100 | 呼叫监管音调,拨号音。 | +| TONE_TYPE_COMMON_SUPERVISORY_BUSY | 101 | 呼叫监管音调,忙。 | +| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION | 102 | 呼叫监管音调,拥塞。 | +| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK | 103 | 呼叫监管音调,无线电 ACK。 | +| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104 | 呼叫监管音调,无线电不可用。 | +| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING | 106 | 呼叫监管音调,呼叫等待。 | +| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE | 107 | 呼叫监管音调,铃声。 | +| TONE_TYPE_COMMON_PROPRIETARY_BEEP | 200 | 专有声调,一般蜂鸣声。 | +| TONE_TYPE_COMMON_PROPRIETARY_ACK | 201 | 专有声调,ACK。 | +| TONE_TYPE_COMMON_PROPRIETARY_PROMPT | 203 | 专有声调,PROMPT。 | +| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP | 204 | 专有声调,双重蜂鸣声。 | + +## TonePlayer9+ + +提供播放和管理DTMF(Dual Tone Multi Frequency,双音多频)音调的方法,包括各种系统监听音调、专有音调,如拨号音、通话回铃音等。 + +### load9+ + +load(type: ToneType, callback: AsyncCallback<void>): void + +加载DTMF音调配置。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :--------------| :-------------------------- | :-----| :------------------------------ | +| type | ToneType(#tonetype9) | 是 | 配置的音调类型。 | +| callback | AsyncCallback | 是 | 使用callback方式异步返回缓冲区。 | + +**示例:** + +```js +tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => { + if (err) { + console.error(`callback call load failed error: ${err.message}`); + return; + } else { + console.info('callback call load success'); + } +}); +``` + +### load9+ + +load(type: ToneType): Promise<void> + +加载DTMF音调配置。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------------- | :--------------------- | :--- | ---------------- | +| type | ToneType(#tonetype9) | 是 | 配置的音调类型。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------| :-------------------------- | +| Promise | 使用Promise方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => { + console.info('promise call load '); +}).catch(() => { + console.error('promise call load fail'); +}); +``` + +### start9+ + +start(callback: AsyncCallback<void>): void + +启动DTMF音调播放。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :------------------- | :--- | :----------------------------- | +| callback | AsyncCallback | 是 | 使用callback方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.start((err) => { + if (err) { + console.error(`callback call start failed error: ${err.message}`); + return; + } else { + console.info('callback call start success'); + } +}); +``` + +### start9+ + +start(): Promise<void> + +启动DTMF音调播放。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------- | +| Promise | 使用Promise方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.start().then(() => { + console.info('promise call start'); +}).catch(() => { + console.error('promise call start fail'); +}); +``` + +### stop9+ + +stop(callback: AsyncCallback<void>): void + +停止当前正在播放的音调。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :------------------- | :--- | :----------------------------- | +| callback | AsyncCallback | 是 | 使用callback方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.stop((err) => { + if (err) { + console.error(`callback call stop error: ${err.message}`); + return; + } else { + console.error('callback call stop success '); + } +}); +``` + +### stop9+ + +stop(): Promise<void> + +停止当前正在播放的音调。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------- | +| Promise | 使用Promise方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.stop().then(() => { + console.info('promise call stop finish'); +}).catch(() => { + console.error('promise call stop fail'); +}); +``` + +### release9+ + +release(callback: AsyncCallback<void>): void + +释放与此TonePlay对象关联的资源。使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :------------------- | :--- | :---------------------------- | +| callback | AsyncCallback | 是 | 使用callback方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.release((err) => { + if (err) { + console.error(`callback call release failed error: ${err.message}`); + return; + } else { + console.info('callback call release success '); + } +}); +``` + +### release9+ + +release(): Promise<void> + +释放与此TonePlay对象关联的资源。使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Tone + +**返回值:** + +| 类型 | 说明 | +| :------------- | :---------------------------- | +| Promise | 使用Promise方式异步返回结果。 | + +**示例:** + +```js +tonePlayer.release().then(() => { + console.info('promise call release'); +}).catch(() => { + console.error('promise call release fail'); +}); +``` 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-config-policy.md b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md index d8531e35a584b9ba62f2b43e46ffb4b1ea9f5698..03ba2c499362119c7206d46fcacddaab74e08130 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md +++ b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md @@ -32,7 +32,7 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>) **示例:** ```js configPolicy.getOneCfgFile('etc/config.xml', (error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); @@ -87,7 +87,7 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) **示例:** ```js configPolicy.getCfgFiles('etc/config.xml', (error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); @@ -140,7 +140,7 @@ getCfgDirList(callback: AsyncCallback<Array<string>>) **示例:** ```js configPolicy.getCfgDirList((error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); diff --git a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md index 6932941c9689c232a7a6f2c96efd4db620a3fe19..b759733187f276b6396380571bee3f48c1d930b0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -10,16 +10,18 @@ continuationManager模块提供了流转/协同入口管理服务能力,包括 ## 导入模块 -```js +```ts import continuationManager from '@ohos.continuation.continuationManager' ``` -## continuationManager.register +## continuationManager.register(deprecated) register(callback: AsyncCallback\): void; 注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -30,7 +32,7 @@ register(callback: AsyncCallback\): void; **示例:** - ```js + ```ts let token = -1; continuationManager.register((err, data) => { if (err.code != 0) { @@ -42,12 +44,14 @@ register(callback: AsyncCallback\): void; }); ``` -## continuationManager.register +## continuationManager.register(deprecated) register(options: ContinuationExtraParams, callback: AsyncCallback\): void; 连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -59,7 +63,7 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\): vo **示例:** - ```js + ```ts let token = -1; let continuationExtraParams = { deviceType: ["00E"] @@ -74,12 +78,14 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\): vo }); ``` -## continuationManager.register +## continuationManager.register(deprecated) register(options?: ContinuationExtraParams): Promise\; 连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -96,7 +102,7 @@ register(options?: ContinuationExtraParams): Promise\; **示例:** - ```js + ```ts let token = -1; let continuationExtraParams = { deviceType: ["00E"] @@ -111,6 +117,116 @@ register(options?: ContinuationExtraParams): Promise\; }); ``` +## continuationManager.registerContinuation9+ + +registerContinuation(callback: AsyncCallback\): void; + +注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回流转管理服务连接后生成的token。 | + +**示例:** + + ```ts + let token = -1; + try { + continuationManager.registerContinuation((err, data) => { + if (err.code != 0) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.registerContinuation9+ + +registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\): void; + +连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 是 | 过滤可选择设备列表的额外参数。 | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回流转管理服务连接后生成的token。 | + +**示例:** + + ```ts + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.registerContinuation(continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.registerContinuation9+ + +registerContinuation(options?: ContinuationExtraParams): Promise\; + +连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 否 | 过滤可选择设备列表的额外参数,该参数可缺省| + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\ | Promise形式返回流转管理服务连接后生成的token。 | + +**示例:** + + ```ts + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.register(continuationExtraParams) + .then((data) => { + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }) + .catch((err) => { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + + ## continuationManager.on("deviceConnect")(deprecated) on(type: "deviceConnect", callback: Callback\): void; @@ -130,7 +246,7 @@ on(type: "deviceConnect", callback: Callback\): void; **示例:** - ```js + ```ts continuationManager.on("deviceConnect", (data) => { console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); @@ -157,7 +273,7 @@ on(type: "deviceDisconnect", callback: Callback\): void; **示例:** - ```js + ```ts continuationManager.on("deviceDisconnect", (data) => { console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); }); @@ -182,7 +298,7 @@ off(type: "deviceConnect", callback?: Callback\): void; **示例:** - ```js + ```ts continuationManager.off("deviceConnect", (data) => { console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); @@ -209,7 +325,7 @@ off(type: "deviceDisconnect", callback?: Callback\): void; **示例:** - ```js + ```ts continuationManager.off("deviceDisconnect", (data) => { console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); }); @@ -233,16 +349,20 @@ on(type: "deviceConnect", token: number, callback: Callback\ { - console.info('onDeviceConnect len: ' + data.length); - for (let i = 0; i < data.length; i++) { - console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id)); - console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type)); - console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name)); - } - }); + try { + continuationManager.on("deviceConnect", token, (data) => { + console.info('onDeviceConnect len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id)); + console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type)); + console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name)); + } + }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` ## continuationManager.on("deviceDisconnect")9+ @@ -263,15 +383,19 @@ on(type: "deviceDisconnect", token: number, callback: Callback\>) **示例:** - ```js + ```ts let token = 1; - continuationManager.on("deviceDisconnect", token, (data) => { - console.info('onDeviceDisconnect len: ' + data.length); - for (let i = 0; i < data.length; i++) { - console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i])); - } - console.info('onDeviceDisconnect finished.'); - }); + try { + continuationManager.on("deviceDisconnect", token, (data) => { + console.info('onDeviceDisconnect len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i])); + } + console.info('onDeviceDisconnect finished.'); + }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` ## continuationManager.off("deviceConnect")9+ @@ -291,9 +415,13 @@ off(type: "deviceConnect", token: number): void; **示例:** - ```js + ```ts let token = 1; - continuationManager.off("deviceConnect", token); + try { + continuationManager.off("deviceConnect", token); + } catch (err) { + console.error('off failed, cause: ' + JSON.stringify(err)); + } ``` ## continuationManager.off("deviceDisconnect")9+ @@ -313,17 +441,23 @@ off(type: "deviceDisconnect", token: number): void; **示例:** - ```js + ```ts let token = 1; - continuationManager.off("deviceDisconnect", token); + try { + continuationManager.off("deviceDisconnect", token); + } catch (err) { + console.error('off failed, cause: ' + JSON.stringify(err)); + } ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, callback: AsyncCallback\): void; 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerondeviceconnect9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -335,7 +469,7 @@ startDeviceManager(token: number, callback: AsyncCallback\): void; **示例:** - ```js + ```ts let token = 1; continuationManager.startDeviceManager(token, (err, data) => { if (err.code != 0) { @@ -346,12 +480,14 @@ startDeviceManager(token: number, callback: AsyncCallback\): void; }); ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void; 拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -364,7 +500,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As **示例:** - ```js + ```ts let token = 1; let continuationExtraParams = { deviceType: ["00E"] @@ -378,12 +514,14 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As }); ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\; 拉起设备选择模块,可显示组网内可选择设备列表信息,使用Promise方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -401,7 +539,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\9+
    + +startContinuationDeviceManager(token: number, callback: AsyncCallback\): void; + +拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + try { + continuationManager.startContinuationDeviceManager(token, (err, data) => { + if (err.code != 0) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.startContinuationDeviceManager9+ + +startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void; + +拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 是 | 过滤可选择设备列表的额外参数。 | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.startContinuationDeviceManager(token, continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.startContinuationDeviceManager9+ + +startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\; + +拉起设备选择模块,可显示组网内可选择设备列表信息,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | 否 | 过滤可选择设备列表的额外参数,该参数可缺省| + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\ | Promise形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.startContinuationDeviceManager(token, continuationExtraParams) + .then((data) => { + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.updateConnectStatus(deprecated) updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void; 通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -434,7 +683,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, **示例:** - ```js + ```ts let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { @@ -446,12 +695,14 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, }); ``` -## continuationManager.updateConnectStatus +## continuationManager.updateConnectStatus(deprecated) updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\; 通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -470,7 +721,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) **示例:** - ```js + ```ts let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) @@ -482,12 +733,90 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) }); ``` -## continuationManager.unregister +## continuationManager.updateContinuationState9+ + +updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void; + +通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | deviceId | string | 是 | 设备ID。 | + | status | [DeviceConnectState](#deviceconnectstate) | 是 | 设备连接状态。 | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + let deviceId: string = "test deviceId"; + try { + continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { + if (err.code != 0) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.updateContinuationState9+ + +updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\; + +通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | deviceId | string | 是 | 设备ID。 | + | status | [DeviceConnectState](#deviceconnectstate) | 是 | 设备连接状态。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\ | Promise形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + let deviceId: string = "test deviceId"; + try { + continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) + .then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } + ``` + + +## continuationManager.unregister(deprecated) unregister(token: number, callback: AsyncCallback\): void; 解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -499,7 +828,7 @@ unregister(token: number, callback: AsyncCallback\): void; **示例:** - ```js + ```ts let token = 1; continuationManager.unregister(token, (err, data) => { if (err.code != 0) { @@ -510,12 +839,14 @@ unregister(token: number, callback: AsyncCallback\): void; }); ``` -## continuationManager.unregister +## continuationManager.unregister(deprecated) unregister(token: number): Promise\; 解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。 +> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 + **系统能力**:SystemCapability.Ability.DistributedAbilityManager **参数:** @@ -532,7 +863,7 @@ unregister(token: number): Promise\; **示例:** - ```js + ```ts let token = 1; continuationManager.unregister(token) .then((data) => { @@ -543,6 +874,76 @@ unregister(token: number): Promise\; }); ``` +## continuationManager.unregisterContinuation9+ + +unregisterContinuation(token: number, callback: AsyncCallback\): void; + +解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + | callback | AsyncCallback\ | 是 | AsyncCallback形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + try { + continuationManager.unregisterContinuation(token, (err, data) => { + if (err.code != 0) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.unregisterContinuation9+ + +unregisterContinuation(token: number): Promise\; + +解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Ability.DistributedAbilityManager + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | token | number | 是 | 注册后的token。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\ | Promise形式返回接口调用结果。 | + +**示例:** + + ```ts + let token = 1; + try { + continuationManager.unregisterContinuation(token) + .then((data) => { + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + + ## DeviceConnectState 设备连接状态。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md new file mode 100755 index 0000000000000000000000000000000000000000..78f5ac3a52a5904c1e1987b19767621f15f39d7f --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md @@ -0,0 +1,367 @@ +# 键鼠穿越管理 + +键鼠穿越功能,即两台或多台设备组网协同后可以共用一套键盘鼠标。 +键鼠穿越管理模块,提供实现键盘、鼠标等外接输入设备的跨设备协同操作。在设备组网的情况下,提供多设备间共享键鼠的开关,设备穿越状态更新以及键鼠穿越光标自适应显示。 + +> **说明** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import inputDeviceCooperate from '@ohos.multimodalInput.inputDeviceCooperate' +``` + +## inputDeviceCooperate.enable9+ + +enable(enable: boolean, callback: AsyncCallback\): void + +键鼠穿越开关开启或关闭,使用callback异步回调。 + +**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------------------------- | +| enable | boolean | 是 | 键鼠穿越开关开启或关闭状态。true: 键鼠穿越开关开启; false: 键鼠穿越开关关闭。 +| callback | AsyncCallback\ | 是 | 异步回调函数。当键鼠穿越开关开启或关闭成功,err为undefined,否则为错误对象。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.enable(true, (err) => { + if (err) { + console.log(`Turn on the key mouse crossing switch failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log(`Turn on the key mouse crossing switch success.`); + }); +} catch (err) { + console.log(`Turn on the key mouse crossing switch failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.enable9+ + +enable(enable: boolean): Promise\ + +键鼠穿越开关开启或关闭,使用Promise方式作为异步方法。 + +**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------- | ---- | ------------------------------------------------------------------- | +| enable | boolean | 是 | 键鼠穿越开关开启或关闭状态。true: 键鼠穿越开关开启; false: 键鼠穿越开关关闭。 | + + + +**返回值**: + +| 参数 | 说明 | +| ------------------- | ------------------------------- | +| Promise\ | Promise实例,用于异步获取结果。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.enable(false).then((err) => { + console.log(`Turn on the key mouse crossing switch success`); + }, (err) => { + console.log(`Turn on the key mouse crossing switch failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + }); +} catch (err) { + console.log(`Turn on the key mouse crossing switch failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.start9+ + +start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback\): void + +启动键鼠穿越,使用callback异步回调。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------- | +| sinkDeviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 | +| srcInputDeviceId | number | 是 | 键鼠穿越待穿越外设标识符。 | +| callback | AsyncCallback\ | 是 | 异步回调函数。当键鼠穿越启动成功,err为undefined,否则为错误对象。| + + + +**示例**: + +```js +try { + inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (err) => { + if (err) { + console.log(`Start key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log(`Start key mouse crossing success.`); + }); +} catch (err) { + console.log(`Start key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.start9+ + +start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ + +启动键鼠穿越,使用Promise方式作为异步方法。 + +**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------- | +| sinkDeviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 | +| srcInputDeviceId | number | 是 | 键鼠穿越待穿越外设标识符。 | + + + +**返回值**: + +| 参数名 | 说明 | +| ---------------------- | ------------------------------- | +| Promise\ | Promise实例,用于异步获取结果。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then((err) => { + console.log(`Start key mouse crossing success.`); + }, (err) => { + console.log(`Start key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + }); +} catch (err) { + console.log(`Start key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.stop9+ + +stop(callback: AsyncCallback\): void + +停止键鼠穿越,使用callback异步回调。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback\ | 是 | 异步回调函数,返回查询结果。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.stop((err) => { + if (err) { + console.log(`Stop key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log(`Stop key mouse crossing success.`); + }); +} catch (err) { + console.log(`Stop key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.stop9+ + +stop(): Promise\ + +停止键鼠穿越,使用Promise异步回调。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 说明 | +| -------- | ---------------------------- | +| Promise\ | Promise实例,用于异步获取结果。 | + +**示例**: + +```js +try { + inputDeviceCooperate.stop().then((err) => { + console.log(`Stop key mouse crossing success.`); + }, (err) => { + console.log(`Stop key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + }); +} catch (err) { + console.log(`Stop key mouse crossing failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.getState9+ + +getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void + +获取键鼠穿越开关的状态,使用callback异步回调。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------- | ---- | ---------------------------- | +| deviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 | +| callback | AsyncCallback<{ state: boolean }> | 是 | 异步回调函数,接收键鼠穿越开关状态。 | + +**示例**: + +```js +try { + inputDeviceCooperate.getState(deviceDescriptor, (err, data) => { + if (err) { + console.log(`Get the status failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log(`Get the status success. data=${JSON.stringify(data)}`); + }); +} catch (err) { + console.log(`Get the status failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## inputDeviceCooperate.getState9+ + +getState(deviceDescriptor: string): Promise<{ state: boolean }> + +获取键鼠穿越开关的状态,使用Promise异步回调。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------- | ---- | ---------------------------- | +| deviceDescriptor | string | 是 | 键鼠穿越目标设备描述符。 | + + + +**返回值**: + +| 参数 | 说明 | +| ------------------- | ------------------------------- | +| Promise<{ state: boolean }>| Promise实例,用于异步获取结果。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.getState(deviceDescriptor).then((data) => { + console.log(`Get the status success. data=${JSON.stringify(data)}`); + }, (err) => { + console.log(`Get the status failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + }); +} catch (err) { + console.log(`Get the status failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## on('cooperation')9+ + +on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void + +注册监听键鼠穿越状态。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | 是 | 注册类型,'cooperation'。 | +| callback | AsyncCallback<{ deviceDescriptor: string, eventMsg: [EventMsg](#eventmsg) }> | 是 | 异步回调函数,接收键鼠穿越事件消息。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.on('cooperation', (data) => { + if (data) { + console.log(`error: ${JSON.stringify(data)}`); + } else { + console.log(`cooperation: ${JSON.stringify(data)}`); + } + }); +} catch (err) { + console.log(`Registered failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## off('cooperation')9+ + +off(type: 'cooperation', callback?: AsyncCallback\): void + +关闭监听键鼠穿越状态。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | 是 | 注册类型,'cooperation'。 | +| callback | AsyncCallback | 否 | 异步回调函数,用于返回结果。 | + + + +**示例**: + +```js +try { + inputDeviceCooperate.off('cooperation', (err) => { + if (err) { + console.log(`error: ${JSON.stringify(err)}`); + } else { + console.log(`Unregistered succeed`); + } + }); +} catch (err) { + console.log(`Unregistered failed. error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); +} +``` + +## EventMsg9+ + +键鼠穿越事件。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +| 参数名 | 值 | 说明 | +| -------- | --------- | ----------------- | +| MSG_COOPERATE_INFO_START | 200 | 键鼠穿越消息,表示键鼠穿越开始。 | +| MSG_COOPERATE_INFO_SUCCESS | 201 | 键鼠穿越消息,表示键鼠穿越成功。 | +| MSG_COOPERATE_INFO_FAIL | 202 | 键鼠穿越消息,表示键鼠穿越失败。 | +| MSG_COOPERATE_STATE_ON | 500 | 键鼠穿越状态,表示键鼠穿越状态开启。 | +| MSG_COOPERATE_STATE_OFF | 501 | 键鼠穿越状态,表示键鼠穿越状态关闭。 | \ No newline at end of file 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/arkui-ts/ts-interpolation-calculation.md b/zh-cn/application-dev/reference/apis/js-apis-curve.md similarity index 89% rename from zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md rename to zh-cn/application-dev/reference/apis/js-apis-curve.md index f12674493dd658953d876d3f2094ce36e5a5c905..4dc69624440e229b6bce9e312941581ba965454e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-interpolation-calculation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-curve.md @@ -1,9 +1,10 @@ # 插值计算 -设置动画插值曲线,用于构造阶梯曲线对象、构造三阶贝塞尔曲线对象和构造弹簧曲线对象。 +本模块提供设置动画插值曲线功能,用于构造阶梯曲线对象、构造三阶贝塞尔曲线对象和构造弹簧曲线对象。 > **说明:** -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 本模块首批接口从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 导入模块 @@ -20,11 +21,13 @@ initCurve(curve?: Curve):ICurve 插值曲线的初始化函数,可以根据入参创建一个插值曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve | [Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | **返回值:** @@ -48,6 +51,8 @@ stepsCurve(count: number, end: boolean):ICurve 构造阶梯曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -77,6 +82,7 @@ cubicBezierCurve(x1: number, y1: number, x2: number, y2: number):ICurve 构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -108,6 +114,7 @@ springCurve(velocity: number, mass: number, stiffness: number, damping: number) 构造弹簧曲线对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -143,6 +150,8 @@ interpolate(fraction: number): number 插值曲线的插值计算函数,可以通过传入的归一化时间参数返回当前的插值 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -171,11 +180,13 @@ init(curve?: Curve): string 插值曲线的初始化函数,可以根据入参创建一个插值曲线对象,从API version9开始废弃,推荐使用[Curves.initCurve](#curvesinitcurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 默认值 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve |[Curve](ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | ## Curves.steps(deprecated) @@ -185,6 +196,8 @@ steps(count: number, end: boolean): string 构造阶梯曲线对象,从API version9开始废弃,推荐使用[Curves. stepsCurve](# curvesstepscurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -200,6 +213,7 @@ cubicBezier(x1: number, y1: number, x2: number, y2: number): string 构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间,API version9开始废弃,推荐使用 [Curves.cubicBezierCurve](#curvescubicbeziercurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -217,6 +231,8 @@ spring(velocity: number, mass: number, stiffness: number, damping: number): stri 构造弹簧曲线对象,从API version9开始废弃,推荐使用[Curves.springCurve](#curvesspringcurve9)。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 5842ca50f551afcad9ec25e894cccf3a6f6286e7..af0bb8865dbb86539bd726d6136472c13f7c8599 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -329,7 +329,7 @@ data_preferences.removePreferencesFromCache(context, 'mystore', function (err) { removePreferencesFromCache(context: Context, name: string): Promise<void> -从内存中移除指定的Preferences实例,使用callback异步回调。 +从内存中移除指定的Preferences实例,使用Promise异步回调。 调用该接口后,应用不允许再使用该Preferences实例进行数据操作,否则会出现数据一致性问题。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-info.md b/zh-cn/application-dev/reference/apis/js-apis-device-info.md index 65c69aa3057f0c586e7d3e03980def48bf66e97a..2a302cf33e2e0f5e6605e468b8ddf61f1f588c66 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-info.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-info.md @@ -1,5 +1,7 @@ # 设备信息 +本模块提供产品信息。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -11,11 +13,11 @@ import deviceInfo from '@ohos.deviceInfo' ## 属性 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Startup.SystemInfo。 +**系统能力**:SystemCapability.Startup.SystemInfo。 **权限**:以下各项所需要的权限有所不同,详见下表。 -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | deviceType | string | 是 | 否 | 设备类型。 | | manufacture | string | 是 | 否 | 设备厂家名称。 | 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-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md index 94c6667faeba346e31277f6f84327bf563025a8e..d9e03d2412cc526c7401b0994979428f073ca95d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @@ -36,11 +36,74 @@ getDistributedAccountAbility(): DistributedAccountAbility 提供查询和更新分布式帐号登录状态方法(需要先获取分布式帐号的单实例对象)。 -### queryOsAccountDistributedInfo +### getOsAccountDistributedInfo9+ + +getOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void + +获取分布式帐号信息,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS 或 ohos.permission.GET_DISTRIBUTED_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | 是 | 获取分布式帐号信息的回调。 | + +**示例:** + ```js + const accountAbility = account_distributedAccount.getDistributedAccountAbility(); + try { + accountAbility.getOsAccountDistributedInfo((err, data) => { + console.log("getOsAccountDistributedInfo err: " + JSON.stringify(err)); + console.log('Query account info name: ' + data.name); + console.log('Query account info id: ' + data.id); + }); + } catch (e) { + console.log("getOsAccountDistributedInfo exception: " + JSON.stringify(e)); + } + ``` + +### getOsAccountDistributedInfo9+ + +getOsAccountDistributedInfo(): Promise<DistributedInfo> + +获取分布式帐号信息,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS 或 ohos.permission.GET_DISTRIBUTED_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC。 + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<[DistributedInfo](#distributedinfo)> | Promise实例,用于获取异步返回结果。 | + +**示例:** + ```js + const accountAbility = account_distributedAccount.getDistributedAccountAbility(); + try { + accountAbility.getOsAccountDistributedInfo().then((data) => { + console.log('Query account info name: ' + data.name); + console.log('Query account info id: ' + data.id); + }).catch((err) => { + console.log("getOsAccountDistributedInfo err: " + JSON.stringify(err)); + }); + } catch (e) { + console.log("getOsAccountDistributedInfo exception: " + JSON.stringify(e)); + } + ``` +### queryOsAccountDistributedInfo(deprecated) queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void 获取分布式帐号信息,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountDistributedInfo](#getosaccountdistributedinfo9) +> +> 从 API version 7开始支持。 **系统能力:** SystemCapability.Account.OsAccount @@ -55,18 +118,21 @@ queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): v **示例:** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); - accountAbility.queryOsAccountDistributedInfo((err, data) => { + accountAbility.queryOsAccountDistributedInfo((err, data) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log('Query account info name: ' + data.name); console.log('Query account info id: ' + data.id); }); ``` -### queryOsAccountDistributedInfo +### queryOsAccountDistributedInfo(deprecated) queryOsAccountDistributedInfo(): Promise<DistributedInfo> 获取分布式帐号信息,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountDistributedInfo](#getosaccountdistributedinfo9-1) +> +> 从 API version 7开始支持。 **系统能力:** SystemCapability.Account.OsAccount @@ -81,7 +147,7 @@ queryOsAccountDistributedInfo(): Promise<DistributedInfo> **示例:** ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); - accountAbility.queryOsAccountDistributedInfo().then((data) => { + accountAbility.queryOsAccountDistributedInfo().then((data) => { console.log('Query account info name: ' + data.name); console.log('Query account info id: ' + data.id); }).catch((err) => { @@ -89,11 +155,80 @@ queryOsAccountDistributedInfo(): Promise<DistributedInfo> }); ``` -### updateOsAccountDistributedInfo +### setOsAccountDistributedInfo9+ + +setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void + +更新分布式帐号信息,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | accountInfo | [DistributedInfo](#distributedinfo) | 是 | 分布式帐号信息。 | + | callback | AsyncCallback<void> | 是 | 更新分布式帐号信息的回调。 | + +**示例:** + ```js + const accountAbility = account_distributedAccount.getDistributedAccountAbility(); + let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; + try { + accountAbility.setOsAccountDistributedInfo(accountInfo, (err) => { + console.log("setOsAccountDistributedInfo err: " + JSON.stringify(err)); + }); + } catch (e) { + console.log("setOsAccountDistributedInfo exception: " + JSON.stringify(e)); + } + ``` + +### setOsAccountDistributedInfo9+ + +setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> + +更新分布式帐号信息,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | accountInfo | [DistributedInfo](#distributedinfo) | 是 | 分布式帐户信息。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** + ```js + const accountAbility = account_distributedAccount.getDistributedAccountAbility(); + let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; + try { + accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => { + console.log('setOsAccountDistributedInfo Success'); + }).catch((err) => { + console.log("setOsAccountDistributedInfo err: " + JSON.stringify(err)); + }); + } catch (e) { + console.log("setOsAccountDistributedInfo exception: " + JSON.stringify(e)); + } + ``` +### updateOsAccountDistributedInfo(deprecated) updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void 更新分布式帐号信息,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[setOsAccountDistributedInfo](#setosaccountdistributedinfo9) +> +> 从 API version 7开始支持。 **系统能力:** SystemCapability.Account.OsAccount @@ -110,17 +245,19 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; - accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { + accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); }); ``` -### updateOsAccountDistributedInfo +### updateOsAccountDistributedInfo(deprecated) updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> 更新分布式帐号信息,使用Promise方式异步返回结果。 - +> **说明:** 从API version 9开始废弃,建议使用[setOsAccountDistributedInfo](#setosaccountdistributedinfo9-1) +> +> 从 API version 7开始支持。 **系统能力:** SystemCapability.Account.OsAccount **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS。 @@ -147,8 +284,6 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> console.log("updateOsAccountDistributedInfo err: " + JSON.stringify(err)); }); ``` - - ## DistributedInfo 提供操作系统帐户的分布式信息。 @@ -160,4 +295,6 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> | name | string | 是 | 分布式帐号名称,非空字符串。 | | id | string | 是 | 分布式帐号UID,非空字符串。 | | event | string | 是 | 分布式帐号登录状态,包括登录、登出、Token失效和注销,分别对应以下字符串:
    - Ohos.account.event.LOGIN
    - Ohos.account.event.LOGOUT
    - Ohos.account.event.TOKEN_INVALID
    - Ohos.account.event.LOGOFF | +| nickname9+ | string | 否 | 分布式帐号的昵称,非空字符串。 | +| avatar9+ | string | 否 | 分布式帐号的头像,非空字符串。 | | scalableData | object | 否 | 分布式帐号扩展信息,根据业务所需,以k-v形式传递定制化信息。
    说明:该参数是预留的可选项,目前查询和更新的方法实现中未使用。 | 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-distributedMissionManager.md b/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md index e8ca23e3ff2a86e54745961919e06caf0b766b96..4cba4c6d6ea8c76ad4e8167305ffa1dd30fd79e9 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @@ -1,6 +1,6 @@ # 分布式任务管理 -分布式任务管理模块提供跨设备系统任务管理能力,包括注册系统任务状态监听、取消系统任务状态监听、开始同步远端任务列表、停止同步远端任务列表操作。 +分布式任务管理模块提供跨设备系统任务管理能力,包括注册系统任务状态监听、取消系统任务状态监听、开始同步远端任务列表、停止同步远端任务列表、迁移任务操作。 > **说明:** > @@ -48,16 +48,23 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); } var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId }; var options = { notifyMissionsChanged: NotifyMissionsChanged, notifySnapshot: NotifySnapshot, notifyNetDisconnect: NotifyNetDisconnect } - distributedMissionManager.registerMissionListener(parameter, options, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.registerMissionListener(parameter, options, (error) => { + if (error.code != 0) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } + console.info('registerMissionListener finished') + }) + } catch (error) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.registerMissionListener @@ -97,19 +104,23 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); } var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId }; var options = { notifyMissionsChanged: NotifyMissionsChanged, notifySnapshot: NotifySnapshot, notifyNetDisconnect: NotifyNetDisconnect } - distributedMissionManager.registerMissionListener(parameter, options) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.registerMissionListener(parameter, options) + .then(data => { + console.info('registerMissionListener finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` @@ -134,11 +145,18 @@ unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback& ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId }; - distributedMissionManager.unRegisterMissionListener(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.unRegisterMissionListener(parameter, (error) => { + if (error.code != 0) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } + console.info('unRegisterMissionListener finished') + }) + } catch (error) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` @@ -168,14 +186,18 @@ unRegisterMissionListener(parameter: MissionDeviceInfo): Promise<void> ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId }; - distributedMissionManager.unRegisterMissionListener(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.unRegisterMissionListener(parameter) + .then(data => { + console.info('unRegisterMissionListener finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.startSyncRemoteMissions @@ -199,13 +221,20 @@ startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback< ```ts var parameter = { - deviceId: remoteDeviceId, + deviceId: remoteDeviceId, fixConflict: false, tag: 0 }; - distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { + if (error.code != 0) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + console.info('startSyncRemoteMissions finished') + }) + } catch (error) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.startSyncRemoteMissions @@ -234,16 +263,20 @@ startSyncRemoteMissions(parameter: MissionParameter): Promise<void> ```ts var parameter = { - deviceId: remoteDeviceId, + deviceId: remoteDeviceId, fixConflict: false, tag: 0 }; - distributedMissionManager.startSyncRemoteMissions(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.startSyncRemoteMissions(parameter) + .then(data => { + console.info('startSyncRemoteMissions finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.stopSyncRemoteMissions @@ -267,11 +300,18 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback< ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId }; - distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { + if (error.code != 0) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + console.info('stopSyncRemoteMissions finished') + }) + } catch (error) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.stopSyncRemoteMissions @@ -300,14 +340,113 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: remoteDeviceId + }; + try { + distributedMissionManager.stopSyncRemoteMissions(parameter) + .then(data => { + console.info('stopSyncRemoteMissions finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + ``` + +## distributedMissionManager.continueMission + +continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback<void>): void; + +迁移任务,以回调函数的方式返回。 + +**需要权限**:ohos.permission.MANAGE_MISSIONS, ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | 是 | 迁移信息。 | +| options | [ContinueCallback](#continuecallback) | 是 | 迁移任务完成回调函数。 | +| callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | + +**示例:** + + ```ts + var parameter = { + srcDeviceId: localDeviceId + dstDeviceId: remoteDeviceId + missionId: remoteMissionId + wantParams: {"key": "value"} + }; + function OnContinueDone(resultCode) { + console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode)); + }; + var options = { + OnContinueDone: OnContinueDone + }; + try { + distributedMissionManager.continueMission(parameter, options, (error) => { + if (error.code != 0) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } + console.info('continueMission finished') + }) + } catch (error) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } + ``` + +## distributedMissionManager.continueMission + +continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise<void> + +迁移任务,以promise方式返回执行结果。 + +**需要权限**:ohos.permission.MANAGE_MISSIONS, ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | 是 | 迁移信息。 | +| options | [ContinueCallback](#continuecallback) | 是 | 迁移任务完成回调函数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | promise方式返回执行结果。 | + +**示例:** + + ```ts + var parameter = { + srcDeviceId: localDeviceId + dstDeviceId: remoteDeviceId + missionId: remoteMissionId + wantParams: {"key": "value"} + }; + function OnContinueDone(resultCode) { + console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode)); + }; + var options = { + OnContinueDone: OnContinueDone }; - distributedMissionManager.stopSyncRemoteMissions(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.continueMission(parameter, options) + .then(data => { + console.info('continueMission finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('continueMission failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } ``` ## MissionCallback @@ -348,4 +487,31 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | ------ | ---- | ---- | ------- | -| deviceId | string | 是 | 是 | 表示设备ID。 | \ No newline at end of file +| deviceId | string | 是 | 是 | 表示设备ID。 | + +## ContinueDeviceInfo + +表示发起任务迁移时所需参数的枚举。 + +**需要权限**:ohos.permission.MANAGE_MISSIONS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------- | +| srcDeviceId | string | 是 | 是 | 表示任务迁移源设备ID。 | +| dstDeviceId | string | 是 | 是 | 表示任务迁移目标设备ID。 | +| missionId | string | 是 | 是 | 表示任务ID。 | +| wantParams | {[key: string]: any} | 是 | 是 | 表示扩展参数。 | + +## ContinueCallback + +表示迁移完成后,返回迁移结果回调函数。 + +**需要权限**:ohos.permission.MANAGE_MISSIONS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------- | -------- | ---- | ---- | ------------------ | +| onContinueDone | function | 是 | 否 | 通知迁移完成,返回迁移结果。 | \ No newline at end of file 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-enterprise-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 5fc83540eba1c318e92c183684ad4e33bde099d5..b6f71f05e5f2b8e22c5b2887f0faf87b8ea74cce 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -14,7 +14,7 @@ import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; ## enterpriseDeviceManager.enableAdmin -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\): void +enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\): void 以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。 @@ -29,7 +29,17 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | | type | [AdminType](#admintype) | 是 | 激活的设备管理员类型 | -| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | --------------------------------------------------------------- | +| 9200003 | The administrator ability component is invalid. | +| 9200004 | Failed to activate the administrator application of the device. | +| 9200007 | The system ability work abnormally. | **示例**: @@ -42,18 +52,18 @@ let enterpriseInfo = { name: "enterprise name", description: "enterprise description" } -enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, (error, result) => { +enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, error => { if (error != null) { console.log("error occurs" + error); return; } - console.log("result is " + result); + console.log("enableAdmin success"); }); ``` ## enterpriseDeviceManager.enableAdmin -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\): void +enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\): void 以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。 @@ -69,7 +79,17 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | | type | [AdminType](#admintype) | 是 | 激活的设备管理员类型 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | --------------------------------------------------------------- | +| 9200003 | The administrator ability component is invalid. | +| 9200004 | Failed to activate the administrator application of the device. | +| 9200007 | The system ability work abnormally. | **示例**: @@ -82,18 +102,18 @@ let enterpriseInfo = { name: "enterprise name", description: "enterprise description" } -enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, (error, result) => { +enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => { if (error != null) { console.log("error occurs" + error); return; } - console.log("result is " + result); + console.log("enableAdmin success"); }); ``` ## enterpriseDeviceManager.enableAdmin -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\ +enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\ 以异步方法根据给定的包名和类名激活设备管理员应用,使用Promise形式返回是否激活成功。 @@ -114,7 +134,17 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\ | Promise形式返回是否激活成功 | +| Promise\ | Promise形式返回是否激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | --------------------------------------------------------------- | +| 9200003 | The administrator ability component is invalid. | +| 9200004 | Failed to activate the administrator application of the device. | +| 9200007 | The system ability work abnormally. | **示例**: @@ -128,16 +158,14 @@ let enterpriseInfo = { description: "enterprise description" } enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100) -.then((result) => { - console.log("result is " + result); -}).catch(error => { +.catch(error => { console.log("error occurs" + error); }); ``` ## enterpriseDeviceManager.disableAdmin -disableAdmin(admin: Want, callback: AsyncCallback\): void +disableAdmin(admin: Want, callback: AsyncCallback\): void 以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。 @@ -150,7 +178,15 @@ disableAdmin(admin: Want, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ------------------- | | admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | **示例**: @@ -159,18 +195,18 @@ let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", }; -enterpriseDeviceManager.disableAdmin(wantTemp, (error, result) => { +enterpriseDeviceManager.disableAdmin(wantTemp, error => { if (error != null) { console.log("error occurs" + error); return; } - console.log("result is " + result); + console.log("disableAdmin success "); }); ``` ## enterpriseDeviceManager.disableAdmin -disableAdmin(admin: Want, userId: number, callback: AsyncCallback\): void +disableAdmin(admin: Want, userId: number, callback: AsyncCallback\): void 以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。 @@ -184,7 +220,15 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\): vo | -------- | ----------------------------------- | ---- | ---------------------------- | | admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | **示例**: @@ -193,18 +237,18 @@ let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", }; -enterpriseDeviceManager.disableAdmin(wantTemp, 100, (error, result) => { +enterpriseDeviceManager.disableAdmin(wantTemp, 100, error => { if (error != null) { console.log("error occurs" + error); return; } - console.log("result is " + result); + console.log("disableAdmin success "); }); ``` ## enterpriseDeviceManager.disableAdmin -disableAdmin(admin: Want, userId?: number): Promise\ +disableAdmin(admin: Want, userId?: number): Promise\ 以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Promise形式返回是否去激活成功。 @@ -223,7 +267,15 @@ disableAdmin(admin: Want, userId?: number): Promise\ | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\ | Promise形式返回是否激活成功 | +| Promise\ | Promise形式返回是否激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | **示例**: @@ -232,16 +284,14 @@ let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", }; -enterpriseDeviceManager.disableAdmin(wantTemp, 100).then((result) => { - console.log("result is " + result); -}).catch(error => { +enterpriseDeviceManager.disableAdmin(wantTemp, 100).catch(error => { console.log("error occurs" + error); }); ``` ## enterpriseDeviceManager.disableSuperAdmin -disableSuperAdmin(bundleName: String, callback: AsyncCallback\): void +disableSuperAdmin(bundleName: String, callback: AsyncCallback\): void 以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。 @@ -252,24 +302,32 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------- | ---- | ------------------- | | bundleName | String | 是 | 超级设备管理员应用的包名 | -| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | +| callback | AsyncCallback\ | 是 | callback方式返回是否去激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | **示例**: ```js let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.disableSuperAdmin(bundleName, (error, result) => { +enterpriseDeviceManager.disableSuperAdmin(bundleName, error => { if (error != null) { console.log("error occurs" + error); return; } - console.log("result is " + result); + console.log("disableSuperAdmin success"); }); ``` ## enterpriseDeviceManager.disableSuperAdmin -disableSuperAdmin(bundleName: String): Promise\ +disableSuperAdmin(bundleName: String): Promise\ 以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。 @@ -285,15 +343,21 @@ disableSuperAdmin(bundleName: String): Promise\ | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\ | Promise形式返回是否激活成功 | +| Promise\ | Promise形式返回是否激活成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | **示例**: ```js let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.disableSuperAdmin(bundleName).then((result) => { - console.log("result is " + result); -}).catch(error => { +enterpriseDeviceManager.disableSuperAdmin(bundleName).catch(error => { console.log("error occurs" + error); }); ``` @@ -313,6 +377,14 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\): void | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | callback | AsyncCallback\ | 是 | callback方式返回是否处于激活状态 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------------- | +| 9200005 | Failed to deactivate the administrator application of the device. | + **示例**: ```js @@ -469,6 +541,15 @@ getDeviceSettingsManager(callback: AsyncCallback<DeviceSettingsManager>): | -------- | --------------------------------------- | ---- | ----------------------------------- | | callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)> | 是 | callback方式返回DeviceSettingsManager对象 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | +| 9200002 | The administrator application does not have permission to manage the device. | + **示例:** ```js @@ -505,6 +586,15 @@ getDeviceSettingsManager(): Promise<DeviceSettingsManager> | ------------------------------------ | ---------------------------------- | | Promise<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)> | Promise方式返回DeviceSettingsManager对象 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | +| 9200002 | The administrator application does not have permission to manage the device. | + **示例:** ```js @@ -537,7 +627,15 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa | -------------- | ----------------------------------- | ---- | ---------------------- | | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | -| callback | AsyncCallback\; | 是 | callback方式返回是否设置企业信息成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | **示例:** @@ -550,11 +648,12 @@ let enterpriseInfo = { name: "enterprise name", description: "enterprise description" } -enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) -.then((result) => { - console.log("result is " + result); -}).catch(error => { - console.log("error occurs" + error); +enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => { + if (error != null) { + console.log("error occurs" + error); + return; + } + console.log("setEnterpriseInfo success"); }); ``` @@ -577,7 +676,15 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<boole | 类型 | 说明 | | ----------------- | --------------------- | -| Promise\ | Promise方式返回是否设置企业信息成功 | +| Promise\ | Promise方式返回是否设置企业信息成功 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | **示例:** @@ -590,10 +697,7 @@ let enterpriseInfo = { name: "enterprise name", description: "enterprise description" } -enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) -.then((result) => { - console.log("result is " + result); -}).catch(error => { +enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => { console.log("error occurs" + error); }); ``` @@ -613,6 +717,14 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): v | admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 | | callback | AsyncCallback<[EnterpriseInfo](#enterpriseinfo)> | 是 | callback方式返回设备管理员应用的企业信息 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | + **示例:** ```js @@ -650,6 +762,14 @@ getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> | ---------------------------------------- | ------------------------- | | Promise<[EnterpriseInfo](#enterpriseinfo)> | Promise方式返回设备管理员应用的企业信息对象 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ----------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | + **示例:** ```js @@ -665,6 +785,146 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { }); ``` +## enterpriseDeviceManager.subscribeManagedEvent + +subscribeManagedEvent(admin: Want, managedEvents: Array\, callback: AsyncCallback\): void + +订阅系统管理事件。使用callback异步回调。 + +**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用。 | +| managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 订阅事件数组。 | +| callback | AsyncCallback\ | 是 | 回调函数。当系统管理事件订阅成功err为null,否则为错误对象。 | + +**示例:** + +```js +let wantTemp = { + bundleName: "bundleName", + abilityName: "abilityName", +}; +let events = [0, 1]; +enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events, (error) => { + if (error) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## enterpriseDeviceManager.subscribeManagedEvent + +subscribeManagedEvent(admin: Want, managedEvents: Array\): Promise\ + +订阅系统管理事件。使用Promise异步回调。 + +**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用。 | +| managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 订阅事件数组。 | + +**返回值:** + +| 类型 | 说明 | +| ----- | ----------------------------------- | +| Promise\ | Promise对象。无返回结果的Promise对象。 | + +**示例:** + +```js +let wantTemp = { + bundleName: "bundleName", + abilityName: "abilityName", +}; +let events = [0, 1]; +enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events).then(() => { +}).catch((error) => { + console.log("error code:" + error.code + " error message:" + error.message); +}) +``` + +## enterpriseDeviceManager.unsubscribeManagedEvent + +unsubscribeManagedEvent(admin: Want, managedEvents: Array\, callback: AsyncCallback\): void + +取消订阅系统管理事件。使用callback异步回调。 + +**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用。 | +| managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 取消订阅事件数组。 | +| callback | AsyncCallback\ | 是 | 回调函数。当系统管理事件取消订阅成功err为null,否则为错误对象。 | + +**示例:** + +```js +let wantTemp = { + bundleName: "bundleName", + abilityName: "abilityName", +}; +let events = [0, 1]; +enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events, (error) => { + if (error) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## enterpriseDeviceManager.unsubscribeManagedEvent + +unsubscribeManagedEvent(admin: Want, managedEvents: Array\): Promise\ + +取消订阅系统管理事件。使用callback异步回调。 + +**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用。 | +| managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 取消订阅事件数组。 | + +**返回值:** + +| 类型 | 说明 | +| ----- | ----------------------------------- | +| Promise\ | Promise对象。无返回结果的Promise对象。 | + +**示例:** + +```js +let wantTemp = { + bundleName: "bundleName", + abilityName: "abilityName", +}; +let events = [0, 1]; +enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events).then(() => { +}).catch((error) => { + console.log("error code:" + error.code + " error message:" + error.message); +}) +``` + ## EnterpriseInfo 设备管理员应用的企业信息 @@ -686,3 +946,15 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { | ----------------- | ---- | ----- | | ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 | | ADMIN_TYPE_SUPER | 0x01 | 超级管理员 | + +## ManagedEvent + +可订阅系统管理事件。 + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +| 名称 | 默认值 | 说明 | +| ----------------- | ---- | ----- | +| MANAGED_EVENT_BUNDLE_ADDED | 0 | 应用安装事件。 | +| MANAGED_EVENT_BUNDLE_REMOVED | 1 | 应用卸载事件。 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md index a7d5fb7be764610e2ea3aa6e549e13d47f093b1c..bde972905f82560fda26fd0c39ee6092d22953a2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md @@ -40,6 +40,15 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\): void | time | number | 是 | 时间戳(ms)。 | | callback | AsyncCallback | 是 | 回调函数。当系统时间设置成功err为null,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | +| 9200002 | The administrator application does not have permission to manage the device. | + **示例:** ```js @@ -85,6 +94,14 @@ setDateTime(admin: Want, time: number): Promise\ | ----- | ----------------------------------- | | Promise | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | The application is not a administrator of the device. | +| 9200002 | The administrator application does not have permission to manage the device. | **示例:** 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-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 910e24c94f91b79e056116fda9cee671c8403537..b484641befa58116731651679257ddab918d6e78 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -16,11 +16,13 @@ import i18n from '@ohos.i18n'; ``` -## i18n.getDisplayLanguage +## System9+ -getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string +### getDisplayCountry9+ -获取指定语言的本地化显示文本。 +static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string + +获取指定国家的本地化显示文本。 **系统能力**:SystemCapability.Global.I18n @@ -28,28 +30,38 @@ getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): st | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------- | ---- | ---------------- | -| language | string | 是 | 指定语言。 | -| locale | string | 是 | 显示指定语言的区域ID。 | +| country | string | 是 | 指定国家。 | +| locale | string | 是 | 显示指定国家的区域ID。 | | sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | **返回值:** | 类型 | 说明 | | ------ | ------------- | -| string | 指定语言的本地化显示文本。 | +| string | 指定国家的本地化显示文本。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.getDisplayLanguage("zh", "en-GB", true); - i18n.getDisplayLanguage("zh", "en-GB"); + try { + var displayCountry = i18n.System.getDisplayCountry("zh-CN", "en-GB"); + } catch(error) { + console.error(`call System.getDisplayCountry failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getDisplayLanguage9+ -## i18n.getDisplayCountry - -getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string +static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string -获取指定国家的本地化显示文本。 +获取指定语言的本地化显示文本。 **系统能力**:SystemCapability.Global.I18n @@ -57,130 +69,180 @@ getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): stri | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------- | ---- | ---------------- | -| country | string | 是 | 指定国家。 | -| locale | string | 是 | 显示指定国家的区域ID。 | +| language | string | 是 | 指定语言。 | +| locale | string | 是 | 显示指定语言的区域ID。 | | sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | **返回值:** | 类型 | 说明 | | ------ | ------------- | -| string | 指定国家的本地化显示文本。 | +| string | 指定语言的本地化显示文本。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.getDisplayCountry("zh-CN", "en-GB", true); - i18n.getDisplayCountry("zh-CN", "en-GB"); + try { + var displayLanguage = i18n.System.getDisplayLanguage("zh", "en-GB"); + } catch(error) { + console.error(`call System.getDisplayLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getSystemLanguages9+ -## i18n.isRTL7+ - -isRTL(locale: string): boolean +static getSystemLanguages(): Array<string> -获取是否为从右至左显示语言。 +获取系统支持的语言列表。 **系统能力**:SystemCapability.Global.I18n -**参数:** +**返回值:** -| 参数名 | 类型 | 说明 | -| ------ | ------ | ------- | -| locale | string | 指定区域ID。 | +| 类型 | 说明 | +| ------------------- | ------------ | +| Array<string> | 系统支持的语言ID列表。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | true表示该locale从右至左显示语言;false表示该locale从左至右显示语言。 | +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.isRTL("zh-CN");// 中文不是RTL语言,返回false - i18n.isRTL("ar-EG");// 阿语是RTL语言,返回true + try { + var systemLanguages = i18n.System.getSystemLanguages(); + } catch(error) { + console.error(`call System.getSystemLanguages failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getSystemCountries9+ -## i18n.getSystemLanguage - -getSystemLanguage(): string +static getSystemCountries(language: string): Array<string> -获取系统语言。 +获取针对输入语言系统支持的区域列表。 **系统能力**:SystemCapability.Global.I18n +**参数:** + +| 参数名 | 类型 | 说明 | +| -------- | ------ | ----- | +| language | string | 语言ID。 | + **返回值:** -| 类型 | 说明 | -| ------ | ------- | -| string | 系统语言ID。 | +| 类型 | 说明 | +| ------------------- | ------------ | +| Array<string> | 系统支持的区域ID列表。 | -**示例:** - ```js - i18n.getSystemLanguage(); - ``` +**错误码:** +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 -## i18n.setSystemLanguage +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | -setSystemLanguage(language: string): boolean +**示例:** + ```js + try { + var systemCountries = i18n.System.getSystemCountries('zh'); + } catch(error) { + console.error(`call System.getSystemCountries failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` -设置系统语言。当前调用该接口不支持系统界面语言的实时刷新。 +### isSuggested9+ -此接口为系统接口。 +static isSuggested(language: string, region?: string): boolean -**需要权限**:ohos.permission.UPDATE_CONFIGURATION +判断当前语言和区域是否匹配。 **系统能力**:SystemCapability.Global.I18n **参数:** -| 参数名 | 类型 | 说明 | -| -------- | ------ | ----- | -| language | string | 语言ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------- | +| language | string | 是 | 合法的语言ID,例如zh。 | +| region | string | 否 | 合法的地区ID,例如CN | **返回值:** -| 类型 | 说明 | -| ------- | ------------------------------------- | -| boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 | +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.setSystemLanguage('zh'); + try { + var res = i18n.System.isSuggested('zh', 'CN'); + } catch(error) { + console.error(`call System.isSuggested failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getSystemLanguage9+ -## i18n.getSystemLanguages9+ +static getSystemLanguage(): string -getSystemLanguages(): Array<string> - -获取系统支持的语言列表。 - -此接口为系统接口。 +获取系统语言。 **系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| ------------------- | ------------ | -| Array<string> | 系统支持的语言ID列表。 | +| 类型 | 说明 | +| ------ | ------- | +| string | 系统语言ID。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.getSystemLanguages(); + try { + var systemLanguage = i18n.System.getSystemLanguage(); + } catch(error) { + console.error(`call System.getSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### setSystemLanguage9+ -## i18n.getSystemCountries9+ +static setSystemLanguage(language: string): void -getSystemCountries(language: string): Array<string> - -获取针对输入语言系统支持的区域列表。 +设置系统语言。当前调用该接口不支持系统界面语言的实时刷新。 此接口为系统接口。 +**需要权限**:ohos.permission.UPDATE_CONFIGURATION + **系统能力**:SystemCapability.Global.I18n **参数:** @@ -189,21 +251,26 @@ getSystemCountries(language: string): Array<string> | -------- | ------ | ----- | | language | string | 语言ID。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -| ------------------- | ------------ | -| Array<string> | 系统支持的区域ID列表。 | +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.getSystemCountries('zh'); + try { + i18n.System.setSystemLanguage('zh'); + } catch(error) { + console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getSystemRegion9+ -## i18n.getSystemRegion - -getSystemRegion(): string +static getSystemRegion(): string 获取系统地区。 @@ -215,15 +282,26 @@ getSystemRegion(): string | ------ | ------- | | string | 系统地区ID。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + **示例:** ```js - i18n.getSystemRegion(); + try { + var systemRegion = i18n.System.getSystemRegion(); + } catch(error) { + console.error(`call System.getSystemRegion failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### setSystemRegion9+ -## i18n.setSystemRegion - -setSystemRegion(region: string): boolean +static setSystemRegion(region: string): void 设置系统区域。 @@ -239,21 +317,26 @@ setSystemRegion(region: string): boolean | ------ | ------ | ----- | | region | string | 地区ID。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -| ------- | ------------------------------------- | -| boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 | +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.setSystemRegion('CN'); + try { + i18n.System.setSystemRegion('CN'); + } catch(error) { + console.error(`call System.setSystemRegion failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getSystemLocale9+ -## i18n.getSystemLocale - -getSystemLocale(): string +static getSystemLocale(): string 获取系统区域。 @@ -265,15 +348,26 @@ getSystemLocale(): string | ------ | ------- | | string | 系统区域ID。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + **示例:** ```js - i18n.getSystemLocale(); + try { + var systemLocale = i18n.System.getSystemLocale(); + } catch(error) { + console.error(`call System.getSystemLocale failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### setSystemLocale9+ -## i18n.setSystemLocale - -setSystemLocale(locale: string): boolean +static setSystemLocale(locale: string): void 设置系统Locale。 @@ -289,159 +383,465 @@ setSystemLocale(locale: string): boolean | ------ | ------ | --------------- | | locale | string | 指定区域ID,例如zh-CN。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 | +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.setSystemLocale('zh-CN'); + try { + i18n.System.setSystemLocale('zh-CN'); + } catch(error) { + console.error(`call System.setSystemLocale failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### is24HourClock9+ -## i18n.isSuggested9+ - -isSuggested(language: string, region?: string): boolean - -判断当前语言和区域是否匹配。 +static is24HourClock(): boolean -此接口为系统接口。 +判断系统时间是否为24小时制。 **系统能力**:SystemCapability.Global.I18n -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------- | -| language | string | 是 | 合法的语言ID,例如zh。 | -| region | string | 否 | 合法的地区ID,例如CN | - **返回值:** | 类型 | 说明 | | ------- | ---------------------------------------- | -| boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | +| boolean | 返回true,表示系统24小时开关开启;返回false,表示系统24小时开关关闭。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.isSuggested('zh', 'CN'); + try { + var is24HourClock = i18n.System.is24HourClock(); + } catch(error) { + console.error(`call System.is24HourClock failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### set24HourClock9+ -## i18n.getCalendar8+ +static set24HourClock(option: boolean): void -getCalendar(locale: string, type? : string): Calendar +修改系统时间的24小时制设置。 -获取日历对象。 +此接口为系统接口。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION **系统能力**:SystemCapability.Global.I18n **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ---------------------------------------- | -| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。 | -| type | string | 否 | 合法的日历类型,目前合法的类型有buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, persian。当type没有给出时,采用区域默认的日历类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ---------------------------------------- | +| option | boolean | 是 | option为true,表示开启系统24小时制开关;返回false,表示关闭系统24小时开关。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -| ---------------------- | ----- | -| [Calendar](#calendar8) | 日历对象。 | +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - i18n.getCalendar("zh-Hans", "gregory"); + // 将系统时间设置为24小时制 + try { + i18n.System.set24HourClock(true); + } catch(error) { + console.error(`call System.set24HourClock failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### addPreferredLanguage9+ -## Calendar8+ - +static addPreferredLanguage(language: string, index?: number): void -### setTime8+ +在系统偏好语言列表中的指定位置添加偏好语言。 -setTime(date: Date): void +此接口为系统接口。 -设置日历对象内部的时间日期。 +**需要权限**:ohos.permission.UPDATE_CONFIGURATION **系统能力**:SystemCapability.Global.I18n **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ---- | ---- | ----------------- | -| date | Date | 是 | 将要设置的日历对象的内部时间日期。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------- | +| language | string | 是 | 待添加的偏好语言。 | +| index | number | 否 | 偏好语言的添加位置。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - var calendar = i18n.getCalendar("en-US", "gregory"); - var date = new Date(2021, 10, 7, 8, 0, 0, 0); - calendar.setTime(date); + // 将语言zh-CN添加到系统偏好语言列表中 + var language = 'zh-CN'; + var index = 0; + try { + i18n.System.addPreferredLanguage(language, index); + } catch(error) { + console.error(`call System.addPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### removePreferredLanguage9+ -### setTime8+ +static removePreferredLanguage(index: number): void -setTime(time: number): void +删除系统偏好语言列表中指定位置的偏好语言。 -设置日历对象内部的时间日期, time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 +此接口为系统接口。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION **系统能力**:SystemCapability.Global.I18n **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ---------------------------------------- | -| time | number | 是 | time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | --------------------- | +| index | number | 是 | 待删除偏好语言在系统偏好语言列表中的位置。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - var calendar = i18n.getCalendar("en-US", "gregory"); - calendar.setTime(10540800000); + // 删除系统偏好语言列表中的第一个偏好语言 + var index = 0; + try { + i18n.System.removePreferredLanguage(index); + } catch(error) { + console.error(`call System.removePreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getPreferredLanguageList9+ -### set8+ - -set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void +static getPreferredLanguageList(): Array<string> -设置日历对象的年、月、日、时、分、秒。 +获取系统偏好语言列表。 **系统能力**:SystemCapability.Global.I18n -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------ | -| year | number | 是 | 设置的年。 | -| month | number | 是 | 设置的月。 | -| date | number | 是 | 设置的日。 | -| hour | number | 否 | 设置的小时。 | -| minute | number | 否 | 设置的分钟。 | -| second | number | 否 | 设置的秒。 | +| 类型 | 说明 | +| ------------------- | --------- | +| Array<string> | 系统偏好语言列表。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | **示例:** ```js - var calendar = i18n.getCalendar("zh-Hans"); - calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + try { + var preferredLanguageList = i18n.System.getPreferredLanguageList(); + } catch(error) { + console.error(`call System.getPreferredLanguageList failed, error code: ${error.code}, message: ${error.message}.`) + } ``` +### getFirstPreferredLanguage9+ -### setTimeZone8+ - -setTimeZone(timezone: string): void +static getFirstPreferredLanguage(): string -设置日历对象的时区。 +获取偏好语言列表中的第一个偏好语言。 **系统能力**:SystemCapability.Global.I18n -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ------------------------- | -| timezone | string | 是 | 设置的时区id,如“Asia/Shanghai”。 | +| 类型 | 说明 | +| ------ | -------------- | +| string | 偏好语言列表中的第一个语言。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + +**示例:** + ```js + try { + var firstPreferredLanguage = i18n.System.getFirstPreferredLanguage(); + } catch(error) { + console.error(`call System.getFirstPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + +### getAppPreferredLanguage9+ + +static getAppPreferredLanguage(): string + +获取应用的偏好语言。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------ | -------- | +| string | 应用的偏好语言。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + +**示例:** + ```js + try { + var appPreferredLanguage = i18n.System.getAppPreferredLanguage(); + } catch(error) { + console.error(`call System.getAppPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + +### setUsingLocalDigit9+ + +static setUsingLocalDigit(flag: boolean): void + +设置是否打开本地数字开关。 + +此接口为系统接口。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------- | ---- | ------------------------------- | +| flag | boolean | 是 | true表示打开本地数字开关,false表示关闭本地数字开关。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + +**示例:** + ```ts + try { + i18n.System.setUsingLocalDigit(true); + } catch(error) { + console.error(`call System.setUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + +### getUsingLocalDigit9+ + +static getUsingLocalDigit(): boolean + +获取系统当前是否打开本地数字开关。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | true表示系统当前已打开本地数字开关,false表示系统当前未打开本地数字开关。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.i18n错误码](../errorcodes/errorcode-i18n.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 890001 | Unspported para value. | + +**示例:** + ```ts + try { + var status = i18n.System.getUsingLocalDigit(); + } catch(error) { + console.error(`call System.getUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + + +## i18n.isRTL7+ + +isRTL(locale: string): boolean + +获取是否为从右至左显示语言。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 说明 | +| ------ | ------ | ------- | +| locale | string | 指定区域ID。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | true表示该locale从右至左显示语言;false表示该locale从左至右显示语言。 | + +**示例:** + ```js + i18n.isRTL("zh-CN");// 中文不是RTL语言,返回false + i18n.isRTL("ar-EG");// 阿语是RTL语言,返回true + ``` + + +## i18n.getCalendar8+ + +getCalendar(locale: string, type? : string): Calendar + +获取日历对象。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。 | +| type | string | 否 | 合法的日历类型,目前合法的类型有buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, persian。当type没有给出时,采用区域默认的日历类型。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ----- | +| [Calendar](#calendar8) | 日历对象。 | + +**示例:** + ```js + i18n.getCalendar("zh-Hans", "gregory"); + ``` + + +## Calendar8+ + + +### setTime8+ + +setTime(date: Date): void + +设置日历对象内部的时间日期。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ---- | ---- | ----------------- | +| date | Date | 是 | 将要设置的日历对象的内部时间日期。 | + +**示例:** + ```js + var calendar = i18n.getCalendar("en-US", "gregory"); + var date = new Date(2021, 10, 7, 8, 0, 0, 0); + calendar.setTime(date); + ``` + + +### setTime8+ + +setTime(time: number): void + +设置日历对象内部的时间日期, time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ---------------------------------------- | +| time | number | 是 | time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 | + +**示例:** + ```js + var calendar = i18n.getCalendar("en-US", "gregory"); + calendar.setTime(10540800000); + ``` + + +### set8+ + +set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void + +设置日历对象的年、月、日、时、分、秒。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------ | +| year | number | 是 | 设置的年。 | +| month | number | 是 | 设置的月。 | +| date | number | 是 | 设置的日。 | +| hour | number | 否 | 设置的小时。 | +| minute | number | 否 | 设置的分钟。 | +| second | number | 否 | 设置的秒。 | + +**示例:** + ```js + var calendar = i18n.getCalendar("zh-Hans"); + calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + ``` + + +### setTimeZone8+ + +setTimeZone(timezone: string): void + +设置日历对象的时区。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------- | +| timezone | string | 是 | 设置的时区id,如“Asia/Shanghai”。 | **示例:** ```js @@ -770,39 +1170,6 @@ getLocationName(number: string, locale: string): string | measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。 | -## Util(deprecated) - - -### unitConvert(deprecated) - -static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string - -将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 - -> **说明:** -> 从API version 9开始废弃。建议使用[unitConvert](#unitconvert9)代替。 -> -> 从 API version 8开始支持。 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ---------------------------------------- | -| fromUnit | [UnitInfo](#unitinfo8) | 是 | 要被转换的单位。 | -| toUnit | [UnitInfo](#unitinfo8) | 是 | 要转换为的单位。 | -| value | number | 是 | 要被转换的单位的数量值。 | -| locale | string | 是 | 格式化时使用的区域参数,如:zh-Hans-CN。 | -| style | string | 否 | 格式化使用的风格,取值包括:"long", "short", "narrow"。 | - -**返回值:** - -| 类型 | 说明 | -| ------ | ----------------------- | -| string | 按照toUnit的单位格式化后,得到的字符串。 | - - ## getInstance8+ getInstance(locale?:string): IndexUtil @@ -901,256 +1268,19 @@ getIndex(text: string): string ``` -## Character(deprecated) - - -### isDigit(deprecated) - -static isDigit(char: string): boolean +## i18n.getLineInstance8+ -判断字符串char是否是数字。 +getLineInstance(locale: string): BreakIterator -> **说明:** -> 从API version 9开始废弃。建议使用[isDigit](#isdigit9)代替。 -> -> 从 API version 8开始支持。 +获取一个用于断句的[BreakIterator](#breakiterator8)对象。 **系统能力**:SystemCapability.Global.I18n **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ------------------------------------ | -| boolean | 返回true表示输入的字符是数字,返回false表示输入的字符不是数字。 | - - -### isSpaceChar(deprecated) - -static isSpaceChar(char: string): boolean - -判断字符串char是否是空格符。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isSpaceChar](#isspacechar9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | -------------------------------------- | -| boolean | 返回true表示输入的字符是空格符,返回false表示输入的字符不是空格符。 | - - -### isWhitespace(deprecated) - -static isWhitespace(char: string): boolean - -判断字符串char是否是空白符。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isWhitespace](#iswhitespace9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | -------------------------------------- | -| boolean | 返回true表示输入的字符是空白符,返回false表示输入的字符不是空白符。 | - - -### isRTL(deprecated) - -static isRTL(char: string): boolean - -判断字符串char是否是从右到左语言的字符。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isRTL](#isrtl9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true表示输入的字符是从右到左语言的字符,返回false表示输入的字符不是从右到左语言的字符。 | - - -### isIdeograph(deprecated) - -static isIdeograph(char: string): boolean - -判断字符串char是否是表意文字。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isIdeograph](#isideograph9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true表示输入的字符是表意文字,返回false表示输入的字符不是表意文字。 | - - -### isLetter(deprecated) - -static isLetter(char: string): boolean - -判断字符串char是否是字母。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isLetter](#isletter9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ------------------------------------ | -| boolean | 返回true表示输入的字符是字母,返回false表示输入的字符不是字母。 | - - -### isLowerCase(deprecated) - -static isLowerCase(char: string): boolean - -判断字符串char是否是小写字母。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isLowerCase](#islowercase9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true表示输入的字符是小写字母,返回false表示输入的字符不是小写字母。 | - - -### isUpperCase(deprecated) - -static isUpperCase(char: string): boolean - -判断字符串char是否是大写字母。 - -> **说明:** -> 从API version 9开始废弃。建议使用[isUpperCase](#isuppercase9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true表示输入的字符是大写字母,返回false表示输入的字符不是大写字母。 | - - -### getType(deprecated) - -static getType(char: string): string - -获取输入字符串的一般类别值。 - -> **说明:** -> 从API version 9开始废弃。建议使用[getType](#gettype9)代替。 -> -> 从 API version 8开始支持 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | ---- | ----- | -| char | string | 是 | 输入字符。 | - -**返回值:** - -| 类型 | 说明 | -| ------ | ----------- | -| string | 输入字符的一般类别值。 | - - -## i18n.getLineInstance8+ - -getLineInstance(locale: string): BreakIterator - -获取一个用于断句的[BreakIterator](#breakiterator8)对象。 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ---------------------------------------- | -| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。生成的[BreakIterator](#breakiterator8)将按照locale所指定的区域的规则来进行断句。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| locale | string | 是 | 合法的locale值,例如zh-Hans-CN。生成的[BreakIterator](#breakiterator8)将按照locale所指定的区域的规则来进行断句。 | **返回值:** @@ -1389,232 +1519,61 @@ isBoundary(offset: number): boolean ``` -## i18n.is24HourClock7+ +## i18n.getTimeZone7+ -is24HourClock(): boolean +getTimeZone(zoneID?: string): TimeZone -判断系统时间是否为24小时制。 +获取时区ID对应的时区对象。 **系统能力**:SystemCapability.Global.I18n +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----- | +| zondID | string | 否 | 时区ID。 | + **返回值:** -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | 返回true,表示系统24小时开关开启;返回false,表示系统24小时开关关闭。 | +| 类型 | 说明 | +| -------- | ------------ | +| TimeZone | 时区ID对应的时区对象。 | **示例:** ```js - var is24HourClock = i18n.is24HourClock(); + var timezone = i18n.getTimeZone(); ``` -## i18n.set24HourClock7+ - -set24HourClock(option: boolean): boolean +## TimeZone -修改系统时间的24小时制设置。 -**需要权限**:ohos.permission.UPDATE_CONFIGURATION +### getID -**系统能力**:SystemCapability.Global.I18n +getID(): string -**参数:** +获取时区对象的ID。 -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------- | ---- | ---------------------------------------- | -| option | boolean | 是 | option为true,表示开启系统24小时制开关;返回false,表示关闭系统24小时开关。 | +**系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| ------- | ----------------------------- | -| boolean | 返回true,表示修改成功;返回false,表示修改失败。 | +| 类型 | 说明 | +| ------ | ------------ | +| string | 时区对象对应的时区ID。 | **示例:** ```js - // 将系统时间设置为24小时制 - var success = i18n.set24HourClock(true); + var timezone = i18n.getTimeZone(); + timezone.getID(); ``` -## i18n.addPreferredLanguage8+ - -addPreferredLanguage(language: string, index?: number): boolean +### getDisplayName -在系统偏好语言列表中的指定位置添加偏好语言。 +getDisplayName(locale?: string, isDST?: boolean): string -**需要权限**:ohos.permission.UPDATE_CONFIGURATION - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ---------- | -| language | string | 是 | 待添加的偏好语言。 | -| index | number | 否 | 偏好语言的添加位置。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ----------------------------- | -| boolean | 返回true,表示添加成功;返回false,表示添加失败。 | - -**示例:** - ```js - // 将语言zh-CN添加到系统偏好语言列表中 - var language = 'zh-CN'; - var index = 0; - var success = i18n.addPreferredLanguage(language, index); - ``` - - -## i18n.removePreferredLanguage8+ - -removePreferredLanguage(index: number): boolean - -删除系统偏好语言列表中指定位置的偏好语言。 - -**需要权限**:ohos.permission.UPDATE_CONFIGURATION - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ------ | ---- | --------------------- | -| index | number | 是 | 待删除偏好语言在系统偏好语言列表中的位置。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ----------------------------- | -| boolean | 返回true,表示删除成功;返回false,表示删除失败。 | - -**示例:** - ```js - // 删除系统偏好语言列表中的第一个偏好语言 - var index = 0; - var success = i18n.removePreferredLanguage(index); - ``` - - -## i18n.getPreferredLanguageList8+ - -getPreferredLanguageList(): Array<string> - -获取系统偏好语言列表。 - -**系统能力**:SystemCapability.Global.I18n - -**返回值:** - -| 类型 | 说明 | -| ------------------- | --------- | -| Array<string> | 系统偏好语言列表。 | - -**示例:** - ```js - var preferredLanguageList = i18n.getPreferredLanguageList(); - ``` - - -## i18n.getFirstPreferredLanguage8+ - -getFirstPreferredLanguage(): string - -获取偏好语言列表中的第一个偏好语言。 - -**系统能力**:SystemCapability.Global.I18n - -**返回值:** - -| 类型 | 说明 | -| ------ | -------------- | -| string | 偏好语言列表中的第一个语言。 | - -**示例:** - ```js - var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); - ``` - - -## i18n.getAppPreferredLanguage9+ - -getAppPreferredLanguage(): string - -获取应用的偏好语言。 - -**系统能力**:SystemCapability.Global.I18n - -**返回值:** - -| 类型 | 说明 | -| ------ | -------- | -| string | 应用的偏好语言。 | - -**示例:** - ```js - var appPreferredLanguage = i18n.getAppPreferredLanguage(); - ``` - - -## i18n.getTimeZone7+ - -getTimeZone(zoneID?: string): TimeZone - -获取时区ID对应的时区对象。 - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ----- | -| zondID | string | 否 | 时区ID。 | - -**返回值:** - -| 类型 | 说明 | -| -------- | ------------ | -| TimeZone | 时区ID对应的时区对象。 | - -**示例:** - ```js - var timezone = i18n.getTimeZone(); - ``` - - -## TimeZone - - -### getID - -getID(): string - -获取时区对象的ID。 - -**系统能力**:SystemCapability.Global.I18n - -**返回值:** - -| 类型 | 说明 | -| ------ | ------------ | -| string | 时区对象对应的时区ID。 | - -**示例:** - ```js - var timezone = i18n.getTimeZone(); - timezone.getID(); - ``` - - -### getDisplayName - -getDisplayName(locale?: string, isDST?: boolean): string - -获取时区对象在指定区域的表示。 +获取时区对象在指定区域的表示。 **系统能力**:SystemCapability.Global.I18n @@ -1773,56 +1732,6 @@ static getTimezoneFromCity(cityID: string): TimeZone ``` -## i18n.setUsingLocalDigit9+ - -setUsingLocalDigit(flag: boolean): boolean - -设置是否打开本地数字开关。 - -此接口为系统接口。 - -**需要权限**:ohos.permission.UPDATE_CONFIGURATION - -**系统能力**:SystemCapability.Global.I18n - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------- | ---- | ------------------------------- | -| flag | boolean | 是 | true表示打开本地数字开关,false表示关闭本地数字开关。 | - -**返回值:** - -| 类型 | 说明 | -| ------- | ----------------------------------- | -| boolean | true表示本地数字开关设置成功,false表示本地数字开关设置失败。 | - -**示例:** - ```ts - var status = i18n.setUsingLocalDigit(true); - ``` - - -## i18n.getUsingLocalDigit9+ - -getUsingLocalDigit(): boolean - -获取系统当前是否打开本地数字开关。 - -**系统能力**:SystemCapability.Global.I18n - -**返回值:** - -| 类型 | 说明 | -| ------- | ---------------------------------------- | -| boolean | true表示系统当前已打开本地数字开关,false表示系统当前未打开本地数字开关。 | - -**示例:** - ```ts - var status = i18n.getUsingLocalDigit(); - ``` - - ## Transliterator9+ @@ -2192,4 +2101,535 @@ static getDateOrder(locale: string): string **示例:** ```js i18n.I18NUtil.getDateOrder("zh-CN"); - ``` \ No newline at end of file + ``` + + +## i18n.getDisplayCountry(deprecated) + +getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string + +获取指定国家的本地化显示文本。 + +从API version 9开始不再维护,建议使用[System.getDisplayCountry](#getdisplaycountry9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------- | +| country | string | 是 | 指定国家。 | +| locale | string | 是 | 显示指定国家的区域ID。 | +| sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------- | +| string | 指定国家的本地化显示文本。 | + +**示例:** + ```js + i18n.getDisplayCountry("zh-CN", "en-GB", true); + i18n.getDisplayCountry("zh-CN", "en-GB"); + ``` + + +## i18n.getDisplayLanguage(deprecated) + +getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string + +获取指定语言的本地化显示文本。 + +从API version 9开始不再维护,建议使用[System.getDisplayLanguage](#getdisplaylanguage9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------- | +| language | string | 是 | 指定语言。 | +| locale | string | 是 | 显示指定语言的区域ID。 | +| sentenceCase | boolean | 否 | 本地化显示文本是否要首字母大写。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------- | +| string | 指定语言的本地化显示文本。 | + +**示例:** + ```js + i18n.getDisplayLanguage("zh", "en-GB", true); + i18n.getDisplayLanguage("zh", "en-GB"); + ``` + + +## i18n.getSystemLanguage(deprecated) + +getSystemLanguage(): string + +获取系统语言。 + +从API version 9开始不再维护,建议使用[System.getSystemLanguage](#getsystemlanguage9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------ | ------- | +| string | 系统语言ID。 | + +**示例:** + ```js + i18n.getSystemLanguage(); + ``` + + +## i18n.getSystemRegion(deprecated) + +getSystemRegion(): string + +获取系统地区。 + +从API version 9开始不再维护,建议使用[System.getSystemRegion](#getsystemregion9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------ | ------- | +| string | 系统地区ID。 | + +**示例:** + ```js + i18n.getSystemRegion(); + ``` + + +## i18n.getSystemLocale(deprecated) + +getSystemLocale(): string + +获取系统区域。 + +从API version 9开始不再维护,建议使用[System.getSystemLocale](#getsystemlocale9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------ | ------- | +| string | 系统区域ID。 | + +**示例:** + ```js + i18n.getSystemLocale(); + ``` + + +## i18n.is24HourClock(deprecated) + +is24HourClock(): boolean + +判断系统时间是否为24小时制。 + +从API version 9开始不再维护,建议使用[System.is24HourClock](#is24hourclock9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true,表示系统24小时开关开启;返回false,表示系统24小时开关关闭。 | + +**示例:** + ```js + var is24HourClock = i18n.is24HourClock(); + ``` + + +## i18n.set24HourClock(deprecated) + +set24HourClock(option: boolean): boolean + +修改系统时间的24小时制设置。 + +从API version 9开始不再维护,建议使用[System.set24HourClock](#set24hourclock9)代替。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ---------------------------------------- | +| option | boolean | 是 | option为true,表示开启系统24小时制开关;返回false,表示关闭系统24小时开关。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示修改成功;返回false,表示修改失败。 | + +**示例:** + ```js + // 将系统时间设置为24小时制 + var success = i18n.set24HourClock(true); + ``` + + +## i18n.addPreferredLanguage(deprecated) + +addPreferredLanguage(language: string, index?: number): boolean + +在系统偏好语言列表中的指定位置添加偏好语言。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[System.addPreferredLanguage](#addpreferredlanguage9)代替。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------- | +| language | string | 是 | 待添加的偏好语言。 | +| index | number | 否 | 偏好语言的添加位置。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示添加成功;返回false,表示添加失败。 | + +**示例:** + ```js + // 将语言zh-CN添加到系统偏好语言列表中 + var language = 'zh-CN'; + var index = 0; + var success = i18n.addPreferredLanguage(language, index); + ``` + + +## i18n.removePreferredLanguage(deprecated) + +removePreferredLanguage(index: number): boolean + +删除系统偏好语言列表中指定位置的偏好语言。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[System.removePreferredLanguage](#removepreferredlanguage9)代替。 + +**需要权限**:ohos.permission.UPDATE_CONFIGURATION + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | --------------------- | +| index | number | 是 | 待删除偏好语言在系统偏好语言列表中的位置。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ----------------------------- | +| boolean | 返回true,表示删除成功;返回false,表示删除失败。 | + +**示例:** + ```js + // 删除系统偏好语言列表中的第一个偏好语言 + var index = 0; + var success = i18n.removePreferredLanguage(index); + ``` + + +## i18n.getPreferredLanguageList(deprecated) + +getPreferredLanguageList(): Array<string> + +获取系统偏好语言列表。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[System.getPreferredLanguageList](#getpreferredlanguagelist9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Array<string> | 系统偏好语言列表。 | + +**示例:** + ```js + var preferredLanguageList = i18n.getPreferredLanguageList(); + ``` + + +## i18n.getFirstPreferredLanguage(deprecated) + +getFirstPreferredLanguage(): string + +获取偏好语言列表中的第一个偏好语言。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[System.getFirstPreferredLanguage](#getfirstpreferredlanguage9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** + +| 类型 | 说明 | +| ------ | -------------- | +| string | 偏好语言列表中的第一个语言。 | + +**示例:** + ```js + var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); + ``` + + +## Util(deprecated) + + +### unitConvert(deprecated) + +static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string + +将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[unitConvert](#unitconvert9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------------------------------- | +| fromUnit | [UnitInfo](#unitinfo8) | 是 | 要被转换的单位。 | +| toUnit | [UnitInfo](#unitinfo8) | 是 | 要转换为的单位。 | +| value | number | 是 | 要被转换的单位的数量值。 | +| locale | string | 是 | 格式化时使用的区域参数,如:zh-Hans-CN。 | +| style | string | 否 | 格式化使用的风格,取值包括:"long", "short", "narrow"。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ----------------------- | +| string | 按照toUnit的单位格式化后,得到的字符串。 | + + +## Character(deprecated) + + +### isDigit(deprecated) + +static isDigit(char: string): boolean + +判断字符串char是否是数字。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isDigit](#isdigit9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------ | +| boolean | 返回true表示输入的字符是数字,返回false表示输入的字符不是数字。 | + + +### isSpaceChar(deprecated) + +static isSpaceChar(char: string): boolean + +判断字符串char是否是空格符。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isSpaceChar](#isspacechar9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | -------------------------------------- | +| boolean | 返回true表示输入的字符是空格符,返回false表示输入的字符不是空格符。 | + + +### isWhitespace(deprecated) + +static isWhitespace(char: string): boolean + +判断字符串char是否是空白符。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isWhitespace](#iswhitespace9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | -------------------------------------- | +| boolean | 返回true表示输入的字符是空白符,返回false表示输入的字符不是空白符。 | + + +### isRTL(deprecated) + +static isRTL(char: string): boolean + +判断字符串char是否是从右到左语言的字符。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isRTL](#isrtl9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是从右到左语言的字符,返回false表示输入的字符不是从右到左语言的字符。 | + + +### isIdeograph(deprecated) + +static isIdeograph(char: string): boolean + +判断字符串char是否是表意文字。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isIdeograph](#isideograph9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是表意文字,返回false表示输入的字符不是表意文字。 | + + +### isLetter(deprecated) + +static isLetter(char: string): boolean + +判断字符串char是否是字母。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isLetter](#isletter9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------ | +| boolean | 返回true表示输入的字符是字母,返回false表示输入的字符不是字母。 | + + +### isLowerCase(deprecated) + +static isLowerCase(char: string): boolean + +判断字符串char是否是小写字母。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isLowerCase](#islowercase9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是小写字母,返回false表示输入的字符不是小写字母。 | + + +### isUpperCase(deprecated) + +static isUpperCase(char: string): boolean + +判断字符串char是否是大写字母。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[isUpperCase](#isuppercase9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 返回true表示输入的字符是大写字母,返回false表示输入的字符不是大写字母。 | + + +### getType(deprecated) + +static getType(char: string): string + +获取输入字符串的一般类别值。 + +从API version 8开始支持,从API version 9开始不再维护,建议使用[getType](#gettype9)代替。 + +**系统能力**:SystemCapability.Global.I18n + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | ----- | +| char | string | 是 | 输入字符。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ----------- | +| string | 输入字符的一般类别值。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 2190655106537783e0778c784d15f0cf0070bc56..84ec3d0cc56e71f5bddcac1c5dc9cbace6e8ac64 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -1771,7 +1771,7 @@ createImageReceiver(width: number, height: number, format: number, capacity: num | -------- | ------ | ---- | ---------------------- | | width | number | 是 | 图像的默认宽度。 | | height | number | 是 | 图像的默认高度。 | -| format | number | 是 | 图像格式。 | +| format | number | 是 | 图像格式,取值为[ImageFormat](#imageformat9)常量。 | | capacity | number | 是 | 同时访问的最大图像数。 | **返回值:** @@ -1952,7 +1952,7 @@ receiver.readNextImage().then(img => { }) ``` -### on('imageArrival')9+ +### on9+ on(type: 'imageArrival', callback: AsyncCallback\): void @@ -2017,6 +2017,228 @@ receiver.release().then(() => { }) ``` +## image.createImageCreator9+ + +createImageCreator(width: number, height: number, format: number, capacity: number): ImageCreator + +通过宽、高、图片格式、容量创建ImageCreator实例。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| width | number | 是 | 图像的默认宽度。 | +| height | number | 是 | 图像的默认高度。 | +| format | number | 是 | 图像格式,如YCBCR_422_SP,JPEG。 | +| capacity | number | 是 | 同时访问的最大图像数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------ | --------------------------------------- | +| [ImageCreator](#imagecreator9) | 如果操作成功,则返回ImageCreator实例。 | + +**示例:** + +```js +var creator = image.createImageCreator(8192, 8, 4, 8); +``` + +## ImageCreator9+ + +图像创建模块,用于请求图像原生数据区域,并开放给应用编译原生图像数据的能力。 +在调用以下方法前需要先创建ImageCreator实例。 + +### 属性 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ---------------------------- | ---- | ---- | ------------------ | +| capacity | number | 是 | 否 | 同时访问的图像数。 | +| format | [ImageFormat](#imageformat9) | 是 | 否 | 图像格式。 | + +### dequeueImage9+ + +dequeueImage(callback: AsyncCallback\): void + +从空闲队列中获取buffer图片,用于绘制UI内容,并使用callback返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ---------------------------------------| ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 回调函数,返回最新图片。 | + +**示例:** + +```js +creator.dequeueImage((err, img) => { + if (err) { + console.info('dequeueImage succeeded.'); + } + console.info('dequeueImage failed.')); +}); +``` + +### dequeueImage9+ + +dequeueImage(): Promise\ + +从空闲队列中获取buffer图片,用于绘制UI内容,并使用promise返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**返回值:** + +| 类型 | 说明 | +| --------------- | ------------- | +| Promise\ | 返回绘制的图像。 | + +**示例:** + +```js +creator.dequeueImage().then(img => { + console.info('dequeueImage succeeded.'); +}).catch(error => { + console.log('dequeueImage failed: ' + error); +}) +``` + +### queueImage9+ + +queueImage(interface: Image, callback: AsyncCallback\): void + +将绘制好的图片放入Dirty队列,并使用callback返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | -------------------------| ---- | -------------------- | +| interface | Image | 是 | 绘制好的buffer图像。 | +| callback | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | + +**示例:** + +```js +creator.queueImage(img, (err) => { + if (err) { + console.info('dequeueImage failed: ' + err); + } + console.info('dequeueImage succeeded'); +}) +``` + +### queueImage9+ + +queueImage(interface: Image): Promise\ + +将绘制好的图片放入Dirty队列,并使用promise返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | --------| ---- | ------------------- | +| interface | Image | 是 | 绘制好的buffer图像。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------- | +| Promise\ | 获取回调,失败时返回错误信息。 | + +**示例:** + +```js +creator.queueImage(img).then(() => { + console.info('dequeueImage succeeded.'); +}).catch(error => { + console.info('dequeueImage failed: ' + error); +}) +``` + +### on9+ + +on(type: 'imageRelease', callback: AsyncCallback\): void + +监听imageRelease事件,并使用callback返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | -------------------------| ---- | -------------------- | +| type | string | 是 | 监听事件类型,如'imageRelease'。 | +| callback | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | + +**示例:** + +```js +creator.on('imageRelease', (err) => { + if (err) { + console.info('on faild' + err); + } + console.info('on succeeded'); +}) +``` + +### release9+ + +release(callback: AsyncCallback\): void + +释放当前图像,并使用callback返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**参数:** + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | -------------------------| ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | + +**示例:** + +```js +creator.release((err) => { + if (err) { + console.info('release failed: ' + err); + } + console.info('release succeeded'); +}); +``` +### release9+ + +release(): Promise\ + +释放当前图像,并使用promise返回结果。 + +**系统能力:** SystemCapability.Multimedia.Image.ImageCreator + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------- | +| Promise\ | 获取回调,失败时返回错误信息。 | + +**示例:** + +```js +creator.release().then(() => { + console.info('release succeeded'); +}).catch(error => { + console.info('release failed'); +}) +``` + ## Image9+ 提供基本的图像操作,包括获取图像信息、读写图像数据。调用[readNextImage](#readnextimage9)和[readLatestImage](#readlatestimage9)接口时会返回image。 @@ -2144,7 +2366,7 @@ img.release().then(() =>{ | ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ | | pixels | ArrayBuffer | 是 | 否 | 像素。 | | offset | number | 是 | 否 | 偏移量。 | -| stride | number | 是 | 否 | 像素间距,stride >= region.size.width*4 | +| stride | number | 是 | 否 | 像素间距,stride >= region.size.width*4。 | | region | [Region](#region7) | 是 | 否 | 区域,按照区域读写。写入的区域宽度加X坐标不能大于原图的宽度,写入的区域高度加Y坐标不能大于原图的高度。 | ## ImageInfo @@ -2156,6 +2378,7 @@ img.release().then(() =>{ | 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ------------- | ---- | ---- | ---------- | | size | [Size](#size) | 是 | 是 | 图片大小。 | +| density9+ | number | 是 | 是 | 像素密度,单位为ppi。 | ## Size @@ -2178,8 +2401,13 @@ img.release().then(() =>{ | ---------------------- | ------ | ----------------- | | UNKNOWN | 0 | 未知格式。 | | RGB_565 | 2 | 格式为RGB_565 | -| RGBA_8888 | 3 | 格式为RGBA_8888 | -| BGRA_88889+ | 4 | 格式为BGRA_8888 | +| RGBA_8888 | 3 | 格式为RGBA_8888 | +| BGRA_88889+ | 4 | 格式为BGRA_8888 | +| RGB_8889+ | 5 | 格式为RGB_888 | +| ALPHA_89+ | 6 | 格式为ALPHA_8 | +| RGBA_F169+ | 7 | 格式为RGBA_F16 | +| NV219+ | 8 | 格式为NV21 | +| NV129+ | 9 | 格式为NV12 | ## AlphaType9+ @@ -2191,8 +2419,8 @@ img.release().then(() =>{ | -------- | ------ | ----------------------- | | UNKNOWN | 0 | 未知透明度。 | | OPAQUE | 1 | 没有alpha或图片全透明。 | -| PREMUL | 2 | RGB前乘alpha | -| UNPREMUL | 3 | RGB不前乘alpha | +| PREMUL | 2 | RGB前乘alpha。 | +| UNPREMUL | 3 | RGB不前乘alpha。 | ## ScaleMode9+ @@ -2247,6 +2475,7 @@ PixelMap的初始化选项。 | desiredRegion | [Region](#region7) | 是 | 是 | 解码区域。 | | desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 解码的像素格式。 | | index | number | 是 | 是 | 解码图片序号。 | +| fitDensity9+ | number | 是 | 是 | 图像像素密度,单位为ppi。 | ## Region7+ @@ -2268,8 +2497,9 @@ PixelMap的初始化选项。 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | --------------------------------------------------- | -| format | string | 是 | 是 | 目标格式。
    当前支持格式有:jpeg webp | -| quality | number | 是 | 是 | JPEG编码中设定输出图片质量的参数,取值范围为1-100 | +| format | string | 是 | 是 | 目标格式。
    当前支持格式有:.jpg .png .gif .bmp .webp RAW。 | +| quality | number | 是 | 是 | JPEG编码中设定输出图片质量的参数,取值范围为1-100。 | +| bufferSize9+ | number | 是 | 是 | 用于设置图片大小,默认为10M | ## GetImagePropertyOptions7+ @@ -2296,8 +2526,14 @@ PixelMap的初始化选项。 | IMAGE_WIDTH | "ImageWidth" | 图片宽度。 | | GPS_LATITUDE | "GPSLatitude" | 图片纬度。 | | GPS_LONGITUDE | "GPSLongitude" | 图片经度。 | -| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 | -| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 | +| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 | +| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 | +| DATE_TIME_ORIGINAL9+ | "DateTimeOriginal" | 拍摄时间,例如2022:09:06 15:48:00 | +| EXPOSURE_TIME9+ | "ExposureTime" | 曝光时间,例如1/33 sec.| +| SCENE_TYPE9+ | "SceneType" | 拍摄场景模式,例如人像、风光、运动、夜景等。 | +| ISO_SPEED_RATINGS9+ | "ISOSpeedRatings" | ISO感光度,例如400 | +| F_NUMBER9+ | "FNumber" | 光圈值,例如f/1.8 | + ## ImageFormat9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index d47a7f5604c3609161e6da3faeee04697685b811..2551e73891f1692e7589c807e52a2dc44cef6de9 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -36,12 +36,16 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v **示例:** ```js -let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOptions) { - console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, - "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 } +let callback = function (keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +} +try { + inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback); +} catch (error) { + console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`); } -inputConsumer.on('key', keyOptions, callback); ``` @@ -64,12 +68,16 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): **示例:** ```js -let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOptions) { - console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, - "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 } +let callback = function (keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +} +try { + inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback); +} catch (error) { + console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`); } -inputConsumer.off('key', keyOptions, callback); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index e7536e336b6cd7f61d2822276ad5d91703427f41..b255b0a2f4a3fc86fb06170ae182267c33d3c339 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -16,6 +16,130 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; ``` +## inputDevice.getDeviceList9+ + +getDeviceList(callback: AsyncCallback<Array<number>>): void + +获取所有输入设备的id列表,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------- | +| callback | AsyncCallback<Array<number>> | 是 | 回调函数。 | + +**示例**: + +```js +try { + inputDevice.getDeviceList((error, ids) => { + if (error) { + console.log(`Failed to get device list. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + this.data = ids; + console.log("The device ID list is: " + ids); + }); +} catch (error) { + console.info("getDeviceList " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceList9+ + +getDeviceList(): Promise<Array<number>> + +获取所有输入设备的id列表,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice + +**返回值**: + +| 参数 | 说明 | +| ---------------------------------- | ------------------------------- | +| Promise<Array<number>> | Promise实例,用于异步获取结果。 | + +**示例**: + +```js +try { + inputDevice.getDeviceList().then((ids) => { + console.log("The device ID list is: " + ids); + }); +} catch (error) { + console.info("getDeviceList " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceInfo9+ + +getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): void + +获取输入设备的描述信息,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------------------- | ---- | --------------------------------------- | +| deviceId | number | 是 | 需要获取信息的设备id。 | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回InputDeviceData对象。 | + +**示例**: + +```js +// 示例获取设备id为1的设备name信息。 +try { + inputDevice.getDeviceInfo(1, (error, inputDevice) => { + if (error) { + console.log(`Failed to get device information. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log("The device name is: " + inputDevice.name); + }); +} catch (error) { + console.info("getDeviceInfo " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceInfo9+ + +getDeviceInfo(deviceId: number): Promise<InputDeviceData> + +获取输入设备的描述信息,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| deviceId | number | 是 | 需要获取信息的设备id。 | + +**返回值**: + +| 参数 | 说明 | +| -------------------------------------------------- | ------------------------------- | +| Promise<[InputDeviceData](#inputdevicedata)> | Promise实例,用于异步获取结果。 | + +**示例**: + +```js +// 示例获取设备id为1的设备name信息。 +try { + inputDevice.getDeviceInfo(id).then((inputDevice) => { + console.log("The device name is: " + inputDevice.name); + }); +} catch (error) { + console.info("getDeviceInfo " + error.code + " " + error.message); +} +``` + ## inputDevice.on9+ on(type: “change”, listener: Callback<DeviceListener>): void @@ -35,20 +159,24 @@ on(type: “change”, listener: Callback<DeviceListener>): void ```js let isPhysicalKeyboardExist = true; -inputDevice.on("change", (data) => { +try { + inputDevice.on("change", (data) => { console.log("type: " + data.type + ", deviceId: " + data.deviceId); inputDevice.getKeyboardType(data.deviceId, (err, ret) => { - console.log("The keyboard type of the device is: " + ret); - if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { - // 监听物理键盘已连接。 - isPhysicalKeyboardExist = true; - } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { - // 监听物理键盘已断开。 - isPhysicalKeyboardExist = false; - } + console.log("The keyboard type of the device is: " + ret); + if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + // 监听物理键盘已连接。 + isPhysicalKeyboardExist = true; + } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + // 监听物理键盘已断开。 + isPhysicalKeyboardExist = false; + } }); -}); -// 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。 + }); + // 根据isPhysicalKeyboardExist的值决定软键盘是否弹出。 +} catch (error) { + console.info("oninputdevcie " + error.code + " " + error.message); +} ``` ## inputDevice.off9+ @@ -69,27 +197,40 @@ off(type: “change”, listener?: Callback<DeviceListener>): void **示例**: ```js -function listener(data) { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); +callback: function(data) { + console.log("type: " + data.type + ", deviceId: " + data.deviceId); } -// 监听输入设备的热插拔事件 -inputDevice.on("change", listener); +try { + inputDevice.on("change", this.callback); +} catch (error) { + console.info("oninputdevcie " + error.code + " " + error.message) +} // 单独取消listener的监听。 -inputDevice.off("change", listener); +try { + inputDevice.off("change", this.callback); +} catch (error) { + console.info("offinputdevcie " + error.code + " " + error.message) +} // 取消所有监听。 -inputDevice.off("change"); +try { + inputDevice.off("change"); +} catch (error) { + console.info("offinputdevcie " + error.code + " " + error.message); +} // 取消监听后,软键盘默认都弹出。 ``` -## inputDevice.getDeviceIds +## inputDevice.getDeviceIds(deprecated) getDeviceIds(callback: AsyncCallback<Array<number>>): void 获取所有输入设备的id列表,使用callback方式作为异步方法。 +从API version 9 开始不再维护,建议使用[inputDevice.getDeviceList](#inputdevicegetdevicelist9)代替。 + **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: @@ -106,12 +247,14 @@ inputDevice.getDeviceIds((ids)=>{ }); ``` -## inputDevice.getDeviceIds +## inputDevice.getDeviceIds(deprecated) getDeviceIds(): Promise<Array<number>> 获取所有输入设备的id列表,使用Promise方式作为异步方法。 +从API version 9 开始不再维护,建议使用[inputDevice.getDeviceList](#inputdevicegetdevicelist9)代替。 + **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **返回值**: @@ -128,12 +271,14 @@ inputDevice.getDeviceIds().then((ids)=>{ }); ``` -## inputDevice.getDevice +## inputDevice.getDevice(deprecated) getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void 获取输入设备的描述信息,使用callback方式作为异步方法。 +从API version 9 开始不再维护,建议使用[inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9)代替。 + **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: @@ -152,12 +297,14 @@ inputDevice.getDevice(1, (inputDevice)=>{ }); ``` -## inputDevice.getDevice +## inputDevice.getDevice(deprecated) getDevice(deviceId: number): Promise<InputDeviceData> 获取输入设备的描述信息,使用Promise方式作为异步方法。 +从API version 9 开始不再维护,建议使用[inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9)代替。 + **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: @@ -201,9 +348,13 @@ supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback< ```js // 示例查询id为1的设备对于17、22和2055按键的支持情况。 -inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{ +try { + inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => { console.log("The query result is as follows: " + ret); -}); + }); +} catch (error) { + console.info("supportKeys " + error.code + " " + error.message); +} ``` ## inputDevice.supportKeys9+ @@ -231,9 +382,13 @@ supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<b ```js // 示例查询id为1的设备对于17、22和2055按键的支持情况。 -inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{ +try { + inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => { console.log("The query result is as follows: " + ret); -}) + }); +} catch (error) { + console.info("supportKeys " + error.code + " " + error.message); +} ``` ## inputDevice.getKeyboardType9+ @@ -255,9 +410,18 @@ getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): ```js // 示例查询设备id为1的设备键盘类型。 -inputDevice.getKeyboardType(1, (ret)=>{ - console.log("The keyboard type of the device is: " + ret); -}); +try { + inputDevice.getKeyboardType(1, (error, number) => { + if (error) { + console.log(`Failed to get keyboardtype. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log("The keyboard type of the device is: " + number); + }); +} catch (error) { + console.info("getKeyboardType " + error.code + " " + error.message); +} ``` ## inputDevice.getKeyboardType9+ @@ -278,9 +442,13 @@ getKeyboardType(deviceId: number): Promise<KeyboardType> ```js // 示例查询设备id为1的设备键盘类型。 -inputDevice.getKeyboardType(1).then((ret)=>{ - console.log("The keyboard type of the device is: " + ret); -}) +try { + inputDevice.getKeyboardType(1).then((number) => { + console.log("The keyboard type of the device is: " + number); + }); +} catch (error) { + console.info("getKeyboardType " + error.code + " " + error.message); +} ``` ## DeviceListener9+ diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md index 82c05b94b72c330b921d6d868768d19268fcc023..9654433e873c5803fb1d52def20ecd00e5efea07 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -34,13 +34,24 @@ injectEvent({KeyEvent: KeyEvent}): void **示例:** ```js -let keyEvent = { +try { + var keyEvent = { isPressed: true, keyCode: 2, keyDownDuration: 0, isIntercepted: false + } + inputEventClient.injectKeyEvent({ KeyEvent: keyEvent }); + var keyEvent1 = { + isPressed: false, + keyCode: 2, + keyDownDuration: 0, + isIntercepted: false + }; + inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 }); +} catch (error) { + console.info("injectKeyEvent " + error.code + " " + error.message); } -let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index 6659984f7fa36cafaaae252913f4c84e5f3e6d1a..56743cb2b46490eb8ca89050e3e891e7b5cf064e 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -35,10 +35,14 @@ on(type: "touch", receiver: TouchEventReceiver): void **示例:** ```js -inputMonitor.off("touch", (event) => { - // 消费触屏事件 - return false; -}); +try { + inputMonitor.on("touch", (data)=> { + console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`); + return false; + }); +} catch (error) { + console.info("onMonitor " + error.code + " " + error.message) +} ``` @@ -60,9 +64,14 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void **示例:** ```js -inputMonitor.off("mouse", (event) => { - // 消费鼠标事件 -}); +try { + inputMonitor.on("mouse", (data)=> { + console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`); + return false; + }); +} catch (error) { + console.info("onMonitor " + error.code + " " + error.message) +} ``` @@ -86,7 +95,26 @@ off(type: "touch", receiver?: TouchEventReceiver): void **示例:** ```js -inputMonitor.off("touch"); +// 取消所有监听。 +try { + inputMonitor.off("touch"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} +// 单独取消receiver的监听。 +callback:function(data) { + console.info(`call success ${JSON.stringify(data)}`); +}, +try { + inputMonitor.on("touch", this.callback); +} catch (error) { + console.info("onTouchMonitor " + error.code + " " + error.message) +}, +try { + inputMonitor.off("touch",this.callback); +} catch (error) { + console.info("offTouchMonitor " + error.code + " " + error.message) +} ``` off(type: "mouse", receiver?: Callback<MouseEvent>): void @@ -107,7 +135,26 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void **示例:** ```js -inputMonitor.off("mouse"); +// 取消所有监听。 +try { + inputMonitor.off("mouse"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} +// 单独取消receiver的监听。 +callback:function(data) { + console.info(`call success ${JSON.stringify(data)}`); +}, +try { + inputMonitor.on("mouse", this.callback); +} catch (error) { + console.info("onMouseMonitor " + error.code + " " + error.message) +}, +try { + inputMonitor.off("mouse", this.callback); +} catch (error) { + console.info("offMouseMonitor " + error.code + " " + error.message) +} ``` @@ -133,9 +180,13 @@ inputMonitor.off("mouse"); **示例:** ```js -inputMonitor.on("touch", (event) => { - // 消费触摸输入事件 - return false; -}); -inputMonitor.off("touch"); +try { + inputMonitor.on("touch", (event) => { + // 若返回true,表示本次操作后续所有事件不再分发到窗口,事件都由监听者消费。 + return false; + }); + inputMonitor.off("touch"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md similarity index 93% rename from zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md rename to zh-cn/application-dev/reference/apis/js-apis-matrix4.md index 43d8e5b727ca19041f0c4f9cfdfdfcae59e3f8a6..a53809173e6b63a26bfe5768a870991171ac22e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md @@ -1,10 +1,10 @@ # 矩阵变换 -可对图形进行平移、旋转和缩放等。 +本模块提供矩阵变换功能,可对图形进行平移、旋转和缩放等。 > **说明:** > -> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> 本模块首批接口从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 导入模块 @@ -21,6 +21,8 @@ init(array: Array<number>): Matrix4Transit Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,矩阵为列优先。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -85,6 +87,8 @@ identity(): Matrix4Transit Matrix的初始化函数,可以返回一个单位矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -128,6 +132,8 @@ copy(): Matrix4Transit Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -174,6 +180,8 @@ combine(matrix: Matrix4): Matrix4Transit Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个新的矩阵对象。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -222,9 +230,10 @@ struct Test { invert(): Matrix4Transit - Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效果正好相反。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **返回值:** | 类型 | 说明 | @@ -263,9 +272,10 @@ struct Tests { translate({x?: number, y?: number, z?: number}): Matrix4Transit - Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -310,6 +320,8 @@ scale({x?: number, y?: number, z?: number, centerX?: number, centerY?: number}): Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -356,6 +368,8 @@ rotate({x?: number, y?: number, z?: number, angle?: number, centerX?: Length, ce Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -403,6 +417,8 @@ transformPoint(point: Point): Point Matrix的坐标点转换函数,可以将当前的变换效果作用到一个坐标点上。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + **参数:** | 参数名 | 类型 | 必填 | 说明 | 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-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 37faef2cb6e81218ca34a235a12b678e8fda1559..45c3e9c87a3161561339636e34067a4e8a24745d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -26,7 +26,7 @@ getAccountManager(): AccountManager | --------------------------------- | ------------------------ | | [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); ``` @@ -70,9 +70,13 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.activateOsAccount(localId, (err)=>{ - console.log('activateOsAccount err:' + JSON.stringify(err)); - }); + try { + accountManager.activateOsAccount(localId, (err)=>{ + console.log('activateOsAccount err:' + JSON.stringify(err)); + }); + } catch (e) { + console.log('activateOsAccount exception:' + JSON.stringify(e)); + } ``` ### activateOsAccount @@ -103,19 +107,84 @@ activateOsAccount(localId: number): Promise<void> ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.activateOsAccount(localId).then(() => { - console.log('activateOsAccount success'); - }).catch((err) => { - console.log('activateOsAccount err:' + JSON.stringify(err)); - }); + try { + accountManager.activateOsAccount(localId).then(() => { + console.log('activateOsAccount success'); + }).catch((err) => { + console.log('activateOsAccount err:' + JSON.stringify(err)); + }); + } catch (e) { + console.log('activateOsAccount exception:' + JSON.stringify(e)); + } + ``` + +### isMultiOsAccountEnabled9+ + +isMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void + +判断是否支持多系统帐号,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | --------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isMultiOsAccountEnabled((err, isEnabled) => { + console.log('isMultiOsAccountEnabled err: ' + JSON.stringify(err)); + console.log('isMultiOsAccountEnabled isEnabled: ' + isEnabled); + }); + } catch (e) { + console.log('isMultiOsAccountEnabled exception: ' + JSON.stringify(e)); + } ``` -### isMultiOsAccountEnable +### isMultiOsAccountEnabled9+ + +isMultiOsAccountEnabled(): Promise<boolean> + +判断是否支持多系统帐号,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | + +**示例:** + + ```js + try { + let accountManager = account_osAccount.getAccountManager(); + accountManager.isMultiOsAccountEnabled().then((isEnabled) => { + console.log('isMultiOsAccountEnabled, isEnabled: ' + isEnabled); + }).catch((err) => { + console.log('isMultiOsAccountEnabled err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('isMultiOsAccountEnabled exception: ' + JSON.stringify(e)); + } + ``` + +### isMultiOsAccountEnable(deprecated) isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void 判断是否支持多系统帐号,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isMultiOsAccountEnabled](#ismultiosaccountenabled9) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -124,7 +193,7 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void | -------- | ---------------------------- | ---- | --------------------------------------------------- | | callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -134,12 +203,16 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void }); ``` -### isMultiOsAccountEnable +### isMultiOsAccountEnable(deprecated) isMultiOsAccountEnable(): Promise<boolean> 判断是否支持多系统帐号,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isMultiOsAccountEnabled](#ismultiosaccountenabled9-1) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **返回值:** @@ -148,7 +221,7 @@ isMultiOsAccountEnable(): Promise<boolean> | :--------------------- | :----------------------------------------------------------- | | Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -159,12 +232,86 @@ isMultiOsAccountEnable(): Promise<boolean> }); ``` -### isOsAccountActived +### isOsAccountActivated9+ + +isOsAccountActivated(localId: number, callback: AsyncCallback<boolean>): void + +判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 | + +**示例:** 判断ID为100的系统帐号是否处于激活状态 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; + try { + accountManager.isOsAccountActivated(osLocalId, (err, isActive)=>{ + console.log('isOsAccountActivated err:' + JSON.stringify(err)); + console.log('isOsAccountActivated isActive:' + isActive); + }); + } catch (e) { + console.log('isOsAccountActivated exception:' + JSON.stringify(e)); + } + ``` + +### isOsAccountActivated9+ + +isOsAccountActivated(localId: number): Promise<boolean> + +判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 | + +**示例:** 判断ID为100的系统帐号是否处于激活状态 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let osLocalId = 100; + try { + accountManager.isOsAccountActivated(osLocalId).then((isActive) => { + console.log('isOsAccountActivated, isActive: ' + isActive); + }).catch((err) => { + console.log('isOsAccountActivated err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('isOsAccountActivated exception:' + JSON.stringify(e)); + } + ``` + +### isOsAccountActived(deprecated) isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void 判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[isOsAccountActivated](#isosaccountactivated9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -187,12 +334,16 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi }); ``` -### isOsAccountActived +### isOsAccountActived(deprecated) isOsAccountActived(localId: number): Promise<boolean> 判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃, 建议使用[isOsAccountActivated](#isosaccountactivated9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -221,12 +372,88 @@ isOsAccountActived(localId: number): Promise<boolean> }); ``` -### isOsAccountConstraintEnable +### isConstraintEnabled9+ + +isConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback<boolean>): void + +判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 | + +**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.isConstraintEnabled(localId, 'constraint.wifi', (err, isEnabled)=>{ + console.log('isConstraintEnabled err:' + JSON.stringify(err)); + console.log('isConstraintEnabled isEnabled:' + isEnabled); + }); + } catch (e) { + console.log('isConstraintEnabled exception:' + JSON.stringify(e)); + } + ``` + +### isConstraintEnabled9+ + +isConstraintEnabled(localId: number, constraint: string): Promise<boolean> + +判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 | + +**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.isConstraintEnabled(localId, 'constraint.wifi').then((isEnabled) => { + console.log('isConstraintEnabled, isEnabled: ' + isEnabled); + }).catch((err) => { + console.log('isConstraintEnabled err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('isConstraintEnabled exception:' + JSON.stringify(e)); + } + ``` + +### isOsAccountConstraintEnable(deprecated) isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void 判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isConstraintEnabled](#isconstraintenabled9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -250,12 +477,16 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async }); ``` -### isOsAccountConstraintEnable +### isOsAccountConstraintEnable(deprecated) isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean> 判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isConstraintEnabled](#isconstraintenabled9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -285,12 +516,73 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo }); ``` -### isTestOsAccount +### isTestable9+ + +isTestable(callback: AsyncCallback<boolean>): void + +检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ----------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isTestable((err, isTest) => { + console.log('isTestable err: ' + JSON.stringify(err)); + console.log('isTestable isTest: ' + isTest); + }); + } catch (e) { + console.log('isTestable exception: ' + JSON.stringify(e)); + } + ``` + +### isTestable9+ + +isTestable(): Promise<boolean> + +检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isTestable().then((isTest) => { + console.log('isTestable, isTest: ' + isTest); + }).catch((err) => { + console.log('isTestable err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('isTestable exception: ' + JSON.stringify(e)); + } + ``` + +### isTestOsAccount(deprecated) isTestOsAccount(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isTestable](#istestable9) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -299,7 +591,7 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void | -------- | ---------------------------- | ---- | ----------------------------------------------- | | callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -309,12 +601,16 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void }); ``` -### isTestOsAccount +### isTestOsAccount(deprecated) isTestOsAccount(): Promise<boolean> 检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isTestable](#istestable9-1) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **返回值:** @@ -323,7 +619,7 @@ isTestOsAccount(): Promise<boolean> | :--------------------- | :----------------------------------------------------------- | | Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -334,12 +630,114 @@ isTestOsAccount(): Promise<boolean> }); ``` -### isOsAccountVerified +### isVerified9+ + +isVerified(callback: AsyncCallback<boolean>): void + +检查当前系统帐号是否已验证,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isVerified((err, isVeri) => { + console.log('isVerified err: ' + JSON.stringify(err)); + console.log('isVerified isVeri: ' + isVeri); + }); + } catch (e) { + console.log('isVerified exception: ' + JSON.stringify(e)); + } + ``` + +### isVerified9+ + +isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void + +检查指定系统帐号是否已验证,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| localId | number | 否 | 指定的系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isVerified((err, isVeri) => { + console.log('isVerified err: ' + JSON.stringify(err)); + console.log('isVerified isVeri: ' + isVeri); + }); + } catch (e) { + console.log('isVerified exception: ' + JSON.stringify(e)); + } + ``` + +### isVerified9+ + +isOsAccountVerified(localId?: number): Promise<boolean> + +检查指定系统帐号是否已验证,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------ | +| localId | number | 否 | 指定的系统帐号ID。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.isVerified().then((isVeri) => { + console.log('isVerified, isVeri: ' + isVeri); + }).catch((err) => { + console.log('isVerified err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('isVerified exception: ' + JSON.stringify(e)); + } + ``` + +### isOsAccountVerified(deprecated) isOsAccountVerified(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否已验证,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -348,7 +746,7 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void | -------- | ---------------------------- | ---- | ------------------------------------------- | | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -358,12 +756,16 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void }); ``` -### isOsAccountVerified +### isOsAccountVerified(deprecated) isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void 检查指定系统帐号是否已验证,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -375,7 +777,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo | localId | number | 否 | 指定的系统帐号ID。 | | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -385,12 +787,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo }); ``` -### isOsAccountVerified +### isOsAccountVerified(deprecated) isOsAccountVerified(localId?: number): Promise<boolean> 检查指定系统帐号是否已验证,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[isVerified](#isverified9-2) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -407,7 +813,7 @@ isOsAccountVerified(localId?: number): Promise<boolean> | :--------------------- | :----------------------------------------------------------- | | Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -437,15 +843,19 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void | localId | number | 是 | 要删除的系统帐号ID。 | | callback | AsyncCallback<void> | 是 | 回调结果。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { - accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{ - console.log('removeOsAccount err:' + JSON.stringify(err)); + try { + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => { + accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{ + console.log('removeOsAccount err:' + JSON.stringify(err)); + }); }); - }); + } catch (e) { + console.log('removeOsAccount exception:' + JSON.stringify(e)); + } ``` ### removeOsAccount @@ -472,17 +882,21 @@ removeOsAccount(localId: number): Promise<void> | :------------------ | :---------------------------------- | | Promise<void> | Promise实例,用于获取异步返回结果。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ - accountManager.removeOsAccount(osAccountInfo.localId).then(() => { - console.log('removeOsAccount Success'); - }).catch(() => { - console.log('removeOsAccount err: ' + JSON.stringify(err)); + try { + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + accountManager.removeOsAccount(osAccountInfo.localId).then(() => { + console.log('removeOsAccount Success'); + }).catch(() => { + console.log('removeOsAccount err: ' + JSON.stringify(err)); + }); }); - }); + } catch (e) { + console.log('removeOsAccount exception:' + JSON.stringify(e)); + } ``` ### setOsAccountConstraints @@ -511,9 +925,13 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.setOsAccountConstraints(localId, ['constraint.wifi'], true, (err)=>{ - console.log('setOsAccountConstraints err:' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountConstraints(localId, ['constraint.wifi'], true, (err)=>{ + console.log('setOsAccountConstraints err:' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountConstraints exception:' + JSON.stringify(e)); + } ``` ### setOsAccountConstraints @@ -547,11 +965,15 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => { - console.log('setOsAccountConstraints Success'); - }).catch((err) => { - console.log('setOsAccountConstraints err: ' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => { + console.log('setOsAccountConstraints Success'); + }).catch((err) => { + console.log('setOsAccountConstraints err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountConstraints exception:' + JSON.stringify(e)); + } ``` ### setOsAccountName @@ -580,9 +1002,13 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< let accountManager = account_osAccount.getAccountManager(); let localId = 100; let newName = 'demoName'; - accountManager.setOsAccountName(localId, newName, (err)=>{ - console.debug('setOsAccountName err:' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountName(localId, newName, (err)=>{ + console.debug('setOsAccountName err:' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountName exception:' + JSON.stringify(e)); + } ``` ### setOsAccountName @@ -616,19 +1042,88 @@ setOsAccountName(localId: number, localName: string): Promise<void> let accountManager = account_osAccount.getAccountManager(); let localId = 100; let nameLimit = 'demoName'; - accountManager.setOsAccountName(localId, nameLimit).then(() => { - console.log('setOsAccountName Success'); - }).catch((err) => { - console.log('setOsAccountName err: ' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountName(localId, nameLimit).then(() => { + console.log('setOsAccountName Success'); + }).catch((err) => { + console.log('setOsAccountName err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountName exception:' + JSON.stringify(e)); + } ``` -### getCreatedOsAccountsCount +### getOsAccountCount9+ + +getOsAccountCount(callback: AsyncCallback<number>): void + +获取已创建的系统帐号数量,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getOsAccountCount((err, accountCnt)=>{ + console.log('obtains the number of all os accounts created err:' + JSON.stringify(err)); + console.log('obtains the number of all os accounts created accountCnt:' + accountCnt); + }); + } catch (e) { + console.log('obtains the number of all os accounts created exception:' + JSON.stringify(e)); + } + ``` + +### getOsAccountCount9+ + +getOsAccountCount(): Promise<number> + +获取已创建的系统帐号数量,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getOsAccountCount().then((accountCnt) => { + console.log('getOsAccountCount, accountCnt: ' + accountCnt); + }).catch((err) => { + console.log('getOsAccountCount err: ' + JSON.stringify(err)); + }); + } catch(e) { + console.log('getOsAccountCount exception: ' + JSON.stringify(e)); + } + ``` + +### getCreatedOsAccountsCount(deprecated) getCreatedOsAccountsCount(callback: AsyncCallback<number>): void 获取已创建的系统帐号数量,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -639,7 +1134,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void | -------- | --------------------------- | ---- | ------------------------------------------ | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -649,12 +1144,16 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void }); ``` -### getCreatedOsAccountsCount +### getCreatedOsAccountsCount(deprecated) getCreatedOsAccountsCount(): Promise<number> 获取已创建的系统帐号数量,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountCount](#getosaccountcount9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -665,7 +1164,7 @@ getCreatedOsAccountsCount(): Promise<number> | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -676,12 +1175,73 @@ getCreatedOsAccountsCount(): Promise<number> }); ``` -### getOsAccountLocalIdFromProcess +### queryOsAccountLocalIdFromProcess9+ + +queryOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void + +获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------------------- | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.queryOsAccountLocalIdFromProcess((err, accountID) => { + console.log('queryOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); + console.log('queryOsAccountLocalIdFromProcess accountID: ' + accountID); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromProcess exception: ' + JSON.stringify(e)); + } + ``` + +### queryOsAccountLocalIdFromProcess9+ + +queryOsAccountLocalIdFromProcess(): Promise<number> + +获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.queryOsAccountLocalIdFromProcess().then((accountID) => { + console.log('queryOsAccountLocalIdFromProcess, accountID: ' + accountID); + }).catch((err) => { + console.log('queryOsAccountLocalIdFromProcess err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromProcess exception: ' + JSON.stringify(e)); + } + ``` + +### getOsAccountLocalIdFromProcess(deprecated) getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void 获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -690,7 +1250,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void | -------- | --------------------------- | ---- | -------------------------------------------------- | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -700,12 +1260,16 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void }); ``` -### getOsAccountLocalIdFromProcess +### getOsAccountLocalIdFromProcess(deprecated) getOsAccountLocalIdFromProcess(): Promise<number> 获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromProcess](#queryosaccountlocalidfromprocess9-1) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **返回值:** @@ -714,7 +1278,7 @@ getOsAccountLocalIdFromProcess(): Promise<number> | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -725,12 +1289,82 @@ getOsAccountLocalIdFromProcess(): Promise<number> }); ``` -### getOsAccountLocalIdFromUid +### queryOsAccountLocalIdFromUid9+ + +queryOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void + +从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| uid | number | 是 | 进程uid。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 | + +**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID + + ```js + let accountManager = account_osAccount.getAccountManager(); + let uid = 12345678; + try { + accountManager.queryOsAccountLocalIdFromUid(uid, (err, accountID) => { + console.log('queryOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); + console.log('queryOsAccountLocalIdFromUid: ' + accountID); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromUid exception: ' + JSON.stringify(e)); + } + ``` + +### queryOsAccountLocalIdFromUid9+ + +queryOsAccountLocalIdFromUid(uid: number): Promise<number> + +从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------- | +| uid | number | 是 | 进程uid。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 | + +**示例:** 查询值为12345678的uid所属的系统帐号的帐号ID + + ```js + let accountManager = account_osAccount.getAccountManager(); + let uid = 12345678; + try { + accountManager.queryOsAccountLocalIdFromUid(uid).then((accountID) => { + console.log('queryOsAccountLocalIdFromUid: ' + accountID); + }).catch((err) => { + console.log('queryOsAccountLocalIdFromUid err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromUid exception: ' + JSON.stringify(e)); + } + ``` + +### getOsAccountLocalIdFromUid(deprecated) getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void 从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -751,12 +1385,16 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): }); ``` -### getOsAccountLocalIdFromUid +### getOsAccountLocalIdFromUid(deprecated) getOsAccountLocalIdFromUid(uid: number): Promise<number> 从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromUid](#queryosaccountlocalidfromuid9-1) +> +> 从 API version 7开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -783,12 +1421,86 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> }); ``` -### getOsAccountLocalIdFromDomain8+ +### queryOsAccountLocalIdFromDomain9+ + +getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void + +根据域帐号信息,获取与其关联的系统帐号的帐号ID。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | -------------------------------------------- | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | + +**示例:** + + ```js + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.queryOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { + console.log('queryOsAccountLocalIdFromDomain: ' + JSON.stringify(err)); + console.log('queryOsAccountLocalIdFromDomain: ' + accountID); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromDomain: ' + JSON.stringify(e)); + } + ``` + +### queryOsAccountLocalIdFromDomain9+ + +queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> + +根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | ------------ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; + try { + accountManager.queryOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { + console.log('queryOsAccountLocalIdFromDomain: ' + accountID); + }).catch((err) => { + console.log('queryOsAccountLocalIdFromDomain err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryOsAccountLocalIdFromDomain exception: ' + JSON.stringify(e)); + } + ``` + +### getOsAccountLocalIdFromDomain(deprecated) getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void 根据域帐号信息,获取与其关联的系统帐号的帐号ID。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9) +> +> 从 API version 8开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -800,7 +1512,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall | domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | -**示例:** +**示例:** ```js let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; @@ -811,12 +1523,16 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall }); ``` -### getOsAccountLocalIdFromDomain8+ +### getOsAccountLocalIdFromDomain(deprecated) getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> 根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdFromDomain](#queryosaccountlocalidfromdomain9-1) +> +> 从 API version 8开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -833,7 +1549,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number& | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -861,14 +1577,18 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void | -------- | --------------------------- | ---- | ------------------------------------------------ | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ - console.log('queryMaxOsAccountNumber err:' + JSON.stringify(err)); - console.log('queryMaxOsAccountNumber maxCnt:' + maxCnt); - }); + try { + accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ + console.log('queryMaxOsAccountNumber err:' + JSON.stringify(err)); + console.log('queryMaxOsAccountNumber maxCnt:' + maxCnt); + }); + } catch (e) { + console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(e)); + } ``` ### queryMaxOsAccountNumber @@ -887,23 +1607,101 @@ queryMaxOsAccountNumber(): Promise<number> | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryMaxOsAccountNumber().then((maxCnt) => { - console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); - }).catch((err) => { - console.log('queryMaxOsAccountNumber err: ' + JSON.stringify(err)); - }); + try { + accountManager.queryMaxOsAccountNumber().then((maxCnt) => { + console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); + }).catch((err) => { + console.log('queryMaxOsAccountNumber err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryMaxOsAccountNumber exception:' + JSON.stringify(e)); + } + ``` + +### getOsAccountConstraints9+ + +getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<string>>): void + +获取指定系统帐号的全部约束,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | + +**示例:** 获取ID为100的系统帐号的全部约束 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.getOsAccountConstraints(localId, (err, constraints)=>{ + console.log('getOsAccountConstraints err:' + JSON.stringify(err)); + console.log('getOsAccountConstraints:' + JSON.stringify(constraints)); + }); + } catch (e) { + console.log('getOsAccountConstraints exception:' + JSON.stringify(e)); + } + ``` + +### getOsAccountConstraints9+ + +getOsAccountConstraints(localId: number): Promise<Array<string>> + +获取指定系统帐号的全部约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | + +**示例:** 获取ID为100的系统帐号的全部约束 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.getOsAccountConstraints(localId).then((constraints) => { + console.log('getOsAccountConstraints, constraints: ' + constraints); + }).catch((err) => { + console.log('getOsAccountConstraints err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getOsAccountConstraints exception:' + JSON.stringify(e)); + } ``` -### getOsAccountAllConstraints +### getOsAccountAllConstraints(deprecated) getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void 获取指定系统帐号的全部约束,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -926,10 +1724,14 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array< }); ``` -### getOsAccountAllConstraints +### getOsAccountAllConstraints(deprecated) getOsAccountAllConstraints(localId: number): Promise<Array<string>> +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountConstraints](#getosaccountconstraints9-1) +> +> 从 API version 7开始支持。 + 获取指定系统帐号的全部约束,使用Promise方式异步返回结果。 **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS @@ -978,14 +1780,18 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& | -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ - console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); - console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); - }); + try { + accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ + console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); + console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); + }); + } catch (e) { + console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e)); + } ``` ### queryAllCreatedOsAccounts @@ -1006,23 +1812,91 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> | :---------------------------------------------------------- | :----------------------------------------------------------- | | Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryAllCreatedOsAccounts().then((accountArr) => { - console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); - }).catch((err) => { - console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err)); - }); + try { + accountManager.queryAllCreatedOsAccounts().then((accountArr) => { + console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); + }).catch((err) => { + console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryAllCreatedOsAccounts exception:' + JSON.stringify(e)); + } + ``` + +### getActivatedOsAccountIds9+ + +getActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void + +查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getActivatedOsAccountIds((err, idArray)=>{ + console.log('getActivatedOsAccountIds err:' + JSON.stringify(err)); + console.log('getActivatedOsAccountIds idArray length:' + idArray.length); + for(let i=0;i9+ + +getActivatedOsAccountIds(): Promise<Array<number>> + +查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getActivatedOsAccountIds().then((idArray) => { + console.log('getActivatedOsAccountIds, idArray: ' + idArray); + }).catch((err) => { + console.log('getActivatedOsAccountIds err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getActivatedOsAccountIds exception:' + JSON.stringify(e)); + } ``` -### queryActivatedOsAccountIds8+ +### queryActivatedOsAccountIds(deprecated) queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void 查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9) +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -1031,7 +1905,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): | -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | | callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1044,10 +1918,14 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): }); ``` -### queryActivatedOsAccountIds8+ +### queryActivatedOsAccountIds(deprecated) queryActivatedOsAccountIds(): Promise<Array<number>> +> **说明:** 从API version 9开始废弃,建议使用[getActivatedOsAccountIds](#getactivatedosaccountids9-1) +> +> 从 API version 8开始支持。 + 查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。 **系统能力:** SystemCapability.Account.OsAccount @@ -1058,7 +1936,7 @@ queryActivatedOsAccountIds(): Promise<Array<number>> | :--------------------------------- | :----------------------------------------------------------- | | Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1089,14 +1967,18 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ - console.log('createOsAccount err:' + JSON.stringify(err)); - console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); - }); + try { + accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ + console.log('createOsAccount err:' + JSON.stringify(err)); + console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo)); + }); + } catch (e) { + console.log('createOsAccount exception:' + JSON.stringify(e)); + } ``` ### createOsAccount @@ -1124,15 +2006,19 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf | :--------------------------------------------- | :----------------------------------------------------------- | | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { - console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); - }).catch((err) => { - console.log('createOsAccount err: ' + JSON.stringify(err)); - }); + try { + accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then((accountInfo) => { + console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); + }).catch((err) => { + console.log('createOsAccount err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('createOsAccount exception:' + JSON.stringify(e)); + } ``` ### createOsAccountForDomain8+ @@ -1155,15 +2041,19 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal | domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号信息。 | | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; - accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ - console.log('createOsAccountForDomain err:' + JSON.stringify(err)); - console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); - }); + try { + accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ + console.log('createOsAccountForDomain err:' + JSON.stringify(err)); + console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo)); + }); + } catch (e) { + console.log('createOsAccountForDomain exception:' + JSON.stringify(e)); + } ``` ### createOsAccountForDomain8+ @@ -1191,24 +2081,93 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr | :--------------------------------------------- | :----------------------------------------------------------- | | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); let domainInfo = {domain: 'testDomain', accountName: 'testAccountName'}; - accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { - console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo)); - }).catch((err) => { - console.log('createOsAccountForDomain err: ' + JSON.stringify(err)); - }); + try { + accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { + console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo)); + }).catch((err) => { + console.log('createOsAccountForDomain err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('createOsAccountForDomain exception:' + JSON.stringify(e)); + } + ``` + +### getCurrentOsAccount9+ + +getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void + +查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getCurrentOsAccount((err, curAccountInfo)=>{ + console.log('getCurrentOsAccount err:' + JSON.stringify(err)); + console.log('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo)); + }); + } catch (e) { + console.log('getCurrentOsAccount exception:' + JSON.stringify(e)); + } + ``` + +### getCurrentOsAccount9+ + +getCurrentOsAccount(): Promise<OsAccountInfo> + +查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getCurrentOsAccount().then((accountInfo) => { + console.log('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo)); + }).catch((err) => { + console.log('getCurrentOsAccount err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getCurrentOsAccount exception:' + JSON.stringify(e)); + } ``` -### queryCurrentOsAccount +### queryCurrentOsAccount(deprecated) queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void 查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1219,7 +2178,7 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void | -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1229,12 +2188,16 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void }); ``` -### queryCurrentOsAccount +### queryCurrentOsAccount(deprecated) queryCurrentOsAccount(): Promise<OsAccountInfo> 查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[getCurrentOsAccount](#getcurrentosaccount9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1245,7 +2208,7 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> | :--------------------------------------------- | :----------------------------------------------------------- | | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1280,10 +2243,14 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ - console.log('queryOsAccountById err:' + JSON.stringify(err)); - console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); - }); + try { + accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ + console.log('queryOsAccountById err:' + JSON.stringify(err)); + console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); + }); + } catch (e) { + console.log('queryOsAccountById exception:' + JSON.stringify(e)); + } ``` ### queryOsAccountById @@ -1310,73 +2277,207 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> | :--------------------------------------------- | :----------------------------------------------------------- | | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 | -**示例:** 查询ID为100的系统帐号信息 +**示例:** 查询ID为100的系统帐号信息 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.queryOsAccountById(localId).then((accountInfo) => { + console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo)); + }).catch((err) => { + console.log('queryOsAccountById err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryOsAccountById exception:' + JSON.stringify(e)); + } + ``` + +### getOsAccountType9+ + +getOsAccountType(callback: AsyncCallback<OsAccountType>): void + +查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | +| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getOsAccountType((err, accountType) => { + console.log('getOsAccountType err: ' + JSON.stringify(err)); + console.log('getOsAccountType accountType: ' + accountType); + }); + } catch (e) { + console.log('getOsAccountType exception: ' + JSON.stringify(e)); + } + ``` + +### getOsAccountType9+ + +getOsAccountType(): Promise<OsAccountType> + +查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + try { + accountManager.getOsAccountType().then((accountType) => { + console.log('getOsAccountType, accountType: ' + accountType); + }).catch((err) => { + console.log('getOsAccountType err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getOsAccountType exception: ' + JSON.stringify(e)); + } + ``` + +### getOsAccountTypeFromProcess(deprecated) + +getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void + +查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。 + +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9) +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | +| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | + +**示例:** + + ```js + let accountManager = account_osAccount.getAccountManager(); + accountManager.getOsAccountTypeFromProcess((err, accountType) => { + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess accountType: ' + accountType); + }); + ``` + +### getOsAccountTypeFromProcess(deprecated) + +getOsAccountTypeFromProcess(): Promise<OsAccountType> + +查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。 + +> **说明:** 从API version 9开始废弃,建议使用[getOsAccountType](#getosaccounttype9-1) +> +> 从 API version 7开始支持。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | + +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - let localId = 100; - accountManager.queryOsAccountById(localId).then((accountInfo) => { - console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo)); + accountManager.getOsAccountTypeFromProcess().then((accountType) => { + console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); }).catch((err) => { - console.log('queryOsAccountById err: ' + JSON.stringify(err)); + console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); }); ``` -### getOsAccountTypeFromProcess +### queryDistributedVirtualDeviceId9+ -getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void +queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void -查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。 +获取分布式虚拟设备ID,使用callback回调异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | -| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.getOsAccountTypeFromProcess((err, accountType) => { - console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); - console.log('getOsAccountTypeFromProcess accountType: ' + accountType); - }); + try { + accountManager.queryDistributedVirtualDeviceId((err, virtualID) => { + console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); + console.log('queryDistributedVirtualDeviceId virtualID: ' + virtualID); + }); + } catch (e) { + console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e)); + } ``` -### getOsAccountTypeFromProcess +### queryDistributedVirtualDeviceId9+ -getOsAccountTypeFromProcess(): Promise<OsAccountType> +queryDistributedVirtualDeviceId(): Promise<string> -查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。 +获取分布式虚拟设备ID,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount **返回值:** -| 类型 | 说明 | -| :--------------------------------------------- | :----------------------------------------------------------- | -| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.getOsAccountTypeFromProcess().then((accountType) => { - console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); - }).catch((err) => { - console.log('getOsAccountTypeFromProcess err: ' + JSON.stringify(err)); - }); + try { + accountManager.queryDistributedVirtualDeviceId().then((virtualID) => { + console.log('queryDistributedVirtualDeviceId, virtualID: ' + virtualID); + }).catch((err) => { + console.log('queryDistributedVirtualDeviceId err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryDistributedVirtualDeviceId exception: ' + JSON.stringify(e)); + } ``` -### getDistributedVirtualDeviceId +### getDistributedVirtualDeviceId(deprecated) getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void 获取分布式虚拟设备ID,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1387,7 +2488,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void | -------- | --------------------------- | ---- | ------------------------------------ | | callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1397,12 +2498,16 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void }); ``` -### getDistributedVirtualDeviceId +### getDistributedVirtualDeviceId(deprecated) getDistributedVirtualDeviceId(): Promise<string> 获取分布式虚拟设备ID,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1) +> +> 从 API version 7开始支持。 + **需要权限:** ohos.permission.DISTRIBUTED_DATASYNC 或 ohos.permission.MANAGE_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1413,7 +2518,7 @@ getDistributedVirtualDeviceId(): Promise<string> | :-------------------- | :----------------------------------------------------------- | | Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); @@ -1448,10 +2553,14 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ - console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err)); - console.log('get photo:' + photo + ' by localId: ' + localId); - }); + try { + accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ + console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err)); + console.log('get photo:' + photo + ' by localId: ' + localId); + }); + } catch (e) { + console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e)); + } ``` ### getOsAccountProfilePhoto @@ -1483,11 +2592,15 @@ getOsAccountProfilePhoto(localId: number): Promise<string> ```js let accountManager = account_osAccount.getAccountManager(); let localId = 100; - accountManager.getOsAccountProfilePhoto(localId).then((photo) => { - console.log('getOsAccountProfilePhoto: ' + photo); - }).catch((err) => { - console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err)); - }); + try { + accountManager.getOsAccountProfilePhoto(localId).then((photo) => { + console.log('getOsAccountProfilePhoto: ' + photo); + }).catch((err) => { + console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getOsAccountProfilePhoto exception:' + JSON.stringify(e)); + } ``` ### setOsAccountProfilePhoto @@ -1519,9 +2632,13 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' - accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ - console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ + console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e)); + } ``` ### setOsAccountProfilePhoto @@ -1558,19 +2675,93 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+ '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==' - accountManager.setOsAccountProfilePhoto(localId, photo).then(() => { - console.log('setOsAccountProfilePhoto success'); - }).catch((err) => { - console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err)); - }); + try { + accountManager.setOsAccountProfilePhoto(localId, photo).then(() => { + console.log('setOsAccountProfilePhoto success'); + }).catch((err) => { + console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setOsAccountProfilePhoto exception:' + JSON.stringify(e)); + } + ``` + +### queryOsAccountLocalIdBySerialNumber9+ + +queryOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void + +通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | --------------------------- | ---- | ------------------------------------------------ | +| serialNumber | number | 是 | 帐号SN码。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 | + +**示例:** 查询与SN码12345关联的系统帐号的ID + + ```js + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; + try { + accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ + console.log('ger localId err:' + JSON.stringify(err)); + console.log('get localId:' + localId + ' by serialNumber: ' + serialNumber); + }); + } catch (e) { + console.log('ger localId exception:' + JSON.stringify(e)); + } + ``` + +### queryOsAccountLocalIdBySerialNumber9+ + +queryOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> + +通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------ | ---- | ---------- | +| serialNumber | number | 是 | 帐号SN码。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 | + +**示例:** 查询与SN码12345关联的系统帐号的ID + + ```js + let accountManager = account_osAccount.getAccountManager(); + let serialNumber = 12345; + try { + accountManager.queryOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { + console.log('queryOsAccountLocalIdBySerialNumber localId: ' + localId); + }).catch((err) => { + console.log('queryOsAccountLocalIdBySerialNumber err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('queryOsAccountLocalIdBySerialNumber exception: ' + JSON.stringify(e)); + } ``` -### getOsAccountLocalIdBySerialNumber8+ +### getOsAccountLocalIdBySerialNumber(deprecated) getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void 通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9) +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -1591,12 +2782,16 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& }); ``` -### getOsAccountLocalIdBySerialNumber8+ +### getOsAccountLocalIdBySerialNumber(deprecated) getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> 通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[queryOsAccountLocalIdBySerialNumber](#queryosaccountlocalidbyserialnumber9-1) +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -1623,12 +2818,82 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> }); ``` -### getSerialNumberByOsAccountLocalId8+ +### querySerialNumberByOsAccountLocalId9+ + +querySerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void + +通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 | + +**示例:** 获取ID为100的系统帐号关联的SN码 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.querySerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ + console.log('ger serialNumber err:' + JSON.stringify(err)); + console.log('get serialNumber:' + serialNumber + ' by localId: ' + localId); + }); + } catch (e) { + console.log('ger serialNumber exception:' + JSON.stringify(e)); + } + ``` + +### querySerialNumberByOsAccountLocalId9+ + +querySerialNumberByOsAccountLocalId(localId: number): Promise<number> + +通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 | + +**示例:** 获取ID为100的系统帐号关联的SN码 + + ```js + let accountManager = account_osAccount.getAccountManager(); + let localId = 100; + try { + accountManager.querySerialNumberByOsAccountLocalId(localId).then((serialNumber) => { + console.log('querySerialNumberByOsAccountLocalId serialNumber: ' + serialNumber); + }).catch((err) => { + console.log('querySerialNumberByOsAccountLocalId err: ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('querySerialNumberByOsAccountLocalId exception:' + JSON.stringify(e)); + } + ``` + +### getSerialNumberByOsAccountLocalId(deprecated) getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void 通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9) +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -1649,12 +2914,16 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu }); ``` -### getSerialNumberByOsAccountLocalId8+ +### getSerialNumberByOsAccountLocalId(deprecated) getSerialNumberByOsAccountLocalId(localId: number): Promise<number> 通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。 +> **说明:** 从API version 9开始废弃,建议使用[querySerialNumberByOsAccountLocalId](#queryserialnumberbyosaccountlocalid9-1) +> +> 从 API version 8开始支持。 + **系统能力:** SystemCapability.Account.OsAccount **参数:** @@ -1701,14 +2970,18 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g | name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 | | callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ console.log('receive localId:' + receiveLocalId); } - accountManager.on('activating', 'osAccountOnOffNameA', onCallback); + try { + accountManager.on('activating', 'osAccountOnOffNameA', onCallback); + } catch (e) { + console.log('receive localId exception:' + JSON.stringify(e)); + } ``` ### off @@ -1731,14 +3004,18 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number | name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 | | callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); function offCallback(){ console.log('off enter') } - accountManager.off('activating', 'osAccountOnOffNameA', offCallback); + try { + accountManager.off('activating', 'osAccountOnOffNameA', offCallback); + } catch (e) { + console.log('off exception:' + JSON.stringify(e)); + } ``` ### getBundleIdFromUid9+ @@ -1758,15 +3035,19 @@ getBundleIdFromUid(uid: number, callback: AsyncCallback<number>): void; | uid | number | 是 | 进程uid。 | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是与uid对应的bundleId。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); let testUid = 1000000; - accountManager.getBundleIdFromUid(testUid, (err, bundleId) => { - console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); - console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId)); - }); + try { + accountManager.getBundleIdFromUid(testUid, (err, bundleId) => { + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(bundleId)); + }); + } catch (e) { + console.info('getBundleIdFromUid exception:' + JSON.stringify(e)); + } ``` ### getBundleIdFromUid9+ @@ -1790,16 +3071,20 @@ getBundleIdFromUid(uid: number): Promise<number>; | :-------------------- | :----------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回的是与uid对应的bundleId。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); let testUid = 1000000; - accountManager.getBundleIdFromUid(testUid).then((result) => { - console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result)); - }).catch((err)=>{ - console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); - }); + try { + accountManager.getBundleIdFromUid(testUid).then((result) => { + console.info('getBundleIdFromUid bundleId:' + JSON.stringify(result)); + }).catch((err)=>{ + console.info('getBundleIdFromUid errInfo:' + JSON.stringify(err)); + }); + } catch (e) { + console.info('getBundleIdFromUid exception:' + JSON.stringify(e)); + } ``` ### isMainOsAccount9+ @@ -1810,7 +3095,7 @@ isMainOsAccount(callback: AsyncCallback<boolean>): void; 此接口为系统接口,三方应用不支持调用。 -**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1820,14 +3105,18 @@ isMainOsAccount(callback: AsyncCallback<boolean>): void; | -------- | -------------------------- | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<boolean> | 是 | 回调结果,返回的是当前进程是否处于主用户,是则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.isMainOsAccount((err,result)=>{ - console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); - console.info('isMainOsAccount result:' + JSON.stringify(result)); - }); + try { + accountManager.isMainOsAccount((err,result)=>{ + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); + console.info('isMainOsAccount result:' + JSON.stringify(result)); + }); + } catch (e) { + console.info('isMainOsAccount exception:' + JSON.stringify(e)); + } ``` ### isMainOsAccount9+ @@ -1837,7 +3126,7 @@ isMainOsAccount(): Promise<boolean>; 此接口为系统接口,三方应用不支持调用。 -**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1847,15 +3136,19 @@ isMainOsAccount(): Promise<boolean>; | :-------------------- | :----------------------------------------------------------- | | Promise<boolean> | Promise实例,用于获取异步返回结果,回调结果,返回的是当前进程是否处于主用户,是则返回true,否则返回false。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.isMainOsAccount().then((result) => { - console.info('isMainOsAccount result:' + JSON.stringify(result)); - }).catch((err)=>{ - console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); - }); + try { + accountManager.isMainOsAccount().then((result) => { + console.info('isMainOsAccount result:' + JSON.stringify(result)); + }).catch((err)=>{ + console.info('isMainOsAccount errInfo:' + JSON.stringify(err)); + }); + } catch (e) { + console.info('isMainOsAccount exception:' + JSON.stringify(e)); + } ``` ### queryOsAccountConstraintSourceTypes9+ @@ -1865,7 +3158,7 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callbac 此接口为系统接口,三方应用不支持调用。 -**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1877,14 +3170,18 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callbac | constraint | string | 是 | 要查询的[约束](#系统帐号约束列表)名称 | | callback | AsyncCallback<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | 是 | 回调结果,返回的是指定系统帐号的指定[约束](#系统帐号约束列表)来源信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{ - console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); - console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos)); - }); + try { + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi',(err,sourceTypeInfos)=>{ + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(sourceTypeInfos)); + }); + } catch (e) { + console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e)); + } ``` ### queryOsAccountConstraintSourceTypes9+ @@ -1895,7 +3192,7 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis 此接口为系统接口,三方应用不支持调用。 -**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.GET_LOCAL_ACCOUNTS **系统能力:** SystemCapability.Account.OsAccount @@ -1912,15 +3209,19 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis | :-------------------- | :----------------------------------------------------------- | | Promise<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | Promise实例,用于获取异步返回结果,返回的是指定系统帐号的指定[约束](#系统帐号约束列表)来源信息。 | -**示例:** +**示例:** ```js let accountManager = account_osAccount.getAccountManager(); - accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => { - console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result)); - }).catch((err)=>{ - console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); - }); + try { + accountManager.queryOsAccountConstraintSourceTypes(100, 'constraint.wifi').then((result) => { + console.info('queryOsAccountConstraintSourceType sourceTypeInfos:' + JSON.stringify(result)); + }).catch((err)=>{ + console.info('queryOsAccountConstraintSourceType errInfo:' + JSON.stringify(err)); + }); + } catch (e) { + console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e)); + } ``` ## UserAuth8+ @@ -1998,8 +3299,12 @@ getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number; let userAuth = new account_osAccount.UserAuth(); let authType = account_osAccount.AuthType.PIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; - let status = userAuth.getAvailableStatus(authType, authTrustLevel); - console.log('getAvailableStatus status = ' + status); + try { + let status = userAuth.getAvailableStatus(authType, authTrustLevel); + console.log('getAvailableStatus status = ' + status); + } catch (e) { + console.log('getAvailableStatus exception = ' + JSON.stringify(e)); + } ``` ### getProperty8+ @@ -2021,7 +3326,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp | request | [GetPropertyRequest](#getpropertyrequest8) | 是 | 请求信息,包括认证类型和属性类型列表。 | | callback | AsyncCallback<[ExecutorProperty](#executorproperty8)> | 是 | 回调结果,返回的是调用者属性。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let keys = [ @@ -2033,10 +3338,14 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp authType: account_osAccount.AuthType.PIN, keys: keys }; - userAuth.getProperty(request, (err, result) => { - console.log('getProperty err = ' + JSON.stringify(err)); - console.log('getProperty result = ' + JSON.stringify(result)); - }); + try { + userAuth.getProperty(request, (err, result) => { + console.log('getProperty err = ' + JSON.stringify(err)); + console.log('getProperty result = ' + JSON.stringify(result)); + }); + } catch (e) { + console.log('getProperty exception = ' + JSON.stringify(e)); + } ``` ### getProperty8+ @@ -2063,7 +3372,7 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>; | :---------------------------------------------------------------- | :-------------------------------------------------- | | Promise<[ExecutorProperty](#executorproperty8)> | Promise实例,用于获取异步返回结果,返回的是调用者属性。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let keys = [ @@ -2075,11 +3384,15 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>; authType: account_osAccount.AuthType.PIN, keys: keys }; - userAuth.getProperty(request).then((result) => { - console.log('getProperty result = ' + JSON.stringify(result)); - }).catch((err) => { - console.log('getProperty error = ' + JSON.stringify(err)); - }); + try { + userAuth.getProperty(request).then((result) => { + console.log('getProperty result = ' + JSON.stringify(result)); + }).catch((err) => { + console.log('getProperty error = ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getProperty exception = ' + JSON.stringify(e)); + } ``` ### setProperty8+ @@ -2101,7 +3414,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): | request | [SetPropertyRequest](#setpropertyrequest8)| 是 | 请求信息,包括认证类型和要设置的密钥值。 | | callback | AsyncCallback<number> | 是 | 回调结果,返回一个[数值](#resultcode8),指示属性设置是否成功。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let request = { @@ -2109,10 +3422,14 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): key: account_osAccount.SetPropertyType.INIT_ALGORITHM, setInfo: new Uint8Array([0]) }; - userAuth.setProperty(request, (err, result) => { - console.log('setProperty error = ' + JSON.stringify(err)); - console.log('setProperty result = ' + JSON.stringify(result)); - }); + try { + userAuth.setProperty(request, (err, result) => { + console.log('setProperty error = ' + JSON.stringify(err)); + console.log('setProperty result = ' + JSON.stringify(result)); + }); + } catch (e) { + console.log('setProperty exception = ' + JSON.stringify(e)); + } ``` ### setProperty8+ @@ -2139,7 +3456,7 @@ setProperty(request: SetPropertyRequest): Promise<number>; | :-------------------- | :-------------------------------------------------------------------------------------------- | | Promise<number> | Promise实例,用于获取异步返回结果,返回一个[数值](#resultcode8),指示属性设置是否成功。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let request = { @@ -2147,11 +3464,15 @@ setProperty(request: SetPropertyRequest): Promise<number>; key: account_osAccount.SetPropertyType.INIT_ALGORITHM, setInfo: new Uint8Array([0]) }; - userAuth.setProperty(request).then((result) => { - console.log('setProperty result = ' + JSON.stringify(result)); - }).catch((err) => { - console.log('setProperty error = ' + JSON.stringify(err)); - }); + try { + userAuth.setProperty(request).then((result) => { + console.log('setProperty result = ' + JSON.stringify(result)); + }).catch((err) => { + console.log('setProperty error = ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('setProperty exception = ' + JSON.stringify(e)); + } ``` ### auth8+ @@ -2182,18 +3503,22 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, | :--------- | :----------------- | | Uint8Array | 返回取消的上下文ID。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let challenge = new Uint8Array([0]); let authType = account_osAccount.AuthType.PIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; - userAuth.auth(challenge, authType, authTrustLevel, { - onResult: function(result,extraInfo){ - console.log('auth result = ' + result); - console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); - } - }); + try { + userAuth.auth(challenge, authType, authTrustLevel, { + onResult: function(result,extraInfo){ + console.log('auth result = ' + result); + console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); + } + }); + } catch (e) { + console.log('auth exception = ' + JSON.stringify(e)); + } ``` ### authUser8+ @@ -2225,24 +3550,28 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev | :--------- | :----------------- | | Uint8Array | 返回取消的上下文ID。 | -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let userID = 100; let challenge = new Uint8Array([0]); let authType = account_osAccount.AuthType.PIN; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; - userAuth.authUser(userID, challenge, authType, authTrustLevel, { - onResult: function(result,extraInfo){ - console.log('authUser result = ' + result); - console.log('authUser extraInfo = ' + JSON.stringify(extraInfo)); - } - }); + try { + userAuth.authUser(userID, challenge, authType, authTrustLevel, { + onResult: function(result,extraInfo){ + console.log('authUser result = ' + result); + console.log('authUser extraInfo = ' + JSON.stringify(extraInfo)); + } + }); + } catch (e) { + console.log('authUser exception = ' + JSON.stringify(e)); + } ``` ### cancelAuth8+ -cancelAuth(contextID: Uint8Array): number; +cancelAuth(contextID: Uint8Array): void; 取消特定的认证。 @@ -2258,13 +3587,7 @@ cancelAuth(contextID: Uint8Array): number; | ----------| ---------- | ---- | ------------------------------------------ | | contextID | Uint8Array | 是 | 指示身份验证上下文ID,此ID动态生成没有具体值。 | -**返回值:** - -| 类型 | 说明 | -| :----- | :-------------------------------------------------------- | -| number | 返回一个[数字](#resultcode8),指示取消是否成功。 | - -**示例:** +**示例:** ```js let userAuth = new account_osAccount.UserAuth(); let pinAuth = new account_osAccount.PINAuth(); @@ -2275,8 +3598,11 @@ cancelAuth(contextID: Uint8Array): number; console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); } }); - let result = userAuth.cancelAuth(contextID); - console.log('cancelAuth result = ' + result); + try { + userAuth.cancelAuth(contextID); + } catch (e) { + console.log('cancelAuth exception = ' + JSON.stringify(e)); + } ``` ## PINAuth8+ @@ -2300,7 +3626,7 @@ constructor() let pinAuth = new account_osAccount.PINAuth(); ``` -### registerInputer +### registerInputer8+ registerInputer(inputer: IInputer): boolean; @@ -2324,19 +3650,23 @@ registerInputer(inputer: IInputer): boolean; | :------ | :-------------------------------------------- | | boolean | 返回布尔值,true表示注册成功,false表示注册失败。 | -**示例:** +**示例:** ```js let pinAuth = new account_osAccount.PINAuth(); let password = new Uint8Array([0, 0, 0, 0, 0]); - let result = pinAuth.registerInputer({ - onGetData: (pinSubType, callback) => { - callback.onSetData(pinSubType, password); - } - }); - console.log('registerInputer result = ' + result); + try { + let result = pinAuth.registerInputer({ + onGetData: (pinSubType, callback) => { + callback.onSetData(pinSubType, password); + } + }); + console.log('registerInputer result = ' + result); + } catch (e) { + console.log('registerInputer exception = ' + JSON.stringify(e)); + } ``` -### unregisterInputer +### unregisterInputer8+ unregisterInputer(): void; @@ -2348,7 +3678,7 @@ unregisterInputer(): void; **需要权限:** ohos.permission.ACCESS_PIN_AUTH -**示例:** +**示例:** ```js let pinAuth = new account_osAccount.PINAuth(); pinAuth.unregisterInputer(); @@ -2393,13 +3723,17 @@ openSession(callback: AsyncCallback<Uint8Array>): void; | -------- | -------------------------------- | ---- | -------------------------------- | | callback | AsyncCallback<Uint8Array> | 是 | 回调结果,返回的是挑战值,非0即成功,为0则失败。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); - userIDM.openSession((err, challenge) => { - console.log('openSession error = ' + JSON.stringify(err)); - console.log('openSession challenge = ' + JSON.stringify(challenge)); - }); + try { + userIDM.openSession((err, challenge) => { + console.log('openSession error = ' + JSON.stringify(err)); + console.log('openSession challenge = ' + JSON.stringify(challenge)); + }); + } catch (e) { + console.log('openSession exception = ' + JSON.stringify(e)); + } ``` ### openSession8+ @@ -2420,14 +3754,18 @@ openSession(): Promise<Uint8Array>; | :------------------------ | :------------------------------------------------------- | | Promise<Uint8Array> | Promise实例,用于获取异步返回结果,返回的是挑战值,非0即成功,为0则失败。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); - userIDM.openSession().then((challenge) => { - console.info('openSession challenge = ' + JSON.stringify(challenge)); - }).catch((err) => { - console.info('openSession error = ' + JSON.stringify(err)); - }); + try { + userIDM.openSession().then((challenge) => { + console.info('openSession challenge = ' + JSON.stringify(challenge)); + }).catch((err) => { + console.info('openSession error = ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('openSession exception = ' + JSON.stringify(e)); + } ``` ### addCredential8+ @@ -2449,7 +3787,7 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; | credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 | | callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是结果和获取信息。 | -**示例:** +**示例:** ```js let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let pinAuth = new account_osAccount.PINAuth(); @@ -2465,12 +3803,16 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; }; let userIDM = new account_osAccount.UserIdentityManager(); userIDM.openSession((err, challenge) => { + try { userIDM.addCredential(credentialInfo, { onResult: (result, extraInfo) => { console.log('updateCredential result = ' + result); console.log('updateCredential extraInfo = ' + extraInfo); } }); + } catch (e) { + console.log('updateCredential exception = ' + JSON.stringify(e)); + } }); ``` @@ -2493,7 +3835,7 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; | credentialInfo | [CredentialInfo](#credentialinfo8) | 是 | 指示凭据信息。 | | callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是结果和获取信息。 | -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); let userAuth = new account_osAccount.UserAuth(); @@ -2516,12 +3858,16 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; return; } credentialInfo.token = extraInfo.token; - userIDM.updateCredential(credentialInfo, { - onResult: (result, extraInfo) => { - console.log('updateCredential result = ' + result); - console.log('updateCredential extraInfo = ' + extraInfo); - } - }); + try { + userIDM.updateCredential(credentialInfo, { + onResult: (result, extraInfo) => { + console.log('updateCredential result = ' + result); + console.log('updateCredential extraInfo = ' + extraInfo); + } + }); + } catch (e) { + console.log('updateCredential exception = ' + JSON.stringify(e)); + } } }); }); @@ -2539,7 +3885,7 @@ closeSession(): void; **需要权限:** ohos.permission.MANAGE_USER_IDM -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); userIDM.closeSession(); @@ -2547,7 +3893,7 @@ closeSession(): void; ### cancel8+ -cancel(challenge: Uint8Array): number; +cancel(challenge: Uint8Array): void; 根据挑战值取消条目。 @@ -2563,18 +3909,16 @@ cancel(challenge: Uint8Array): number; | -------- | ----------- | ---- | ----- | | challenge | Uint8Array | 是 | 挑战值。 | -**返回值:** - -| 类型 | 说明 | -| :----- | :-------------------------------------------------------- | -| number | 返回一个[数字](#resultcode8),指示取消是否成功。 | -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); let challenge = new Uint8Array([0]); - let result = userIDM.cancel(challenge); - console.log('cancel result: ' + result); + try { + userIDM.cancel(challenge); + } catch(err) { + console.log("cancel err:" + JSON.stringify(err)); + } ``` ### delUser8+ @@ -2596,16 +3940,20 @@ delUser(token: Uint8Array, callback: IIdmCallback): void; | token | Uint8Array | 是 | 身份验证令牌。 | | callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是删除结果。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); let token = new Uint8Array([0]); - userIDM.delUser(token, { - onResult: (result, extraInfo) => { - console.log('delUser result = ' + result); - console.log('delUser extraInfo = ' + JSON.stringify(extraInfo)); - } - }); + try { + userIDM.delUser(token, { + onResult: (result, extraInfo) => { + console.log('delUser result = ' + result); + console.log('delUser extraInfo = ' + JSON.stringify(extraInfo)); + } + }); + } catch (e) { + console.log('delUser exception = ' + JSON.stringify(e)); + } ``` ### delCred8+ @@ -2628,17 +3976,21 @@ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): vo | token | Uint8Array | 是 | 身份验证令牌。 | | callback | [IIdmCallback](#iidmcallback8) | 是 | 回调结果,返回的是删除结果。 | -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); let credentialId = new Uint8Array([0]); let token = new Uint8Array([0]); - userIDM.delCred(credentialId, token, { - onResult: (result, extraInfo) => { - console.log('delCred result = ' + result); - console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); - } - }); + try { + userIDM.delCred(credentialId, token, { + onResult: (result, extraInfo) => { + console.log('delCred result = ' + result); + console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); + } + }); + } catch (e) { + console.log('delCred exception = ' + JSON.stringify(e)); + } ``` ### getAuthInfo8+ @@ -2660,13 +4012,17 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void; | callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调结果,返回的是当前用户指定类型的所有已注册凭据信息。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); - userIDM.getAuthInfo((err, result) => { - console.log('getAuthInfo err = ' + JSON.stringify(err)); - console.log('getAuthInfo result = ' + JSON.stringify(result)); - }); + try { + userIDM.getAuthInfo((err, result) => { + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); + }); + } catch (e) { + console.log('getAuthInfo exception = ' + JSON.stringify(e)); + } ``` ### getAuthInfo8+ @@ -2688,13 +4044,17 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred | authType | [AuthType](#authtype8) | 是 | 认证类型。 | | callback | AsyncCallback<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | 是 | 回调结果,返回的是当前用户指定类型的所有已注册凭据信息。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); - userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => { - console.log('getAuthInfo err = ' + JSON.stringify(err)); - console.log('getAuthInfo result = ' + JSON.stringify(result)); - }); + try { + userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => { + console.log('getAuthInfo err = ' + JSON.stringify(err)); + console.log('getAuthInfo result = ' + JSON.stringify(result)); + }); + } catch (e) { + console.log('getAuthInfo exception = ' + JSON.stringify(e)); + } ``` ### getAuthInfo8+ @@ -2721,14 +4081,18 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>; | :------------------------------------------- | :------------------------------------------------------------------------ | | Promise<Array<[EnrolledCredInfo](#enrolledcredinfo8)>> | Promise实例,用于获取异步返回结果,返回的是当前用户指定类型的所有已注册凭据信息。| -**示例:** +**示例:** ```js let userIDM = new account_osAccount.UserIdentityManager(); - userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => { - console.log('getAuthInfo result = ' + JSON.stringify(result)) - }).catch((err) => { - console.log('getAuthInfo error = ' + JSON.stringify(err)); - }); + try { + userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => { + console.log('getAuthInfo result = ' + JSON.stringify(result)) + }).catch((err) => { + console.log('getAuthInfo error = ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('getAuthInfo exception = ' + JSON.stringify(e)); + } ``` ## IInputData8+ @@ -2754,7 +4118,7 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; | pinSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 | | data | Uint8Array | 是 | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 | -**示例:** +**示例:** ```js let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let passwordNumber = new Uint8Array([1, 2, 3, 4]); @@ -2791,7 +4155,7 @@ onGetData: (pinSubType: AuthSubType, callback: IInputData) => void; | ---------- | --------------------------------------- | ---- | --------------- | | callback | [IInputData](#iinputdata8) | 是 | 指示密码数据回调。| -**示例:** +**示例:** ```js let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let passwordNumber = new Uint8Array([1, 2, 3, 4]); @@ -2832,7 +4196,7 @@ onResult: (result: number, extraInfo: AuthResult) => void; | result | number | 是 | 表示身份认证结果代码。| | extraInfo | [AuthResult](#authresult8) | 是 | 表示不同情况下的具体信息,如果认证通过,则在extrainfo中返回认证令牌,如果身份验证失败,则在extrainfo中返回剩余的身份验证时间,如果身份验证执行器被锁定,冻结时间将在extrainfo中返回。| -**示例:** +**示例:** ```js let authCallback = { onResult: (result, extraInfo) => { @@ -2860,7 +4224,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | acquire | number | 是 | 指示不同身份验证执行器的tip代码。| | extraInfo | any | 是 | 保留参数。 | -**示例:** +**示例:** ```js let authCallback = { onResult: (result, extraInfo) => { @@ -2898,7 +4262,7 @@ onResult: (result: number, extraInfo: RequestResult) => void; | result | number | 是 | 表示身份认证结果代码。 | | extraInfo | [AuthResult](#authresult8) | 是 | 针对不同情况传递具体信息。| -**示例:** +**示例:** ```js let idmCallback = { onResult: (result, extraInfo) => { @@ -2926,7 +4290,7 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | acquire | number | 是 | 指示不同身份验证执行器的tip代码。| | extraInfo | any | 是 | 保留参数。 | -**示例:** +**示例:** ```js let idmCallback = { onResult: (result, extraInfo) => { 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-permissionrequestresult.md b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md index 11d26b8696f7cdbaf638778496c0529042e5d9ec..6a457a5df80e460b264b3bfd3e9019b661282bf2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -37,4 +37,4 @@ export default class MainAbility extends Ability { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | permissions | Array<string> | 是 | 否 | 用户传入的权限。| -| authResults | Array<number> | 是 | 否 | 相应请求权限的结果。0表示授权成功,-1表示失败。 | +| authResults | Array<number> | 是 | 否 | 相应请求权限的结果。0表示授权成功,非0表示失败。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md index 15ded243b7583d8ecc33e7c6734f36ef364b332b..6a9c09f1a21e7d18e21643085d2023eabd21ef85 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -30,13 +30,13 @@ setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void **示例**: ```js -pointer.setPointerVisible(true, (err, data) => { - if (err) { - console.log(`set pointer visible failed. err=${JSON.stringify(err)}`); - return; - } - console.log(`set pointer visible success.`); -); +try { + pointer.setPointerVisible(true, (err, data) => { + console.log(`Set pointer visible success`); + }); +} catch (err) { + console.log(`Set pointer visible failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.setPointerVisible9+ @@ -62,11 +62,13 @@ setPointerVisible(visible: boolean): Promise<void> **示例**: ```js -pointer.setPointerVisible(false).then(data => { - console.log(`set mouse pointer visible success`); -}, data => { - console.log(`set mouse pointer visible failed err=${JSON.stringify(data)}`); -}); +try { + pointer.setPointerVisible(false).then(data => { + console.log(`Set mouse pointer visible success`); + }); +} catch { + console.log(`Set mouse pointer visible failed err=${JSON.stringify(data)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.isPointerVisible9+ @@ -86,9 +88,13 @@ isPointerVisible(callback: AsyncCallback<boolean>): void **示例**: ```js -pointer.isPointerVisible((visible)=>{ - console.log("The mouse pointer visible attributes is " + visible); -}); +try { + pointer.isPointerVisible(visible, (err, data) => { + console.log(`The mouse pointer visible attributes is ` + visible); + }); +} catch (err) { + console.log(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.isPointerVisible9+ @@ -108,9 +114,13 @@ isPointerVisible(): Promise<boolean> **示例**: ```js -pointer.isPointerVisible().then( data => { - console.log(`isPointerThen success data=${JSON.stringify(data)}`); -}); +try { + pointer.isPointerVisible().then((data) => { + console.log(`The mouse pointer visible attributes is success. data=${JSON.stringify(data)}`); + }); +} catch (err) { + ponsole.info(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.setPointerSpeed9+ @@ -131,13 +141,13 @@ setPointerSpeed(speed: number, callback: AsyncCallback<void>): void **示例**: ```js -pointer.setPointerSpeed(5, (err, data) => { - if (err) { - console.log(`set pointer speed failed. err=${JSON.stringify(err)}`); - return; - } - console.log(`set pointer speed success.`); -); +try { + pointer.setPointerSpeed(5, (err, data) => { + console.log(`Set pointer speed success`); + }); +} catch (err) { + console.log(`Set pointer speed failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.setPointerSpeed9+ @@ -163,11 +173,13 @@ setPointerSpeed(speed: number): Promise<void> **示例**: ```js -pointer.setPointerSpeed(5).then(data => { - console.log(`set pointer speed success`); -}, err => { - console.log(`set pointer speed failed err=${JSON.stringify(err)}`); -}); +try { + pointer.setPointerSpeed(5).then(data => { + console.log(`Set pointer speed success`); + }); +} catch (err) { + console.log(`Set pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.getPointerSpeed9+ @@ -187,9 +199,13 @@ getPointerSpeed(callback: AsyncCallback<number>): void **示例**: ```js -pointer.getPointerSpeed((speed)=>{ - console.log("The pointer speed is " + speed); -}); +try { + pointer.getPointerSpeed(speed, (err, data) => { + console.log(`The pointer speed is ` + speed); + }); +} catch (err) { + console.log(`Failed to get the pointer speed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.getPointerSpeed9+ @@ -209,9 +225,13 @@ getPointerSpeed(): Promise<number> **示例**: ```js -pointer.getPointerSpeed().then( data => { - console.log(`getPointerSpeed success data=${JSON.stringify(data)}`); -}); +try { + pointer.getPointerSpeed().then(data => { + console.log(`Get pointer speed success. data=${JSON.stringify(data)}`); + }); +} catch (err) { + console.log(`Get pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); +} ``` ## pointer.getPointerStyle9+ @@ -239,9 +259,17 @@ window.getTopWindow((err, data) => { windowClass = data; windowClass.getProperties((err, data) => { var windowId = data.id; - pointer.getPointerStyle(windowId, (err, ret) => { - console.log("The mouse pointer style is: " + ret); - }); + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId, (err, ret) => { + console.log(`The mouse pointer style is: ` + ret); + }); + } catch (err) { + console.log(`Failed to get the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); + } }); }); ``` @@ -260,7 +288,6 @@ getPointerStyle(windowId: number): Promise<PointerStyle> | ---------------------------------------- | ------------------- | | Promise<[PointerStyle](#pointerstyle9)> | Promise实例,用于异步获取结果。 | - **示例**: ```js @@ -271,9 +298,17 @@ window.getTopWindow((err, data) => { windowClass = data; windowClass.getProperties((err, data) => { var windowId = data.id; - pointer.getPointerStyle(windowId).then((ret) => { - console.log("The mouse pointer style is: " + ret); - }); + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId).then((ret) => { + console.log(`The mouse pointer style is: ` + ret); + }); + } catch (err) { + console.log(`Get pointer style failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); + } }); }); ``` @@ -304,9 +339,17 @@ window.getTopWindow((err, data) => { windowClass = data; windowClass.getProperties((err, data) => { var windowId = data.id; - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, (err) => { - console.log(`Set mouse pointer style success.`); - }); + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, (err) => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (err) { + console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); + } }); }); ``` @@ -336,9 +379,17 @@ window.getTopWindow((err, data) => { windowClass = data; windowClass.getProperties((err, data) => { var windowId = data.id; - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { - console.log(`Set mouse pointer style success`); - }); + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (err) { + console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(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 f9f478f905bff0a406e6740be71778ed2d3883e7..27194b10e072fb54ef5f7ed0b672606ff08a9d0d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @@ -1,10 +1,10 @@ # 隐私管理 -该模块主要提供权限使用记录等隐私管理接口。 +本模块主要提供权限使用记录等隐私管理接口。 > **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> 本模块接口为系统接口,三方应用不支持调用。 +> 本模块接口为系统接口。 ## 导入模块 @@ -39,6 +39,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n | :------------ | :---------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | + **示例:** ```js @@ -75,7 +84,16 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n | permissionName | string | 是 | 应用权限名称。 | | successCount | number | 是 | 访问成功的次数。 | | failCount | number | 是 | 访问失败的次数。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当添加使用记录成功时,err为undefine;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | **示例:** @@ -100,7 +118,7 @@ try { getPermissionUsedRecords(request: PermissionUsedRequest): Promise<PermissionUsedResponse> -获取历史权限使用记录。 +获取历史权限使用记录。使用Promise异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -116,7 +134,16 @@ getPermissionUsedRecords(request: PermissionUsedRequest): Promise<PermissionU | 类型 | 说明 | | :------------ | :---------------------------------- | -| Promise<[PermissionUsedResponse](#permissionusedresponse)> | Promise对象。返回权限使用记录。| +| Promise<[PermissionUsedResponse](#permissionusedresponse)> | Promise对象。返回查询的权限使用记录。| + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | **示例:** @@ -148,7 +175,7 @@ try { getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback<PermissionUsedResponse>): void -获取历史权限使用记录。 +获取历史权限使用记录。使用callback异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -159,7 +186,16 @@ getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------ | | request | [PermissionUsedRequest](#permissionusedrequest) | 是 | 查询权限使用记录的请求。 | -| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | 是 | 回调函数。返回权限使用记录。 | +| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | 是 | 回调函数。当查询记录成功时,err为undefine,data为查询到的权限使用记录;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | **示例:** @@ -193,7 +229,7 @@ try { startUsingPermission(tokenID: number, permissionName: string): Promise<void> -应用开始使用某项权限,可监听应用在前后台使用权限,并将使用权限的记录落盘,由系统服务调用。 +应用开始使用某项权限,可监听应用在前后台使用权限,并将使用权限的记录落盘,由系统服务调用。使用Promise异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -212,6 +248,16 @@ startUsingPermission(tokenID: number, permissionName: string): Promise<void&g | ------------- | --------------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。| +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100004 | The interface is not used together. | + **示例:** ```js @@ -233,7 +279,7 @@ try { startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback<void>): void -应用开始使用某项权限,可监听应用在前后台使用权限,并将使用权限的记录落盘,由系统服务调用。 +应用开始使用某项权限,可监听应用在前后台使用权限,并将使用权限的记录落盘,由系统服务调用。使用callback异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -245,7 +291,17 @@ startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCal | -------------- | --------------------- | ---- | ------------------------------------ | | tokenID | number | 是 | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | string | 是 | 需要使用的权限名。 | -| callback | AsyncCallback<void> | 是 | 异步回调,返回开始使用权限的结果。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当开始使用权限成功时,err为undefine;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100004 | The interface is not used together. | **示例:** @@ -270,7 +326,7 @@ try { stopUsingPermission(tokenID: number, permissionName: string): Promise<void> -应用停止使用某项权限,与Start对应,由系统服务调用。 +应用停止使用某项权限,与Start对应,由系统服务调用。使用Promise异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -289,6 +345,16 @@ stopUsingPermission(tokenID: number, permissionName: string): Promise<void> | ------------- | --------------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。| +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100004 | The interface is not used together. | + **示例:** ```js @@ -310,7 +376,7 @@ try { stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback<void>): void -应用停止使用某项权限,与Start对应,由系统服务调用。 +应用停止使用某项权限,与Start对应,由系统服务调用。使用callback异步回调。 **需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 @@ -322,7 +388,17 @@ stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCall | -------------- | --------------------- | ---- | ------------------------------------ | | tokenID | number | 是 | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | string | 是 | 需要使用的权限名。 | -| callback | AsyncCallback<void> | 是 | 异步回调,返回停止使用权限的结果。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当停止使用权限成功时,err为undefine;否则为错误对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100002 | TokenId does not exist. | +| 12100003 | Permission does not exist. | +| 12100004 | The interface is not used together. | **示例:** @@ -347,11 +423,9 @@ try { on(type: 'activeStateChange', permissionNameList: Array<string>, callback: Callback<ActiveChangeResponse>): void -订阅指定权限列表的权限使用状态变更事件,使用callback回调异步返回结果。 +订阅指定权限列表的权限使用状态变更事件。 -此接口为系统接口。 - -**需要权限:** ohos.permission.PERMISSION_USED_STATS +**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -361,7 +435,16 @@ on(type: 'activeStateChange', permissionNameList: Array<string>, callback: | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 订阅事件类型,固定为'activeStateChange',权限使用状态变更事件。 | | permissionNameList | Array<string> | 否 | 订阅的权限名列表,为空时表示订阅所有的权限使用状态变化。 | -| callback | Callback<[ActiveChangeResponse](#activechangeresponse9)> | 是 | 订阅指定权限使用状态变更事件的回调。 | +| callback | Callback<[ActiveChangeResponse](#activechangeresponse)> | 是 | 订阅指定权限使用状态变更事件的回调。 | + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100004 | The interface is not used together. | +| 12100005 | The number of listeners exceeds the limit. | **示例:** @@ -382,11 +465,9 @@ try { off(type: 'activeStateChange', permissionNameList: Array<string>, callback?: Callback<ActiveChangeResponse>): void; -取消订阅指定权限列表的权限使用状态变更事件,使用callback回调异步返回结果。 +取消订阅指定权限列表的权限使用状态变更事件。 -此接口为系统接口。 - -**需要权限:** ohos.permission.PERMISSION_USED_STATS +**需要权限:** ohos.permission.PERMISSION_USED_STATS,仅系统应用可用。 **系统能力:** SystemCapability.Security.AccessToken @@ -396,7 +477,15 @@ off(type: 'activeStateChange', permissionNameList: Array<string>, callback | ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 订阅事件类型,固定为'activeStateChange',权限使用状态变更事件。 | | permissionNameList | Array<string> | 否 | 订阅的权限名列表,为空时表示订阅所有的权限状态变化,必须与on的输入一致。 | -| callback | Callback<[ActiveChangeResponse](#activechangeresponse9)> | 否 | 取消订阅指定tokenId与指定权限名状态变更事件的回调。| +| callback | Callback<[ActiveChangeResponse](#activechangeresponse)> | 否 | 取消订阅指定tokenId与指定权限名状态变更事件的回调。| + +**错误码:** + +以下错误码的详细介绍请参见[程序访问控制错误码](../errorcodes/errorcode-access-token.md)。 +| 错误码ID | 错误信息 | +| -------- | -------- | +| 12100001 | Parameter invalid. | +| 12100004 | The interface is not used together. | **示例:** @@ -426,7 +515,7 @@ try { 表示使用记录的查询请求。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------------- | @@ -443,7 +532,7 @@ try { 表示所有应用的访问记录。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------------- | @@ -455,7 +544,7 @@ try { 某个应用的访问记录。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------------- | @@ -469,7 +558,7 @@ try { 某个权限的访问记录。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------------- | @@ -486,7 +575,7 @@ try { 单次访问记录详情。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------------- | @@ -496,9 +585,9 @@ try { ## PermissionActiveStatus -表示权限使用状态类型的枚举。 +表示权限使用状态变化类型的枚举。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +**系统能力:** SystemCapability.Security.AccessToken | 名称 | 默认值 | 描述 | | ------------------------- | ------ | ---------------- | @@ -508,11 +597,13 @@ try { ## ActiveChangeResponse - **系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken +表示某次权限使用状态变化的详情。 + + **系统能力:** SystemCapability.Security.AccessToken | 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | ---------------------- | ---- | ---- | --------------------- | -| tokenId | number | 是 | 否 | 调用方的应用身份标识 | -| permissionName | string | 是 | 否 | 使用状态发生变化的权限名 | +| tokenId | number | 是 | 否 | 被订阅的应用身份标识 | +| permissionName | string | 是 | 否 | 权限使用状态发生变化的权限名 | | deviceId | string | 是 | 否 | 设备号 | -| activeStatus | [PermissionActiveStatus](#permissionactivestatus9) | 是 | 否 | 权限使用状态类型 | +| activeStatus | [PermissionActiveStatus](#permissionactivestatus) | 是 | 否 | 权限使用状态变化类型 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-prompt.md index 0553da25895103c1ada4a4ce65bd56e3cebaf53e..b757e22f002c9b512580c886f4371ad1a56cbc7f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-prompt.md @@ -3,7 +3,8 @@ 创建并显示文本提示框、对话框和操作菜单。 > **说明:** -> +> 从API Version 9 开始,该接口不再维护,推荐使用新接口[@ohos.promptAction (弹窗)](js-apis-promptAction.md) +> > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -45,7 +46,7 @@ prompt.showToast({ | 名称 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| message | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | | duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 | | bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 | @@ -146,8 +147,8 @@ prompt.showDialog({ | 名称 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------------------------------- | -| title | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 标题文本。 | -| message | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 内容文本。 | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 内容文本。 | | buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | ## ShowDialogSuccessResponse @@ -255,7 +256,7 @@ prompt.showActionMenu({ | 名称 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | ---------------------------------------- | -| title | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | | buttons | Array<[Button](#button)> | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | ## ActionMenuSuccessResponse @@ -276,6 +277,6 @@ prompt.showActionMenu({ | 名称 | 类型 | 必填 | 说明 | | ----- | ---------------------------------------- | ---- | ------- | -| text | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | -| color | string\| [Resource](../../ui/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | +| text | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | +| color | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md new file mode 100644 index 0000000000000000000000000000000000000000..af1d690e2d349dc7625d64d130005c9e454492a0 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md @@ -0,0 +1,341 @@ +# 弹窗 + +创建并显示文本提示框、对话框和操作菜单。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import promptAction from '@ohos.promptAction' +``` + +## promptAction.showToast + +showToast(options: ShowToastOptions): void + +创建并显示文本提示框。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------------- | ---- | ------- | +| options | [ShowToastOptions](#showtoastoptions) | 是 | 文本弹窗选项。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showToast({ + message: 'Message Info', + duration: 2000, + }); +} catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); +}; + +``` + +![zh-cn_image_0001](figures/zh-cn_image_0001.gif) + +## ShowToastOptions + +文本提示框的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 | +| bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 | + +## promptAction.showDialog + +showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse> + +创建并显示对话框,对话框响应后同步返回结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 对话框选项。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | -------- | +| Promise<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 对话框响应结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', + }, + { + text: 'button2', + color: '#000000', + } + ], + }) + .then(data => { + console.info('showDialog success, click button: ' + data.index); + }) + .catch(err => { + console.info('showDialog error: ' + err); + }) +} catch (error) { + console.error(`showDialog args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0002](figures/zh-cn_image_0002.gif) + +## promptAction.showDialog + +showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>):void + +创建并显示对话框,对话框响应结果异步返回。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------ | +| options | [ShowDialogOptions](#showdialogoptions) | 是 | 页面显示对话框信息描述。 | +| callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 是 | 对话框响应结果回调。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showDialog({ + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', + }, + { + text: 'button2', + color: '#000000', + } + ] + }, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; + } + console.info('showDialog success callback, click button: ' + data.index); + }); +} catch (error) { + console.error(`showDialog args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0002](figures/zh-cn_image_0002.gif) + +## ShowDialogOptions + +对话框的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 内容文本。 | +| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | + +## ShowDialogSuccessResponse + +对话框的响应结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 说明 | +| ----- | ------ | ------------------- | +| index | number | 选中按钮在buttons数组中的索引。 | + +## promptAction.showActionMenu + +showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenuSuccessResponse>):void + +创建并显示操作菜单,菜单响应结果异步返回。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | +| callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 是 | 菜单响应结果回调。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ] + }, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; + } + console.info('showActionMenu success callback, click button: ' + data.index); + }) +} catch (error) { + console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0005](figures/zh-cn_image_0005.gif) + +## promptAction.showActionMenu + +showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse> + +创建并显示操作菜单,菜单响应后同步返回结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------- | +| options | [ActionMenuOptions](#actionmenuoptions) | 是 | 操作菜单选项。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | 菜单响应结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.promptAction(弹窗)](../errorcodes/errorcode-promptAction.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + +**示例:** + +```js +try { + promptAction.showActionMenu({ + title: 'showActionMenu Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ] + }) + .then(data => { + console.info('showActionMenu success, click button: ' + data.index); + }) + .catch(err => { + console.info('showActionMenu error: ' + err); + }) +} catch (error) { + console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`); +}; +``` + +![zh-cn_image_0005](figures/zh-cn_image_0005.gif) + +## ActionMenuOptions + +操作菜单的选项。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +| 名称 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 否 | 标题文本。 | +| buttons | Array<[Button](#button)> | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | + +## ActionMenuSuccessResponse + +操作菜单的响应结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ------------------------ | +| index | number | 否 | 选中按钮在buttons数组中的索引,从0开始。 | + +## Button + +菜单中的菜单项按钮。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ----- | ---------------------------------------- | ---- | ------- | +| text | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本内容。 | +| color | string\| [Resource](../arkui-ts/ts-types.md#resource类型)9+ | 是 | 按钮文本颜色。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index cfb5c0c75a9058ae41d3e1f613d19ecbebfe2322..1ba8a552f29850c589f0f192910fd6e7bb740ee7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -1206,7 +1206,7 @@ resume(callback: AsyncCallback<void>): void | 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | url | string | 是 | 资源地址。 | -| header | object | 否 | 添加要包含在下载请求中的HTTP或HTTPS标志头。 | +| header | object | 否 | 添加要包含在下载请求中的HTTPS标志头。
    开发者可以通过header的X-TLS-Version参数指定需要使用的TLS版本(如果不指定,则默认使用CURL_SSLVERSION_TLSv1_2版本,指定则使用指定版本。)
    CURL_SSLVERSION_TLSv1_0
    CURL_SSLVERSION_TLSv1_1
    CURL_SSLVERSION_TLSv1_2
    CURL_SSLVERSION_TLSv1_3
    通过header的X-Cipher-List参数指定需要使用的密码套件(如果不指定,则默认使用安全密码套件,指定则使用指定密码套件。)
    -1.2允许使用的密码套件白名单:
    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
    TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,
    TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
    TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
    TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
    TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,
    TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,
    TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
    TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,
    TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
    TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
    -1.3允许使用的密码套件白名单:
    TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256
    -1.3新增国密算法套:
    TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | | enableMetered | boolean | 否 | 设置是否允许在按流量计费的连接下下载。
    - true:是
    - false:否 | | enableRoaming | boolean | 否 | 设置是否允许在漫游网络中下载。
    - true:是
    - false:否| | description | string | 否 | 设置下载会话的描述。 | 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-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index 4735f20e7e94bd8013e93f0b3bca3b9ca21a608e..2a7401953f2f3442039ab871b698bf9f58eb5099 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -14,108 +14,403 @@ import router from '@ohos.router' ``` -## router.push +## router.pushUrl9+ -push(options: RouterOptions): void +pushUrl(options: RouterOptions): Promise<void> 跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | --------- | | options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | **示例:** + ```js -router.push({ - url: 'pages/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, }, - }, -}); + }) + .then(() => { + // success + }) + .catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` -## router.push9+ -push(options: RouterOptions, mode: RouterMode): void +## router.pushUrl9+ + +pushUrl(options: RouterOptions, callback: AsyncCallback<void>): void 跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | --------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | + +**示例:** + +```js +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, + }, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }); +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` +## router.pushUrl9+ + +pushUrl(options: RouterOptions, mode: RouterMode): Promise<void> + +跳转到应用内的指定页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------- | | options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | | mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | **示例:** + ```js -router.push({ - url: 'pages/routerpage2/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, }, - }, -},router.RouterMode.Standard); + }, router.RouterMode.Standard) + .then(() => { + // success + }) + .catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` -## router.replace +## router.pushUrl9+ -replace(options: RouterOptions): void +pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void -用应用内的某个页面替换当前页面,并销毁被替换的页面。 +跳转到应用内的指定页面。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 100002 | Uri error. The uri of router is not exist. | +| 100003 | Page stack error. The pages are pushed too much. | + +**示例:** + +```js +try { + router.pushUrl({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, + }, router.RouterMode.Standard, (err) => { + if (err) { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('pushUrl success'); + }); +} catch (error) { + console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions): Promise<void> + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ------------------ | | options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + **示例:** ```js -router.replace({ - url: 'pages/detail', - params: { - data1: 'message', - }, -}); +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }) + .then(() => { + // success + }) + .catch(err => { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` - ## router.replace9+ +## router.replaceUrl9+ -replace(options: RouterOptions, mode: RouterMode): void +replaceUrl(options: RouterOptions, callback: AsyncCallback<void>): void 用应用内的某个页面替换当前页面,并销毁被替换的页面。 -**系统能力:** SystemCapability.ArkUI.ArkUI.Full +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite **参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| callback | AsyncCallback<void> | 是 | 异常响应回调 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + +**示例:** + +```js +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, (err) => { + if (err) { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('replaceUrl success'); + }); +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void> + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------- | | options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | | mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------- | +| Promise<void> | 异常返回结果 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + **示例:** ```js -router.replace({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, -}, router.RouterMode.Standard); +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, router.RouterMode.Standard) + .then(() => { + // success + }) + .catch(err => { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + }) +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; +``` + +## router.replaceUrl9+ + +replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | +| 200002 | Uri error. The uri of router is not exist. | + +**示例:** + +```js +try { + router.replaceUrl({ + url: 'pages/detail', + params: { + data1: 'message', + }, + }, router.RouterMode.Standard, (err) => { + if (err) { + console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('replaceUrl success'); + }); +} catch (error) { + console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`); +}; ``` ## router.back @@ -127,6 +422,7 @@ back(options?: RouterOptions ): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ------------------------------------------------------------ | | options | [RouterOptions](#routeroptions) | 否 | 返回页面描述信息,其中参数url指路由跳转时会返回到指定url的界面,如果页面栈上没有url页面,则不响应该情况。如果url未设置,则返回上一页,页面栈里面的page不会回收,出栈后会被回收。 | @@ -160,11 +456,13 @@ getLength(): string **系统能力:** SystemCapability.ArkUI.ArkUI.Full **返回值:** + | 类型 | 说明 | | ------ | ------------------ | | string | 页面数量,页面栈支持最大数值是32。 | **示例:** + ```js var size = router.getLength(); console.log('pages stack size = ' + size); @@ -205,25 +503,38 @@ console.log('current path = ' + page.path); | name | string | 表示当前页面的名称,即对应文件名。 | | path | string | 表示当前页面的路径。 | -## router.enableAlertBeforeBackPage +## router.enableBackPageAlert9+ -enableAlertBeforeBackPage(options: EnableAlertOptions): void +enableBackPageAlert(options: EnableAlertOptions): void 开启页面返回询问对话框。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------------------------- | ---- | --------- | | options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信息描述。 | +**错误码:** + +以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。 + +| 错误码ID | 错误码信息 | +| --------- | ------- | +| 100001 | Internal error. | + **示例:** - ```js - router.enableAlertBeforeBackPage({ + ```js +try { + router.enableBackPageAlert({ message: 'Message Info' - }); + }); +} catch(error) { + console.error(`enableBackPageAlert failed, code is ${error.code}, message is ${error.message}`); +} ``` ## EnableAlertOptions @@ -244,6 +555,7 @@ disableAlertBeforeBackPage(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** + ```js router.disableAlertBeforeBackPage(); ``` @@ -400,4 +712,145 @@ struct Second { .height('100%') } } -``` \ No newline at end of file +``` + +## router.push(deprecated) + +push(options: RouterOptions): void + +跳转到应用内的指定页面。 + +从API version9开始不再维护,建议使用[pushUrl9+](#routerpushurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | --------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | + + +**示例:** + +```js +router.push({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +}); +``` +## router.push(deprecated) + +push(options: RouterOptions, mode: RouterMode): void + +跳转到应用内的指定页面。 + +从API version9开始不再维护,建议使用[pushUrl9+](#routerpushurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + + +**示例:** + +```js +router.push({ + url: 'pages/routerpage2/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +},router.RouterMode.Standard); +``` + +## router.replace(deprecated) + +replace(options: RouterOptions): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +从API version9开始不再维护,建议使用[replaceUrl9+](#routerreplaceurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | + +**示例:** + +```js +router.replace({ + url: 'pages/detail', + params: { + data1: 'message', + }, +}); +``` + + ## router.replace(deprecated) + +replace(options: RouterOptions, mode: RouterMode): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +从API version9开始不再维护,建议使用[replaceUrl9+](#routerreplaceurl9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------------------- | ---- | ---------- | +| options | [RouterOptions](#routeroptions) | 是 | 替换页面描述信息。 | +| mode | [RouterMode](#routermode9) | 是 | 跳转页面使用的模式。 | + +**示例:** + +```js +router.replace({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, +}, router.RouterMode.Standard); +``` + +## router.enableAlertBeforeBackPage(deprecated) + +enableAlertBeforeBackPage(options: EnableAlertOptions): void + +开启页面返回询问对话框。 + +从API version9开始不再维护,建议使用[enableBackPageAlert9+](#routerenablebackpagealert9) + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | --------- | +| options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信息描述。 | + +**示例:** + + ```js + router.enableAlertBeforeBackPage({ + message: 'Message Info' + }); + ``` \ 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 aabf35833b0c56d5771279c55ec0ea9b9ab2f192..90c18d897092a30423a010bb41096440571f9964 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -21,776 +21,888 @@ sensor模块提供订阅传感器数据基本能力,包括订阅、取消订 import sensor from '@ohos.sensor'; ``` -## sensor.on +## sensor.on9+ -### ACCELEROMETER +### ACCELEROMETER9+ -on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>,options?: Options): void +on(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse>,options?: Options): void -监听加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅加速度计传感器数据。 -**需要权限**:ohos.permission.ACCELEROMETER +**需要权限**:ohos.permission.ACCELEROMETER **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的加速度传感器类型为 ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` -### LINEAR_ACCELERATION(deprecated) +```js +try { + sensor.on(sensor.SensorId.ACCELEROMETER,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, options?: Options): void +### ACCELEROMETER_UNCALIBRATED9+ -监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<AccelerometerUncalibratedResponse>,options?: Options): void -从API Version9开始该接口不再维护,请使用[sensor.on.LINEAR_ACCELEROMETER](#linear_accelerometer9) +订阅未校准的加速度计传感器数据。 -**需要权限**:ohos.permission.ACCELEROMETER +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的未校准加速度传感器类型为ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +### AMBIENT_LIGHT9+ + +on(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>, options?: Options): void + +订阅环境光传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -### LINEAR_ACCELEROMETER9+ +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9) | 是 | 要订阅的环境光传感器类型为AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>, options?: Options): void +**错误码**: -监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**需要权限**:ohos.permission.ACCELEROMETER +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.AMBIENT_LIGHT,function(data){ + console.info('Illumination: ' + data.intensity); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +### AMBIENT_TEMPERATURE9+ + +on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatureResponse>,options?: Options): void + +订阅环境温度传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的环境温度传感器类型为AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` -### ACCELEROMETER_UNCALIBRATED +```js +try { + sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE,function(data){ + console.info('Temperature: ' + data.temperature); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>, options?: Options): void +### BAROMETER9+ -监听未校准加速度计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +on(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>, options?: Options): void -**需要权限**:ohos.permission.ACCELEROMETER +订阅气压计传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); - }, - {interval: 10000000} - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的气压计传感器类型为BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -### GRAVITY +**错误码**: -on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>,options?: Options): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听重力传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.BAROMETER,function(data){ + console.info('Atmospheric pressure: ' + data.pressure); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +### GRAVITY9+ + +on(type: SensorId.GRAVITY, callback: Callback<GravityResponse>,options?: Options): void + +订阅重力传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9) | 是 | 要订阅的重力传感器类型为GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.GRAVITY,function(data){ console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### GYROSCOPE +### GYROSCOPE9+ -on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>, options?: Options): void +on(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>,options?: Options): void -监听陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅校准的陀螺仪传感器数据。 -**需要权限**:ohos.permission.GYROSCOPE +**需要权限**:ohos.permission.GYROSCOPE -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的陀螺仪传感器类型为GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 返回注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.GYROSCOPE,function(data){ console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### GYROSCOPE_UNCALIBRATED +### GYROSCOPE_UNCALIBRATED9+ -on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<GyroscopeUncalibratedResponse>, options?: Options): void +on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncalibratedResponse>, + options?: Options): void -监听未校准陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅未经校准的陀螺仪传感器数据 -**需要权限**:ohos.permission.GYROSCOPE +**需要权限**:ohos.permission.GYROSCOPE -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED,function(data){ console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); console.info('X-coordinate bias: ' + data.biasX); console.info('Y-coordinate bias: ' + data.biasY); console.info('Z-coordinate bias: ' + data.biasZ); - }, - {interval: 10000000} - ); - ``` + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### SIGNIFICANT_MOTION +### HALL9+ -on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>, options?: Options): void +on(type: SensorId.HALL, callback: Callback<HallResponse>, options?: Options): void -监听大幅动作传感器数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅心率传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | - -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ - console.info('Scalar data: ' + data.scalar); - }, - {interval: 10000000} - ); - ``` - -### PEDOMETER_DETECTION -on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>, options?: Options): void +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的霍尔传感器类型为HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -监听计步检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**错误码**: -**需要权限**:ohos.permission.ACTIVITY_MOTION +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**系统能力**:SystemCapability.Sensors.Sensor +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**示例:** -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ - console.info('Scalar data: ' + data.scalar); - }, - {interval: 10000000} - ); - ``` +```js +try { + sensor.on(sensor.SensorId.HALL,function(data){ + console.info('Status: ' + data.status); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### PEDOMETER +### HEART_RATE9+ -on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>, options?: Options): void +on(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>,options?: Options): void -监听计步传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅心率传感器数据。 -**需要权限**:ohos.permission.ACTIVITY_MOTION +**需要权限**:ohos.permission.READ_HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | --------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ - console.info('Steps: ' + data.steps); - }, - {interval: 10000000} - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的心率传感器类型为HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -### AMBIENT_TEMPERATURE +**错误码**: -on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<AmbientTemperatureResponse>, options?: Options): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听环境温度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | - -**示例:** - - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ - console.info('Temperature: ' + data.temperature); - }, - {interval: 10000000} - ); - ``` +```js +try { + sensor.on(sensor.SensorId.HEART_RATE,function(data){ + console.info('Heart rate: ' + data.heartRate); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### MAGNETIC_FIELD +### HUMIDITY9+ -on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>,options?: Options): void +on(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>,options?: Options): void -监听磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅湿度传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的湿度传感器类型为HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` +**错误码**: -### MAGNETIC_FIELD_UNCALIBRATED +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**示例:** -**系统能力**:SystemCapability.Sensors.Sensor +```js +try { + sensor.on(sensor.SensorId.HUMIDITY,function(data){ + console.info('Humidity: ' + data.humidity); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**参数:** +### LINEAR_ACCELERATION9+ -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAccelerometerResponse>, + options?: Options): void -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); - }, - {interval: 10000000} - ); - ``` +订阅线性加速度传感器数据。 -### PROXIMITY +**需要权限**:ohos.permission.ACCELEROMETER -on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>,options?: Options): void +**系统能力**:SystemCapability.Sensors.Sensor -监听接近光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**参数:** -**系统能力**:SystemCapability.Sensors.Sensor +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的线性加速度传感器类型为LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**错误码**: -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ - console.info('Distance: ' + data.distance); - }, - {interval: 10000000} - ); - ``` +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -### HUMIDITY +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>,options?: Options): void +**示例:** -监听湿度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +```js +try { + sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**系统能力**:SystemCapability.Sensors.Sensor +### MAGNETIC_FIELD9+ -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | -------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +on(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>,options?: Options): void -**示例:** +订阅磁场传感器数据。 - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ - console.info('Humidity: ' + data.humidity); - }, - {interval: 10000000} - ); - ``` +**系统能力**:SystemCapability.Sensors.Sensor -### BAROMETER +**参数:** -on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>,options?: Options): void +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的磁场传感器类型为MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -监听气压计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**错误码**: -**系统能力**:SystemCapability.Sensors.Sensor +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**参数:** +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**示例:** -**示例:** +```js +try { + sensor.on(sensor.SensorId.MAGNETIC_FIELD,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ - console.info('Atmospheric pressure: ' + data.pressure); - }, - {interval: 10000000} - ); - ``` +### MAGNETIC_FIELD_UNCALIBRATED9+ -### HALL +on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void -on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, options?: Options): void +订阅未校准的磁场传感器数据 -监听霍尔传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:SystemCapability.Sensors.Sensor +**参数:** -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ - console.info('Status: ' + data.status); - }, - {interval: 10000000} - ); - ``` +**错误码**: -### AMBIENT_LIGHT +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>, options?: Options): void +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -监听环境光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**示例:** -**系统能力**:SystemCapability.Sensors.Sensor +```js +try { + sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +### ORIENTATION9+ -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ - console.info(' Illumination: ' + data.intensity); - }, - {interval: 10000000} - ); - ``` +on(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>,options?: Options): void -### ORIENTATION +订阅定向传感器数据。 -on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>, options?: Options): void +**系统能力**:SystemCapability.Sensors.Sensor -监听方向传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +**错误码**: -**系统能力**:SystemCapability.Sensors.Sensor +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的方向传感器类型为ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + +```js +try { + sensor.on(sensor.SensorId.ORIENTATION,function(data){ console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Z axis: ' + data.alpha); - }, - {interval: 10000000} - ); - ``` + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### HEART_RATE(deprecated) +### PEDOMETER9+ -on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, options?: Options): void +on(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>, options?: Options): void -监听心率传感器数据变化一次。 +订阅计步器传感器数据。 -从API Version9开始该接口不再维护,请使用[sensor.on.HEART_BEAT_RATE](#heart_beat_rate9) +**需要权限**:ohos.permission.ACTIVITY_MOTION -**需要权限**:ohos.permission.HEALTH_DATA +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:SystemCapability.Sensors.Sensor +**错误码**: -**参数:** +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| type | [SensorId](#sensorid9) | 是 | 要订阅的计步传感器类型为PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -### HEART_BEAT_RATE9+ +**示例:** + +```js +try { + sensor.on(sensor.SensorId.PEDOMETER,function(data){ + console.info('Steps: ' + data.steps); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -on(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback<HeartRateResponse>, options?: Options): void +### PEDOMETER_DETECTION9+ -监听心率传感器数据变化一次。 +on(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>, + options?: Options): void -**需要权限**:ohos.permission.READ_HEALTH_DATA +订阅计步器检测传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的计步检测传感器类型为PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** ```js -sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE,function(data){ - console.info("Heart rate: " + data.heartRate); -}, - {interval: 10000000} -); +try { + sensor.on(sensor.SensorId.PEDOMETER_DETECTION,function(data){ + console.info('Scalar data: ' + data.scalar); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` -### ROTATION_VECTOR +### PROXIMITY9+ -on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<RotationVectorResponse>,options?: Options): void +on(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>, options?: Options): void -监听旋转矢量传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 +订阅接近传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的接近光传感器类型为PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('Scalar quantity: ' + data.w); - }, - {interval: 10000000} - ); - ``` - -### WEAR_DETECTION - -on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>,options?: Options): void -监听佩戴检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 - -**系统能力**:SystemCapability.Sensors.Sensor - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +```js +try { + sensor.on(sensor.SensorId.PROXIMITY,function(data){ + console.info('Distance: ' + data.distance); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ - console.info('Wear status: ' + data.value); - }, - {interval: 10000000} - ); - ``` +### ROTATION_VECTOR9+ -## sensor.once +on(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorResponse>, + options?: Options): void -### ACCELEROMETER +订阅旋转矢量传感器数据。 -once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>): void +**系统能力**:SystemCapability.Sensors.Sensor -监听加速度传感器的数据变化一次。 +**参数:** -**需要权限**:ohos.permission.ACCELEROMETER +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的旋转矢量传感器类型为ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**系统能力**:SystemCapability.Sensors.Sensor +**错误码**: -**参数:** +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ + +```js +try { + sensor.on(sensor.SensorId.ROTATION_VECTOR,function(data){ console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); - } - ); - ``` - -### LINEAR_ACCELERATION(deprecated) - -once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void + console.info('Scalar quantity: ' + data.w); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -监听线性加速度传感器数据变化一次。 +### SIGNIFICANT_MOTION9+ -从API Version9开始该接口不再维护,请用[sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9) +on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>, + options?: Options): void -**需要权限**:ohos.permission.ACCELERATION +订阅重要的运动传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | - -### LINEAR_ACCELEROMETER9+ - -once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>): void - -订阅一次线性加速度传感器数据。 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的大幅动作传感器类型为SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**需要权限**:ohos.permission.ACCELEROMETER +**错误码**: -**系统能力**:SystemCapability.Sensors.Sensor +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - } - ); - ``` +**示例:** -### ACCELEROMETER_UNCALIBRATED +```js +try { + sensor.on(sensor.SensorId.SIGNIFICANT_MOTION,function(data){ + console.info('Scalar data: ' + data.scalar); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>): void +### WEAR_DETECTION9+ -监听未校准加速度传感器的数据变化一次。 +on(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse>, + options?: Options): void -**需要权限**:ohos.permission.ACCELEROMETER +订阅磨损检测传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | -**示例:** - ``` - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); - } - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要订阅的佩戴检测传感器类型为WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -### GRAVITY +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听重力传感器的数据变化一次。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | --------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | +```js +try { + sensor.on(sensor.SensorId.WEAR_DETECTION,function(data){ + console.info('Wear status: ' + data.value); + }, {interval: 10000000} ); +} catch(err) { + console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - } - ); - ``` +## sensor.once9+ -### GYROSCOPE +### ACCELEROMETER9+ -once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>): void +once(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse>): void -监听陀螺仪传感器的数据变化一次。 +订阅一次加速度计传感器数据。 -**需要权限**:ohos.permission.GYROSCOPE +**需要权限**:ohos.permission.ACCELEROMETER **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 加速度传感器类型为ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { + +```js +try { + sensor.once(sensor.SensorId.ACCELEROMETER,function(data){ console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); } ); - ``` +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### GYROSCOPE_UNCALIBRATED +### ACCELEROMETER_UNCALIBRATED9+ -once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback<GyroscopeUncalibratedResponse>): void +once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<AccelerometerUncalibratedResponse>): void -监听未校准陀螺仪传感器的数据变化一次。 +订阅一次未校准的加速度计传感器数据。 -**需要权限**:ohos.permission.GYROSCOPE +**需要权限**:ohos.permission.ACCELEROMETER **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 未校准加速度传感器类型为ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { + +```js +try { + sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function(data) { console.info('X-coordinate component: ' + data.x); console.info('Y-coordinate component: ' + data.y); console.info('Z-coordinate component: ' + data.z); @@ -799,2052 +911,5190 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l console.info('Z-coordinate bias: ' + data.biasZ); } ); - ``` +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -### SIGNIFICANT_MOTION +### AMBIENT_LIGHT9+ -once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<SignificantMotionResponse>): void +once(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>): void -监听有效运动传感器的数据变化一次。 +订阅环境光传感器数据一次。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 环境光传感器类型为AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { - console.info('Scalar data: ' + data.scalar); - } - ); - ``` -### PEDOMETER_DETECTION +```js +try { + sensor.once(sensor.SensorId.AMBIENT_LIGHT, function(data) { + console.info('Illumination: ' + data.intensity); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<PedometerDetectionResponse>): void +### AMBIENT_TEMPERATURE9+ -监听计步检测传感器数据变化一次。 +once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatureResponse>): void -**需要权限**:ohos.permission.ACTIVITY_MOTION +一次订阅环境温度传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 环境温度传感器类型为AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { - console.info('Scalar data: ' + data.scalar); - } - ); - ``` -### PEDOMETER +```js +try { + sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function(data) { + console.info('Temperature: ' + data.temperature); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>): void +### BAROMETER9+ -监听计步器传感器数据变化一次。 +once(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>): void -**需要权限**:ohos.permission.ACTIVITY_MOTION +订阅一次气压计传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 气压计传感器类型为BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { - console.info('Steps: ' + data.steps); - } - ); - ``` -### AMBIENT_TEMPERATURE +```js +try { + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { + console.info('Atmospheric pressure: ' + data.pressure); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<AmbientTemperatureResponse>): void +### GRAVITY9+ -监听环境温度传感器数据变化一次。 +once(type: SensorId.GRAVITY, callback: Callback<GravityResponse>): void + +订阅一次重力传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +**参数:** -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { - console.info('Temperature: ' + data.temperature); - } - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 重力传感器类型为GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | -### MAGNETIC_FIELD +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听磁场传感器数据变化一次。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** -**参数:** +```js +try { + sensor.once(sensor.SensorId.GRAVITY, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | - -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - } - ); - ``` +### GYROSCOPE9+ -### MAGNETIC_FIELD_UNCALIBRATED +once(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>): void -once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>): void +订阅一次陀螺仪传感器数据。 -监听未校准磁场传感器数据变化一次。 +**需要权限**:ohos.permission.GYROSCOPE **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | - -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); - } - ); - ``` -### PROXIMITY +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 陀螺仪传感器类型为GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>): void +**错误码**: -监听接近光传感器数据变化一次。 +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**系统能力**:SystemCapability.Sensors.Sensor +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**参数:** +**示例:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +```js +try { + sensor.once(sensor.SensorId.GYROSCOPE, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) { - console.info('Distance: ' + data.distance); - } - ); - ``` +### GYROSCOPE_UNCALIBRATED9+ -### HUMIDITY +once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncalibratedResponse>): void -once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>): void +一次订阅未校准的陀螺仪传感器数据。 -监听湿度传感器数据变化一次。 +**需要权限**:ohos.permission.GYROSCOPE -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { - console.info('Humidity: ' + data.humidity); - } - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -### BAROMETER +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听气压计传感器数据变化一次。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** + +```js +try { + sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +### HALL9+ + +once(type: SensorId.HALL, callback: Callback<HallResponse>): void + +订阅一次霍尔传感器数据。 + +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { - console.info('Atmospheric pressure: ' + data.pressure); - } - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 霍尔传感器类型为HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | -### HALL +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听霍尔传感器数据变化一次。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | +```js +try { + sensor.once(sensor.SensorId.HALL, function(data) { + console.info('Status: ' + data.status); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { - console.info('Status: ' + data.status); - } - ); - ``` +### HEART_RATE9+ -### AMBIENT_LIGHT +once(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>): void -once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>): void +订阅一次心率传感器数据。 -监听环境光传感器数据变化一次。 +**需要权限**:ohos.permission.READ_HEALTH_DATA -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | -------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 心率传感器类型为HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -**示例:** +**错误码**: - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { - console.info(' Illumination: ' + data.intensity); - } - ); - ``` +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -### ORIENTATION +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>): void +**示例:** -监听方向传感器数据变化一次。 +```js +try { + sensor.once(sensor.SensorId.HEART_BEAT_RATE, function(data) { + console.info('Heart rate: ' + data.heartRate); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**系统能力**:SystemCapability.Sensors.Sensor +### HUMIDITY9+ -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +once(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>): void -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { - console.info('The device rotates at an angle around the X axis: ' + data.beta); - console.info('The device rotates at an angle around the Y axis: ' + data.gamma); - console.info('The device rotates at an angle around the Z axis: ' + data.alpha); - } - ); - ``` +订阅一次湿度传感器数据。 -### ROTATION_VECTOR +**系统能力**:SystemCapability.Sensors.Sensor -once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<RotationVectorResponse>): void +**参数:** -监听旋转矢量传感器数据变化一次。 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 湿度传感器类型为HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -**系统能力**:SystemCapability.Sensors.Sensor +**错误码**: -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('Scalar quantity: ' + data.w); - } - ); - ``` +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -### HEART_RATE(deprecated) +**示例:** -once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void +```js +try { + sensor.once(sensor.SensorId.HUMIDITY, function(data) { + console.info('Humidity: ' + data.humidity); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -监听心率传感器数据变化一次。 +### LINEAR_ACCELERATION9+ -从API Version9开始该接口不再维护,请使用[sensor.once.HEART_BEAT_RATE](#heart_beat_rate9) +once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAccelerometerResponse>): void -**需要权限**:ohos.permission.HEART_RATE +订阅一次线性加速度传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 线性加速度传感器类型为LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -### HEART_BEAT_RATE9+ +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback<HeartRateResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -订阅一次心率传感器数据。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +### MAGNETIC_FIELD9+ + +once(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>): void -**需要权限**:ohos.permission.READ_HEALTH_DATA +订阅一次磁场传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, function(data) { - console.info("Heart rate: " + data.heartRate); - } - ); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 磁场传感器类型为MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -### WEAR_DETECTION +**错误码**: -once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -监听佩戴检测传感器数据变化一次。 +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**系统能力**:SystemCapability.Sensors.Sensor +**示例:** -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +```js +try { + sensor.once(sensor.SensorId.MAGNETIC_FIELD, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { - console.info("Wear status: "+ data.value); - } - ); - ``` +### MAGNETIC_FIELD_UNCALIBRATED9+ -## sensor.off +once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticFieldUncalibratedResponse>): void -### ACCELEROMETER +订阅一次未经校准的磁场传感器数据。 -off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<AccelerometerResponse>): void +**系统能力**:SystemCapability.Sensors.Sensor -取消订阅传感器数据。 +**参数:** -**需要权限**:ohos.permission.ACCELEROMETER +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -**系统能力**:SystemCapability.Sensors.Sensor +**错误码**: -**参数:** +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**示例:** +**示例:** ```js -function callback(data) { - console.info('x-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); ``` -### ACCELEROMETER_UNCALIBRATED - -off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback<AccelerometerUncalibratedResponse>): void +### ORIENTATION9+ -取消订阅传感器数据。 +once(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>): void -**需要权限**:ohos.permission.ACCELEROMETER +订阅一次定向传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 方向传感器类型为ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -**示例:** +**错误码**: -```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); -} -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback); -``` - -### AMBIENT_LIGHT +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightResponse>): void +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -取消订阅传感器数据。 +**示例:** -**系统能力**:SystemCapability.Sensors.Sensor +```js +try { + sensor.once(sensor.SensorId.ORIENTATION, function(data) { + console.info('The device rotates at an angle around the X axis: ' + data.beta); + console.info('The device rotates at an angle around the Y axis: ' + data.gamma); + console.info('The device rotates at an angle around the Z axis: ' + data.alpha); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**参数:** +### PEDOMETER9+ -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +once(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>): void -**示例:** +订阅一次计步器传感器数据。 -```js -function callback(data) { - console.info(' Illumination: ' + data.intensity); -} -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); -``` +**需要权限**:ohos.permission.ACTIVITY_MOTION -### AMBIENT_TEMPERATURE +**系统能力**:SystemCapability.Sensors.Sensor -off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatureResponse>): void +**参数:** -取消订阅传感器数据。 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 计步传感器类型为PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -**系统能力**:SystemCapability.Sensors.Sensor +**错误码**: -**参数:** +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Temperature: ' + data.temperature); +try { + sensor.once(sensor.SensorId.PEDOMETER, function(data) { + console.info('Steps: ' + data.steps); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback); ``` -### AMBIENT_TEMPERATURE +### PEDOMETER_DETECTION9+ -off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerResponse>): void +once(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>): void -取消订阅传感器数据。 +订阅一次计步器检测传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**需要权限**:ohos.permission.ACTIVITY_MOTION -**参数:** +**系统能力**:SystemCapability.Sensors.Sensor -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +**参数:** -**示例:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 计步检测传感器类型为PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** ```js -function callback(data) { - console.info('Atmospheric pressure: ' + data.pressure); +try { + sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function(data) { + console.info('Scalar data: ' + data.scalar); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback); ``` -### GRAVITY +### PROXIMITY9+ -off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityResponse>): void +once(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>): void -取消订阅传感器数据。 +订阅一次接近传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 接近光传感器类型为PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -**示例:** +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + sensor.once(sensor.SensorId.PROXIMITY, function(data) { + console.info('Distance: ' + data.distance); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); ``` -### GYROSCOPE +### ROTATION_VECTOR9+ -off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeResponse>): void - -取消订阅传感器数据。 +once(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorResponse>): void -**需要权限**:ohos.permission.GYROSCOPE +订阅一次旋转矢量传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 旋转矢量传感器类型为ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + sensor.once(sensor.SensorId.ROTATION_VECTOR, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('Scalar quantity: ' + data.w); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); ``` -### GYROSCOPE_UNCALIBRATED - -off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncalibratedResponse>): void +### SIGNIFICANT_MOTION9+ -取消订阅传感器数据。 +once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>): void -**需要权限**:ohos.permission.GYROSCOPE +订阅一次重要的运动传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 有效运动传感器类型为SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function(data) { + console.info('Scalar data: ' + data.scalar); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback); ``` -### HALL +### WEAR_DETECTION9+ -off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse>): void +once(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void -取消订阅传感器数据。 +订阅一次磨损检测传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 佩戴检测传感器类型为WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | + +**错误码**: + +以下错误码的详细介绍请参见 [ohos.sensor(传感器)错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** ```js -function callback(data) { - console.info('Status: ' + data.status); +try { + sensor.once(sensor.SensorId.WEAR_DETECTION, function(data) { + console.info("Wear status: "+ data.value); + } + ); +} catch(err) { + console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); ``` -### HEART_RATE(deprecated) +## sensor.off9+ -off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void +### ACCELEROMETER9+ -取消订阅传感器数据。 +off(type: SensorId.ACCELEROMETER, callback?: Callback<AccelerometerResponse>): void -从API Version9开始该接口不再维护,请使用[sensor.off.HEART_BEAT_RATE](#heart_beat_rate9) +取消订阅加速度计传感器数据。 -**需要权限**:ohos.permission.HEALTH_DATA +**需要权限**:ohos.permission.ACCELEROMETER **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的加速度传感器类型为ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | -### HEART_BEAT_RATE9+ +**示例:** + +```js +try { + function callback(data) { + console.info('x-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off(sensor.SensorId.ACCELEROMETER, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -off(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback?: Callback<HeartRateResponse>): void +### ACCELEROMETER_UNCALIBRATED9+ -取消订阅传感器数据。 +off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback<AccelerometerUncalibratedResponse>): void + +取消订阅未校准的加速度计传感器数据。 -**需要权限**:ohos.permission.READ_HEALTH_DATA +**需要权限**:ohos.permission.ACCELEROMETER **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的未校准加速度计传感器类型为ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | **示例:** ```js -function callback(data) { - console.info("Heart rate: " + data.heartRate); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback); ``` -### HUMIDITY +### AMBIENT_LIGHT9+ -off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityResponse>): void +off(type: SensorId.AMBIENT_LIGHT, callback?: Callback<LightResponse>): void -取消订阅传感器数据。 +取消订阅环境光传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的环境光传感器类型为AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Humidity: ' + data.humidity); +try { + function callback(data) { + console.info('Illumination: ' + data.intensity); + } + sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback); ``` -### LINEAR_ACCELERATION(deprecated) - -off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback<LinearAccelerometerResponse>): void - -取消订阅传感器数据。 +### AMBIENT_TEMPERATURE9+ -从API Version9开始该接口不再维护,请使用[sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9) +off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatureResponse>): void -**需要权限**:ohos.permission.ACCELEROMETER +取消订阅环境温度传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的环境温度传感器类型为AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | -### LINEAR_ACCELEROMETER9+ +**示例:** -off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback?: Callback<LinearAccelerometerResponse>): void +```js +try { + function callback(data) { + console.info('Temperature: ' + data.temperature); + } + sensor.off( sensor.SensorId.AMBIENT_TEMPERATURE, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -取消订阅传感器数据。 +### BAROMETER9+ -**需要权限**:ohos.permission.ACCELEROMETER +off(type: SensorId.BAROMETER, callback?: Callback<BarometerResponse>): void + +取消订阅气压计传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的气压计传感器类型为BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | **示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + function callback(data) { + console.info('Atmospheric pressure: ' + data.pressure); + } + sensor.off(sensor.SensorId.BAROMETER, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); ``` -### MAGNETIC_FIELD +### GRAVITY9+ - off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void +off(type: SensorId.GRAVITY, callback?: Callback<GravityResponse>): void -取消订阅传感器数据。 +取消订阅重力传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的重力传感器类型为GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off( sensor.SensorId.GRAVITY, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); ``` -### MAGNETIC_FIELD_UNCALIBRATED +### GYROSCOPE9+ - off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticFieldUncalibratedResponse>): void +off(type: SensorId.GYROSCOPE, callback?: Callback<GyroscopeResponse>): void -取消订阅传感器数据。 +取消订阅陀螺仪传感器数据。 + +**需要权限**:ohos.permission.GYROSCOPE **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的陀螺仪传感器类型为GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('X-coordinate bias: ' + data.biasX); - console.info('Y-coordinate bias: ' + data.biasY); - console.info('Z-coordinate bias: ' + data.biasZ); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off(sensor.SensorId.GYROSCOPE, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback); ``` -### ORIENTATION +### GYROSCOPE_UNCALIBRATED9+ - off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback<OrientationResponse>): void +off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncalibratedResponse>): void -取消订阅传感器数据。 + 取消订阅未校准的陀螺仪传感器数据。 + +**需要权限**:ohos.permission.GYROSCOPE **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('The device rotates at an angle around the X axis: ' + data.beta); - console.info('The device rotates at an angle around the Y axis: ' + data.gamma); - console.info('The device rotates at an angle around the Z axis: ' + data.alpha); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); ``` -### PEDOMETER +### HALL9+ -off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerResponse>): void - -取消订阅传感器数据。 +off(type: SensorId.HALL, callback?: Callback<HallResponse>): void -**需要权限**:ohos.permission.ACTIVITY_MOTION +取消订阅霍尔传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的霍尔传感器类型为HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Steps: ' + data.steps); +try { + function callback(data) { + console.info('Status: ' + data.status); + } + sensor.off(sensor.SensorId.HALL, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); ``` -### PEDOMETER_DETECTION +### HEART_RATE9+ -off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback<PedometerDetectionResponse>): void +off(type: SensorId.HEART_RATE, callback?: Callback<HeartRateResponse>): void -取消订阅传感器数据。 +取消订阅心率传感器数据。 -**需要权限**:ohos.permission.ACTIVITY_MOTION +**需要权限**:ohos.permission.READ_HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的心率传感器类型为HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Scalar data: ' + data.scalar); +try { + function callback(data) { + console.info("Heart rate: " + data.heartRate); + } + sensor.off(sensor.SensorId.HEART_RATE, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); ``` -### PROXIMITY +### HUMIDITY9+ -off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityResponse>): void +off(type: SensorId.HUMIDITY, callback?: Callback<HumidityResponse>): void -取消订阅传感器数据。 +取消订阅湿度传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的湿度传感器类型为HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Distance: ' + data.distance); +try { + function callback(data) { + console.info('Humidity: ' + data.humidity); + } + sensor.off(sensor.SensorId.HUMIDITY, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback); ``` -### ROTATION_VECTOR +### LINEAR_ACCELEROMETER9+ -off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<RotationVectorResponse>): void +off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback<LinearAccelerometerResponse>): void -取消订阅传感器数据。 +取消订阅线性加速度传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**需要权限**:ohos.permission.ACCELEROMETER -**参数:** +**系统能力**:SystemCapability.Sensors.Sensor -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +**参数:** -**示例:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的线性加速度传感器类型为LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | + +**示例:** ```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - console.info('Scalar quantity: ' + data.w); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); ``` -### SIGNIFICANT_MOTION +### MAGNETIC_FIELD9+ -off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionResponse>): void +off(type: SensorId.MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void -取消订阅传感器数据。 +取消订阅磁场传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的磁场传感器类型为MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -**示例:** +**示例:** ```js -function callback(data) { - console.info('Scalar data: ' + data.scalar); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback); ``` -### WEAR_DETECTION +### MAGNETIC_FIELD_UNCALIBRATED9+ -off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearDetectionResponse>): void +off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticFieldUncalibratedResponse>): void -取消订阅传感器数据。 +取消订阅未校准的磁场传感器数据。 -**系统能力**:SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -**示例:** +**示例:** ```js -function accCallback(data) { - console.info('Wear status: ' + data.value); +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); } -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback); ``` -## sensor.transformCoordinateSystem +### ORIENTATION9+ -transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions, callback: AsyncCallback<Array<number>>): void +off(type: SensorId.ORIENTATION, callback?: Callback<OrientationResponse>): void -旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 +取消订阅方向传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ---------------------------------------- | ---- | ----------- | -| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | -| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | -| callback | AsyncCallback<Array<number>> | 是 | 返回转换后的旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的方向传感器类型为ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -**示例:** +**示例:** ```js -sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) { - if (err) { - console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); - return; - } - console.info("Operation successed. Data obtained: " + data); - for (var i=0; i < data.length; i++) { - console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); +try { + function callback(data) { + console.info('The device rotates at an angle around the X axis: ' + data.beta); + console.info('The device rotates at an angle around the Y axis: ' + data.gamma); + console.info('The device rotates at an angle around the Z axis: ' + data.alpha); } - }) + sensor.off(sensor.SensorId.ORIENTATION, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` -## sensor.transformCoordinateSystem -transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> +### PEDOMETER9+ -旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 +off(type: SensorId.PEDOMETER, callback?: Callback<PedometerResponse>): void -**系统能力**:SystemCapability.Sensors.Sensor +取消订阅计步器传感器数据。 -**参数:** +**需要权限**:ohos.permission.ACTIVITY_MOTION -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ---------------------------------------- | ---- | -------- | -| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | -| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | +**系统能力**:SystemCapability.Sensors.Sensor -**返回值:** +**参数:** -| 类型 | 说明 | -| ---------------------------------- | ----------- | -| Promise<Array<number>> | 返回转换后的旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的计步传感器类型为PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -**示例:** +**示例:** ```js -const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}); - promise.then((data) => { - console.info("Operation successed."); - for (var i=0; i < data.length; i++) { - console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); - } - }).catch((err) => { - console.info("Operation failed"); -}) +try { + function callback(data) { + console.info('Steps: ' + data.steps); + } + sensor.off(sensor.SensorId.PEDOMETER, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` -## sensor.getGeomagneticField +### PEDOMETER_DETECTION9+ -getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback<GeomagneticResponse>): void +off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback<PedometerDetectionResponse>): void -获取地球上特定位置的地磁场。 +取消订阅计步器检测传感器数据。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- | -| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | -| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | -| callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的计步检测传感器类型为PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | + +**示例:** -**示例:** ```js -sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) { - if (err) { - console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); - return; +try { + function callback(data) { + console.info('Scalar data: ' + data.scalar); } - console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' + - data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + - ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); -}); + sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` -## sensor.getGeomagneticField -getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> +### PROXIMITY9+ -获取地球上特定位置的地磁场。 +off(type: SensorId.PROXIMITY, callback?: Callback<ProximityResponse>): void + +取消订阅接近传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------- | ----------------------------------- | ---- | ----------------- | -| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | -| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | +**参数:** -**返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ------- | -| Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的接近光传感器类型为PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -**示例:** - ```js - const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000); - promise.then((data) => { - console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + - data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + - ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); - }).catch((reason) => { - console.info('Operation failed.'); - }) - ``` +**示例:** + +```js +try { + function callback(data) { + console.info('Distance: ' + data.distance); + } + sensor.off(sensor.SensorId.PROXIMITY, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -## sensor.getAltitude +### ROTATION_VECTOR9+ -getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback<number>): void +off(type: SensorId.ROTATION_VECTOR, callback?: Callback<RotationVectorResponse>): void -根据气压值获取设备所在的海拔高度。 +取消订阅旋转矢量传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------- | --------------------------- | ---- | -------------------- | -| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | -| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | -| callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的旋转矢量传感器类型为ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | -**示例:** +**示例:** - ```js - sensor.getAltitude(0, 200, function(err, data) { - if (err) { - console.error( - "Operation failed. Error code: " + err.code + ", message: " + err.message); - return; - } - console.info("Successed to get getAltitude interface get data: " + data); - }); - ``` +```js +try { + function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('Scalar quantity: ' + data.w); + } + sensor.off(sensor.SensorId.ROTATION_VECTOR, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -## sensor.getAltitude +### SIGNIFICANT_MOTION9+ -getAltitude(seaPressure: number, currentPressure: number): Promise<number> +off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionResponse>): void -根据气压值获取设备所在的海拔高度。 +取消订阅重要的运动传感器数据。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------- | ------ | ---- | -------------------- | -| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | -| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的大幅动作传感器类型为SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | -**返回值:** +**示例:** -| 类型 | 说明 | -| --------------------- | ------------------ | -| Promise<number> | 返回设备所在的海拔高度(单位:米)。 | +```js +try { + function callback(data) { + console.info('Scalar data: ' + data.scalar); + } + sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -**示例:** +### WEAR_DETECTION9+ - ```js - const promise = sensor.getAltitude(0, 200); +off(type: SensorId.WEAR_DETECTION, callback?: Callback<WearDetectionResponse>): void + +取消订阅磨损检测传感器数据。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorId](#sensorid9) | 是 | 要取消订阅的佩戴检测传感器类型为WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | + +**示例:** + +```js +try { + function accCallback(data) { + console.info('Wear status: ' + data.value); + } + sensor.off(sensor.SensorId.WEAR_DETECTION, accCallback); +} catch(err) { + console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` + +## sensor.getGeomagneticInfo9+ + +getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback<GeomagneticResponse>): void + +获取地球上特定位置的地磁场 。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | +| callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getGeomagneticInfo错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getGeomagneticInfo({latitude:80, longitude:0, altitude:0}, 1580486400000, function(data) { + console.info('sensor_getGeomagneticInfo_callback x: ' + data.x + ',y: ' + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + }); +} catch (err) { + console.error('getGeomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getGeomagneticInfo9+ + +getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> + +获取地球上特定位置的地磁场 。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ----------------------------------- | ---- | ---------------------------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------------------- | -------------- | +| Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getGeomagneticInfo错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.getGeomagneticInfo({latitude:80, longitude:0, altitude:0}, 1580486400000); promise.then((data) => { - console.info(' sensor_getAltitude_Promise success', data); - }).catch((err) => { - console.error("Operation failed"); + console.info('sensor_getGeomagneticInfo_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + }).catch((reason) => { + console.info('Operation failed.'); }) - ``` +} catch (err) { + console.error('getGeomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` +## sensor.getDeviceAltitude9+ -## sensor.getGeomagneticDip +getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback<number>): void -getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallback<number>): void +根据当前气压获取设备所在的海拔高度。 -根据倾斜矩阵计算地磁倾斜角。 +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | --------------------------- | ---- | ------------------------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +| callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getDeviceAltitude错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getDeviceAltitude(0, 200, function(data) { + console.info('Successed to get getDeviceAltitude interface get data: ' + data); + }); +} catch (err) { + console.error('getDeviceAltitude failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getDeviceAltitude9+ + +getDeviceAltitude(seaPressure: number, currentPressure: number): Promise<number> + +根据当前气压获取设备所在的海拔高度。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | --------------------------- | ---- | -------------- | -| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | -| callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------ | ---- | ------------------------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------------------ | +| Promise<number> | 返回设备所在的海拔高度(单位:米)。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getDeviceAltitude错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { - if (err) { - console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' + - err.message); - return; - } - console.info("Successed to get getGeomagneticDip interface get data: " + data); +```js +try { + const promise = sensor.getDeviceAltitude (0, 200); + promise.then((data) => { + console.info('sensor_getDeviceAltitude_Promise success', data); + }).catch((err) => { + console.error("Operation failed"); }) - ``` +} catch (err) { + console.error('getDeviceAltitude failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` -## sensor.getGeomagneticDip +## sensor.getInclination9+ -getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> +getInclination(inclinationMatrix: Array<number>, callback: AsyncCallback<number>): void -根据倾斜矩阵计算地磁倾斜角。 +从倾角矩阵计算地磁倾角的弧度。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | ------------------- | ---- | ------- | -| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | --------------------------- | ---- | ---------------------------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | +| callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getInclination错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getInclination ([1, 0, 0, 0, 1, 0, 0, 0, 1], function(data) { + console.info('Successed to get getInclination interface get data: ' + data); + }) +} catch (err) { + console.error('getInclination failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getInclination9+ + + getInclination(inclinationMatrix: Array<number>): Promise<number> + + 从倾角矩阵计算地磁倾角的弧度。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------------------- | ---- | -------------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | **返回值:** -| 类型 | 说明 | -| --------------------- | -------------- | +| 类型 | 说明 | +| --------------------- | ---------------------------- | | Promise<number> | 返回地磁倾斜角,单位为弧度。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getInclination错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** - ```js - const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); +```js +try { + const promise = sensor.getInclination ([1, 0, 0, 0, 1, 0, 0, 0, 1]); promise.then((data) => { - console.info('getGeomagneticDip_promise successed', data); + console.info('getInclination_promise successed', data); }).catch((err) => { console.error("Operation failed"); }) - ``` +} catch (err) { + console.error('getInclination failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` -## sensor. getAngleModify +## sensor.getAngleVariation9+ -getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void + getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, + callback: AsyncCallback): void -获取两个旋转矩阵之间的角度变化。 +得到两个旋转矩阵之间的角度变化。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------------- | ---------------------------------------- | ---- | ------------------ | -| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | -| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -| callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ---------------------------------------- | ---- | --------------------------------- | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getAngleVariation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { - if (err) { - console.error('Failed to register data, error code is: ' + err.code + ', message: ' + - err.message); - return; - } +```js +try { + sensor.getAngleVariation([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(data) { for (var i=0; i < data.length; i++) { console.info("data[" + i + "]: " + data[i]); } }) - ``` - +} catch (err) { + console.error('getAngleVariation failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` -## sensor. getAngleModify +## sensor.getAngleVariation9+ -getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise<Array<number>> +getAngleVariation(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise -获取两个旋转矩阵之间的角度变化。 +得到两个旋转矩阵之间的角度变化。 **系统能力**:SystemCapability.Sensors.Sensor -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------------------- | ------------------- | ---- | --------- | -| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | -| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ------------------- | ---- | ------------------ | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | | **返回值:** -| 类型 | 说明 | -| ---------------------------------- | ------------------ | +| 类型 | 说明 | +| ---------------------------------- | --------------------------------- | | Promise<Array<number>> | 返回z、x、y轴方向的旋转角度变化。 | +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getAngleVariation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + **示例:** - ```js - const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); +```js +try { + const promise = sensor.getAngleVariation([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); promise.then((data) => { - console.info('getAngleModifiy_promise success'); for (var i=0; i < data.length; i++) { - console.info("data[" + i + "]: " + data[i]); + console.info('data[' + i + ']: ' + data[i]); } }).catch((reason) => { - console.info("promise::catch", reason); + console.info('promise::catch ', reason); }) - ``` - +} catch (err) { + console.error('getAngleVariation failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` -## sensor.createRotationMatrix +## sensor.getRotationMatrix9+ -createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void +getRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback): void -将旋转矢量转换为旋转矩阵。 +将旋转向量转换为旋转矩阵。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------- | ---- | ------- | -| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -| callback | AsyncCallback<Array<number>> | 是 | 返回旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | -------------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回旋转矩阵。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | **示例:** - ```js - sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { - if (err) { - console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + - err.message); - return; - } +```js +try { + sensor.getRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(data) { for (var i=0; i < data.length; i++) { - console.info("data[" + i + "]: " + data[i]); + console.info('data[' + i + ']: ' + data[i]); } }) - ``` +} catch (err) { + console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` +## sensor.getRotationMatrix9+ -## sensor.createRotationMatrix +getRotationMatrix(rotationVector: Array<number>): Promise -createRotationMatrix(rotationVector: Array<number>): Promise<Array<number>> +将旋转向量转换为旋转矩阵。 -将旋转矢量转换为旋转矩阵。 +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | -------------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | -------------- | +| Promise<Array<number>> | 返回旋转矩阵。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.getRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + for (var i=0; i < data.length; i++) { + console.info('data[' + i + ']: ' + data[i]); + } + }).catch((reason) => { + console.info('promise::catch ', reason); + }) +} catch (err) { + console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.transformRotationMatrix9+ + +transformRotationMatrix(inRotationVector: Array<number>, coordinates: CoordinatesOptions, + callback: AsyncCallback): void + +旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------- | ---- | ------- | -| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ----------------------------------------- | ---- | ---------------------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回转换后的旋转矩阵。 | -**返回值:** +**错误码**: -| 类型 | 说明 | -| ---------------------------------- | ------- | -| Promise<Array<number>> | 返回旋转矩阵。 | +以下错误码的详细介绍请参见 [sensor.transformRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.transformRotationMatrix([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(data) { + for (var i=0; i < data.length; i++) { + console.info('transformRotationMatrix data[' + i + '] = ' + data[i]); + } + }) +} catch (err) { + console.error('transformRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.transformRotationMatrix9+ + +transformRotationMatrix(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise + +旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ----------------------------------------- | ---- | ---------------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | ---------------------- | +| Promise<Array<number>> | 返回转换后的旋转矩阵。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.transformRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.transformRotationMatrix([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}); + promise.then((data) => { + for (var i=0; i < data.length; i++) { + console.info('transformRotationMatrix data[' + i + '] = ' + data[i]); + } + }).catch((err) => { + console.info("Operation failed"); +}) +} catch (err) { + console.error('transformRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getQuaternion9+ + +getQuaternion(rotationVector: Array<number>, callback: AsyncCallback): void + +将旋转向量转换为归一化四元数。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | -------------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回四元数。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getQuaternion错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getQuaternion ([0.20046076, 0.21907, 0.73978853, 0.60376877], function(data) { + for (var i=0; i < data.length; i++) { + console.info('data[' + i + ']: ' + data[i]); + } + }) +} catch (err) { + console.error('getQuaternion failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getQuaternion9+ + +getQuaternion(rotationVector: Array<number>): Promise + +将旋转向量转换为归一化四元数。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | -------------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | ------------ | +| Promise<Array<number>> | 返回四元数。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getQuaternion错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.getQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info('getQuaternionn_promise successed'); + for (var i=0; i < data.length; i++) { + console.info('data[' + i + ']: ' + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) +} catch (err) { + console.error('getQuaternion failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getOrientation9+ + +getOrientation(rotationMatrix: Array<number>, callback: AsyncCallback): void + +根据旋转矩阵计算设备的方向。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | --------------------------------- | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回围绕z、x、y轴方向的旋转角度。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getOrientation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getOrientation([1, 0, 0, 0, 1, 0, 0, 0, 1], function(data) { + console.info("SensorJsAPI--->Successed to get getOrientation interface get data: " + data); + for (var i = 1; i < data.length; i++) { + console.info('sensor_getOrientation_callback ' + data[i]); + } + }) +} catch (err) { + console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getOrientation9+ + +getOrientation(rotationMatrix: Array<number>): Promise + +根据旋转矩阵计算设备的方向。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | -------------- | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------- | --------------------------------- | +| Promise<Array<number>> | 返回围绕z、x、y轴方向的旋转角度。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getOrientation错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.getOrientation([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info('sensor_getOrientation_Promise success', data); + for (var i = 1; i < data.length; i++) { + console.info('sensor_getOrientation_promise ' + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) +} catch (err) { + console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getRotationMatrix9+ + +getRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>, callback: AsyncCallback<RotationMatrixResponse>): void + +根据重力矢量和地磁矢量计算旋转矩阵。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------------------------------------------ | ---- | -------------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | +| callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | 是 | 返回旋转矩阵。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getRotationMatrix ([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(data) { + console.info('sensor_getRotationMatrix_callback ' + JSON.stringify(data)); + }) +} catch (err) { + console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getRotationMatrix9+ + +getRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> + +根据重力矢量和地磁矢量计算旋转矩阵。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------- | ---- | -------------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | -------------- | +| Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | 返回旋转矩阵。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getRotationMatrix错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + const promise = sensor.getRotationMatrix ([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); + promise.then((data) => { + console.info('sensor_getRotationMatrix_callback ' + JSON.stringify(data)); + }).catch((err) => { + console.info('promise failed'); + }) +} catch (err) { + console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getSensorList9+ + + getSensorList(callback: AsyncCallback): void + +获取设备上的所有传感器信息。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ---------------- | +| callback | AsyncCallback | 是 | 返回传感器列表。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSensorList错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getSensorList((data) => { + console.info('getSensorList callback in ' + data.length); + for (var i = 0; i < data.length; i++) { + console.info("getSensorList " + JSON.stringify(data[i])); + } + }); +} catch (err) { + console.error('getSensorList failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getSensorList9+ + + getSensorList(): Promise< Array<Sensor>> + +获取设备上的所有传感器信息。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**返回值:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------- | +| promise | Promise | 是 | 返回传感器列表。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSensorList错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getSensorList().then((data) => { + console.info('getSensorList promise in ' + data.length); + for (var i = 0; i < data.length; i++) { + console.info("getSensorList " + JSON.stringify(data[i])); + } + }, (error)=>{ + console.error('getSensorList failed'); + }); +} catch (err) { + console.error('getSensorList failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getSingleSensor9+ + +getSingleSensor(type: SensorId, callback: AsyncCallback<Sensor>): void + +获取指定类型的传感器信息。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ---------------- | +| type | [SensorId](#sensorid9) | 是 | 传感器类型。 | +| callback | AsyncCallback<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSingleSensor错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER, (error, data) => { + console.info('getSingleSensor ' + JSON.stringify(data)); + }); +} catch (err) { + console.error('getSingleSensor failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## sensor.getSingleSensor9+ + + getSingleSensor(type: SensorId): Promise<Sensor> + +获取指定类型的传感器信息。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------- | ---- | ------------ | +| type | [SensorId](#sensorid9) | 是 | 传感器类型。 | + +**返回值:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------- | ---- | ---------------- | +| promise | Promise<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | + +**错误码**: + +以下错误码的详细介绍请参见 [sensor.getSingleSensor错误码](../errorcodes/errorcode-sensor.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------ | +| 14500101 | Service exception. | + +**示例:** + +```js +try { + sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER).then((data) => { + console.info('getSingleSensor '+ JSON.stringify(data)); + }, (error)=>{ + console.error('getSingleSensor failed'); + }); +} catch (err) { + console.error('getSingleSensor failed. Error code: ' + err.code + '; message: ' + err.message); +} +``` + +## SensorId9+ + +表示要订阅或取消订阅的传感器类型。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 默认值 | 说明 | +| --------------------------- | ------ | ---------------------- | +| ACCELEROMETER | 1 | 加速度传感器。 | +| GYROSCOPE | 2 | 陀螺仪传感器。 | +| AMBIENT_LIGHT | 5 | 环境光传感器。 | +| MAGNETIC_FIELD | 6 | 磁场传感器。 | +| BAROMETER | 8 | 气压计传感器。 | +| HALL | 10 | 霍尔传感器。 | +| PROXIMITY | 12 | 接近光传感器。 | +| HUMIDITY | 13 | 湿度传感器。 | +| ORIENTATION | 256 | 方向传感器。 | +| GRAVITY | 257 | 重力传感器。 | +| LINEAR_ACCELEROMETER | 258 | 线性加速度传感器。 | +| ROTATION_VECTOR | 259 | 旋转矢量传感器。 | +| AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | +| MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | +| GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | +| SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | +| PEDOMETER_DETECTION | 265 | 计步检测传感器。 | +| PEDOMETER | 266 | 计步传感器。 | +| HEART_RATE | 278 | 心率传感器。 | +| WEAR_DETECTION | 280 | 佩戴检测传感器。 | +| ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | + +## SensorType(deprecated) + +表示要订阅或取消订阅的传感器类型。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 默认值 | 说明 | +| ------------------------------------------ | ------ | ---------------------- | +| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | +| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | +| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | +| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | +| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | +| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | +| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | +| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | +| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | 线性加速度传感器。 | +| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | +| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | +| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | +| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | +| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | +| SENSOR_TYPE_ID_HEART_RATE | 278 | 心率传感器。 | +| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | +| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | + + +## Response + +传感器数据的时间戳。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | ------------------------ | +| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | + +## Sensor9+ + +指示传感器信息。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 说明 | +| --------------- | -------- | ---------------------- | +| sensorName | string | 传感器名称。 | +| venderName | string | 传感器供应商。 | +| firmwareVersion | string | 传感器固件版本。 | +| hardwareVersion | string | 传感器硬件版本。 | +| sensorId | number | 传感器类型id。 | +| maxRange | number | 传感器的最大测量范围。 | +| minSamplePeriod | number | 允许的最小采样周期。 | +| maxSamplePeriod | number | 允许的最大采样周期。 | +| precision | number | 传感器精度。 | +| power | number | 传感器电源。 | + +## AccelerometerResponse + +加速度传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ------------------------------------ | +| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | + + +## LinearAccelerometerResponse + +线性加速度传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ---------------------------------------- | +| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | + + +## AccelerometerUncalibratedResponse + +未校准加速度计传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | ------------------------------------------------ | +| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | +| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | +| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | +| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | + + +## GravityResponse + +重力传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ---------------------------------------- | +| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | + + +## OrientationResponse + +方向传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | --------------------------------- | +| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | +| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | +| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | + + +## RotationVectorResponse + +旋转矢量传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ----------------- | +| x | number | 是 | 是 | 旋转矢量x轴分量。 | +| y | number | 是 | 是 | 旋转矢量y轴分量。 | +| z | number | 是 | 是 | 旋转矢量z轴分量。 | +| w | number | 是 | 是 | 标量。 | + + +## GyroscopeResponse + +陀螺仪传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | -------------------------------- | +| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | + + +## GyroscopeUncalibratedResponse + +未校准陀螺仪传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | ------------------------------------------ | +| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | +| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | +| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | +| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | + + +## SignificantMotionResponse + +有效运动传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | + + +## ProximityResponse + +接近光传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | ---- | ---- | ------------------------------------------------------ | +| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | + + +## LightResponse + +环境光传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | ---------------------- | +| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | + + +## HallResponse + +霍尔传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有。 | + + +## MagneticFieldResponse + +磁场传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ---------------------------- | +| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。 | + + +## MagneticFieldUncalibratedResponse + +未校准磁场传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | -------------------------------------- | +| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | +| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | +| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | +| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | + + +## PedometerResponse + +计步传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | ---------------- | +| steps | number | 是 | 是 | 用户的行走步数。 | + + +## HumidityResponse + +湿度传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | ---- | ---- | --------------------------------------------------------- | +| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | + + +## PedometerDetectionResponse + +计步检测传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | + + +## AmbientTemperatureResponse + +温度传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----------- | -------- | ---- | ---- | -------------------------- | +| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | + + +## BarometerResponse + +气压计传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | ---- | ---- | ------------------------ | +| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | + + +## HeartRateResponse + +心率传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | --------------------------------------- | +| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | + + +## WearDetectionResponse + +佩戴检测传感器数据,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----- | -------- | ---- | ---- | ------------------------------------------------ | +| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | + + +## Options + +设置传感器上报频率。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 说明 | +| -------- | -------- | ------------------------------------------- | +| interval | number | 表示传感器的上报频率,默认值为200000000ns。 | + +## RotationMatrixResponse + +设置旋转矩阵响应对象。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ----------- | ------------------- | ---- | ---- | ---------- | +| rotation | Array<number> | 是 | 是 | 旋转矩阵。 | +| inclination | Array<number> | 是 | 是 | 倾斜矩阵。 | + + +## CoordinatesOptions + +设置坐标选项对象。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | -------- | ---- | ---- | ----------- | +| x | number | 是 | 是 | x坐标方向。 | +| y | number | 是 | 是 | y坐标方向。 | + + +## GeomagneticResponse + +设置地磁响应对象,继承于[Response](#response)。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------------- | -------- | ---- | ---- | -------------------------------------------------- | +| x | number | 是 | 是 | 地磁场的北分量。 | +| y | number | 是 | 是 | 地磁场的东分量。 | +| z | number | 是 | 是 | 地磁场的垂直分量。 | +| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | +| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | +| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | +| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | + +## LocationOptions + +指示地理位置。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | ---------- | +| latitude | number | 是 | 是 | 纬度。 | +| longitude | number | 是 | 是 | 经度。 | +| altitude | number | 是 | 是 | 海拔高度。 | + +## sensor.on(deprecated) + +### ACCELEROMETER(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>,options?: Options): void + +监听加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.ACCELEROMETER](#accelerometer9)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + +### LINEAR_ACCELERATION(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, options?: Options): void + +监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.LINEAR_ACCELEROMETER](#linear_accelerometer9)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +### LINEAR_ACCELEROMETER9+ + +on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, + options?: Options): void + +监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + +### ACCELEROMETER_UNCALIBRATED(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>, options?: Options): void + +监听未校准加速度计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + }, + {interval: 10000000} + ); + ``` + +### GRAVITY(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>,options?: Options): void + +监听重力传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.GRAVITY](#gravity9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + +### GYROSCOPE(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>, options?: Options): void + +监听陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.GYROSCOPE](#gyroscope9)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + +### GYROSCOPE_UNCALIBRATED(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<GyroscopeUncalibratedResponse>, options?: Options): void + +监听未校准陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + }, + {interval: 10000000} + ); + ``` + +### SIGNIFICANT_MOTION(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>, options?: Options): void + +监听大幅动作传感器数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.SIGNIFICANT_MOTION](#significant_motion9) 代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ + console.info('Scalar data: ' + data.scalar); + }, + {interval: 10000000} + ); + ``` + +### PEDOMETER_DETECTION(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>, options?: Options): void + +监听计步检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.PEDOMETER_DETECTION](#pedometer_detection9)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ + console.info('Scalar data: ' + data.scalar); + }, + {interval: 10000000} + ); + ``` + +### PEDOMETER(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>, options?: Options): void + +监听计步传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.PEDOMETER](#pedometer9)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ + console.info('Steps: ' + data.steps); + }, + {interval: 10000000} + ); + ``` + +### AMBIENT_TEMPERATURE(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<AmbientTemperatureResponse>, options?: Options): void + +监听环境温度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.AMBIENT_TEMPERATURE](#ambient_temperature9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ + console.info('Temperature: ' + data.temperature); + }, + {interval: 10000000} + ); + ``` + +### MAGNETIC_FIELD(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>,options?: Options): void + +监听磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.MAGNETIC_FIELD](#magnetic_field9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + +### MAGNETIC_FIELD_UNCALIBRATED(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void + +监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + }, + {interval: 10000000} + ); + ``` + +### PROXIMITY(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>,options?: Options): void + +监听接近光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.PROXIMITY](#proximity9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ + console.info('Distance: ' + data.distance); + }, + {interval: 10000000} + ); + ``` + +### HUMIDITY(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>,options?: Options): void + +监听湿度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.HUMIDITY](#humidity9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ + console.info('Humidity: ' + data.humidity); + }, + {interval: 10000000} + ); + ``` + +### BAROMETER(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>,options?: Options): void + +监听气压计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.BAROMETER](#barometer9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ + console.info('Atmospheric pressure: ' + data.pressure); + }, + {interval: 10000000} + ); + ``` + +### HALL(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, options?: Options): void + +监听霍尔传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.HALL](#hall9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ + console.info('Status: ' + data.status); + }, + {interval: 10000000} + ); + ``` + +### AMBIENT_LIGHT(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>, options?: Options): void + +监听环境光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.AMBIENT_LIGHT](#ambient_light9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ + console.info(' Illumination: ' + data.intensity); + }, + {interval: 10000000} + ); + ``` + +### ORIENTATION(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>, options?: Options): void + +监听方向传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.ORIENTATION](#orientation9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ + console.info('The device rotates at an angle around the X axis: ' + data.beta); + console.info('The device rotates at an angle around the Y axis: ' + data.gamma); + console.info('The device rotates at an angle around the Z axis: ' + data.alpha); + }, + {interval: 10000000} + ); + ``` + +### HEART_RATE(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, options?: Options): void + +监听心率传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.on.HEART_BEAT_RATE](#heart_beat_rate9)代替。 + +**需要权限**:ohos.permission.HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +### HEART_BEAT_RATE9+ + +on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, + options?: Options): void + +监听心率传感器数据变化一次。 + +**需要权限**:ohos.permission.HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +**示例:** + +```js +sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE,function(data){ + console.info("Heart rate: " + data.heartRate); +}, + {interval: 10000000} +); +``` + +### ROTATION_VECTOR(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<RotationVectorResponse>,options?: Options): void + +监听旋转矢量传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.ROTATION_VECTOR](#rotation_vector9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('Scalar quantity: ' + data.w); + }, + {interval: 10000000} + ); + ``` + +### WEAR_DETECTION(deprecated) + +on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>,options?: Options): void + +监听佩戴检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 + +从API version 9 开始不再维护,建议使用[sensor.on.WEAR_DETECTION](#wear_detection9)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ + console.info('Wear status: ' + data.value); + }, + {interval: 10000000} + ); + ``` + +## sensor.once(deprecated) + +### ACCELEROMETER(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>): void + +监听加速度传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.ACCELEROMETER](#accelerometer9-1)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + +### LINEAR_ACCELERATION(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void + +监听线性加速度传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9)代替。 + +**需要权限**:ohos.permission.ACCELERATION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | + +### LINEAR_ACCELEROMETER9+ + +once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void + +订阅一次线性加速度传感器数据。 + +**需要权限**:ohos.permission.ACCELERATION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | + +**示例:** + + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + +### ACCELEROMETER_UNCALIBRATED(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>): void + +监听未校准加速度传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-1)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | + +**示例:** + ``` + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + ); + ``` + +### GRAVITY(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>): void + +监听重力传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.GRAVITY](#gravity9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + +### GYROSCOPE(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>): void + +监听陀螺仪传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.GYROSCOPE](#gyroscope9-1)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + +### GYROSCOPE_UNCALIBRATED(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback<GyroscopeUncalibratedResponse>): void + +监听未校准陀螺仪传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-1)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + ); + ``` + +### SIGNIFICANT_MOTION(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<SignificantMotionResponse>): void + +监听有效运动传感器的数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.SIGNIFICANT_MOTION](#significant_motion9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { + console.info('Scalar data: ' + data.scalar); + } + ); + ``` + +### PEDOMETER_DETECTION(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<PedometerDetectionResponse>): void + +监听计步检测传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.PEDOMETER_DETECTION](#pedometer_detection9-1)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { + console.info('Scalar data: ' + data.scalar); + } + ); + ``` + +### PEDOMETER(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>): void + +监听计步器传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.PEDOMETER](#pedometer9-1)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { + console.info('Steps: ' + data.steps); + } + ); + ``` + +### AMBIENT_TEMPERATURE(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<AmbientTemperatureResponse>): void + +监听环境温度传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.AMBIENT_TEMPERATURE](#ambient_temperature9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { + console.info('Temperature: ' + data.temperature); + } + ); + ``` + +### MAGNETIC_FIELD(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>): void + +监听磁场传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.MAGNETIC_FIELD](#magnetic_field9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + +### MAGNETIC_FIELD_UNCALIBRATED(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>): void + +监听未校准磁场传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); + } + ); + ``` + +### PROXIMITY(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>): void + +监听接近光传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.PROXIMITY](#proximity9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) { + console.info('Distance: ' + data.distance); + } + ); + ``` + +### HUMIDITY(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>): void + +监听湿度传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.HUMIDITY](#humidity9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { + console.info('Humidity: ' + data.humidity); + } + ); + ``` + +### BAROMETER(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>): void + +监听气压计传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.BAROMETER](#barometer9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { + console.info('Atmospheric pressure: ' + data.pressure); + } + ); + ``` + +### HALL(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>): void + +监听霍尔传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.HALL](#hall9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { + console.info('Status: ' + data.status); + } + ); + ``` + +### AMBIENT_LIGHT(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>): void + +监听环境光传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.AMBIENT_LIGHT](#ambient_light9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | + +**示例:** + + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { + console.info(' Illumination: ' + data.intensity); + } + ); + ``` + +### ORIENTATION(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>): void + +监听方向传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.ORIENTATION](#orientation9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { + console.info('The device rotates at an angle around the X axis: ' + data.beta); + console.info('The device rotates at an angle around the Y axis: ' + data.gamma); + console.info('The device rotates at an angle around the Z axis: ' + data.alpha); + } + ); + ``` + +### ROTATION_VECTOR(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<RotationVectorResponse>): void + +监听旋转矢量传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.ROTATION_VECTOR](#rotation_vector9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('Scalar quantity: ' + data.w); + } + ); + ``` + +### HEART_RATE(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void + +监听心率传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.HEART_BEAT_RATE](#heart_beat_rate9)代替。 + +**需要权限**:ohos.permission.HEART_RATE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +### HEART_BEAT_RATE9+ + +once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void + +订阅一次心率传感器数据。 + +**需要权限**:ohos.permission.HEART_RATE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +**示例:** + + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, function(data) { + console.info("Heart rate: " + data.heartRate); + } + ); + ``` + +### WEAR_DETECTION(deprecated) + +once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void + +监听佩戴检测传感器数据变化一次。 + +从API version 9 开始不再维护,建议使用[sensor.once.WEAR_DETECTION](#wear_detection9-1)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { + console.info("Wear status: "+ data.value); + } + ); + ``` + +## sensor.off(deprecated) + +### ACCELEROMETER(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<AccelerometerResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.ACCELEROMETER](#accelerometer9-2)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('x-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback); +``` + +### ACCELEROMETER_UNCALIBRATED(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback<AccelerometerUncalibratedResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-2)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback); +``` + +### AMBIENT_LIGHT(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.AMBIENT_LIGHT](#ambient_light9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | + +**示例:** + +```js +function callback(data) { + console.info(' Illumination: ' + data.intensity); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback); +``` + +### AMBIENT_TEMPERATURE(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatureResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.AMBIENT_TEMPERATURE](#ambient_temperature9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('Temperature: ' + data.temperature); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback); +``` + +### BAROMETER(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.BAROMETER](#barometer9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('Atmospheric pressure: ' + data.pressure); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback); +``` + +### GRAVITY(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.GRAVITY](#gravity9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback); +``` + +### GYROSCOPE(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.GYROSCOPE](#gyroscope9-2)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback); +``` + +### GYROSCOPE_UNCALIBRATED(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncalibratedResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-2)代替。 + +**需要权限**:ohos.permission.GYROSCOPE + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback); +``` + +### HALL(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.HALL](#hall9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('Status: ' + data.status); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); +``` + +### HEART_RATE(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.HEART_BEAT_RATE](#heart_beat_rate9)代替。 + +**需要权限**:ohos.permission.HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +### HEART_BEAT_RATE9+ + +off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void + +取消订阅传感器数据。 + +**需要权限**:ohos.permission.HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | + +**示例:** + +```js +function callback(data) { + console.info("Heart rate: " + data.heartRate); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback); +``` + +### HUMIDITY(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.HUMIDITY](#humidity9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('Humidity: ' + data.humidity); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback); +``` + +### LINEAR_ACCELERATION(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback<LinearAccelerometerResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9)代替。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | + +### LINEAR_ACCELEROMETER9+ + +off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback?:Callback<LinearAccelerometerResponse>): void + +取消订阅传感器数据。 + +**需要权限**:ohos.permission.ACCELEROMETER + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); +``` + +### MAGNETIC_FIELD(deprecated) + + off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void + +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.MAGNETIC_FIELD](#magnetic_field9-2)代替。 + +**系统能力**:SystemCapability.Sensors.Sensor + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | **示例:** - ```js - const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); - promise.then((data) => { - console.info('createRotationMatrix_promise success'); - for (var i=0; i < data.length; i++) { - console.info("data[" + i + "]: " + data[i]); - } - }).catch((reason) => { - console.info("promise::catch", reason); - }) - ``` +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); +``` +### MAGNETIC_FIELD_UNCALIBRATED(deprecated) -## sensor.createQuaternion + off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticFieldUncalibratedResponse>): void -createQuaternion(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void +取消订阅传感器数据。 -将旋转矢量转换为四元数。 +从API version 9 开始不再维护,建议使用[sensor.off.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------- | ---- | ------- | -| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -| callback | AsyncCallback<Array<number>> | 是 | 返回四元数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | **示例:** - ```js - sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { - if (err) { - console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + - err.message); - return; - } - for (var i=0; i < data.length; i++) { - console.info("data[" + i + "]: " + data[i]); - } - }) - ``` +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('X-coordinate bias: ' + data.biasX); + console.info('Y-coordinate bias: ' + data.biasY); + console.info('Z-coordinate bias: ' + data.biasZ); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback); +``` +### ORIENTATION(deprecated) -## sensor.createQuaternion + off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback<OrientationResponse>): void -createQuaternion(rotationVector: Array<number>): Promise<Array<number>> +取消订阅传感器数据。 -将旋转矢量转换为四元数。 +从API version 9 开始不再维护,建议使用[sensor.off.ORIENTATION](#orientation9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------- | ---- | ------- | -| rotationVector | Array<number> | 是 | 表示旋转矢量。 | - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------- | ------ | -| Promise<Array<number>> | 返回四元数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | **示例:** - ```js - const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); - promise.then((data) => { - console.info('createQuaternion_promise successed'); - for (var i=0; i < data.length; i++) { - console.info("data[" + i + "]: " + data[i]); - } - }).catch((err) => { - console.info('promise failed'); - }) - ``` +```js +function callback(data) { + console.info('The device rotates at an angle around the X axis: ' + data.beta); + console.info('The device rotates at an angle around the Y axis: ' + data.gamma); + console.info('The device rotates at an angle around the Z axis: ' + data.alpha); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback); +``` +### PEDOMETER(deprecated) -## sensor.getDirection +off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerResponse>): void -getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void +取消订阅传感器数据。 -根据旋转矩阵计算设备的方向。 +从API version 9 开始不再维护,建议使用[sensor.off.PEDOMETER](#pedometer9-2)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ---------------------------------------- | ---- | ------------------ | -| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -| callback | AsyncCallback<Array<number>> | 是 | 返回围绕z、x、y轴方向的旋转角度。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | **示例:** - ```js - sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { - if (err) { - console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + - err.message); - return; - } - console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data); - for (var i = 1; i < data.length; i++) { - console.info("sensor_getDirection_callback" + data[i]); - } - }) - ``` +```js +function callback(data) { + console.info('Steps: ' + data.steps); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); +``` +### PEDOMETER_DETECTION(deprecated) -## sensor.getDirection +off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback<PedometerDetectionResponse>): void -getDirection(rotationMatrix: Array<number>): Promise<Array<number>> +取消订阅传感器数据。 -根据旋转矩阵计算设备的方向。 +从API version 9 开始不再维护,建议使用[sensor.off.PEDOMETER_DETECTION](#pedometer_detection9-2)代替。 + +**需要权限**:ohos.permission.ACTIVITY_MOTION **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------- | ---- | ------- | -| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------- | ------------------ | -| Promise<Array<number>> | 返回围绕z、x、y轴方向的旋转角度。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | **示例:** - ```js - const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); - promise.then((data) => { - console.info('sensor_getAltitude_Promise success', data); - for (var i = 1; i < data.length; i++) { - console.info("sensor_getDirection_promise" + data[i]); - } - }).catch((err) => { - console.info('promise failed'); - }) - ``` +```js +function callback(data) { + console.info('Scalar data: ' + data.scalar); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback); +``` +### PROXIMITY(deprecated) -## sensor.createRotationMatrix +off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityResponse>): void -createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>, callback: AsyncCallback<RotationMatrixResponse>): void +取消订阅传感器数据。 -根据重力矢量和地磁矢量计算旋转矩阵。 +从API version 9 开始不再维护,建议使用[sensor.off.PROXIMITY](#proximity9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ---------------------------------------- | ---- | ------- | -| gravity | Array<number> | 是 | 表示重力向量。 | -| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | -| callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | 是 | 返回旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | **示例:** - ```js - sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { - if (err) { - console.error('error code is: ' + err.code + ', message: ' + err.message); - return; - } - console.info(JSON.stringify(data)); - }) - ``` +```js +function callback(data) { + console.info('Distance: ' + data.distance); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback); +``` +### ROTATION_VECTOR(deprecated) -## sensor.createRotationMatrix +off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<RotationVectorResponse>): void -createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> +取消订阅传感器数据。 -根据重力矢量和地磁矢量计算旋转矩阵。 +从API version 9 开始不再维护,建议使用[sensor.off.ROTATION_VECTOR](#rotation_vector9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------- | ---- | ------- | -| gravity | Array<number> | 是 | 表示重力向量。 | -| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------------- | ------- | -| Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | 返回旋转矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | **示例:** - ```js - const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); - promise.then((data) => { - console.info(JSON.stringify(data)); - }).catch((err) => { - console.info('promise failed'); - }) - ``` +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + console.info('Scalar quantity: ' + data.w); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback); +``` -## sensor.getSensorLists9+ +### SIGNIFICANT_MOTION(deprecated) - getSensorLists(callback: AsyncCallback): void +off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionResponse>): void -获取设备上的所有传感器信息。 +取消订阅传感器数据。 + +从API version 9 开始不再维护,建议使用[sensor.off.SIGNIFICANT_MOTION](#significant_motion9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ---------------- | -| callback | AsyncCallback | 是 | 返回传感器列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | **示例:** ```js -sensor.getSensorLists((error, data) => { - if (error) { - console.error('getSensorLists failed'); - } else { - console.info("getSensorLists callback in" + data.length); - for (var i = 0; i < data.length; i++) { - console.info("getSensorLists " + JSON.stringify(data[i])); - } - } -}); +function callback(data) { + console.info('Scalar data: ' + data.scalar); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback); ``` -## sensor.getSensorLists9+ +### WEAR_DETECTION(deprecated) + +off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearDetectionResponse>): void - getSensorLists(): Promise< Array<Sensor>> +取消订阅传感器数据。 -获取设备上的所有传感器信息。 +从API version 9 开始不再维护,建议使用[sensor.off.WEAR_DETECTION](#wear_detection9-2)代替。 **系统能力**:SystemCapability.Sensors.Sensor -**返回值:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ---------------------------------------- | ---- | ---------------- | -| promise | Promise | 是 | 返回传感器列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | **示例:** ```js -sensor.getSensorLists().then((data) => { - console.info("getSensorLists promise in" + data.length); - for (var i = 0; i < data.length; i++) { - console.info("getSensorLists " + JSON.stringify(data[i])); - } -}, (error)=>{ - console.error('getSensorLists failed'); -}); +function accCallback(data) { + console.info('Wear status: ' + data.value); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback); ``` -## sensor.getSingleSensor9+ +## sensor.transformCoordinateSystem(deprecated) + +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions, callback: AsyncCallback<Array<number>>): void -getSingleSensor(type: SensorType, callback: AsyncCallback<Sensor>): void +旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 -获取指定类型的传感器信息。 +从API version 9 开始不再维护,建议使用[sensor.transformRotationMatrix](#sensortransformrotationmatrix9)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------- | ---- | ---------------- | -| type | SensorType | 是 | 传感器类型。 | -| callback | AsyncCallback<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | ----------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回转换后的旋转矩阵。 | -**示例:** +**示例:** ```js - sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, (error, data) => { - if (error) { - console.error('getSingleSensor failed'); - } else { - console.info("getSingleSensor " + JSON.stringify(data)); - } -}); +sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) { + if (err) { + console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Operation successed. Data obtained: " + data); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }) ``` +## sensor.transformCoordinateSystem(deprecated) -## sensor.getSingleSensor9+ +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> - getSingleSensor(type: SensorType): Promise<Sensor> +旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。 -获取指定类型的传感器信息。 +从API version 9 开始不再维护,建议使用[sensor.transformRotationMatrix](#sensortransformrotationmatrix9-1)代替。 **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------- | ---- | ------------ | -| type | SensorType | 是 | 传感器类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ---------------------------------------- | ---- | -------- | +| inRotationVector | Array<number> | 是 | 表示旋转矩阵。 | +| coordinates | [CoordinatesOptions](#coordinatesoptions) | 是 | 表示坐标系方向。 | **返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | --------------------------------- | ---- | ---------------- | -| promise | Promise<[Sensor](#sensor9)> | 是 | 返回传感器信息。 | +| 类型 | 说明 | +| ---------------------------------- | ----------- | +| Promise<Array<number>> | 返回转换后的旋转矩阵。 | -**示例:** +**示例:** ```js -sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER).then((data) => { - console.info("getSingleSensor " + JSON.stringify(data)); -}, (error)=>{ - console.error('getSingleSensor failed'); -}); +const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}); + promise.then((data) => { + console.info("Operation successed."); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }).catch((err) => { + console.info("Operation failed"); +}) ``` -## SensorType +## sensor.getGeomagneticField(deprecated) -表示要订阅或取消订阅的传感器类型。 +getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback<GeomagneticResponse>): void -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +获取地球上特定位置的地磁场。 + +从API version 9 开始不再维护,建议使用[sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -| 名称 | 默认值 | 说明 | -| --------------------------------------------------------- | ------ | ---------------------- | -| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | -| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | -| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | -| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | -| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | -| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | -| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | -| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | -| SENSOR_TYPE_ID_LINEAR_ACCELERATION(deprecated) | 258 | 线性加速度传感器。 | -| SENSOR_TYPE_ID_LINEAR_ACCELEROMETER9+ | 258 | 线性加速度传感器。 | -| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | -| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | -| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | -| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | -| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | -| SENSOR_TYPE_ID_HEART_RATE(deprecated) | 278 | 心率传感器。 | -| SENSOR_TYPE_ID_HEART_BEAT_RATE9+ | 278 | 心率传感器。 | -| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | -| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | +| callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | 是 | 返回磁场信息。 | -## Response +**示例:** +```js +sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) { + if (err) { + console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); + return; + } + console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); +}); +``` +## sensor.getGeomagneticField(deprecated) -传感器数据的时间戳。 +getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +获取地球上特定位置的地磁场。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | ------------------------ | -| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | +从API version 9 开始不再维护,建议使用[sensor.getGeomagneticInfo](#sensorgetgeomagneticinfo9-1)代替。 -## Sensor9+ +**系统能力**:SystemCapability.Sensors.Sensor -指示传感器信息。 +**参数:** -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ----------------------------------- | ---- | ----------------- | +| locationOptions | [LocationOptions](#locationoptions) | 是 | 地理位置。 | +| timeMillis | number | 是 | 表示获取磁偏角的时间,单位为毫秒。 | -| 名称 | 参数类型 | 说明 | -| --------------- | -------- | ---------------------- | -| sensorName | string | 传感器名称。 | -| venderName | string | 传感器供应商。 | -| firmwareVersion | string | 传感器固件版本。 | -| hardwareVersion | string | 传感器硬件版本。 | -| sensorTypeId | number | 传感器类型id。 | -| maxRange | number | 传感器的最大测量范围。 | -| precision | number | 传感器精度。 | -| power | number | 传感器电源。 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[GeomagneticResponse](#geomagneticresponse)> | 返回磁场信息。 | -## AccelerometerResponse +**示例:** + ```js + const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000); + promise.then((data) => { + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + }).catch((reason) => { + console.info('Operation failed.'); + }) + ``` -加速度传感器数据,继承于[Response](#response)。 +## sensor.getAltitude(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback<number>): void +根据气压值获取设备所在的海拔高度。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | ---------------------- | -| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | +从API version 9 开始不再维护,建议使用[sensor.getDeviceAltitude](#sensorgetdevicealtitude9)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -## LinearAccelerometerResponse +**参数:** -线性加速度传感器数据,继承于[Response](#response)。 +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | --------------------------- | ---- | -------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +| callback | AsyncCallback<number> | 是 | 返回设备所在的海拔高度,单位为米。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**示例:** + ```js + sensor.getAltitude(0, 200, function(err, data) { + if (err) { + console.error( + "Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Successed to get getAltitude interface get data: " + data); + }); + ``` -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | ------------------------ | -| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | +## sensor.getAltitude(deprecated) +getAltitude(seaPressure: number, currentPressure: number): Promise<number> -## AccelerometerUncalibratedResponse +根据气压值获取设备所在的海拔高度。 -未校准加速度计传感器数据,继承于[Response](#response)。 +从API version 9 开始不再维护,建议使用[sensor.getDeviceAltitude](#sensorgetdevicealtitude9-1)代替。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | ---------------------------- | -| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | -| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | -| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | -| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------ | ---- | -------------------- | +| seaPressure | number | 是 | 表示海平面气压值,单位为hPa。 | +| currentPressure | number | 是 | 表示设备所在高度的气压值,单位为hPa。 | +**返回值:** -## GravityResponse +| 类型 | 说明 | +| --------------------- | ------------------ | +| Promise<number> | 返回设备所在的海拔高度(单位:米)。 | -重力传感器数据,继承于[Response](#response)。 +**示例:** -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor + ```js + const promise = sensor.getAltitude(0, 200); + promise.then((data) => { + console.info(' sensor_getAltitude_Promise success', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | ------------------------ | -| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | +## sensor.getGeomagneticDip(deprecated) +getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallback<number>): void -## OrientationResponse +根据倾斜矩阵计算地磁倾斜角。 -方向传感器数据,继承于[Response](#response)。 +从API version 9 开始不再维护,建议使用[sensor.getInclination](#sensorgetinclination9)代替。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**系统能力**:SystemCapability.Sensors.Sensor +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | ----------------- | -| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | -| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | -| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | --------------------------- | ---- | -------------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | +| callback | AsyncCallback<number> | 是 | 返回地磁倾斜角,单位为弧度。 | +**示例:** -## RotationVectorResponse + ```js + sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' + + err.message); + return; + } + console.info("Successed to get getGeomagneticDip interface get data: " + data); + }) + ``` -旋转矢量传感器数据,继承于[Response](#response)。 +## sensor.getGeomagneticDip(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> +根据倾斜矩阵计算地磁倾斜角。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | --------- | -| x | number | 是 | 是 | 旋转矢量x轴分量。 | -| y | number | 是 | 是 | 旋转矢量y轴分量。 | -| z | number | 是 | 是 | 旋转矢量z轴分量。 | -| w | number | 是 | 是 | 标量。 | +从API version 9 开始不再维护,建议使用[sensor.getInclination](#sensorgetinclination9-1)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -## GyroscopeResponse +**参数:** -陀螺仪传感器数据,继承于[Response](#response)。 +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------------------- | ---- | ------- | +| inclinationMatrix | Array<number> | 是 | 表示倾斜矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**返回值:** + +| 类型 | 说明 | +| --------------------- | -------------- | +| Promise<number> | 返回地磁倾斜角,单位为弧度。 | + +**示例:** + + ```js + const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info('getGeomagneticDip_promise successed', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` +## sensor. getAngleModify(deprecated) -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | ------------------- | -| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void +获取两个旋转矩阵之间的角度变化。 -## GyroscopeUncalibratedResponse +从API version 9 开始不再维护,建议使用[sensor.getAngleVariation](#sensorgetanglevariation9)代替。 -未校准陀螺仪传感器数据,继承于[Response](#response)。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ---------------------------------------- | ---- | ------------------ | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回z、x、y轴方向的旋转角度变化。 | -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | ------------------------ | -| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | -| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | -| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | -| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | +**示例:** + ```js + sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { + if (err) { + console.error('Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }) + ``` -## SignificantMotionResponse -有效运动传感器数据,继承于[Response](#response)。 +## sensor. getAngleModify(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise<Array<number>> +获取两个旋转矩阵之间的角度变化。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ---------------------------------------- | -| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | +从API version 9 开始不再维护,建议使用[sensor.getAngleVariation](#sensorgetanglevariation9-1)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -## ProximityResponse +**参数:** -接近光传感器数据,继承于[Response](#response)。 +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | ------------------- | ---- | --------- | +| currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | +| preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ------------------ | +| Promise<Array<number>> | 返回z、x、y轴方向的旋转角度变化。 | -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | ------ | ---- | ---- | ---------------------------- | -| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | +**示例:** + ```js + const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); + promise.then((data) => { + console.info('getAngleModifiy_promise success'); + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info("promise::catch", reason); + }) + ``` -## LightResponse -环境光传感器数据,继承于[Response](#response)。 +## sensor.createRotationMatrix(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void +将旋转矢量转换为旋转矩阵。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | ------ | ---- | ---- | ----------- | -| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | +从API version 9 开始不再维护,建议使用[sensor.getRotationMatrix](#sensorgetrotationmatrix9)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -## HallResponse +**参数:** -霍尔传感器数据,继承于[Response](#response)。 +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回旋转矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**示例:** + ```js + sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }) + ``` -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有。 | +## sensor.createRotationMatrix(deprecated) -## MagneticFieldResponse +createRotationMatrix(rotationVector: Array<number>): Promise<Array<number>> -磁场传感器数据,继承于[Response](#response)。 +将旋转矢量转换为旋转矩阵。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +从API version 9 开始不再维护,建议使用[sensor.getRotationMatrix](#sensorgetrotationmatrix9-1)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ---------------------------- | -| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -## MagneticFieldUncalibratedResponse +**返回值:** -未校准磁场传感器数据,继承于[Response](#response)。 +| 类型 | 说明 | +| ---------------------------------- | ------- | +| Promise<Array<number>> | 返回旋转矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**示例:** + ```js + const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info('createRotationMatrix_promise success'); + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info("promise::catch", reason); + }) + ``` -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | ---------------------- | -| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | -| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | -| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | -| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | +## sensor.createQuaternion(deprecated) -## PedometerResponse +createQuaternion(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void -计步传感器数据,继承于[Response](#response)。 +将旋转矢量转换为四元数。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +从API version 9 开始不再维护,建议使用[sensor.getQuaternion](#sensorgetquaternion9)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | -------- | -| steps | number | 是 | 是 | 用户的行走步数。 | +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回四元数。 | -## HumidityResponse +**示例:** -湿度传感器数据,继承于[Response](#response)。 + ```js + sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }) + ``` -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +## sensor.createQuaternion(deprecated) -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | ------ | ---- | ---- | ------------------------------------ | -| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | +createQuaternion(rotationVector: Array<number>): Promise<Array<number>> +将旋转矢量转换为四元数。 -## PedometerDetectionResponse +从API version 9 开始不再维护,建议使用[sensor.getQuaternion](#sensorgetquaternion9-1)代替。 -计步检测传感器数据,继承于[Response](#response)。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationVector | Array<number> | 是 | 表示旋转矢量。 | -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ---------------------------------------- | -| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ------ | +| Promise<Array<number>> | 返回四元数。 | -## AmbientTemperatureResponse +**示例:** -温度传感器数据,继承于[Response](#response)。 + ```js + const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info('createQuaternion_promise successed'); + for (var i=0; i < data.length; i++) { + console.info("data[" + i + "]: " + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +## sensor.getDirection(deprecated) -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----------- | ------ | ---- | ---- | ------------- | -| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | +getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void +根据旋转矩阵计算设备的方向。 -## BarometerResponse +从API version 9 开始不再维护,建议使用[sensor.getOrientation](#sensorgetorientation9)代替。 -气压计传感器数据,继承于[Response](#response)。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ---------------------------------------- | ---- | ------------------ | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | +| callback | AsyncCallback<Array<number>> | 是 | 返回围绕z、x、y轴方向的旋转角度。 | -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | ------ | ---- | ---- | ------------ | -| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | +**示例:** + ```js + sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data); + for (var i = 1; i < data.length; i++) { + console.info("sensor_getDirection_callback" + data[i]); + } + }) + ``` -## HeartRateResponse -心率传感器数据,继承于[Response](#response)。 +## sensor.getDirection(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +getDirection(rotationMatrix: Array<number>): Promise<Array<number>> +根据旋转矩阵计算设备的方向。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | ------ | ---- | ---- | --------------------- | -| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | +从API version 9 开始不再维护,建议使用[sensor.getOrientation](#sensorgetorientation9-1)代替。 +**系统能力**:SystemCapability.Sensors.Sensor -## WearDetectionResponse +**参数:** -佩戴检测传感器数据,继承于[Response](#response)。 +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------- | ---- | ------- | +| rotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ------------------ | +| Promise<Array<number>> | 返回围绕z、x、y轴方向的旋转角度。 | -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | ------ | ---- | ---- | ------------------------- | -| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | +**示例:** + ```js + const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info('sensor_getAltitude_Promise success', data); + for (var i = 1; i < data.length; i++) { + console.info("sensor_getDirection_promise" + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` -## Options -设置传感器上报频率。 +## sensor.createRotationMatrix(deprecated) -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>, callback: AsyncCallback<RotationMatrixResponse>): void -| 名称 | 参数类型 | 说明 | -| -------- | ------ | --------------------------- | -| interval | number | 表示传感器的上报频率,默认值为200000000ns。 | +根据重力矢量和地磁矢量计算旋转矩阵。 -## RotationMatrixResponse +从API version 9 开始不再维护,建议使用[sensor.getRotationMatrix](#sensorgetrotationmatrix9-2)代替。 -设置旋转矩阵响应对象。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----------- | ------------------- | ---- | ---- | ----- | -| rotation | Array<number> | 是 | 是 | 旋转矩阵。 | -| inclination | Array<number> | 是 | 是 | 倾斜矩阵。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ---------------------------------------- | ---- | ------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | +| callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | 是 | 返回旋转矩阵。 | +**示例:** -## CoordinatesOptions + ```js + sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { + if (err) { + console.error('error code is: ' + err.code + ', message: ' + err.message); + return; + } + console.info(JSON.stringify(data)); + }) + ``` -设置坐标选项对象。 -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +## sensor.createRotationMatrix(deprecated) -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ------ | ---- | ---- | ------ | -| x | number | 是 | 是 | x坐标方向。 | -| y | number | 是 | 是 | y坐标方向。 | +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> +根据重力矢量和地磁矢量计算旋转矩阵。 -## GeomagneticResponse +从API version 9 开始不再维护,建议使用[sensor.getRotationMatrix](#sensorgetrotationmatrix9-3)代替。 -设置地磁响应对象,继承于[Response](#response)。 +**系统能力**:SystemCapability.Sensors.Sensor -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------------- | ------ | ---- | ---- | ------------------------- | -| x | number | 是 | 是 | 地磁场的北分量。 | -| y | number | 是 | 是 | 地磁场的东分量。 | -| z | number | 是 | 是 | 地磁场的垂直分量。 | -| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | -| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | -| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | -| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------- | ---- | ------- | +| gravity | Array<number> | 是 | 表示重力向量。 | +| geomagnetic | Array<number> | 是 | 表示地磁矢量。 | -## LocationOptions +**返回值:** -指示地理位置。 +| 类型 | 说明 | +| ---------------------------------------- | ------- | +| Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | 返回旋转矩阵。 | -**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor +**示例:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | ------ | ---- | ---- | ----- | -| latitude | number | 是 | 是 | 纬度。 | -| longitude | number | 是 | 是 | 经度。 | -| altitude | number | 是 | 是 | 海拔高度。 | + ```js + const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); + promise.then((data) => { + console.info(JSON.stringify(data)); + }).catch((err) => { + console.info('promise failed'); + }) + ``` 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-notification.md b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md index 54fa874345392ddeeedfd19d9921dfe2530a974f..bef54aaed7b8ead58709274e07a9b43de6bd4fa5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md @@ -51,18 +51,17 @@ show(options?: ShowNotificationOptions): void **示例:** ```javascript -export default { - show() { - notification.show({ - contentTitle: 'title info', - contentText: 'text', - clickAction: { - bundleName: 'com.example.testapp', - abilityName: 'notificationDemo', - uri: '/path/to/notification', - }, - }); - }, +export default { + show() { + notification.show({ + contentTitle: 'title info', + contentText: 'text', + clickAction: { + bundleName: 'com.example.testapp', + abilityName: 'notificationDemo', + uri: '/path/to/notification', + }, + }); + }, } -; ``` \ No newline at end of file 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 3b1df63fcc4bcb7d8ab3cebc929da49eef18eeee..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对象自身 | +## 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对象自身。 | +| 类型 | 说明 | +| ---------- | ---------------------------------- | +| [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对象自身。 | +| 类型 | 说明 | +| ---------- | -------------------------------- | +| [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对象自身。 | +| 类型 | 说明 | +| ---------- | ---------------------------------------- | +| [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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件可点击状态,true:可点击,false:不可点击。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件可长按点击状态,true:可长按点击,false:不可长按点击。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------------- | +| b | boolean | 否 | 控件可滑动状态,true:可滑动,false:不可滑动。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | --------------------------------------------------------- | +| b | boolean | 否 | 指定控件使能状态,true:使能,false:未使能。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ----------------------------------------------------- | +| b | boolean | 否 | 控件获焦状态,true:获焦,false:未获焦。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件被选中状态,true:被选中,false:未被选中。默认为true。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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 | 否 | 指定控件被勾选状态,默认为false。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件被勾选状态,true:被勾选,false:未被勾选。默认为false。 | **返回值:** -| 类型 | 说明 | -| ---- | -------------- | -| 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 | 否 | 指定控件能否被勾选状态,默认为false。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| b | boolean | 否 | 指定控件能否被勾选状态,true:能被勾选,false:不能被勾选。默认为false。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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 | 是 | 特征控件的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 特征控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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 | 是 | 特征控件的属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 特征控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| ---- | ---------------- | -| 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\ +| Promise\ | 以Promise形式返回的控件的id值。 | -获取控件对象的key值。 - -**系统能力**: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() } ``` @@ -588,16 +570,25 @@ getBounds(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------- | -| Promise\ | 以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() } ``` @@ -612,21 +603,30 @@ getBoundsCenter(): Promise\ **返回值:** -| 类型 | 说明 | -| --------------- | --------------------------------------- | -| Promise\ | 以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形式返回控件对象可点击状态。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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形式返回控件对象能否长按点击状态。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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形式返回控件对象被勾选状态。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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\ **返回值:** -| 类型 | 说明 | -| -------------- | ------------------------------------------- | -| Promise\ | 以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形式返回控件对象可滑动状态。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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形式返回控件使能状态。 | +| 类型 | 说明 | +| ----------------- | ---------------------------------------------------------- | +| 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形式返回控件对象是否获焦。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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\ | 控件对象被选中的状态 | +| 类型 | 说明 | +| ----------------- | ----------------------------------------------------- | +| 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 | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| --------------------- | ------------------------------------- | -| Promise\ | 以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 | 是 | 目标控件。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------ | ---- | ---------- | +| 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) } ``` @@ -1015,16 +1139,25 @@ pinchOut(scale: number): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------- | ---- | ---------- | -| scale | number | 是 | 指定比例 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------- | +| 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) } ``` @@ -1039,125 +1172,166 @@ pinchIn(scale: number): Promise\ **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----------- | ---- | ---------- | -| scale | number | 是 | 指定比例 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------- | +| 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 | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| on | [On](#on9) | 是 | 目标控件的属性要求。 | **返回值:** -| 类型 | 说明 | -| --------------------- | --------------------------------- | -| Promise\ | 以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 | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| 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 | 是 | 目标控件的属性要求。 | -| time | number | 是 | 查找目标控件的持续时间。单位ms。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------------------- | +| On | [On](#on9) | 是 | 目标控件的属性要求。 | +| time | number | 是 | 查找目标控件的持续时间。单位ms。 | **返回值:** -| 类型 | 说明 | -| --------------------- | --------------------------------- | -| Promise\ | 以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 | 是 | 目标控件的属性要求。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------- | ---- | -------------------- | +| 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 | 是 | 能否旋转屏幕的标识。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | ------------------------------------------------------- | +| 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调用。 +表示存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。 -### WindowFilter9+ +### create9+ -窗口的标志属性信息。 +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() } @@ -1757,15 +2167,24 @@ getBounds(): Promise\ **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------------- | -| Promise\ | 以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形式返回窗口对象是否获焦。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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形式返回窗口对象是否为用户交互窗口。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| 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形式返回操作是否成功完成。 | +以下错误码的详细介绍请参见[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形式返回操作是否成功完成。 | +| 错误码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形式返回操作是否成功完成。 | +以下错误码的详细介绍请参见[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形式返回操作是否成功完成。 | +| 类型 | 说明 | +| -------- | ---------------------------------------- | +| 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形式返回操作是否成功完成。 | +以下错误码的详细介绍请参见[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形式返回操作是否成功完成。 | +| 错误码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形式返回操作是否成功完成。 | +以下错误码的详细介绍请参见[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,145 +2534,1157 @@ async function demo() { ### close9+ -close(): Promise\ +close(): Promise\ 将窗口关闭。 **系统能力**:SystemCapability.Test.UiTest -**返回值:** +**错误码:** + +以下错误码的详细介绍请参见[uitest测试框架错误码](../errorcodes/errorcode-uitest.md)。 -| 类型 | 说明 | -| -------------- | ----------------------------------- | -| Promise\ | 以Promise形式返回操作是否成功完成。 | +| 错误码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+ +## MatchPattern -表示存储多指操作中每根手指每一步动作的坐标点及其行为的二维数组。 +控件属性支持的匹配模式。 -### create9+ +**系统能力**:SystemCapability.Test.UiTest -static create(fingers: number, steps: number): PointerMatrix +| 名称 | 值 | 说明 | +| ----------- | ---- | -------------- | +| EQUALS | 0 | 等于给定值。 | +| CONTAINS | 1 | 包含给定值。 | +| STARTS_WITH | 2 | 从给定值开始。 | +| ENDS_WITH | 3 | 以给定值结束。 | -静态方法,构造一个PointerMatrix对象,并返回该对象。 +## ResizeDirection9+ + +窗口调整大小的方向。 **系统能力**:SystemCapability.Test.UiTest -**参数:** +| 名称 | 说明 | +| ---------- | -------- | +| LEFT | 左方。 | +| RIGHT | 右方。 | +| UP | 上方。 | +| DOWN | 下方。 | +| LEFT_UP | 左上方。 | +| LEFT_DOWN | 左下方。 | +| RIGHT_UP | 右上方。 | +| RIGHT_DOWN | 右下方。 | -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------ | -| fingers | number | 是 | 多指操作中注入的手指数,取值范围:[1,10]。 | -| steps | number | 是 | 每根手指操作的步骤数,取值范围:[1,1000]。 | +## Point9+ -**返回值:** +坐标点信息。 -| 类型 | 说明 | -| ------------- | ----------------------------- | -| PointerMatrix | 返回构造的PointerMatrix对象。 | +**系统能力**:SystemCapability.Test.UiTest -**示例:** +| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| ---- | -------- | ---- | ---- | ---------------- | +| X | number | 是 | 否 | 坐标点的横坐标。 | +| Y | number | 是 | 否 | 坐标点的纵坐标。 | -```js -async function demo() { - let pointerMatrix = PointerMatrix.create(2,3) +## Rect9+ + +控件的边框信息。 + +**系统能力**:SystemCapability.Test.UiTest + +| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| ------- | -------- | ---- | ---- | ------------------------- | +| leftX | number | 是 | 否 | 控件边框的左上角的X坐标。 | +| topY | number | 是 | 否 | 控件边框的左上角的Y坐标。 | +| rightX | number | 是 | 否 | 控件边框的右下角的X坐标。 | +| bottomY | number | 是 | 否 | 控件边框的右下角的Y坐标。 | + +## WindowMode9+ + +**系统能力**:SystemCapability.Test.UiTest + +窗口的窗口模式。 + +| 名称 | 说明 | +| ---------- | ---------- | +| FULLSCREEN | 全屏模式。 | +| PRIMARY | 主窗口。 | +| SECONDARY | 第二窗口。 | +| FLOATING | 浮动窗口。 | + +## DisplayRotation9+ + +**系统能力**:SystemCapability.Test.UiTest + +设备显示器的显示方向。 + +| 名称 | 说明 | +| ------------ | ---------------------------------------- | +| ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 | +| 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) } ``` -### setPoint9+ +### findComponent(deprecated) -setPoint(finger: number, step: number, point: Point): void +findComponent(by: By): Promise\ -设置PointerMatrix对象中指定手指和步骤对应动作的坐标点。 +在UiDriver对象中,根据给出的目标控件属性要求查找目标控件。 + +从API version9开始不再维护,建议使用[findComponent9+](#findcomponent9)。 **系统能力**:SystemCapability.Test.UiTest **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ---------------- | ---- | ---------------- | -| finger | number | 是 | 手指的序号。 | -| step | number | 是 | 步骤的序号。 | -| point | [Point](#point9) | 是 | 该行为的坐标点。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| by | [By](#by) | 是 | 目标控件的属性要求。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------- | --------------------------------- | +| Promise\<[UiComponent](#uicomponent)> | 以Promise形式返回找到的控件对象。 | **示例:** ```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}) + let driver = UiDriver.create() + let button = await driver.findComponent(BY.text('next page')) } ``` -### +### findComponents(deprecated) -## MatchPattern +findComponents(by: By): Promise\> -控件属性支持的匹配模式。 +在UiDriver对象中,根据给出的目标控件属性要求查找出所有匹配控件,以列表保存。 + +从API version9开始不再维护,建议使用[findComponents9+](#findcomponents9)。 **系统能力**:SystemCapability.Test.UiTest -| 名称 | 值 | 说明 | -| ----------- | ---- | -------------- | -| EQUALS | 0 | 等于给定值。 | -| CONTAINS | 1 | 包含给定值。 | -| STARTS_WITH | 2 | 从给定值开始。 | -| ENDS_WITH | 3 | 以给定值结束。 | +**参数:** -## ResizeDirection9+ +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| 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 -| 名称 | 说明 | -| ---------- | -------- | -| LEFT | 左方。 | -| RIGHT | 右方。 | -| UP | 上方。 | -| DOWN | 下方。 | -| LEFT_UP | 左上方。 | -| LEFT_DOWN | 左下方。 | -| RIGHT_UP | 右上方。 | -| RIGHT_DOWN | 右下方。 | +**参数:** -## WindowMode9+ +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------- | ---- | -------------------- | +| 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 -窗口的窗口模式。 +**示例:** -| 名称 | 说明 | -| ---------- | ---------- | -| FULLSCREEN | 全屏模式。 | -| PRIMARY | 主窗口。 | -| SECONDARY | 第二窗口。 | -| FLOATING | 浮动窗口。 | +```js +async function demo() { + let driver = UiDriver.create() + await driver.pressBack() +} +``` -## DisplayRotation9+ +### triggerKey(deprecated) + +triggerKey(keyCode: number): Promise\ + +UiDriver对象采取如下操作:通过key值找到对应键并点击。 + +从API version9开始不再维护,建议使用[triggerKey9+](#triggerkey9)。 **系统能力**:SystemCapability.Test.UiTest -设备显示器的显示方向。 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------- | +| keyCode | number | 是 | 指定的key值。 | -| 名称 | 说明 | -| ------------ | ------------------------------------ | -| ROTATION_0 | 设备显示器不旋转,初始形态垂直显示。 | -| ROTATION_90 | 设备显顺时针旋转90°,水平显示。 | -| ROTATION_180 | 设备显顺时针旋转180°,逆向垂直显示。 | -| ROTATION_270 | 设备显顺时针旋转270°,逆向水平显示。 | +**示例:** + +```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-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index 3f5904c8eca91a72e441ce4497ef5c3899776074..78824946b90c2e74190506e9273551d68e580145 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -43,6 +43,20 @@ export default { console.log("authV9 lockoutDuration " + result.lockoutDuration); } }); + // if need tip + auth.on("tip", { + callback : (result : userIAM_userAuth.TipInfo) => { + switch (result.tip) { + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: + // do something; + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: + // do something; + // ... + default: + // do others + } + } + }); auth.start(); console.log("authV9 start success"); } catch (error) { @@ -249,7 +263,7 @@ callback: (result : EventInfo) => void | 名称 | 参数类型 | 必填 | 说明 | | ------------ | ---------- | ---- | -------------------- | -| module | number | 否 | 认证结果。 | +| module | number | 否 | 认证模块。 | | tip | number | 否 | 认证过程提示信息。 | ## AuthEventKey9+ @@ -298,6 +312,20 @@ on(name : AuthEventKey, callback : AuthEvent) : void console.log("authV9 lockoutDuration " + result.lockoutDuration); } }); + // if need tip + auth.on("tip", { + callback : (result : userIAM_userAuth.TipInfo) => { + switch (result.tip) { + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: + // do something; + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: + // do something; + // ... + default: + // do others + } + } + }); auth.start(); console.log("authV9 start success"); } catch (error) { 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 0ea804ed11d59ffe3834ab6d9ab2c1d79a0ec0ec..5f4b865d34a2b425b4764373d9ba8b00002fd874 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md @@ -13,41 +13,57 @@ vibrator模块提供控制马达振动的能力,如通过接口控制马达启 import vibrator from '@ohos.vibrator'; ``` -## vibrator.vibrate +## vibrator.startVibration9+ -vibrate(duration: number): Promise<void> +startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void -按照指定持续时间触发马达振动。 +按照指定振动效果和振动属性触发马达振动。 **需要权限**:ohos.permission.VIBRATE **系统能力**:SystemCapability.Sensors.MiscDevice -**参数:** +**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | ---------------------- | -| duration | number | 是 | 马达振动时长, 单位ms。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- | +| effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 | +| attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | -**返回值:** +**错误码**: -| 类型 | 说明 | -| ------------------- | -------------------------------------- | -| Promise<void> | Promise对象。无返回结果的Promise对象。 | +以下错误码的详细介绍请参见 [ohos.vibrator错误码](../errorcodes/errorcode-vibrator.md) -**示例:** +| 错误码ID | 错误信息 | +| -------- | ------------------------- | +| 14600101 | Device operation failed。 | - ```js - vibrator.vibrate(1000).then(()=>{ - console.log("Promise returned to indicate a successful vibration."); - }, (error)=>{ - console.log("error.code"+error.code+"error.message"+error.message); - }); - ``` +示例: + +```js +try { + vibrator.startVibration({ + type:'time', + duration:1000, + },{ + id:0, + usage: 'alarm' + }, (error)=>{ + if(error){ + console.log('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message); + }else{ + console.log('Callback returned to indicate a successful vibration.'); + } + }); +} catch(err) { + console.info('errCode: ' + err.code + ' ,msg: ' + err.message); +} +``` -## vibrator.vibrate9+ +## vibrator.startVibration9+ -vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void> +startVibration(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void> 按照指定振动效果和振动属性触发马达振动。 @@ -55,10 +71,10 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void> **系统能力**:SystemCapability.Sensors.MiscDevice -**参数:** +**参数:** | 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------------------- | ---- | :------------- | +| --------- | -------------------------------------- | ---- | -------------- | | effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 | | attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | @@ -68,148 +84,70 @@ vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise<void> | ------------------- | -------------------------------------- | | Promise<void> | Promise对象。无返回结果的Promise对象。 | -**示例:** +**错误码**: -```js -vibrator.vibrate({ - type: 'time', - duration: 1000 -}, { - id: 0, - usage: 'alarm' -}).then(()=>{ - console.log("Promise returned to indicate a successful vibration"); -}).catch((error)=>{ - console.log("error.code" + error.code + "error.message" + error.message); -}) -``` +以下错误码的详细介绍请参见 [ohos.vibrator错误码](../errorcodes/errorcode-vibrator.md) -## vibrator.vibrate - -vibrate(duration: number, callback?: AsyncCallback<void>): void - -按照指定持续时间触发马达振动。 - -**需要权限**:ohos.permission.VIBRATE - -**系统能力**:SystemCapability.Sensors.MiscDevice - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------------------------------------------------------- | -| duration | number | 是 | 马达振动时长, 单位ms。 | -| callback | AsyncCallback<void> | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | +| 错误码ID | 错误信息 | +| -------- | ------------------------- | +| 14600101 | Device operation failed。 | **示例:** ```js - vibrator.vibrate(1000,function(error){ - if(error){ - console.log("error.code" + error.code + "error.message" + error.message); - }else{ - console.log("Callback returned to indicate a successful vibration."); - } - }) +try { + vibrator.startVibration({ + type: 'time', + duration: 1000 + }, { + id: 0, + usage: 'alarm' + }).then(()=>{ + console.log('Promise returned to indicate a successful vibration'); + }).catch((error)=>{ + console.log('error.code' + error.code + 'error.message' + error.message); + }) +} catch(err) { + console.info('errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` +## vibrator.stopVibration9+ -## vibrator.vibrate +stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void -vibrate(effectId: EffectId): Promise<void> - -按照预置振动效果触发马达振动。 +按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 **需要权限**:ohos.permission.VIBRATE **系统能力**:SystemCapability.Sensors.MiscDevice **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------- | ---- | ------------------ | -| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | - -**返回值:** -| 类型 | 说明 | -| ------------------- | -------------------------------------- | -| Promise<void> | Promise对象。无返回结果的Promise对象。 | - -**示例:** - ```js - vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ - console.log("Promise returned to indicate a successful vibration."); - }, (error)=>{ - console.log("error.code" + error.code + "error.message" + error.message); - }); - ``` - - -## vibrator.vibrate - -vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void - -按照指定振动效果触发马达振动。 - -**需要权限**:ohos.permission.VIBRATE - -**系统能力**:SystemCapability.Sensors.MiscDevice -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------------------------------------------------------- | -| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | -| callback | AsyncCallback<void> | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | +| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 | **示例:** ```js - vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ - if(error){ - console.log("error.code" + error.code + "error.message" + error.message); - }else{ - console.log("Callback returned to indicate a successful vibration."); - } - }) +try { + vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ + if(error){ + console.log('error.code' + error.code + 'error.message' + error.message); + }else{ + console.log('Callback returned to indicate successful.'); + } + }) +} catch(err) { + console.info('errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` -## vibrator.vibrate9+ - -vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void - -按照指定振动效果和振动属性触发马达振动。 - -**需要权限**:ohos.permission.VIBRATE - -**系统能力**:SystemCapability.Sensors.MiscDevice - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------------------- | ---- | :--------------------------------------------------------- | -| effect | [VibrateEffect](#vibrateeffect9) | 是 | 马达振动效果。 | -| attribute | [VibrateAttribute](#vibrateattribute9) | 是 | 马达振动属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | +## vibrator.stopVibration9+ -示例: - -```js -vibrator.vibrate({ - type:'time', - duration:1000, -},{ - id:0, - usage: 'alarm' -}, (error)=>{ - if(error){ - console.log("vibrate fail, error.code:" + error.code + ",error.message:" + error.message); - }else{ - console.log("Callback returned to indicate a successful vibration."); - } -}); -``` - -## vibrator.stop - -stop(stopMode: VibratorStopMode): Promise<void> +stopVibration(stopMode: VibratorStopMode): Promise<void> 按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 @@ -218,6 +156,7 @@ stop(stopMode: VibratorStopMode): Promise<void> **系统能力**:SystemCapability.Sensors.MiscDevice **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | ------------------------ | | stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | @@ -231,43 +170,17 @@ stop(stopMode: VibratorStopMode): Promise<void> **示例:** ```js - vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ - console.log("Promise returned to indicate a successful vibration."); - }, (error)=>{ - console.log("error.code" + error.code + "error.message" + error.message); - }); +try { + vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ + console.log('Promise returned to indicate a successful vibration.'); + }, (error)=>{ + console.log('error.code' + error.code + 'error.message' + error.message); + }); +} catch(err) { + console.info('errCode: ' + err.code + ' ,msg: ' + err.message); +} ``` - -## vibrator.stop - -stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; - -按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 - -**需要权限**:ohos.permission.VIBRATE - -**系统能力**:SystemCapability.Sensors.MiscDevice - -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | -| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | -| callback | AsyncCallback<void> | 否 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 | - -**示例:** - - ```js - vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ - if(error){ - console.log("error.code" + error.code + "error.message" + error.message); - }else{ - console.log("Callback returned to indicate successful."); - } - }) - ``` - - ## EffectId 马达振动效果的字符串。 @@ -353,3 +266,200 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void; | physicalFeedback | string | 用于物理反馈振动的场景。 | | simulateReality | string | 用于模拟现实振动的场景。 | +## vibrator.vibrate(deprecated) + +vibrate(duration: number): Promise<void> + +按照指定持续时间触发马达振动。 + +从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9-1) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| duration | number | 是 | 马达振动时长, 单位ms。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise对象。无返回结果的Promise对象。 | + +**示例:** + + ```js +vibrator.vibrate(1000).then(()=>{ + console.log('Promise returned to indicate a successful vibration.'); +}, (error)=>{ + console.log('error.code' + error.code + 'error.message' + error.message); +}); + ``` + +## vibrator.vibrate(deprecated) + +vibrate(duration: number, callback?: AsyncCallback<void>): void + +按照指定持续时间触发马达振动。 + +从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------------------------------- | +| duration | number | 是 | 马达振动时长, 单位ms。 | +| callback | AsyncCallback<void> | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | + +**示例:** + + ```js +vibrator.vibrate(1000,function(error){ + if(error){ + console.log('error.code' + error.code + 'error.message' + error.message); + }else{ + console.log('Callback returned to indicate a successful vibration.'); + } +}) + ``` + + +## vibrator.vibrate(deprecated) + +vibrate(effectId: EffectId): Promise<void> + +按照预置振动效果触发马达振动。 + +从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9-1) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------ | +| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise对象。无返回结果的Promise对象。 | + +**示例:** + + ```js +vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ + console.log('Promise returned to indicate a successful vibration.'); +}, (error)=>{ + console.log('error.code' + error.code + 'error.message' + error.message); +}); + ``` + + +## vibrator.vibrate(deprecated) + +vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void + +按照指定振动效果触发马达振动。 + +从API version 9 开始不再维护,建议使用 [vibrator.startVibration](#vibratorstartvibration9) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------------------------------- | +| effectId | [EffectId](#effectid) | 是 | 预置的振动效果ID。 | +| callback | AsyncCallback<void> | 否 | 回调函数。当马达振动成功,err为undefined,否则为错误对象。 | + +**示例:** + + ```js +vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ + if(error){ + console.log('error.code' + error.code + 'error.message' + error.message); + }else{ + console.log('Callback returned to indicate a successful vibration.'); + } +}) + ``` + +## vibrator.stop(deprecated) + +stop(stopMode: VibratorStopMode): Promise<void> + +按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 + +从API version 9 开始不再维护,建议使用 [vibrator.stopVibration](#vibratorstopvibration9-1) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ------------------------ | +| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------------------------------------- | +| Promise<void> | Promise对象。无返回结果的Promise对象。 | + +**示例:** + + ```js +vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ + console.log('Promise returned to indicate a successful vibration.'); +}, (error)=>{ + console.log('error.code' + error.code + 'error.message' + error.message); +}); + ``` + + +## vibrator.stop(deprecated) + +stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void + +按照要停止指定的振动模式来停止马达的振动。如果要停止的振动模式与触发马达振动时的模式不相同,则调用本接口会失败。 + +从API version 9 开始不再维护,建议使用 [vibrator.stopVibration](#vibratorstopvibration9) 代替。 + +**需要权限**:ohos.permission.VIBRATE + +**系统能力**:SystemCapability.Sensors.MiscDevice + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------- | ---- | ------------------------------------------------------------ | +| stopMode | [VibratorStopMode](#vibratorstopmode) | 是 | 马达停止指定的振动模式。 | +| callback | AsyncCallback<void> | 否 | 回调函数。当马达停止振动成功,err为undefined,否则为错误对象。 | + +**示例:** + + ```js +vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ + if(error){ + console.log('error.code' + error.code + 'error.message' + error.message); + }else{ + console.log('Callback returned to indicate successful.'); + } +}) + ``` 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/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 12c658c75628e84883cdecf837d2a290a79d4d20..51c100cadd33b3f00b64fc5dfb44d3c8f23e9643 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -148,8 +148,6 @@ - [组件内转场](ts-transition-animation-component.md) - [共享元素转场](ts-transition-animation-shared-elements.md) - [路径动画](ts-motion-path-animation.md) - - [矩阵变换](ts-matrix-transformation.md) - - [插值计算](ts-interpolation-calculation.md) - 全局UI方法 - 弹窗 - [警告弹窗](ts-methods-alert-dialog-box.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/Column.png b/zh-cn/application-dev/reference/arkui-ts/figures/Column.png deleted file mode 100644 index 90bb7a5557e42ccc9b6509f96f54328d7a27eea1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/Column.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/Row.png b/zh-cn/application-dev/reference/arkui-ts/figures/Row.png deleted file mode 100644 index 6bf426a5f019e76b7b3a0953643988690eb67b1e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/Row.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/align.png b/zh-cn/application-dev/reference/arkui-ts/figures/align.png new file mode 100644 index 0000000000000000000000000000000000000000..beed805dbff1ec1526bf034c011cf2c7b926eae8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/align.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/badge.png b/zh-cn/application-dev/reference/arkui-ts/figures/badge.png new file mode 100644 index 0000000000000000000000000000000000000000..0041374b52a2be5a93f620dabed0cba74990ee6f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/badge.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/blankmin.png b/zh-cn/application-dev/reference/arkui-ts/figures/blankmin.png new file mode 100644 index 0000000000000000000000000000000000000000..d37582ff571d36ecc41539453192955b84481765 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/blankmin.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup.gif b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup.gif deleted file mode 100644 index 27b1a29a14e3bfca893f853d1e185c7493afb366..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup1.png b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup1.png new file mode 100644 index 0000000000000000000000000000000000000000..7042b41c96d5eca395d4ac035fefb7d55347535d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup1.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup2.png b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup2.png new file mode 100644 index 0000000000000000000000000000000000000000..7d7a2b901873cf2daedd412b96508b6c40aa0244 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup2.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup3.png b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup3.png new file mode 100644 index 0000000000000000000000000000000000000000..53988fae3e8f660fd8411ef44bfa2dc983886a5e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup3.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/column.png b/zh-cn/application-dev/reference/arkui-ts/figures/column.png new file mode 100644 index 0000000000000000000000000000000000000000..27321b5a24798d6d423cbf76eab974f4ebc2d0fb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/column.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/gauge-image.png b/zh-cn/application-dev/reference/arkui-ts/figures/gauge-image.png new file mode 100644 index 0000000000000000000000000000000000000000..d8fa99c3cc70ca08914a3850d95d2511eff923cd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/gauge-image.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/gridSpan.png b/zh-cn/application-dev/reference/arkui-ts/figures/gridSpan.png new file mode 100644 index 0000000000000000000000000000000000000000..80b67bee5bc99e753a2176ce2544b572ca41243e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/gridSpan.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/imageeffect.png b/zh-cn/application-dev/reference/arkui-ts/figures/imageeffect.png new file mode 100644 index 0000000000000000000000000000000000000000..fbcc0c6b68235aa7306556030fc60fed716b26b4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/imageeffect.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/nozindex.png b/zh-cn/application-dev/reference/arkui-ts/figures/nozindex.png new file mode 100644 index 0000000000000000000000000000000000000000..8c131eabacb8bcdee0b8ba891faaab69bb2a08bd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/nozindex.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/opacity.png b/zh-cn/application-dev/reference/arkui-ts/figures/opacity.png new file mode 100644 index 0000000000000000000000000000000000000000..d95114ede941db77cf865d3fab288f602ddcc1d0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/opacity.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif b/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif index 5fb034ddcf247a1fecaaeb33e27d103bd8225a91..727c647d243ae4570de18f5e02d86acbe4ab4153 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/popup.gif b/zh-cn/application-dev/reference/arkui-ts/figures/popup.gif new file mode 100644 index 0000000000000000000000000000000000000000..b32a43bd8fc4ae6416b8402c61e1d8e3b9e694ef Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/popup.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/position.png b/zh-cn/application-dev/reference/arkui-ts/figures/position.png new file mode 100644 index 0000000000000000000000000000000000000000..0c9e34bf611b4d51a49875d71f23fef24d6e2571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/position.png differ 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/figures/row.png b/zh-cn/application-dev/reference/arkui-ts/figures/row.png new file mode 100644 index 0000000000000000000000000000000000000000..dd97ea25d042abb1bf14ea0ba1012eedc57eb135 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/row.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/search.gif b/zh-cn/application-dev/reference/arkui-ts/figures/search.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b4847e0debeea617d8ea9af34112dca636651f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/search.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/search.png b/zh-cn/application-dev/reference/arkui-ts/figures/search.png deleted file mode 100644 index fddf98d7104f3bd8a370b5be86da322834ff0180..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/search.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/size.png b/zh-cn/application-dev/reference/arkui-ts/figures/size.png new file mode 100644 index 0000000000000000000000000000000000000000..5170abe9fb68747018cecc57e27df68806bafac4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/size.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textExp1.png b/zh-cn/application-dev/reference/arkui-ts/figures/textExp1.png new file mode 100644 index 0000000000000000000000000000000000000000..15d8410388040337f52a039f946d20f3cc0504fc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/textExp1.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textExp2.png b/zh-cn/application-dev/reference/arkui-ts/figures/textExp2.png new file mode 100644 index 0000000000000000000000000000000000000000..f6d1aa365e071f3064e25fe45afa4ce4efcddb65 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/textExp2.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textInput.gif b/zh-cn/application-dev/reference/arkui-ts/figures/textInput.gif new file mode 100644 index 0000000000000000000000000000000000000000..d980afbcb988222e44af1b359388a0ed6492264e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/textInput.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textblur.png b/zh-cn/application-dev/reference/arkui-ts/figures/textblur.png new file mode 100644 index 0000000000000000000000000000000000000000..cd151a5e84516952ec7db39c2abd2a1524f728db Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/textblur.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textstyle.png b/zh-cn/application-dev/reference/arkui-ts/figures/textstyle.png new file mode 100644 index 0000000000000000000000000000000000000000..38128cb5f1a6aa7a36a3b4e483bf2815c7170117 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/textstyle.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/touchtarget.gif b/zh-cn/application-dev/reference/arkui-ts/figures/touchtarget.gif new file mode 100644 index 0000000000000000000000000000000000000000..550dfe998ac31230b52ff3972974cdd4a7431b28 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/touchtarget.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/visibility.png b/zh-cn/application-dev/reference/arkui-ts/figures/visibility.png new file mode 100644 index 0000000000000000000000000000000000000000..89018fade9d9bef19dfc8a55d4477ba309353871 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/visibility.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image1_0000001219982725.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image1_0000001219982725.png new file mode 100644 index 0000000000000000000000000000000000000000..b980148e07e0d6d9f42b0df75766da9cbfe09840 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image1_0000001219982725.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104390.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104390.gif deleted file mode 100644 index fe69ab973cfd17f540dd1da4fd04de890af95c74..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104390.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104392.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104392.gif deleted file mode 100644 index ee69d15a36eda3047be045a3d037fd27a37166fe..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104392.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264368.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264368.gif deleted file mode 100644 index 3174da059167d3560a99d50cca06ec678cabed96..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264368.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264384.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264384.gif deleted file mode 100644 index dffa33c4389c4576d2492cd98499b71715b8ead8..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264384.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422916.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422916.png deleted file mode 100644 index 2eb96b00f11e597fcc3e3d5ef32701e0a4ef5f5b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422916.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422918.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422918.gif deleted file mode 100644 index 8b359a2d036a69fd442145d55e23031755c925c1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422918.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582860.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582860.png deleted file mode 100644 index 92ddc7d5d9ee2f87128ed8951b2294ea3c07f650..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582860.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001179613854.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001179613854.gif index b1724791e4acb31d193a0dce267e42c99288c6bd..aed89b3e86f0846762b81c0e40512d77260c8db7 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001179613854.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001179613854.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001184400598.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001184400598.gif deleted file mode 100644 index e97b2a2406059ce3af77ade27bb634845d807726..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001184400598.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001187055946.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001187055946.gif deleted file mode 100644 index 7631bb0d995839d59a9d3876f91fd7e688c35758..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001187055946.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662647.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662647.gif deleted file mode 100644 index b0e5e55e1af19bb46a74300bf2ae60f95225a874..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662647.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662673.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662673.png deleted file mode 100644 index 5499902761b534f84a0405094afe2fb5d4724322..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662673.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864147.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864147.gif deleted file mode 100644 index 016da55bb5d98a3d2787d870bf2575fbaf383990..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864147.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864155.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864155.gif deleted file mode 100644 index 627fff6c85420f981d9ae844d0e53a77d254ac7c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864155.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.png index 8e1eb1e09de7fe545f80f7a0601f63843369375a..048fdc4749a41e0675390e66e61b5d63953ed8e1 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982725.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif index 96afd9a948c90e22cd52ab4c55218bf97591b3ec..3696c7f08f6c7ef551d16da53ca167ddb8b6a5fa 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001251087311.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001251087311.gif index 5c888d43eeb0d0d3ab08e0c2922f136ed0b3d142..cd32b534914c89ab5f72f8e9f4d1197a80df32c8 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001251087311.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001251087311.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252769643.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252769643.gif index 9fa5c075ecc4f157f1e66316f4b56f28ffa2007d..386aad48af566d352f30719a9a00c4a4fc2d2715 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252769643.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252769643.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zindex.png b/zh-cn/application-dev/reference/arkui-ts/figures/zindex.png new file mode 100644 index 0000000000000000000000000000000000000000..bb2193d497c6cce42b5d7c6c94671c8bf7f6158e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/zindex.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md index 2c499e4ddecb93bfbcc8d1afdcc3626754de7701..6d1d1b49596bbd1dc23c5852b8e471918e5d58cf 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -32,7 +32,8 @@ Blank(min?: number | string) ## 示例 - +### 示例1 +Blank组件在横竖屏占满空余空间效果。 ```ts // xxx.ets @Entry @@ -57,3 +58,37 @@ struct BlankExample { 横屏状态 ![zh-cn_image_0000001174104388](figures/zh-cn_image_0000001174104388.gif) + + +### 示例2 +Blank组件的父组件未设置宽度时,min参数的使用效果。 + +```ts +// xxx.ets +@Entry +@Component +struct BlankExample { + build() { + Column({ space: 20 }) { + // blank父组件不设置宽度时,Blank失效,可以通过设置min最小宽度填充固定宽度 + Row() { + Text('Bluetooth').fontSize(18) + Blank().color(Color.Yellow) + Toggle({ type: ToggleType.Switch }) + }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) + + Row() { + Text('Bluetooth').fontSize(18) + // 设置最小宽度为160 + Blank('160').color(Color.Yellow) + Toggle({ type: ToggleType.Switch }) + }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) + + }.backgroundColor(0xEFEFEF).padding(20).width('100%') + } +} +``` +Blank父组件未设置宽度时,子组件间无空白填充,使用min参数设置填充尺寸 + +![blankmin](figures/blankmin.png) + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index 0bf526f273ca4fe094efdf011cce8e5dd55c2956..bb76a56ad6dd536a03971d1217e9b7a91dd5dd8b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -14,7 +14,7 @@ CheckboxGroup(options?: { group?: string }) -创建多选框群组,可以控制群组内的Checkbox全选或者不全选,相同group的Checkbox和CheckboxGroup为同一群组。 +创建多选框群组,可以控制群组内的Checkbox全选或者不全选,group值相同的Checkbox和CheckboxGroup为同一群组。 **参数:** @@ -39,13 +39,13 @@ CheckboxGroup(options?: { group?: string }) | 名称 | 功能描述 | | -------- | -------- | -| onChange (callback: (event: CheckboxGroupResult) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。| +| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult对象说明)) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。| ## CheckboxGroupResult对象说明 | 名称 | 类型 | 描述 | | ------ | ------ | ------- | | name | Array<string> | 群组内所有被选中的多选框名称。 | -| status | SelectStatus | 选中状态。 | +| status | [SelectStatus](#selectstatus枚举说明) | 选中状态。 | ## SelectStatus枚举说明 @@ -66,18 +66,19 @@ struct CheckboxExample { build() { Scroll() { Column() { + // 全选按钮 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { CheckboxGroup({ group: 'checkboxGroup' }) .selectedColor(0xed6f21) .onChange((itemName: CheckboxGroupResult) => { - console.info("TextPicker::dialogResult is" + JSON.stringify(itemName)) + console.info("checkbox group content" + JSON.stringify(itemName)) }) - Text('select all').fontSize(20) + Text('Select All').fontSize(20) } + // 选项1 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) - .select(true) .selectedColor(0x39a2db) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) @@ -85,9 +86,9 @@ struct CheckboxExample { Text('Checkbox1').fontSize(20) } + // 选项2 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) - .select(false) .selectedColor(0x39a2db) .onChange((value: boolean) => { console.info('Checkbox2 change is' + value) @@ -95,9 +96,9 @@ struct CheckboxExample { Text('Checkbox2').fontSize(20) } + // 选项3 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) - .select(true) .selectedColor(0x39a2db) .onChange((value: boolean) => { console.info('Checkbox3 change is' + value) @@ -109,4 +110,10 @@ struct CheckboxExample { } } ``` -![](figures/checkboxgroup.gif) +多选框组三种状态图示: + +![](figures/checkboxgroup1.png) + +![](figures/checkboxgroup2.png) + +![](figures/checkboxgroup3.png) 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 c099110818c1209fb6acfebd0bb50a43ea0d7f77..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,9 +22,9 @@ 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.Circle | +| type8+ | [DataPanelType](#datapaneltype枚举说明) | 否 | 数据面板的类型。
    默认值:DataPanelType.Circle | ## DataPanelType枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md index b7a01966d2beee4a104e0d10982e969a0d7c4ef4..cdf957e31d7c9494de9168b6c0b3655473f2574a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -47,6 +47,7 @@ struct DividerExample { Divider() Row().width('100%').height(40).backgroundColor(0xF1F3F5) + // 纵向分割线 Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC) Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) { Text('bravery') @@ -56,6 +57,7 @@ struct DividerExample { Text('upward') }.width(250) + // 设置分割线宽度和端点样式 Text('Custom Styles').fontSize(9).fontColor(0xCCCCCC) Row().width('100%').height(40).backgroundColor(0xF1F3F5) Divider().vertical(false).strokeWidth(5).color(0x2788D9).lineCap(LineCapStyle.Round) 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 885fe031d58d2b9b5b19f895e1c3efbdd6ebd2c8..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 @@ -21,7 +21,7 @@ Gauge(options:{value: number, min?: number, max?: number}) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| value | number | 是 | 当前数据值。 | +| value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。 | | min | number | 否 | 当前数据段最小值。
    默认值:0 | | max | number | 否 | 当前数据段最大值。
    默认值:100 | @@ -31,11 +31,11 @@ Gauge(options:{value: number, min?: number, max?: number}) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| value | number | 设置当前数据图表的值。
    默认值:0 | -| startAngle | number | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。
    默认值:-150 | -| endAngle | number | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。
    默认值:150 | -| colors | Array<ColorStop> | 设置图表的颜色,支持分段颜色设置。 | -| strokeWidth | Length | 设置环形图表的环形厚度。 | +| value | number | 设置量规图的数据值,可用于动态修改量规图的数据值。
    默认值:0 | +| startAngle | number | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。
    默认值:0 | +| endAngle | number | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。
    默认值:360 | +| colors | Array<[ColorStop](#colorstop)> | 设置量规图的颜色,支持分段颜色设置。 | +| strokeWidth | Length | 设置环形量规图的环形厚度。 | ## ColorStop @@ -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,该颜色不显示。 | ## 示例 @@ -55,15 +55,30 @@ Gauge(options:{value: number, min?: number, max?: number}) @Component struct GaugeExample { build() { - Column() { - Gauge({ value: 50, min: 0, max: 100 }) - .startAngle(210).endAngle(150) - .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) - .strokeWidth(20) + Column({ space: 20 }) { + // 使用默认的min和max为0-100,角度范围默认0-360,value值设置 + // 参数中设置当前值为75 + Gauge({ value: 75 }) + .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // 参数设置当前值为75,属性设置值为25,属性设置优先级高 + Gauge({ value: 75 }) + .value(25) //属性和参数都设置时以参数为准 .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // 210--150度环形图表 + Gauge({ value: 30, min: 0, max: 100 }) + .startAngle(210) + .endAngle(150) + .colors([[0x317AF7, 0.1], [0x5BA854, 0.2], [0xE08C3A, 0.3], [0x9C554B, 0.4]]) + .strokeWidth(20) + .width(200) + .height(200) }.width('100%').margin({ top: 5 }) } } ``` -![zh-cn_image_0000001174422916](figures/zh-cn_image_0000001174422916.png) +![gauge](figures/gauge-image.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 072bc49476ee62742a065c60dd766618e40dbb4f..79c635647e64f55a94a02962f91b4952bb00998c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -52,6 +52,7 @@ Image(src: string | PixelMap | Resource) > **说明:** > > 使用快捷组合键对Image组件复制的前提是,该组件必须处于获焦状态。将Image组件的属性focusable设置为true,即可使用TAB键将焦点切换到Image组件上,再将Image组件的focusOnTouch属性设置为true,即可实现点击获焦。 +> 图片设置svg图源时,支持的标签范围有限,目前支持的svg标签包括svg、rect、circle、ellipse、path、line、polyline、polygon、animate、animateMotion、animateTransform。 ### ImageInterpolation diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md index c832a0840a16df0460aac5e5775460b362144e83..7edd6d11691ffaa297f809d16372f6ebe4bb6662 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md @@ -1,6 +1,6 @@ # PatternLock -图案密码锁组件,以宫格图案的方式输入密码,用于密码验证。手指触碰图案密码锁时开始进入输入状态,手指离开屏幕时结束输入状态并向应用返回输入的密码。 +图案密码锁组件,以九宫格图案的方式输入密码,用于密码验证场景。手指在PatternLock组件区域按下时开始进入输入状态,手指离开屏幕时结束输入状态完成密码输入。 > **说明:** > @@ -18,22 +18,22 @@ PatternLock(controller?: PatternLockController) | 参数名 | 参数类型 | 必填 | 描述 | | ---------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| controller | [PatternLockController](#patternlockcontroller) | 否 | 给组件绑定一个控制器,用来控制组件状态重置。
    默认值:null | +| controller | [PatternLockController](#patternlockcontroller) | 否 | 设置PatternLock组件控制器,可用于控制组件状态重置。 | ## 属性 -不支持`backgroundColor`以外的通用属性设置。 +不支持除backgroundColor以外的通用属性设置。 | 名称 | 参数类型 | 描述 | | --------------- | ------------------------------------- | ------------------------------------------------------------ | -| sideLength | [Length](ts-types.md#length) | 设置组件的宽度和高度(相同值)。最小可以设置为0。
    默认值:300vp | -| circleRadius | [Length](ts-types.md#length) | 设置宫格圆点的半径。
    默认值:14vp | +| sideLength | [Length](ts-types.md#length) | 设置组件的宽度和高度(宽高相同)。设置为0或负数等非法值时组件不显示。
    默认值:300vp | +| circleRadius | [Length](ts-types.md#length) | 设置宫格中圆点的半径。
    默认值:14vp | | regularColor | [ResourceColor](ts-types.md#resourcecolor) | 设置宫格圆点在“未选中”状态的填充颜色。
    默认值:Color.Black | | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置宫格圆点在“选中”状态的填充颜色。
    默认值:Color.Black | -| activeColor | [ResourceColor](ts-types.md#resourcecolor) | 设置宫格圆点在“激活”状态的填充颜色。
    默认值:Color.Black | +| activeColor | [ResourceColor](ts-types.md#resourcecolor) | 设置宫格圆点在“激活”状态的填充颜色(“激活”状态为手指经过圆点但还未选中的状态)。
    默认值:Color.Black | | pathColor | [ResourceColor](ts-types.md#resourcecolor) | 设置连线的颜色。
    默认值:Color.Blue | -| pathStrokeWidth | number \| string | 设置连线的宽度。最小可以设置为0。
    默认值:34vp | -| autoReset | boolean | 设置是否支持用户在完成输入后再次触屏重置组件状态。如果设置为true,用户可以通过触摸图案密码锁重置组件状态(清除之前的输入效果);如果设置为false,用户手指离开屏幕完成输入后,再次触摸图案密码锁(包括圆点)不能改变之前的输入状态。
    默认值:true | +| pathStrokeWidth | number \| string | 设置连线的宽度。设置为0或负数等非法值时连线不显示。
    默认值:34vp | +| autoReset | boolean | 设置在完成密码输入后再次在组件区域按下时是否重置组件状态。设置为true,完成密码输入后再次在组件区域按下时会重置组件状态(即清除之前输入的密码);反之若设置为false,则不会重置组件状态。
    默认值:true | ## 事件 @@ -41,11 +41,11 @@ PatternLock(controller?: PatternLockController) | 名称 | 描述 | | ---------------------------------------- | ---------------------------------------- | -| onPatternComplete(callback: (input: Array\) => void) | 密码输入结束时被调用的回调函数。
    input: 与选中宫格圆点顺序一致的数字数组,数字为选中宫格的索引(0到8)。 | +| onPatternComplete(callback: (input: Array\) => void) | 密码输入结束时触发该回调。
    input: 与选中宫格圆点顺序一致的数字数组,数字为选中宫格圆点的索引值(第一行圆点从左往右依次为0,1,2,第二行圆点依次为3,4,5,第三行圆点依次为6,7,8)。 | ## PatternLockController -PatternLock组件的控制器,可以将此对象绑定至PatternLock组件,然后通过它进行状态重置。 +PatternLock组件的控制器,可以通过它进行组件状态重置。 ### 导入对象 @@ -66,44 +66,48 @@ reset(): void @Entry @Component struct PatternLockExample { - @State passwords: Number[] = [] - @State message: string = 'please input password' - private patternLockController: PatternLockController = new PatternLockController() - + @State passwords: Number[] = []; + @State message: string = 'please input password!'; + private patternLockController: PatternLockController = new PatternLockController(); + build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(this.message).textAlign(TextAlign.Center) + Column() { + Text(this.message).textAlign(TextAlign.Center).margin(20).fontSize(20) PatternLock(this.patternLockController) - .sideLength(150) - .circleRadius(7) - .pathStrokeWidth(17) - .backgroundColor(Color.White) + .sideLength(200) + .circleRadius(9) + .pathStrokeWidth(18) + .activeColor('#B0C4DE') + .selectedColor('#228B22') + .pathColor('#90EE90') + .backgroundColor('#F5F5F5') .autoReset(true) .onPatternComplete((input: Array) => { - // 判断输出的密码格式 + // 输入的密码长度小于5时,提示重新输入 if (input === null || input === undefined || input.length < 5) { - this.message = 'The password length needs to be greater than 5.' - // 重新触发该回调 - return + this.message = 'The password length needs to be greater than 5, please enter again.'; + return; } // 判断密码长度是否大于0 if (this.passwords.length > 0) { - // 判断俩次输入的密码是否相等 + // 判断两次输入的密码是否相同,相同则提示密码设置成功,否则提示重新输入 if (this.passwords.toString() === input.toString()) { - this.passwords = input - this.message = 'Set password successfully: ' + this.passwords.toString() + this.passwords = input; + this.message = 'Set password successfully: ' + this.passwords.toString(); } else { - this.message = 'Inconsistent passwords, please enter again.' + this.message = 'Inconsistent passwords, please enter again.'; } } else { - this.passwords = input - this.message = "Please enter again." + // 提示第二次输入密码 + this.passwords = input; + this.message = "Please enter again."; } }) - Button('reset button').margin(30).onClick(() => { - this.patternLockController.reset() - this.passwords = [] - this.message = 'Please input password' + Button('Reset PatternLock').margin(30).onClick(() => { + // 重置密码锁 + this.patternLockController.reset(); + this.passwords = []; + this.message = 'Please input password'; }) }.width('100%').height('100%') } @@ -111,4 +115,3 @@ struct PatternLockExample { ``` ![patternlock](figures/patternlock.gif) - diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md index 7c462124413e61c899dd88140eaece424090c9d0..77e5cd47836947ba9efe003504a41147cf1508c2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -1,6 +1,6 @@ # Search -提供搜索框组件,用于提供用户搜索内容的输入区域。 +搜索框组件,适用于浏览器的搜索内容输入框等应用场景。 > **说明:** > @@ -18,10 +18,10 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------- | ---------------- | ---- | ------------------------------------------------------------ | -| value | string | 否 | 搜索文本值。 | -| placeholder | string | 否 | 无输入时的提示文本。 | -| icon | string | 否 | 搜索图标路径,默认使用系统搜索图标,支持的图标格式: svg、jpg和png。 | -| controller | SearchController | 否 | 控制器。 | +| value | string | 否 | 设置当前显示的搜索文本内容。 | +| placeholder | string | 否 | 设置无输入时的提示文本。 | +| icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标,图标支持的图源格式: svg、jpg和png。 | +| controller | SearchController | 否 | 设置Search组件控制器。 | ## 属性 @@ -29,26 +29,28 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | 名称 | 参数类型 | 描述 | | ----------------------- | ------------------------------------------------ | ---------------------------------------------- | -| searchButton | string | 搜索框末尾搜索按钮文本值,默认无搜索按钮。 | -| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder颜色。 | -| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | -| textFont | [Font](ts-types.md#font) | 设置搜索框内文本样式。 | -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置文本是否可复制。 | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本对齐方式。
    默认值:TextAlign.Start | +| searchButton | string | 搜索框末尾搜索按钮文本内容,默认无搜索按钮。 | +| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。 | +| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | +| textFont | [Font](ts-types.md#font) | 设置搜索框内输入文本样式。 | +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在搜索框中的对齐方式。
    默认值:TextAlign.Start | +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。 | ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | ---------------------------------------- | ---------------------------------------- | -| onSubmit(callback: (value: string) => void) | 点击搜索图标、搜索按钮或者按下软键盘搜索按钮时触发。
    -value: 当前输入文本框的内容。 | -| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发回调。
    -value: 当前输入文本框的内容。 | -| onCopy(callback: (value: string) => void) | 组件触发系统剪切板复制操作。
    -value: 复制的文本内容。 | -| onCut(callback: (value: string) => void) | 组件触发系统剪切板剪切操作。
    -value: 剪切的文本内容。 | -| onPaste(callback: (value: string) => void) | 组件触发系统剪切板粘贴操作。
    -value: 粘贴的文本内容。 | +| onSubmit(callback: (value: string) => void) | 点击搜索图标、搜索按钮或者按下软键盘搜索按钮时触发该回调。
    -value: 当前搜索框中输入的文本内容。 | +| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发该回调。
    -value: 当前搜索框中输入的文本内容。 | +| onCopy(callback: (value: string) => void) | 长按搜索框弹出剪切板之后,点击剪切板的复制按钮触发该回调。
    -value: 复制的文本内容。 | +| onCut(callback: (value: string) => void) | 长按搜索框弹出剪切板之后,点击剪切板的剪切按钮触发该回调。
    -value: 剪切的文本内容。 | +| onPaste(callback: (value: string) => void) | 长按搜索框弹出剪切板之后,点击剪切板的粘贴按钮触发该回调。
    -value: 粘贴的文本内容。 | ## SearchController -Search组件的控制器,通过它操作Search组件。 +Search组件的控制器,目前通过它可控制Search组件的光标位置。 ### 导入对象 ``` @@ -73,30 +75,37 @@ caretPosition(value: number): void @Entry @Component struct SearchExample { - @State changeValue: string = '' - @State submitValue: string = '' - controller: SearchController = new SearchController() + @State changeValue: string = ''; + @State submitValue: string = ''; + controller: SearchController = new SearchController(); build() { - Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(this.submitValue) - Text(this.changeValue) - Search({value: this.changeValue, placeholder: 'Type to search', controller: this.controller}) - .searchButton('Search') + Column() { + Text('onSubmit:' + this.submitValue).fontSize(18).margin(15) + Text('onChange:' + this.changeValue).fontSize(18).margin(15) + Search({ value: this.changeValue, placeholder: 'Type to search...', controller: this.controller }) + .searchButton('SEARCH') .width(400) - .height(35) + .height(40) .backgroundColor(Color.White) .placeholderColor(Color.Grey) - .placeholderFont({ size: 26, weight: 10, family: 'serif', style: FontStyle.Normal }) + .placeholderFont({ size: 14, weight: 400 }) + .textFont({ size: 14, weight: 400 }) .onSubmit((value: string) => { - this.submitValue = value + this.submitValue = value; }) .onChange((value: string) => { - this.changeValue = value + this.changeValue = value; + }) + .margin(20) + Button('Set caretPosition 1') + .onClick(() => { + // 设置光标位置到输入的第一个字符后 + this.controller.caretPosition(1); }) - .margin({ top: 30, left:10, right:10 }) - } + }.width('100%') } } ``` -![search](figures/search.png) \ No newline at end of file + +![search](figures/search.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 0aa1c8acede3ba6135fd598ac4dc86f4ed43ba4f..80ff26bdd482cdd46e2ac803bd0b896274f4e336 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -1,6 +1,6 @@ # Slider -滑动条组件,用来快速调节设置值,如音量、亮度等。 +滑动条组件,通常用于快速调节设置值,如音量调节、亮度调节等应用场景。 > **说明:** > @@ -23,10 +23,10 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | value | number | 否 | 当前进度值。
    默认值:0 | | min | number | 否 | 设置最小值。
    默认值:0 | | max | number | 否 | 设置最大值。
    默认值:100 | -| step | number | 否 | 设置Slider滑动跳动值,当设置相应的step时,Slider为间歇滑动。
    默认值:1 | -| style | SliderStyle | 否 | 设置Slider的滑块样式。
    默认值:SliderStyle.OutSet | +| step | number | 否 | 设置Slider滑动步长。
    默认值:1 | +| style | SliderStyle | 否 | 设置Slider的滑块与滑轨显示样式。
    默认值:SliderStyle.OutSet | | direction8+ | [Axis](ts-appendix-enums.md#axis) | 否 | 设置滑动条滑动方向为水平或竖直方向。
    默认值:Axis.Horizontal | -| reverse8+ | boolean | 否 | 设置滑动条取值范围是否反向。
    默认值:false | +| reverse8+ | boolean | 否 | 设置滑动条取值范围是否反向,横向Slider默认为从左往右滑动,竖向Slider默认为从上往下滑动。
    默认值:false | ## SliderStyle枚举说明 @@ -38,34 +38,34 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty ## 属性 -不支持触摸热区设置。 +支持除触摸热区以外的通用属性设置。 | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | blockColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑块的颜色。 | | trackColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑轨的背景颜色。 | -| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑轨的已滑动颜色。 | +| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置滑轨的已滑动部分颜色。 | | showSteps | boolean | 设置当前是否显示步长刻度值。
    默认值:false | -| showTips | boolean | 设置滑动时是否显示气泡提示百分比。
    默认值:false | +| showTips | boolean | 设置滑动时是否显示百分比气泡提示。
    默认值:false | | trackThickness | [Length](ts-types.md#length) | 设置滑轨的粗细。 | ## 事件 -通用事件仅支持:OnAppear,OnDisAppear。 +通用事件仅支持挂载卸载事件:OnAppear,OnDisAppear。 | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触发事件回调。
    value:当前进度值。若返回值有小数,可使用Math.toFixed()将数据处理为想要的精度。
    mode:拖动状态。 | +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触发事件回调。
    value:当前滑动进度值。若返回值有小数,可使用Math.toFixed()方法将数据处理为预期的精度。
    mode:拖动状态。 | ## SliderChangeMode枚举说明 | 名称 | 值 | 描述 | | -------- | -------- | -------- | -| Begin | 0 | 用户开始拖动滑块。 | -| Moving | 1 | 用户拖动滑块中。 | -| End | 2 | 用户结束拖动滑块。 | -| Click | 3 | 用户点击滑动条使滑块位置移动。 | +| Begin | 0 | 开始拖动滑块。 | +| Moving | 1 | 正在拖动滑块过程中。 | +| End | 2 | 结束拖动滑块。 | +| Click | 3 | 点击滑动条使滑块位置移动。 | ## 示例 @@ -75,105 +75,150 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty @Entry @Component struct SliderExample { - @State outSetValue: number = 40 - @State inSetValue: number = 40 - @State outVerticalSetValue: number = 40 - @State inVerticalSetValue: number = 40 + @State outSetValueOne: number = 40; + @State inSetValueOne: number = 40; + @State outSetValueTwo: number = 40; + @State inSetValueTwo: number = 40; + @State vOutSetValueOne: number = 40; + @State vInSetValueOne: number = 40; + @State vOutSetValueTwo: number = 40; + @State vInSetValueTwo: number = 40; build() { - Column({ space: 5 }) { - Text('slider out set').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: 8 }) { + Text('outset slider').fontSize(9).fontColor(0xCCCCCC).width('90%').margin(15) Row() { Slider({ - value: this.outSetValue, + value: this.outSetValueOne, min: 0, max: 100, - step: 1, style: SliderStyle.OutSet }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) - .showSteps(true) - .showTips(true) - .onChange((value: number, mode: SliderChangeMode) => { - this.outSetValue = value - console.info('value:' + value + 'mode:' + mode.toString()) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValueOne = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + // toFixed(0)将滑动条返回值处理为整数精度 + Text(this.outSetValueOne.toFixed(0)).fontSize(12) + } + .width('80%') + Row() { + Slider({ + value: this.outSetValueTwo, + step: 10, + style: SliderStyle.OutSet }) - Text(this.outSetValue.toFixed(0)).fontSize(16) + .showSteps(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValueTwo = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + Text(this.outSetValueTwo.toFixed(0)).fontSize(12) } - .padding({ top: 50 }) .width('80%') - Text('slider in set').fontSize(9).fontColor(0xCCCCCC).width('90%') + Text('inset slider').fontSize(9).fontColor(0xCCCCCC).width('90%').margin(15) Row() { Slider({ - value: this.inSetValue, + value: this.inSetValueOne, min: 0, max: 100, - step: 1, style: SliderStyle.InSet }) - .blockColor(0xCCCCCC) - .trackColor(Color.Black) - .selectedColor(0xCCCCCC) - .showSteps(false) - .showTips(false) - .onChange((value: number, mode: SliderChangeMode) => { - this.inSetValue = value - console.info('value:' + value + 'mode:' + mode.toString()) - }) - Text(this.inSetValue.toFixed(0)).fontSize(16) + .blockColor('#191970') + .trackColor('#ADD8E6') + .selectedColor('#4169E1') + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.inSetValueOne = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + Text(this.inSetValueOne.toFixed(0)).fontSize(12) } .width('80%') - Row() { - Column() { - Text('slider out direction set').fontSize(9).fontColor(0xCCCCCC).width('50%') - Slider({ - value: this.outVerticalSetValue, - min: 0, - max: 100, - step: 1, - style: SliderStyle.OutSet, - direction: Axis.Vertical - }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) + Slider({ + value: this.inSetValueTwo, + step: 10, + style: SliderStyle.InSet + }) + .blockColor('#191970') + .trackColor('#ADD8E6') + .selectedColor('#4169E1') .showSteps(true) - .showTips(true) .onChange((value: number, mode: SliderChangeMode) => { - this.outVerticalSetValue = value - console.info('value:' + value + 'mode:' + mode.toString()) + this.inSetValueTwo = value; + console.info('value:' + value + 'mode:' + mode.toString()); }) - Text(this.outVerticalSetValue.toFixed(0)).fontSize(16) + Text(this.inSetValueTwo.toFixed(0)).fontSize(12) + } + .width('80%') + + Row() { + Column() { + Text('vertical outset slider').fontSize(9).fontColor(0xCCCCCC).width('50%').margin(15) + Row() { + Slider({ + value: this.vOutSetValueOne, + style: SliderStyle.OutSet, + direction: Axis.Vertical + }) + .blockColor('#191970') + .trackColor('#ADD8E6') + .selectedColor('#4169E1') + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.vOutSetValueOne = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + Slider({ + value: this.vOutSetValueTwo, + step: 10, + style: SliderStyle.OutSet, + direction: Axis.Vertical + }) + .blockColor('#191970') + .trackColor('#ADD8E6') + .selectedColor('#4169E1') + .showSteps(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.vOutSetValueTwo = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + } }.width('50%').height(300) Column() { - Text('slider in direction set').fontSize(9).fontColor(0xCCCCCC).width('50%') - Slider({ - value: this.inVerticalSetValue, - min: 0, - max: 100, - step: 1, - style: SliderStyle.InSet, - direction: Axis.Vertical - }) - .blockColor(0xCCCCCC) - .trackColor(Color.Black) - .selectedColor(0xCCCCCC) - .showSteps(false) - .showTips(false) - .onChange((value: number, mode: SliderChangeMode) => { - this.inVerticalSetValue = value - console.info('value:' + value + 'mode:' + mode.toString()) - }) - Text(this.inVerticalSetValue.toFixed(0)).fontSize(16) + Text('vertical inset slider').fontSize(9).fontColor(0xCCCCCC).width('50%').margin(15) + Row() { + Slider({ + value: this.vInSetValueOne, + style: SliderStyle.InSet, + direction: Axis.Vertical, + reverse: true // 竖向的Slider默认是上端是min值,下端是max值,因此想要从下往上滑动,需要设置reverse为true + }) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.vInSetValueOne = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + Slider({ + value: this.vInSetValueTwo, + step: 10, + style: SliderStyle.InSet, + direction: Axis.Vertical, + reverse: true + }) + .showSteps(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.vInSetValueTwo = value; + console.info('value:' + value + 'mode:' + mode.toString()); + }) + } }.width('50%').height(300) } - - }.width('100%').margin({ top: 5 }) + }.width('100%') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md index 2fef65d34dbd1015a8bcd69b35f331e65d918ea6..12b32146b34e2ac75dd03e2e887037c7a6a0e016 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md @@ -1,6 +1,6 @@ # Stepper -应用步骤方式切换页面的组件。 +步骤导航器组件,适用于引导用户按照步骤完成任务的导航场景。 > **说明:** @@ -8,8 +8,6 @@ > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - ## 子组件 仅能包含子组件[StepperItem](ts-basic-components-stepperitem.md)。 @@ -24,7 +22,7 @@ Stepper(value?: { index?: number }) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------| -------- | --------------- | -------- | -| index | number | 否 | 设置步骤导航器显示第几个StepperItem。
    默认值:0 | +| index | number | 否 | 设置步骤导航器当前显示StepperItem的索引值。
    默认值:0 | ## 属性 @@ -38,9 +36,9 @@ Stepper(value?: { index?: number }) | -------- | -------- | | onFinish(callback: () => void) | 步骤导航器最后一个StepperItem的nextLabel被点击时触发该回调 。 | | onSkip(callback: () => void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 | -| onChange(callback: (prevIndex?: number, index?: number) => void) | 点击左边或者右边文本按钮进行步骤切换时触发该事件。
    - prevIndex:切换前的步骤页索引值。
    - index:切换后的步骤页(前一页或者下一页)索引值。 | -| onNext(callback: (index?: number, pendingIndex?: number) => void) | 点击切换下一步骤时触发该事件。
    - index:当前步骤页索引值。
    - pendingIndex:下一步骤页索引值。 | -| onPrevious(callback: (index?: number, pendingIndex?: number) => void) | 点击切换上一步骤时触发该事件。
    - index:当前步骤页索引值。
    - pendingIndex:上一步骤页索引值。 | +| onChange(callback: (prevIndex?: number, index?: number) => void) | 点击当前StepperItem的prevLabel或nextLabel进行步骤切换时触发该回调。
    - prevIndex:切换前的步骤页索引值。
    - index:切换后的步骤页(前一页或者下一页)索引值。 | +| onNext(callback: (index?: number, pendingIndex?: number) => void) | 点击StepperItem的nextLabel切换下一步骤时触发该回调。
    - index:当前步骤页索引值。
    - pendingIndex:下一步骤页索引值。 | +| onPrevious(callback: (index?: number, pendingIndex?: number) => void) | 点击StepperItem的prevLabel切换上一步骤时触发该回调。
    - index:当前步骤页索引值。
    - pendingIndex:上一步骤页索引值。 | ## 示例 @@ -50,76 +48,86 @@ Stepper(value?: { index?: number }) @Entry @Component struct StepperExample { - @State currentIndex: number = 0 - @State firstState: ItemState = ItemState.Normal - @State secondState: ItemState = ItemState.Normal + @State currentIndex: number = 0; + @State firstState: ItemState = ItemState.Normal; + @State secondState: ItemState = ItemState.Normal; + @State thirdState: ItemState = ItemState.Normal; build() { Stepper({ index: this.currentIndex }) { + // 第一个步骤页 StepperItem() { - Text('Page One') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({ top: 250 }) + Column() { + Text('Page One') + .fontSize(35) + .fontColor(Color.Blue) + .lineHeight(50) + .margin({ top: 250, bottom: 50 }) + Button('change status:' + this.firstState) + .onClick(() => { + this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip; + }) + }.width('100%') } - .nextLabel('') - .position({ x: '35%', y: 0 }) - + .nextLabel('Next') + .status(this.firstState) + // 第二个步骤页 StepperItem() { - Text('Page Two') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({ top: 250 }) - .onClick(() => { - this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip - }) + Column() { + Text('Page Two') + .fontSize(35) + .fontColor(Color.Blue) + .lineHeight(50) + .margin({ top: 250, bottom: 50 }) + Button('change status:' + this.secondState) + .onClick(() => { + this.secondState = this.secondState === ItemState.Disabled ? ItemState.Normal : ItemState.Disabled; + }) + }.width('100%') } .nextLabel('Next') .prevLabel('Previous') - .status(this.firstState) - .position({ x: '35%', y: 0 }) - + .status(this.secondState) + // 第三个步骤页 StepperItem() { - Text('Page Three') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({ top: 250 }) - .onClick(() => { - this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting - }) + Column() { + Text('Page Three') + .fontSize(35) + .fontColor(Color.Blue) + .lineHeight(50) + .margin({ top: 250, bottom: 50 }) + Button('change status:' + this.thirdState) + .onClick(() => { + this.thirdState = this.thirdState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting; + }) + }.width('100%') } - .position({ x: '35%', y: 0 }) - .status(this.secondState) - + .status(this.thirdState) + // 第四个步骤页 StepperItem() { Text('Page four') .fontSize(35) .fontColor(Color.Blue) - .width(200) + .width('100%') + .textAlign(TextAlign.Center) .lineHeight(50) .margin({ top: 250 }) } - .position({ x: '35%', y: 0 }) .nextLabel('Finish') } .onFinish(() => { - console.log('onFinish') + // 此处可处理点击最后一页的Finish时的逻辑,例如路由跳转等 + console.info('onFinish'); }) .onSkip(() => { - console.log('onSkip') + // 此处可处理点击跳过时的逻辑,例如动态修改Stepper的index值使其跳转到某一步骤页等 + console.info('onSkip'); }) .onChange((prevIndex: number, index: number) => { - this.currentIndex = index + this.currentIndex = index; }) - .align(Alignment.Center) } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md index ef51de1cc1d89511764887f30c382f53bc3ba175..9141c2052e93f441f40ae1aefa21837d9eb19ff6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md @@ -22,18 +22,18 @@ StepperItem() | 参数名 | 参数类型 | 参数描述 | | -------- | -------- | -------- | -| prevLabel | string | 当步骤导航器大于一页,除第一页默认值都为“返回”。 | -| nextLabel | string | 步骤导航器大于一页时,最后一页默认值为“开始”,其余页默认值为“下一步”。 | -| status | ItemState | 步骤导航器元素的状态。
    默认值:ItemState.Normal | +| prevLabel | string | 设置左侧文本按钮内容,第一页没有左侧文本按钮,当步骤导航器大于一页时,除第一页外默认值都为“返回”。 | +| nextLabel | string | 设置右侧文本按钮内容,最后一页默认值为“开始”,其余页默认值为“下一步”。 | +| status | ItemState | 步骤导航器nextLabel的显示状态。
    默认值:ItemState.Normal | ## ItemState枚举说明 -| 名称 | 描述 | -| -------- | -------- | -| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | -| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | -| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 | -| Skip | 跳过状态,表示跳过当前步骤, 进入下一个StepperItem。 | +| 名称 | 值 | 描述 | +| -------- | -------- |-------- | +| Normal | 0 |正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | +| Disabled | 1 |不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | +| Waiting | 2 | 等待状态,右侧文本按钮不显示,显示等待进度条,不可点击进入下一个StepperItem。 | +| Skip | 3 |跳过状态,右侧文本按钮显示“跳过”,此时可在Stepper的onSkip回调中自定义相关逻辑。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 3362e271b8c4e1f03dfef68bbb857bfa6df00d76..79498c8d67311ba7ff356a9c90e8358c80dd6c1d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -28,12 +28,12 @@ Text(content?: string | Resource) | 名称 | 参数类型 | 描述 | | ----------------------- | ----------------------------------- | ------------------------------------------- | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置多行文本的文本对齐方式。
    默认值:TextAlign.Start | +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在水平方向的对齐方式。
    默认值:TextAlign.Start | | textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。
    默认值:{overflow: TextOverflow.Clip}
    **说明:**
    文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。
    需配合`maxLines`使用,单独设置不生效。 | | maxLines | number | 设置文本的最大行数。
    默认值:Infinity
    **说明:**
    默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。 | | lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | | decoration | {
    type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
    color?: [ResourceColor](ts-types.md#resourcecolor)
    } | 设置文本装饰线样式及其颜色。
    默认值:{
    type: TextDecorationType.None,
    color:Color.Black
    } | -| baselineOffset | number \| string | 设置文本基线的偏移量。 | +| baselineOffset | number \| string | 设置文本基线的偏移量,默认值0。 | | letterSpacing | number \| string | 设置文本字符间距。 | | minFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最小显示字号。 | | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | 设置文本最大显示字号。 | @@ -47,6 +47,8 @@ Text(content?: string | Resource) ## 示例 +### 示例1 +textAlign,textOverflow,maxLines,lineHeight使用示例。 ```ts // xxx.ets @Entry @@ -54,77 +56,184 @@ Text(content?: string | Resource) struct TextExample1 { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { - Text('lineHeight').fontSize(9).fontColor(0xCCCCCC) - Text('This is the text with the line height set This is the text with the line height set This is the text with the line height set.') - .lineHeight(25).fontSize(12).border({ width: 1 }).padding(10) + // 文本水平方向对齐方式设置 + // 单行文本 + Text('textAlign').fontSize(9).fontColor(0xCCCCCC) + Text('TextAlign set to Center.') + .textAlign(TextAlign.Center) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('TextAlign set to Start.') + .textAlign(TextAlign.Start) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('TextAlign set to End.') + .textAlign(TextAlign.End) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') - Text('TextOverflow').fontSize(9).fontColor(0xCCCCCC) - Text('This is the setting of textOverflow to none text content This is the setting of textOverflow to none text content.') + // 多行文本 + Text('This is the text content with textAlign set to Center.') + .textAlign(TextAlign.Center) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with textAlign set to Start.') + .textAlign(TextAlign.Start) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with textAlign set to End.') + .textAlign(TextAlign.End) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + + + // 文本超长时显示方式 + Text('TextOverflow+maxLines').fontSize(9).fontColor(0xCCCCCC) + // 超出maxLines截断内容展示 + Text('This is the setting of textOverflow to Clip text content This is the setting of textOverflow to None text content. This is the setting of textOverflow to Clip text content This is the setting of textOverflow to None text content.') .textOverflow({ overflow: TextOverflow.None }) - .fontSize(12).border({ width: 1 }).padding(10) - Text('This is the setting of textOverflow to Clip text content This is the setting of textOverflow to Clip text content.') - .textOverflow({ overflow: TextOverflow.Clip }) - .maxLines(1).fontSize(12).border({ width: 1 }).padding(10) - Text('This is set textOverflow to Ellipsis text content This is set textOverflow to Ellipsis text content.'.split('').join('\u200B')) + .maxLines(1) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + + // 超出maxLines展示省略号 + Text('This is set textOverflow to Ellipsis text content This is set textOverflow to Ellipsis text content.'.split('') + .join('\u200B')) .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(1).fontSize(12).border({ width: 1 }).padding(10) + .maxLines(1) + .fontSize(12) + .border({ width: 1 }) + .padding(10) - Text('decoration').fontSize(9).fontColor(0xCCCCCC) - Text('This is the text content with the decoration set to Underline and the color set to Red.') - .decoration({ type: TextDecorationType.Underline, color: Color.Red }) + Text('lineHeight').fontSize(9).fontColor(0xCCCCCC) + Text('This is the text with the line height set. This is the text with the line height set.') .fontSize(12).border({ width: 1 }).padding(10) - Text('This is the text content with the decoration set to LineThrough and the color set to Red.') - .decoration({ type: TextDecorationType.LineThrough, color: Color.Red }) - .fontSize(12).border({ width: 1 }).padding(10) - Text('This is the text content with the decoration set to Overline and the color set to Red.') - .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + Text('This is the text with the line height set. This is the text with the line height set.') .fontSize(12).border({ width: 1 }).padding(10) + .lineHeight(20) }.height(600).width(350).padding({ left: 35, right: 35, top: 35 }) } } ``` +![textExp1](figures/textExp1.png) -![zh-cn_image_0000001219864155](figures/zh-cn_image_0000001219864155.gif) - +### 示例2 +decoration,baselineOffset,letterSpacing,textCase使用示例: ```ts -// xxx.ets @Entry @Component struct TextExample2 { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Text('decoration').fontSize(9).fontColor(0xCCCCCC) + Text('This is the text content with the decoration set to LineThrough and the color set to Red.') + .decoration({ + type: TextDecorationType.LineThrough, + color: Color.Red + }) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + + + Text('This is the text content with the decoration set to Overline and the color set to Red.') + .decoration({ + type: TextDecorationType.Overline, + color: Color.Red + }) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + + + Text('This is the text content with the decoration set to Underline and the color set to Red.') + .decoration({ + type: TextDecorationType.Underline, + color: Color.Red + }) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + + // 文本基线偏移 + Text('baselineOffset').fontSize(9).fontColor(0xCCCCCC) + Text('This is the text content with baselineOffset 0.') + .baselineOffset(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with baselineOffset 30.') + .baselineOffset(30) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with baselineOffset -20.') + .baselineOffset(-20) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + + // 文本字符间距 + Text('letterSpacing').fontSize(9).fontColor(0xCCCCCC) + Text('This is the text content with letterSpacing 0.') + .letterSpacing(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with letterSpacing 3.') + .letterSpacing(3) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('This is the text content with letterSpacing -1.') + .letterSpacing(-1) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + Text('textCase').fontSize(9).fontColor(0xCCCCCC) Text('This is the text content with textCase set to Normal.') .textCase(TextCase.Normal) - .fontSize(12).border({ width: 1 }).padding(10).width('100%') + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + // 文本全小写展示 Text('This is the text content with textCase set to LowerCase.') .textCase(TextCase.LowerCase) - .fontSize(12).border({ width: 1 }).padding(10).width('100%') + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('100%') + // 文本全大写展示 Text('This is the text content with textCase set to UpperCase.') .textCase(TextCase.UpperCase) .fontSize(12).border({ width: 1 }).padding(10) - Text('textAlign').fontSize(9).fontColor(0xCCCCCC) - Text('This is the text content with textAlign set to Center.') - .textAlign(TextAlign.Center) - .fontSize(12).border({ width: 1 }).padding(10).width('100%') - Text('This is the text content with textAlign set to Start.') - .textAlign(TextAlign.Start) - .fontSize(12).border({ width: 1 }).padding(10).width('100%') - Text('This is the text content with textAlign set to End.') - .textAlign(TextAlign.End) - .fontSize(12).border({ width: 1 }).padding(10).width('100%') - - Text('baselineOffset').fontSize(9).fontColor(0xCCCCCC) - Text('This is the text content with baselineOffset set to 10.') - .baselineOffset(10).fontSize(12).border({ width: 1 }).padding(10).width('100%') - Text('This is the text content with baselineOffset set to 30.') - .baselineOffset(30).fontSize(12).border({ width: 1 }).padding(10).width('100%') - Text('This is the text content with baselineOffset set to -10.') - .baselineOffset(-10).fontSize(12).border({ width: 1 }).padding(10).width('100%') }.height(700).width(350).padding({ left: 35, right: 35, top: 35 }) } } ``` - -![zh-cn_image_0000001174422918](figures/zh-cn_image_0000001174422918.gif) +![textExp1](figures/textExp2.png) 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-basic-components-textclock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md index 675e57599dbb993dffb2e2f29bc9fd3b65b0636c..d3201827e9f9528d5b449a760534c996958e5ab5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textclock.md @@ -21,6 +21,21 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController | timeZoneOffset | number | 否 | 设置时区偏移量。
    取值范围为[-14, 12],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8。
    对横跨国际日界线的国家或地区,用-13(UTC+13)和-14(UTC+14)来保证整个国家或者区域处在相同的时间,当设置的值不在取值范围内时,将使用当前系统的时区偏移量。
    默认值:当前系统的时区偏移量 | | controller | [TextClockController](#textclockcontroller) | 否 | 绑定一个控制器,用来控制文本时钟的状态。| +## 属性 + +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + +| 名称 | 参数类型 | 描述 | +| ------ | --------------- | ------------------------------------------------------------ | +| format | string | 设置显示时间格式。
    日期间隔符固定为"/",时间间隔符为":"。
    如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,
    hhmmss显示为hh:mm:ss。
    时间格式只用写一位即可,如"hhmmss"等同于"hms"。
    支持的时间格式化字符串:
    - YYYY/yyyy:完整年份。
    - YY/yy:年份后两位。
    - M:月份(若想使用01月则使用MM)。
    - d:日期(若想使用01日则使用dd)。
    - D:年中日(一年中的第几天)。
    - H:24小时制。
    - h:12小时制。
    - m:分钟。
    - s:秒。
    - SSS:毫秒。
    若格式未匹配,则使用默认值。
    默认值: 'hms'| + +## 事件 + +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + +| 名称 | 功能描述 | +| -------------------------------------------- | ------------------------------------------------------------ | +| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
    - value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | ## TextClockController @@ -44,24 +59,6 @@ stop() 停止文本时钟。 - -## 属性 - -除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: - -| 名称 | 参数类型 | 描述 | -| ------ | --------------- | ------------------------------------------------------------ | -| format | string | 设置显示时间格式。
    日期间隔符固定为"/",时间间隔符为":"。
    如yyyyMMdd,yyyy-MM-dd显示为yyyy/MM/dd,
    hhmmss显示为hh:mm:ss。
    时间格式只用写一位即可,如"hhmmss"等同于"hms"。
    支持的时间格式化字符串:
    - YYYY/yyyy:完整年份。
    - YY/yy:年份后两位。
    - M:月份(若想使用01月则使用MM)。
    - d:日期(若想使用01日则使用dd)。
    - D:年中日(一年中的第几天)。
    - H:24小时制。
    - h:12小时制。
    - m:分钟。
    - s:秒。
    - SSS:毫秒。
    默认值: 'hms'| - -## 事件 - -除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: - -| 名称 | 功能描述 | -| -------------------------------------------- | ------------------------------------------------------------ | -| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
    value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | - - ## 示例 ```ts @@ -101,4 +98,3 @@ struct Second { } ``` ![text_clock](figures/text_clock.gif) - diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 891a64f002bcc49e64f9414722cdc0e70b162021..f7d8be3e1bffe926962c57433f017ca02c74d232 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -1,6 +1,6 @@ # TextInput -可以输入单行文本并支持响应输入事件的组件。 +单行文本输入框组件。 > **说明:** > @@ -20,38 +20,38 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------------- | ---------------------------------------- | ---- | --------------- | -| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 无输入时的提示文本。 | +| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。 | | text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。 | | controller8+ | [TextInputController](#textinputcontroller8) | 否 | 设置TextInput控制器。 | ## 属性 -除支持通用属性以及[文本样式设置](ts-universal-attributes-text-style.md)的属性外,还支持以下属性: +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: | 名称 | 参数类型 | 描述 | | ------------------------ | ---------------------------------------- | ---------------------------------------- | | type | InputType | 设置输入框类型。
    默认值:InputType.Normal | -| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder颜色。| +| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。| | placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | | enterKeyType | EnterKeyType | 设置输入法回车键类型。
    默认值:EnterKeyType.Done | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。 | | maxLength | number | 设置文本的最大输入字符数。 | -| 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) | 设置文本是否可复制。 | -| showPasswordIcon9+ | boolean | 密码输入模式时,密码框末尾的图标是否显示。
    默认值:true | -| style9+ | TextInputStyle | TextInput风格。
    默认值:TextInputStyle.Default | -| textAlign9+ | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本水平对齐式。
    默认值:TextAlign.Start | +| inputFilter8+ | {
    value: [ResourceStr](ts-types.md#resourcestr),
    error?: (value: string) => void
    } | 正则表达式,匹配表达式的输入允许显示,不匹配的输入将被过滤。目前仅支持单个字符匹配,不支持字符串匹配。
    - value:设置正则表达式。
    - error:正则匹配失败时,返回被过滤的内容。 | +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。 | +| showPasswordIcon9+ | boolean | 密码输入模式时,输入框末尾的图标是否显示。
    默认值:true | +| style9+ | TextInputStyle | 设置输入框为默认风格或内联输入风格。
    默认值:TextInputStyle.Default | +| textAlign9+ | [TextAlign](ts-appendix-enums.md#textalign) | 设置输入文本在输入框中的对齐方式。
    默认值:TextAlign.Start | ## EnterKeyType枚举说明 | 名称 | 描述 | | ------------------- | --------- | -| Go | 显示Go文本。 | +| Go | 显示为前往样式。 | | Search | 显示为搜索样式。 | | Send | 显示为发送样式。 | | Next | 显示为下一个样式。 | -| Done | 标准样式。 | +| Done | 显示为确认样式。 | ## InputType枚举说明 @@ -59,7 +59,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | ------------------ | ------------- | | Normal | 基本输入模式。
    支持输入数字、字母、下划线、空格、特殊字符。 | | Password | 密码输入模式。 | -| Email | e-mail地址输入模式。 | +| Email | 邮箱地址输入模式。 | | Number | 纯数字输入模式。 | | PhoneNumber9+ | 电话号码输入模式。
    支持输入数字、+ 、-、*、#,长度不限。 | @@ -67,20 +67,22 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 名称 | 描述 | | ------------------ | ------------- | -| Default | 默认风格,光标宽1.5vp,光标高度和字体大小高度相关,字体越大光标越高。 | -| Inline | 内联输入风格。文字选中时底板与输入框同高。 | +| Default | 默认风格,光标宽1.5vp,光标高度与文本选中底板高度和字体大小相关。 | +| Inline | 内联输入风格。文本选中底板高度与输入框高度相同。 | ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | ---------------------------------------- | ---------------------------------------- | -| onChange(callback: (value: string) => void) | 输入发生变化时,触发回调。 | -| onSubmit(callback: (enterKey: EnterKeyType) => void) | 回车键或者软键盘回车键触发该回调,参数为当前软键盘回车键类型。 | -| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | 输入状态变化时,触发回调。 | -| onEditChange(callback: (isEditing: boolean) => void) 8+ | 输入状态变化时,触发回调。 | -| onCopy8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发回调。
    value:复制的文本内容。 | -| onCut8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发回调。
    value:剪切的文本内容。 | -| onPaste8+(callback:(value: string) => void) | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发回调。
    value:粘贴的文本内容。 | +| onChange(callback: (value: string) => void) | 输入内容发生变化时,触发该回调。 | +| onSubmit(callback: (enterKey: EnterKeyType) => void) | 按下输入法回车键触发该回调,返回值为当前输入法回车键的类型。 | +| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | 输入状态变化时,触发该回调。从API 8开始,建议使用onEditChange。 | +| onEditChange(callback: (isEditing: boolean) => void)8+ | 输入状态变化时,触发该回调。isEditing为true表示正在输入。 | +| onCopy(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板复制按钮,触发该回调。
    value:复制的文本内容。 | +| onCut(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板剪切按钮,触发该回调。
    value:剪切的文本内容。 | +| onPaste(callback:(value: string) => void)8+ | 长按输入框内部区域弹出剪贴板后,点击剪切板粘贴按钮,触发该回调。
    value:粘贴的文本内容。 | ## TextInputController8+ @@ -105,60 +107,53 @@ caretPosition(value: number): void ## 示例 - -### 单行文本输入 - ```ts // xxx.ets @Entry @Component -struct TextInputExample1 { - @State text: string = '' +struct TextInputExample { + @State text: string = ''; + controller: TextInputController = new TextInputController(); build() { Column() { - TextInput({ placeholder: 'input your word' }) - .placeholderColor("rgb(0,0,225)") - .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) + TextInput({ placeholder: 'input your word...', controller: this.controller }) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 14, weight: 400 }) .caretColor(Color.Blue) - .height(50) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .fontFamily("sans-serif") - .fontStyle(FontStyle.Normal) - .fontColor(Color.Red) + .width(400) + .height(40) + .margin(20) + .fontSize(14) + .fontColor(Color.Black) .onChange((value: string) => { - this.text = value + this.text = value; + }) + Text(this.text) + Button('Set caretPosition 1') + .margin(15) + .onClick(() => { + // 将光标移动至第一个字符后 + this.controller.caretPosition(1); }) - Text(this.text).width('90%') - } + // 密码输入框 + TextInput({ placeholder: 'input your password...' }) + .width(400) + .height(40) + .margin(20) + .type(InputType.Password) + .maxLength(9) + .showPasswordIcon(true) + // 内联风格输入框 + TextInput({ placeholder: 'inline style' }) + .width(400) + .height(50) + .margin(20) + .borderRadius(0) + .style(TextInputStyle.Inline) + }.width('100%') } } ``` - -![zh-cn_image_0000001252769643](figures/zh-cn_image_0000001252769643.gif) - - -### 设置光标 - -```ts -// xxx.ets -@Entry -@Component -struct TextInputExample2 { - @State text: string = '' - controller: TextInputController = new TextInputController() - build() { - Column() { - TextInput({ placeholder: 'Please input your words.', controller:this.controller}) - Button('caretPosition') - .onClick(() => { - this.controller.caretPosition(4) - }) - } - } -} -``` - -![zh-cn_image_0000001208256092](figures/zh-cn_image_0000001208256092.png) +![textInput](figures/textInput.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md index 993fc551a87ea814e98aa90e25271b6cecab9ca9..d5e0b6879170894cd859e1882783c798a6afeb76 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md @@ -6,40 +6,33 @@ > > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - - - ## 子组件 无 - ## 接口 TextTimer(options?: { isCountDown?: boolean, count?: number, controller?: TextTimerController }) -**参数:** +**参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | -| ----------- | -------- | -------- | -------- | -------- | +| ----------- | -------- | -------- | -------- | | isCountDown | boolean | 否 | 是否倒计时。
    默认值:false | -| count | number | 否 | 倒计时时间(isCountDown为true时生效),单位为毫秒。
    - count<=0时,使用默认值为倒计时初始值。
    - count>0时,count值为倒计时初始值。
    默认值:60000 | +| count | number | 否 | 倒计时时间(isCountDown为true时生效),单位为毫秒。最长不超过86400000毫秒(24小时)。 0<count<86400000时,count值为倒计时初始值。否则,使用默认值为倒计时初始值。
    默认值:60000 | | controller | [TextTimerController](#texttimercontroller) | 否 | TextTimer控制器。 | ## 属性 | 名称 | 参数类型 | 描述 | | -------- | ---------------------- | ---------------------- | -| format | string | 自定义格式,需至少包含一个hh、mm、ss、ms中的关键字。
    默认值:'hh:mm:ss.ms' | - +| format | string | 自定义格式,需至少包含一个HH、mm、ss、SS中的关键字。如使用yy、MM、dd等日期格式,则使用默认值。
    默认值:'HH:mm:ss.SS' | ## 事件 -| 名称 | 功能描述 | -| -------- | -------- | -| onTimer(event: (utc: number, elapsedTime: number) => void) | 时间文本发生变化时触发。
    utc:当前显示的时间,单位为毫秒。
    elapsedTime:计时器经过的时间,单位为毫秒。 | - +| 名称 | 功能描述 | +| ---------------------------------------- | ---------------------------------------- | +| onTimer(event: (utc: number, elapsedTime: number) => void) | 时间文本发生变化时触发。
    utc:Linux时间戳,即自1970年1月1日起经过的毫秒数。
    elapsedTime:计时器经过的时间,单位为毫秒。 | ## TextTimerController @@ -70,7 +63,6 @@ reset() 重置计时器。 - ## 示例 ```ts @@ -79,7 +71,7 @@ reset() @Component struct TextTimerExample { textTimerController: TextTimerController = new TextTimerController() - @State format: string = 'hh:mm:ss.ms' + @State format: string = 'HH:mm:ss.SS' build() { Column() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index b5c2b650af2ca4707c9f07a9943a71677385eb39..dc5baf58784ab8c7c34408e2bc4da97475d1ad27 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -474,6 +474,35 @@ mediaPlayGestureAccess(access: boolean) } ``` +### multiWindowAccess9+ + +multiWindowAccess(multiWindow: boolean) + +设置是否开启多窗口权限,默认不开启。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------------- | ------- | ---- | ---- | ----------------- | +| multiWindow | boolean | 是 | false | 设置是否开启多窗口权限。 | + +**示例:** + + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .multiWindowAccess(true) + } + } + } + ``` + ### cacheMode cacheMode(cacheMode: CacheMode) @@ -1785,6 +1814,74 @@ onFullScreenExit(callback: () => void) } ``` +### onWindowNew9+ + +onWindowNew(callback: (event: {isAlert: boolean, isUserTrigger: boolean, targetUrl: string, handler: ControllerHandler}) => void) + +通知用户新建窗口请求。 + +**参数:** + +| 参数名 | 参数类型 | 参数描述 | +| ----------- | ------------------------------- | ---------------- | +| isAlert | boolean | true代表请求创建对话框,false代表新标签页。 | +| isUserTrigger | boolean | true代表用户触发,false代表非用户触发。 | +| targetUrl | string | 目标url。 | +| handler | [ControllerHandler](#controllerhandler9) | 用于设置新建窗口的WebController实例。 | + +**示例:** + + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller: this.controller }) + .multiWindowAccess(true) + .onWindowNew((event) => { + console.log("onWindowNew..."); + var popController: WebController = new WebController(); + event.handler.setWebController(popController); + }) + } + } + } + ``` + +### onWindowExit9+ + +onWindowExit(callback: () => void) + +通知用户窗口关闭请求。 + +**参数:** + +| 参数名 | 参数类型 | 参数描述 | +| ----------- | ------------------------------- | ---------------- | +| callback | () => void | 窗口请求关闭的回调函数。 | + +**示例:** + + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller: this.controller }) + .onWindowExit((event) => { + console.log("onWindowExit..."); + }) + } + } + } + ``` + ## ConsoleMessage Web组件获取控制台信息对象。示例代码参考[onConsole事件](#onconsole)。 @@ -1875,6 +1972,22 @@ exitFullScreen(): void 通知开发者Web组件退出全屏。 +## ControllerHandler9+ + +设置用户新建web组件的的WebController对象。示例代码参考[onWindowNew事件](#onwindownew9)。 + +### setWebController9+ + +setWebController(controller: WebController): void + +设置WebController对象。 + +**参数:** + +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------ | ---- | ---- | ----------- | +| controller | WebController | 是 | - | 新建web组件的的WebController对象。 | + ## WebResourceError web组件资源管理错误信息对象。示例代码参考[onErrorReceive事件](#onerrorreceive)。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md index f1bc8b9ee610cc20aec1a496a8a9a44a81514a4e..6db7e8dbfb219c2538725ccb8fd908f902ccc5b0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md @@ -6,11 +6,6 @@ > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## 子组件 支持单个子组件。 @@ -42,15 +37,6 @@ | position | [BadgePosition](#badgeposition枚举说明) | 否 | BadgePosition.RightTop | 设置提示点显示位置。 | | style | [BadgeStyle](#badgestyle对象说明) | 是 | - | Badge组件可设置样式,支持设置文本颜色、尺寸、圆点颜色和尺寸。 | -## BadgeStyle对象说明 - -| 名称 | 类型 | 必填 | 默认值 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| color | [ResourceColor](ts-types.md) | 否 | Color.White | 文本颜色。 | -| fontSize | number \| string | 否 | 10 | 文本大小。 | -| badgeSize | number \| string | 是 | - | badge的大小。 | -| badgeColor | [ResourceColor](ts-types.md) | 否 | Color.Red | badge的颜色。 | - ## BadgePosition枚举说明 | 名称 | 描述 | @@ -59,6 +45,13 @@ | Right | 圆点显示在右侧纵向居中。 | | Left | 圆点显示在左侧纵向居中。 | +## BadgeStyle对象说明 +| 名称 | 类型 | 必填 | 默认值 | 描述 | + | -------- | -------- | -------- | -------- | -------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.White | 文本颜色。 | +| fontSize | number \| string | 否 | 10 | 文本大小。 | +| badgeSize | number \| string | 是 | - | badge的大小。 | +| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | Color.Red | badge的颜色。 | ## 示例 @@ -67,44 +60,92 @@ @Entry @Component struct BadgeExample { - @State counts: number = 1 - @State message: string = 'new' + @State counts: number = 1; + @State message: string = 'new'; build() { - Flex({ justifyContent: FlexAlign.SpaceAround }) { - Badge({ - count: this.counts, - maxCount: 99, - style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } - }) { - Button('message') - .onClick(() => { - this.counts++ - }) - .width(100).height(50).backgroundColor(0x317aff) - }.width(100).height(50) - - Badge({ - value: this.message, - style: { color: 0xFFFFFF, fontSize: 9, badgeSize: 20, badgeColor: Color.Blue } - }) { - Text('message') - .width(80).height(50).fontSize(16).lineHeight(37) - .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) - }.width(80).height(50) - - Badge({ - value: ' ', - position: BadgePosition.Right, - style: { badgeSize: 6, badgeColor: Color.Red } - }) { - Text('message') - .width(90).height(50).fontSize(16).lineHeight(37) - .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) - }.width(90).height(50) - }.width('100%').margin({ top: 5 }) + Column() { + Text('numberBadge').width('80%') + Row({ space: 10 }) { + // 数字上标,maxCount默认99,超过99展示99+ + Badge({ + count: this.counts, + maxCount: 99, + position: BadgePosition.RightTop, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++; + }) + .width(100).height(50).backgroundColor(0x317aff) + }.width(100).height(50) + + // 数字上标 + Badge({ + count: this.counts, + maxCount: 99, + position: BadgePosition.Left, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++; + }) + .width(100).height(50).backgroundColor(0x317aff) + }.width(100).height(50) + + + // 数字上标 + Badge({ + count: this.counts, + maxCount: 99, + position: BadgePosition.Right, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++; + }) + .width(100).height(50).backgroundColor(0x317aff) + }.width(100).height(50) + }.margin(10) + + Text('stringBadge').width('80%') + Row({ space: 30 }) { + Badge({ + value: this.message, + style: { color: 0xFFFFFF, fontSize: 9, badgeSize: 20, badgeColor: Color.Blue } + }) { + Text('message') + .width(80) + .height(50) + .fontSize(16) + .lineHeight(37) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(0xF3F4ED) + }.width(80).height(50) + + // value为空,设置圆点标记 + Badge({ + value: '', + position: BadgePosition.Right, + style: { badgeSize: 6, badgeColor: Color.Red } + }) { + Text('message') + .width(90) + .height(50) + .fontSize(16) + .lineHeight(37) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(0xF3F4ED) + }.width(90).height(50) + }.margin(10) + } } } ``` -![zh-cn_image_0000001219864147](figures/zh-cn_image_0000001219864147.gif) +![badge](figures/badge.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md index 89c881153a6ecf8028938f2bd35e903d7c2a63dc..6b34c3cee54a5b1d6094505abe506a6b9e2bc00b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md @@ -20,7 +20,7 @@ Column(value?: {space?: string | number}) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 纵向布局元素间距。
    默认值:0 | +| space | string \| number | 否 | 纵向布局元素垂直方向间距。
    默认值:0 | ## 属性 @@ -40,38 +40,47 @@ Column(value?: {space?: string | number}) struct ColumnExample { build() { Column() { - Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column({ space: 5 }) { - Column().width('100%').height(30).backgroundColor(0xAFEEEE) - Column().width('100%').height(30).backgroundColor(0x00FFFF) - }.width('90%').height(100).border({ width: 1 }) - - Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('50%').height(30).backgroundColor(0xAFEEEE) - Column().width('50%').height(30).backgroundColor(0x00FFFF) - }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }) - - Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('50%').height(30).backgroundColor(0xAFEEEE) - Column().width('50%').height(30).backgroundColor(0x00FFFF) - }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }) - - Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('30%').height(30).backgroundColor(0xAFEEEE) - Column().width('30%').height(30).backgroundColor(0x00FFFF) - }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.Center) - - Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('30%').height(30).backgroundColor(0xAFEEEE) - Column().width('30%').height(30).backgroundColor(0x00FFFF) - }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.End) + // 设置子元素垂直方向间距为5 + Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: 5 }) { + Column().width('100%').height(30).backgroundColor(0xAFEEEE) + Column().width('100%').height(30).backgroundColor(0x00FFFF) + }.width('90%').height(100).border({ width: 1 }) + + // 设置子元素水平方向对齐方式 + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }) + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }) + + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }) + + // 设置子元素垂直方向的对齐方式 + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('90%').height(30).backgroundColor(0xAFEEEE) + Column().width('90%').height(30).backgroundColor(0x00FFFF) + }.height(100).border({ width: 1 }).justifyContent(FlexAlign.Center) + + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('90%').height(30).backgroundColor(0xAFEEEE) + Column().width('90%').height(30).backgroundColor(0x00FFFF) + }.height(100).border({ width: 1 }).justifyContent(FlexAlign.End) }.width('100%').padding({ top: 5 }) } } ``` -![zh-cn_image_0000001219982721](figures/Column.png) +![column](figures/column.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-columnsplit.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-columnsplit.md index 1173d54869b5dbf9b89a9cddc186565ed317b01b..dd96432e8b7f5368ad47c9fc9b1823a362a2b75c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-columnsplit.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-columnsplit.md @@ -1,15 +1,10 @@ # ColumnSplit -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 将子组件纵向布局,并在每个子组件之间插入一根横向的分割线。 +> **说明:** +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 ## 子组件 @@ -30,7 +25,8 @@ ColumnSplit() > **说明:** > 与RowSplit相同,ColumnSplit的分割线最小能拖动到刚好包含子组件。 - +> +> 在真机中查看拖动效果,预览器中不支持拖动。 ## 示例 @@ -49,7 +45,7 @@ struct ColumnSplitExample { Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) } - .resizeable(true) + .resizeable(true) // 可拖动 .width('90%').height('60%') }.width('100%') } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md index 6f94eece93ee10164499d401438263123f7ea06f..27fbd173f704132eb302d27c2191d258761e8533 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-counter.md @@ -1,15 +1,13 @@ # Counter +计数器组件,提供相应的增加或者减少的计数操作。 + > **说明:** > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -计数器组件,提供相应的增加或者减少的计数操作。 - -## 权限列表 -无 ## 子组件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md index 0faa4e3a99be989f94c2f0a84d25d6435735663a..895184056c41747c9a5f970c89882c7cf4b7cc6e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -20,8 +20,8 @@ Navigator(value?: {target: string, type?: NavigationType}) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | -------------- | ---- | ---------------------------------------------- | -| target | string | 是 | 指定跳转目标页面的路径。 | -| type | NavigationType | 否 | 指定路由方式。
    默认值:NavigationType.Push | +| target | string | 是 | 指定跳转目标页面的路径。 | +| type | [NavigationType](#navigationtype枚举说明) | 否 | 指定路由方式。
    默认值:NavigationType.Push | ## NavigationType枚举说明 @@ -37,9 +37,9 @@ Navigator(value?: {target: string, type?: NavigationType}) | 名称 | 参数 | 描述 | | ------ | ------- | ------------------------------------------------------------ | | active | boolean | 当前路由组件是否处于激活状态,处于激活状态时,会生效相应的路由操作。 | -| params | object | 跳转时要同时传递到目标页面的数据,可在目标页面使用router.getParams()获得。 | -| target | string | 设置跳转目标页面的路径。 | -| type | NavigationType | 设置路由方式。
    默认值:NavigationType.Push | +| params | object | 跳转时要同时传递到目标页面的数据,可在目标页面使用[router.getParams()](../apis/js-api-router.md#routergetparams)获得。 | +| target | string | 设置跳转目标页面的路径。 目标页面需加入main_pages.json文件中。 | +| type | [NavigationType](#navigationtype枚举说明) | 设置路由方式。
    默认值:NavigationType.Push | ## 示例 @@ -49,7 +49,7 @@ Navigator(value?: {target: string, type?: NavigationType}) @Entry @Component struct NavigatorExample { - @State active: boolean = false + @State active: boolean = false; @State Text: object = {name: 'news'} build() { @@ -57,13 +57,13 @@ struct NavigatorExample { Navigator({ target: 'pages/container/navigator/Detail', type: NavigationType.Push }) { Text('Go to ' + this.Text['name'] + ' page') .width('100%').textAlign(TextAlign.Center) - }.params({ text: this.Text }) + }.params({ text: this.Text }) // 传参数到Detail页面 Navigator() { Text('Back to previous page').width('100%').textAlign(TextAlign.Center) }.active(this.active) .onClick(() => { - this.active = true + this.active = true; }) }.height(150).width(350).padding(35) } @@ -72,12 +72,13 @@ struct NavigatorExample { ```ts // Detail.ets -import router from '@system.router' +import router from '@ohos.router' @Entry @Component struct DetailExample { - @State text: any = router.getParams().text + // 接收Navigator.ets的传参 + @State text: any = router.getParams().text; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md index b59cf14a8370853483539d53b73e410c520b28ae..9c0dd645c5a809fa4007e964c2e72932bc35e727 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md @@ -27,8 +27,8 @@ Panel(show: boolean) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| type | PanelType | 设置可滑动面板的类型。
    默认值:PanelType.Foldable | -| mode | PanelMode | 设置可滑动面板的初始状态。 | +| type | [PanelType](#paneltype枚举说明) | 设置可滑动面板的类型。
    默认值:PanelType.Foldable | +| mode | [PanelMode](#panelmode枚举说明) | 设置可滑动面板的初始状态。 | | dragBar | boolean | 设置是否存在dragbar,true表示存在,false表示不存在。
    默认值:true | | fullHeight | string \| number | 指定PanelMode.Full状态下的高度。 | | halfHeight | string \| number | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md index d1849a00c4bf3ced1ec7d953c60303b16ea5bd09..d03a2a041999f38c12d8dad5d2cd1f70e8656a7d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -29,7 +29,7 @@ Refresh\(value: \{ refreshing: boolean, offset?: number | string , fr | 名称 | 描述 | | -------- | -------- | -| onStateChange(callback: (state: RefreshStatus) => void)| 当前刷新状态变更时,触发回调。
    - state:刷新状态。 | +| onStateChange(callback: (state: [RefreshStatus](#refreshstatus枚举说明)) => void)| 当前刷新状态变更时,触发回调。
    - state:刷新状态。 | | onRefreshing(callback: () => void)| 进入刷新状态时触发回调。 | ## RefreshStatus枚举说明 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 6b55112ff56f38e83372fb7f319f6e99eb440c2b..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,22 +10,16 @@ ## 规则说明 * 容器内子组件区分水平方向,垂直方向: - * 水平方向为left, middle, right,对应容器的HorizontalAlign.Start, HorizontalAlign.Center, HorizontalAlign.End - * 垂直方向为top, center, bottom,对应容器的VerticalAlign.Top, VerticalAlign.Center, VerticalAlign.Bottom + * 水平方向为left, middle, right,对应容器的HorizontalAlign.Start, HorizontalAlign.Center, HorizontalAlign.End。 + * 垂直方向为top, center, bottom,对应容器的VerticalAlign.Top, VerticalAlign.Center, VerticalAlign.Bottom。 * 子组件可以将容器或者其他子组件设为锚点: - * 参与相对布局的容器内组件必须设置id,容器id固定为__container__ - * 无id的子组件位置设置默认为容器左上方 - * 此子组件某一方向上的三个位置可以将容器或其他子组件的同方向三个位置为锚点,同方向上两个以上位置设置锚点以后会跳过第三个 - * 同方向上两个以上位置设置锚点时此子组件额外设置width,height不生效 - * 对齐后需要额外偏移可设置offset + * 参与相对布局的容器内组件必须设置id,容器id固定为__container__。 + * 此子组件某一方向上的三个位置可以将容器或其他子组件的同方向三个位置为锚点,同方向上两个以上位置设置锚点以后会跳过第三个。 + * 前端页面设置的子组件尺寸大小不会受到相对布局规则的影响。 + * 对齐后需要额外偏移可设置offset。 * 特殊情况 - * 互相依赖,环形依赖时容器内子组件全部不绘制 - * 同方向上两个以上位置设置锚点但锚点位置逆序时此子组件大小为0,即不绘制 - -## 权限列表 - -无 - + * 互相依赖,环形依赖时容器内子组件全部不绘制。 + * 同方向上两个以上位置设置锚点但锚点位置逆序时此子组件大小为0,即不绘制。 ## 子组件 @@ -42,47 +36,61 @@ RelativeContainer() @Entry @Component struct Index { - build() { Row() { - Button("Extra button").width(100).height(50) - RelativeContainer() { - Button("Button 1").width(120).height(30) - .alignRules({ - middle: { anchor: "__container__", align: HorizontalAlign.Center }, - }) - .id("bt1").borderWidth(1).borderColor(Color.Black) - Text("This is text 2").fontSize(20).padding(10) - .alignRules({ - bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, - top: { anchor: "bt1", align: VerticalAlign.Bottom }, - right:{ anchor: "bt1", align: HorizontalAlign.Center } - }).id("tx2").borderWidth(1).borderColor(Color.Black).height(30) - - LoadingProgress().color(Color.Blue) - .alignRules({ - left: { anchor: "bt1", align: HorizontalAlign.End }, - top: { anchor: "tx2", align: VerticalAlign.Center }, - bottom: { anchor: "__container__", align: VerticalAlign.Bottom } - }).id("lp3").borderWidth(1).borderColor(Color.Black) - .height(30).width(30) - - 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) - .alignRules({ - left: { anchor: "tx2", align: HorizontalAlign.End }, - right:{ anchor: "__container__", align: HorizontalAlign.End }, - top: { anchor: "__container__", align: VerticalAlign.Top }, - bottom: { anchor: "lp3", align: VerticalAlign.Top } - }).id("g4").borderWidth(1).borderColor(Color.Black) - - } - .width(200).height(200) - .backgroundColor(Color.Orange) - + Button("Extra button").width(100).height(50) + + RelativeContainer() { + Button("Button 1") + .width(120) + .height(30) + .alignRules({ + middle: { anchor: "__container__", align: HorizontalAlign.Center }, + }) + .id("bt1") + .borderWidth(1) + .borderColor(Color.Black) + + Text("This is text 2") + .fontSize(20) + .padding(10) + .alignRules({ + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, + top: { anchor: "bt1", align: VerticalAlign.Bottom }, + right: { anchor: "bt1", align: HorizontalAlign.Center } + }) + .id("tx2") + .borderWidth(1) + .borderColor(Color.Black) + .height(30) + + Button("Button 3") + .width(100) + .height(100) + .alignRules({ + 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) + + Text("This is text 4") + .fontSize(20) + .padding(10) + .alignRules({ + 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("tx4") + .borderWidth(1) + .borderColor(Color.Black) + } + .width(200).height(200) + .backgroundColor(Color.Orange) } .height('100%') } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md index 54c51fe6288d6b11bc989f0a1d5e0af02c3ec25f..ba536c338ffb88ce73f1a0619d722f8b1c2743c0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md @@ -40,38 +40,41 @@ Row(value?:{space?: number | string }) struct RowExample { build() { Column({ space: 5 }) { + // 设置子组件水平方向的间距为5 Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row({ space: 5 }) { - Row().width('30%').height(50).backgroundColor(0xAFEEEE) - Row().width('30%').height(50).backgroundColor(0x00FFFF) - }.width('90%').height(107).border({ width: 1 }) - - Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('30%').height(50).backgroundColor(0xAFEEEE) - Row().width('30%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Top).height('15%').border({ width: 1 }) - - Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('30%').height(50).backgroundColor(0xAFEEEE) - Row().width('30%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Center).height('15%').border({ width: 1 }) - - Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('30%').height(50).backgroundColor(0xAFEEEE) - Row().width('30%').height(50).backgroundColor(0x00FFFF) - }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End) - - Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('30%').height(50).backgroundColor(0xAFEEEE) - Row().width('30%').height(50).backgroundColor(0x00FFFF) - }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center) + Row({ space: 5 }) { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').height(107).border({ width: 1 }) + + // 设置子元素垂直方向对齐方式 + Text('alignItems(Bottom)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').alignItems(VerticalAlign.Bottom).height('15%').border({ width: 1 }) + + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').alignItems(VerticalAlign.Center).height('15%').border({ width: 1 }) + + // 设置子元素水平方向对齐方式 + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End) + + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center) }.width('100%') } } ``` -![zh-cn_image_0000001174422908](figures/Row.png) +![row](figures/row.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-rowsplit.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-rowsplit.md index 0cec1a56838513830296eb80e4860ffde3ddb795..ae460606c107c01221789228b458b7160e66d93a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-rowsplit.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-rowsplit.md @@ -7,10 +7,6 @@ 将子组件横向布局,并在每个子组件之间插入一根纵向的分割线。 -## 权限列表 - -无 - ## 子组件 @@ -30,6 +26,8 @@ RowSplit() > **说明:** > RowSplit的分割线最小能拖动到刚好包含子组件。 +> +> 在真机中查看拖动效果,预览器中不支持拖动。 ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 4768ef64f18bc63f33b96c1cd1a927ad46585afd..e0a02896e93d84a2134a740731beae086e0f71d3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -24,9 +24,9 @@ Scroll(scroller?: Scroller) | 名称 | 参数类型 | 描述 | | -------------- | ---------------------------------------- | --------- | -| scrollable | ScrollDirection | 设置滚动方向。
    默认值:ScrollDirection.Vertical | +| scrollable | [ScrollDirection](#scrolldirection枚举说明) | 设置滚动方向。
    默认值:ScrollDirection.Vertical | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
    默认值:BarState.Off | -| scrollBarColor | string \| number \| Color | 设置滚动条的颜色。 | +| scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | | scrollBarWidth | string \| number | 设置滚动条的宽度。 | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。
    默认值:EdgeEffect.None | @@ -161,14 +161,15 @@ scrollBy(dx: Length, dy: Length): void ## 示例 +### 示例1 ```ts // xxx.ets @Entry @Component struct ScrollExample { - scroller: Scroller = new Scroller() - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; build() { Stack({ alignContent: Alignment.TopStart }) { @@ -186,38 +187,39 @@ struct ScrollExample { }, item => item) }.width('100%') } - .scrollable(ScrollDirection.Vertical) - .scrollBar(BarState.On) - .scrollBarColor(Color.Gray) - .scrollBarWidth(30) + .scrollable(ScrollDirection.Vertical) // 滚动方向纵向 + .scrollBar(BarState.On) // 滚动条常驻显示 + .scrollBarColor(Color.Gray) // 滚动条颜色 + .scrollBarWidth(30) // 滚动条宽度 + .edgeEffect(EdgeEffect.None) .onScroll((xOffset: number, yOffset: number) => { - console.info(xOffset + ' ' + yOffset) + console.info(xOffset + ' ' + yOffset); }) .onScrollEdge((side: Edge) => { - console.info('To the edge') + console.info('To the edge'); }) .onScrollEnd(() => { - console.info('Scroll Stop') + console.info('Scroll Stop'); }) - + Button('scroll 150') .onClick(() => { // 点击后下滑指定距离150.0vp - this.scroller.scrollBy(0,150) + this.scroller.scrollBy(0,150); }) .margin({ top: 10, left: 20 }) Button('scroll 100') .onClick(() => { // 点击后滑动到指定位置,即下滑100.0vp的距离 - this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) + this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }); }) .margin({ top: 60, left: 20 }) Button('back top') .onClick(() => { // 点击后回到顶部 - this.scroller.scrollEdge(Edge.Top) + this.scroller.scrollEdge(Edge.Top); }) .margin({ top: 110, left: 20 }) Button('next page') .onClick(() => { // 点击后滑到下一页 - this.scroller.scrollPage({ next: true }) + this.scroller.scrollPage({ next: true }); }) .margin({ top: 170, left: 20 }) }.width('100%').height('100%').backgroundColor(0xDCDCDC) @@ -227,14 +229,14 @@ struct ScrollExample { ![zh-cn_image_0000001174104386](figures/zh-cn_image_0000001174104386.gif) - +### 示例2 ```ts @Entry @Component struct NestedScroll { - @State listPosition: number = 0 // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。 - private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - private scroller: Scroller = new Scroller() + @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。 + private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + private scroller: Scroller = new Scroller(); build() { Flex() { @@ -255,18 +257,18 @@ struct NestedScroll { } .width("100%").height("50%").edgeEffect(EdgeEffect.None) .onReachStart(() => { - this.listPosition = 0 + this.listPosition = 0; }) .onReachEnd(() => { - this.listPosition = 2 + this.listPosition = 2; }) .onScrollBegin((dx: number, dy: number) => { if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) { - this.scroller.scrollBy(0, -dy) - return { dxRemain: dx, dyRemain: 0 } + this.scroller.scrollBy(0, -dy); + return { dxRemain: dx, dyRemain: 0 }; } this.listPosition = 1; - return { dxRemain: dx, dyRemain: dy } + return { dxRemain: dx, dyRemain: dy }; }) Text("Scroll Area") 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-drawing-components-circle.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index 4da279cc7c27cfb55c8f441f0d5906496351d128..1d790cb18e416d3369d63c4d07e7513972c67a81 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -30,14 +30,14 @@ Circle(options?: {width?: string | number, height?: string | number}) | -------- | -------- | -------- | -------- | | fill | [ResourceColor](ts-types.md) | 否 | 设置填充区域颜色。
    默认值:Color.Black | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 否 | 设置填充区域透明度。
    默认值:1 | -| stroke | [ResourceColor](ts-types.md) | 否 | 设置线条颜色。
    默认值:Color.Black | -| strokeDashArray | Array<Length> | 否 | 设置线条间隙。
    默认值:[] | -| strokeDashOffset | number \| string | 否 | 线条绘制起点的偏移量。
    默认值:0 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 否 | 设置线条端点绘制样式。
    默认值:LineCapStyle.Butt | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 否 | 设置线条拐角绘制样式。
    默认值:LineJoinStyle.Miter | +| stroke | [ResourceColor](ts-types.md) | 否 | 设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | 否 | 设置边框间隙。
    默认值:[] | +| strokeDashOffset | number \| string | 否 | 边框绘制起点的偏移量。
    默认值:0 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 否 | 设置边框端点绘制样式。
    默认值:LineCapStyle.Butt | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 否 | 设置边框拐角绘制样式。
    默认值:LineJoinStyle.Miter | | strokeMiterLimit | number \| string | 否 | 设置锐角绘制成斜角的极限值。
    默认值:4 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 否 | 设置线条透明度。
    默认值:1 | -| strokeWidth | Length | 否 | 设置线条宽度。
    默认值:1 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 否 | 设置边框透明度。
    默认值:1 | +| strokeWidth | Length | 否 | 设置边框宽度。
    默认值:1 | | antiAlias | boolean | 否 | 是否开启抗锯齿效果。
    默认值:true | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index 6825c18b27042263f7d1f3d585e51df7cc104c0c..bedfc7713757b2291914cab626aa27af1501923f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -31,14 +31,14 @@ ellipse(options?: {width?: string | number, height?: string | number}) | -------- | -------- | -------- | -------- | -------- | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 |设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 |设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md index b9059c4c36e6fb7f1642633b3402fb3a5f7b178a..616f06a5994845272abc6f453590222744dabfa2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -50,9 +50,10 @@ Line(value?: {width?: string | number, height?: string | number}) | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | - ## 示例 +### 示例1 + ```ts // xxx.ets @Entry @@ -79,7 +80,15 @@ struct LineExample { .startPoint([0, 0]) .endPoint([100, 100]) .strokeWidth(3) - .strokeDashArray([1, 3]) + .strokeDashArray([10, 3]) + .backgroundColor('#F5F5F5') + // strokeDashOffset用于定义关联虚线strokeDashArray数组渲染时的偏移 + Line({ width: 50, height: 50 }) + .startPoint([0, 0]) + .endPoint([100, 100]) + .strokeWidth(3) + .strokeDashArray([10, 3]) + .strokeDashOffset(5) .backgroundColor('#F5F5F5') } } @@ -87,3 +96,46 @@ struct LineExample { ``` ![zh-cn_image_0000001219982725](figures/zh-cn_image_0000001219982725.png) + +### 示例2 + +```ts +// xxx.ets +@Entry +@Component +struct LineExample1 { + build() { + Row({ space: 10 }) { + // 当LineCapStyle值为Butt时 + Line() + .width(100) + .height(200) + .startPoint([50, 50]) + .endPoint([50, 200]) + .strokeWidth(20) + .strokeLineCap(LineCapStyle.Butt) + .backgroundColor('#F5F5F5').margin(10) + // 当LineCapStyle值为Round时 + Line() + .width(100) + .height(200) + .startPoint([50, 50]) + .endPoint([50, 200]) + .strokeWidth(20) + .strokeLineCap(LineCapStyle.Round) + .backgroundColor('#F5F5F5') + // 当LineCapStyle值为Square时 + Line() + .width(100) + .height(200) + .startPoint([50, 50]) + .endPoint([50, 200]) + .strokeWidth(20) + .strokeLineCap(LineCapStyle.Square) + .backgroundColor('#F5F5F5') + } + } +} +``` + +![zh-cn_image1_0000001219982725](figures/zh-cn_image1_0000001219982725.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md index 5929aa6c23a2eab7ad9b5cf08584b635cebf41cc..ecdc9f2e09cbab6f5e1ac00ad5b47ef61edc28e0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -32,7 +32,7 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str | commands | string | '' | 否 | 路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](../../ui/ts-pixel-units.md)。 | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index cb1f6803ae97b70c086b64d4fba4498a9ebaf576..eefd1d43c4fc7e487001ed1c1945591f5a38f0fc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -33,14 +33,14 @@ Polygon(value?: {width?: string | number, height?: string | number}) | points | Array<Point> | [] | 否 | 多边形的顶点坐标列表。 | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框线条。 | +| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | ## Point diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index dd862ca6184c0d4684a4f3c0677380ec79e8b4f9..8042a9947528a5f0e70761fb56a9df721a8a688c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -33,7 +33,7 @@ Polyline(value?: {width?: string | number, height?: string | number}) | points | Array<Point> | [] | 否 | 折线经过坐标点列表。 | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index a7582c53b2ea630fda8cde04b89174273ccab123..d2549d5bb3d22419b36aae65fc144f9bd56fb3fb 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -19,34 +19,34 @@ Rect(value?: {width?: string | number,height?: string | number,radius?: string | **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | -| width | string \| number | 否 | 0 | 宽度。 | -| height | string \| number | 否 | 0 | 高度。 | -| radius | string \| number \| Array<string \| number> | 否 | 0 | 圆角半径,支持分别设置四个角的圆角度数。 | -| radiusWidth | string \| number | 否 | 0 | 圆角宽度。 | -| radiusHeight | string \| number | 否 | 0 | 圆角高度。 | +| width | string \| number | 否 | 0 | 宽度。 | +| height | string \| number | 否 | 0 | 高度。 | +| radius | string \| number \| Array<string \| number> | 否 | 0 | 圆角半径,支持分别设置四个角的圆角度数。 | +| radiusWidth | string \| number | 否 | 0 | 圆角宽度。 | +| radiusHeight | string \| number | 否 | 0 | 圆角高度。 | ## 属性 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | +| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | -| radiusWidth | string \| number | 0 | 否 | 圆角的宽度,仅设置宽时宽高一致。 | -| radiusHeight | string \| number | 0 | 否 | 圆角的高度,仅设置高时宽高一致。 | +| radiusWidth | string \| number | 0 | 否 | 圆角的宽度,仅设置宽时宽高一致。 | +| radiusHeight | string \| number | 0 | 否 | 圆角的高度,仅设置高时宽高一致。 | | radius | string \| number \| Array<string \| number> | 0 | 否 | 圆角半径大小。 | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index ac8e3eb10f828f85a6fd8fdfa364fee75a9ca1a2..709e897f90d1940b5388b18c148592a0e1f74361 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -14,7 +14,7 @@ ## 子组件 -可以包含子组件。 +包含[Rect](ts-drawing-components-rect.md)、[Path](ts-drawing-components-path.md)、[Circle](ts-drawing-components-circle.md)、[Ellipse](ts-drawing-components-ellipse.md)、[Polyline](ts-drawing-components-polyline.md)、[Polygon](ts-drawing-components-polygon.md)、[Image](ts-basic-components-image.md)、[Text](ts-basic-components-text.md)、[Column](ts-container-column.md)、[Row](ts-container-row.md)子组件。 ## 接口 @@ -37,14 +37,14 @@ Shape(value?: PixelMap) | viewPort | {
    x?: number \| string,
    y?: number \| string,
    width?: number \| string,
    height?: number \| string
    } | { x:0, y:0, width:0, height:0 } | 否 | 形状的视口。 | | fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | | fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | +| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框线条。 | +| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | number \| string | 1 | 否 | 设置线条宽度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | +| strokeWidth | number \| string | 1 | 否 | 设置边框宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | | mesh8+ | Array<number>,number,number | [],0,0 | 否 | 设置mesh效果。第一个参数为长度(column + 1)* (row + 1)* 2的数组,它记录了扭曲后的位图各个顶点位置,第二个参数为mesh矩阵列数column,第三个参数为mesh矩阵行数row。 | 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/arkui-ts/ts-universal-attributes-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md index 93b24639efdf7911b1e9d5d2dc7911cd81e76f97..a81f4e0390a61127903e9ca41168c6b2e8786c1a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md @@ -1,19 +1,20 @@ # 栅格设置 > **说明:** -> - 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -> -> - 栅格布局的列宽、列间距由距离最近的GridContainer父组件决定。使用栅格属性的组件树上至少需要有1个GridContainer容器组件。 +> +> - 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 栅格布局的列宽、列间距由距离最近的GridContainer父组件决定。使用栅格属性的组件树上至少需要有1个GridContainer容器组件。 ## 属性 -| 名称 | 参数类型 | 描述 | -| ----------- | --------------------------| ----------------------------------------------- | +| 名称 | 参数类型 | 描述 | +| ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | useSizeType | {
    xs?: number \| { span: number, offset: number },
    sm?: number \| { span: number, offset: number },
    md?: number \| { span: number, offset: number },
    lg?: number \| { span: number, offset: number }
    } | 设置在特定设备宽度类型下的占用列数和偏移列数,span: 占用列数; offset: 偏移列数。
    当值为number类型时,仅设置列数, 当格式如{"span": 1, "offset": 0}时,指同时设置占用列数与偏移列数。
    - xs: 指设备宽度类型为SizeType.XS时的占用列数和偏移列数。
    - sm: 指设备宽度类型为SizeType.SM时的占用列数和偏移列数。
    - md: 指设备宽度类型为SizeType.MD时的占用列数和偏移列数。
    - lg: 指设备宽度类型为SizeType.LG时的占用列数和偏移列数。 | -| gridSpan | number | 默认占用列数,指useSizeType属性没有设置对应尺寸的列数(span)时,占用的栅格列数。
    **说明:**
    设置了栅格span属性,组件的宽度由栅格布局决定。
    默认值:1 | -| gridOffset | number | 默认偏移列数,指useSizeType属性没有设置对应尺寸的偏移(offset)时, 当前组件沿着父组件Start方向,偏移的列数,也就是当前组件位于第n列。
    **说明:**
    - 配置该属性后,当前组件在父组件水平方向的布局不再跟随父组件原有的布局方式,而是沿着父组件的Start方向偏移一定位移。
    - 偏移位移 = (列宽 + 间距)\* 列数。
    - 设置了偏移(gridOffset)的组件之后的兄弟组件会根据该组件进行相对布局,类似相对布局。
    默认值:0 | +| gridSpan | number | 默认占用列数,指useSizeType属性没有设置对应尺寸的列数(span)时,占用的栅格列数。
    **说明:**
    设置了栅格span属性,组件的宽度由栅格布局决定。
    默认值:1 | +| gridOffset | number | 默认偏移列数,指useSizeType属性没有设置对应尺寸的偏移(offset)时, 当前组件沿着父组件Start方向,偏移的列数,也就是当前组件位于第n列。
    **说明:**
    - 配置该属性后,当前组件在父组件水平方向的布局不再跟随父组件原有的布局方式,而是沿着父组件的Start方向偏移一定位移。
    - 偏移位移 = (列宽 + 间距)\* 列数。
    - 设置了偏移(gridOffset)的组件之后的兄弟组件会根据该组件进行相对布局,类似相对布局。
    默认值:0 | ## 示例 @@ -23,42 +24,76 @@ @Entry @Component struct GridContainerExample1 { + build() { + Column() { + Text('useSizeType').fontSize(15).fontColor(0xCCCCCC).width('90%') + GridContainer() { + Row({}) { + Row() { + Text('Left').fontSize(25) + } + .useSizeType({ + xs: { span: 1, offset: 0 }, sm: { span: 1, offset: 0 }, + md: { span: 1, offset: 0 }, lg: { span: 2, offset: 0 } + }) + .height("100%") + .backgroundColor(0x66bbb2cb) - build(){ - GridContainer() { - Row({}) { - Row() { - Text('Left').fontSize(25) - } - .useSizeType({ - xs: { span: 1, offset: 0 }, sm: { span: 1, offset: 0 }, - md: { span: 1, offset: 0 }, lg: { span: 2, offset: 0 } - }) - .height("100%") - .backgroundColor(0x66bbb2cb) - Row() { - Text('Center').fontSize(25) + Row() { + Text('Center').fontSize(25) + } + .useSizeType({ + xs: { span: 1, offset: 0 }, sm: { span: 2, offset: 1 }, + md: { span: 5, offset: 1 }, lg: { span: 7, offset: 2 } + }) + .height("100%") + .backgroundColor(0x66b6c5d1) + + Row() { + Text('Right').fontSize(25) + } + .useSizeType({ + xs: { span: 1, offset: 0 }, sm: { span: 1, offset: 3 }, + md: { span: 2, offset: 6 }, lg: { span: 3, offset: 9 } + }) + .height("100%") + .backgroundColor(0x66bbb2cb) } - .useSizeType({ - xs: { span: 1, offset: 0 }, sm: { span: 2, offset: 1 }, - md: { span: 5, offset: 1 }, lg: { span: 7, offset: 2 } - }) - .height("100%") - .backgroundColor(0x66b6c5d1) + .height(200) + + } + .backgroundColor(0xf1f3f5) + .margin({ top: 10 }) + + // 单独设置组件的span和offset,在sm尺寸大小的设备上使用useSizeType中sm的数据实现一样的效果 + Text('gridSpan,gridOffset').fontSize(15).fontColor(0xCCCCCC).width('90%') + GridContainer() { Row() { - Text('Right').fontSize(25) - } - .useSizeType({ - xs: { span: 1, offset: 0 }, sm: { span: 1, offset: 3 }, - md: { span: 2, offset: 6 }, lg: { span: 3, offset: 9 } - }) - .height("100%") - .backgroundColor(0x66bbb2cb) + Row() { + Text('Left').fontSize(25) + } + .gridSpan(1) + .height("100%") + .backgroundColor(0x66bbb2cb) + + Row() { + Text('Center').fontSize(25) + } + .gridSpan(2) + .gridOffset(1) + .height("100%") + .backgroundColor(0x66b6c5d1) + + Row() { + Text('Right').fontSize(25) + } + .gridSpan(1) + .gridOffset(3) + .height("100%") + .backgroundColor(0x66bbb2cb) + }.height(200) } - .height(200) } - .backgroundColor(0xf1f3f5) - .margin({ top: 10 }) } } ``` @@ -74,3 +109,7 @@ struct GridContainerExample1 { **图3** 设备宽度为LG ![zh-cn_image_0000001219982727](figures/zh-cn_image_0000001219982727.png) + +**图4** 单独设置gridSpan和gridOffset在特定屏幕大小下的效果与useSizeType效果一致 + +![gridSpan](figures/gridSpan.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index a58be16636b4a4f0e005b43b5ce32ff6129c9a0b..3fc5257703195527dba8b5c37e8497b69fd9bb54 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -1,16 +1,11 @@ # 图像效果 -例如背景模糊、内容模糊和灰度效果等。 +设置组件的模糊,阴影效果以及设置图片的图像效果。 > **说明:** > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## 属性 @@ -18,63 +13,113 @@ | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | | blur | number | - | 为当前组件添加内容模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。 | | backdropBlur | number | - | 为当前组件添加背景模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。 | -| shadow | {
    radius: number \| [Resource](ts-types.md#resource),
    color?: Color \| string \| Resource,
    offsetX?: number \| Resource,
    offsetY?: number \| Resource
    } | - | 为当前组件添加阴影效果,入参为模糊半径(必填)、阴影的颜色(可选,默认为灰色)、X轴的偏移量(可选,默认为0),Y轴的偏移量(可选,默认为0),偏移量单位为px。 | +| shadow | {
    radius: number \| [Resource](ts-types.md#resource),
    color?: [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource),
    offsetX?: number \| [Resource](ts-types.md#resource),
    offsetY?: number \| [Resource](ts-types.md#resource)
    } | - | 为当前组件添加阴影效果,入参为模糊半径(必填)、阴影的颜色(可选,默认为灰色)、X轴的偏移量(可选,默认为0),Y轴的偏移量(可选,默认为0),偏移量单位为px。 | | grayscale | number | 0.0 | 为当前组件添加灰度效果。值定义为灰度转换的比例,入参1.0则完全转为灰度图像,入参则0.0图像无变化,入参在0.0和1.0之间时,效果呈线性变化。(百分比) | | brightness | number | 1.0 | 为当前组件添加高光效果,入参为高光比例,值为1时没有效果,小于1时亮度变暗,0为全黑;大于1时亮度增加,数值越大亮度越大。 | | saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大;小于1时消色成分越大,饱和度越小。(百分比) | | contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图像越清晰醒目;小于1时,值越小对比度越低;当对比度为0时,图像变为全灰。(百分比) | | invert | number | 0 | 反转输入的图像。入参为图像反转的比例。值为1时完全反转。值为0则图像无变化。(百分比) | -| colorBlend 8+ | Color \| string \| [Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 | +| colorBlend 8+ | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 | | sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例。值为1则完全是深褐色的,值为0图像无变化。 (百分比) | -| hueRotate | number\|string | '0deg' | 色相旋转效果,输入参数为旋转角度。 | +| hueRotate | number \| string | '0deg' | 色相旋转效果,输入参数为旋转角度。 | ## 示例 -示例效果请以真机运行为准,当前IDE预览器不支持。 - +### 示例1 +模糊属性的用法,blur内容模糊,backdropBlur背景模糊。 ```ts // xxx.ets @Entry @Component -struct ImageEffectsExample { - +struct BlurEffectsExample { build() { - Column({space: 10}) { - // 对字体进行模糊 + Column({ space: 10 }) { + // 对字体进行模糊 Text('font blur').fontSize(15).fontColor(0xCCCCCC).width('90%') - Text('text').blur(3).width('90%').height(40) - .fontSize(16).backgroundColor(0xF9CF93).padding({ left: 5 }) + Flex({ alignItems: ItemAlign.Center }) { + Text('original text').margin(10) + Text('blur text') + .blur(1).margin(10) + Text('blur text') + .blur(2).margin(10) + Text('blur text') + .blur(3).margin(10) + }.width('90%').height(40) + .backgroundColor(0xF9CF93) + // 对背景进行模糊 Text('backdropBlur').fontSize(15).fontColor(0xCCCCCC).width('90%') - Text().width('90%').height(40).fontSize(16).backdropBlur(3) - .backgroundImage('/comment/bg.jpg') + Text() + .width('90%') + .height(40) + .fontSize(16) + .backdropBlur(3) + .backgroundImage('/pages/attrs/image/image.jpg') .backgroundImageSize({ width: 1200, height: 160 }) + }.width('100%').margin({ top: 5 }) + } +} +``` +![textblur](figures/textblur.png) + +### 示例2 +设置图片的效果,包括阴影,灰度,高光,饱和度,对比度,图像反转,叠色,色相旋转等。 +```ts +// xxx.ets +@Entry +@Component +struct ImageEffectsExample { + build() { + Column({ space: 10 }) { + // 添加阴影效果,图片效果不变 Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40) - .shadow({ radius: 10, color: Color.Gray, offsetX: 5, offsetY: 5 }) + Image($r('app.media.image')) + .width('90%') + .height(40) + .shadow({ radius: 10, color: Color.Green, offsetX: 20, offsetY: 30 }) + // 灰度效果0~1,越接近1,灰度越明显 Text('grayscale').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).grayscale(0.6) + Image($r('app.media.image')).width('90%').height(40).grayscale(0.3) + Image($r('app.media.image')).width('90%').height(40).grayscale(0.8) + // 高光效果,1为正常图片,<1变暗,>1亮度增大 Text('brightness').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).brightness(2.0) + Image($r('app.media.image')).width('90%').height(40).brightness(1.2) + // 饱和度,原图为1 Text('saturate').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).saturate(2.0) + Image($r('app.media.image')).width('90%').height(40).saturate(2.0) + Image($r('app.media.image')).width('90%').height(40).saturate(0.7) + // 对比度,1为原图,>1值越大越清晰,<1值越小越模糊 Text('contrast').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).contrast(2.0) + Image($r('app.media.image')).width('90%').height(40).contrast(2.0) + Image($r('app.media.image')).width('90%').height(40).contrast(0.8) + // 图像反转比例 Text('invert').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).invert(1) + Image($r('app.media.image')).width('90%').height(40).invert(0.2) + Image($r('app.media.image')).width('90%').height(40).invert(0.8) + + // 叠色添加 + Text('colorBlend').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(40).colorBlend(Color.Green) + Image($r('app.media.image')).width('90%').height(40).colorBlend(Color.Blue) + // 深褐色 + Text('sepia').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(40).sepia(0.8) + + // 色相旋转 Text('hueRotate').fontSize(15).fontColor(0xCCCCCC).width('90%') - Image($r('app.media.bg')).width('90%').height(40).hueRotate(90) + Image($r('app.media.image')).width('90%').height(40).hueRotate(90) }.width('100%').margin({ top: 5 }) } } ``` -image-effect \ No newline at end of file +![imageeffect](figures/imageeffect.png) + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md index 3290c21537a94041090bc9f7e2152c4bc5da28cc..0fb3e705c61d405b77d32d30d6ec48ac67bc1471 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md @@ -11,7 +11,7 @@ | 名称 | 参数说明 | 描述 | | --------------- | ------ | ---------------------------------------- | -| aspectRatio | number | 指定当前组件的宽高比。 | +| aspectRatio | number | 指定当前组件的宽高比,aspectRatio = width/height。 | | displayPriority | number | 设置当前组件在布局容器中显示的优先级,当父容器空间不足时,低优先级的组件会被隐藏。
    **说明:**
    仅在Row/Column/Flex(单行)容器组件中生效。 | @@ -22,29 +22,32 @@ @Entry @Component struct AspectRatioExample { - private children : string[] = ['1', '2', '3', '4', '5', '6'] + private children: string[] = ['1', '2', '3', '4', '5', '6']; build() { - Column({space: 20}) { + Column({ space: 20 }) { Text('using container: row').fontSize(14).fontColor(0xCCCCCC).width('100%') - Row({space: 10}) { + Row({ space: 10 }) { ForEach(this.children, (item) => { + // 组件宽度 = 组件高度*1.5 = 90 Text(item) .backgroundColor(0xbbb2cb) .fontSize(20) .aspectRatio(1.5) .height(60) + // 组件高度 = 组件宽度/1.5 = 60/1.5 = 40 Text(item) .backgroundColor(0xbbb2cb) .fontSize(20) .aspectRatio(1.5) .width(60) - }, item=>item) + }, item => item) } - .size({width: "100%", height: 100}) + .size({ width: "100%", height: 100 }) .backgroundColor(0xd2cab3) .clip(true) + // grid子元素width/height=3/2 Text('using container: grid').fontSize(14).fontColor(0xCCCCCC).width('100%') Grid() { ForEach(this.children, (item) => { @@ -54,12 +57,12 @@ struct AspectRatioExample { .fontSize(40) .aspectRatio(1.5) } - }, item=>item) + }, item => item) } .columnsTemplate('1fr 1fr 1fr') .columnsGap(10) .rowsGap(10) - .size({width: "100%", height: 165}) + .size({ width: "100%", height: 165 }) .backgroundColor(0xd2cab3) }.padding(10) } @@ -74,40 +77,44 @@ struct AspectRatioExample { ```ts class ContainerInfo { - label : string = '' - size : string = '' + label: string = ''; + size: string = ''; } class ChildInfo { - text : string = '' - priority : number = 0 + text: string = ''; + priority: number = 0; } @Entry @Component struct DisplayPriorityExample { - private container : ContainerInfo[] = [ - {label: 'Big container', size: '90%'}, - {label: 'Middle container', size: '50%'}, - {label: 'Small container', size: '30%'} + // 显示容器大小 + private container: ContainerInfo[] = [ + { label: 'Big container', size: '90%' }, + { label: 'Middle container', size: '50%' }, + { label: 'Small container', size: '30%' } ] - private children : ChildInfo[] = [ - {text: '1\n(priority:2)', priority: 2}, - {text: '2\n(priority:1)', priority: 1}, - {text: '3\n(priority:3)', priority: 3}, - {text: '4\n(priority:1)', priority: 1}, - {text: '5\n(priority:2)', priority: 2} + private children: ChildInfo[] = [ + { text: '1\n(priority:2)', priority: 2 }, + { text: '2\n(priority:1)', priority: 1 }, + { text: '3\n(priority:3)', priority: 3 }, + { text: '4\n(priority:1)', priority: 1 }, + { text: '5\n(priority:2)', priority: 2 } ] - @State currentIndex : number = 0 + @State currentIndex: number = 0; build() { - Column({space: 10}) { + Column({ space: 10 }) { + // 切换父级容器大小 Button(this.container[this.currentIndex].label).backgroundColor(0x317aff) - .onClick((event: ClickEvent) => { - this.currentIndex = (this.currentIndex + 1) % this.container.length + .onClick(() => { + this.currentIndex = (this.currentIndex + 1) % this.container.length; }) - Flex({justifyContent: FlexAlign.SpaceBetween}) { - ForEach(this.children, (item)=>{ + // 通过变量设置Flex父容器宽度 + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(this.children, (item) => { + // 使用displayPriority给子组件绑定显示优先级 Text(item.text) .width(120) .height(60) @@ -115,11 +122,11 @@ struct DisplayPriorityExample { .textAlign(TextAlign.Center) .backgroundColor(0xbbb2cb) .displayPriority(item.priority) - }, item=>item.text) + }, item => item.text) } .width(this.container[this.currentIndex].size) .backgroundColor(0xd2cab3) - }.width("100%").margin({top:50}) + }.width("100%").margin({ top: 50 }) } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index 3ed37a6353f0f36a24575241e23b3e62ad4a7b8c..912a81a63445d0c95963190a7fc4d894346ed19c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -12,25 +12,25 @@ | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。
    默认值:Alignment.Center | +| align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容的对齐方式,当元素的width和height大小大于元素本身内容大小时生效。
    默认值:Alignment.Center | | direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。
    默认值:Direction.Auto | -| position | [Position](ts-types.md#position8) | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | -| markAnchor | [Position](ts-types.md#position8) | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。
    默认值:
    {
    x: 0,
    y: 1
    } | -| offset | [Position](ts-types.md#position8) | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
    默认值:
    {
    x: 0,
    y: 1
    } | +| position | [Position](ts-types.md#position8) | 绝对定位,设置元素左上角相对于父容器左上角偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | +| markAnchor | [Position](ts-types.md#position8) | 设置元素在位置定位时的锚点,以元素左上角作为基准点进行偏移。通常配合position和offset属性使用,单独使用时,效果类似offset
    默认值:
    {
    x: 0,
    y: 0
    } | +| offset | [Position](ts-types.md#position8) | 相对定位,设置元素相对于自身的偏移量。设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
    默认值:
    {
    x: 0,
    y: 0
    } | | alignRules9+ | {
    left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
    right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
    middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
    top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
    bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
    center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }
    } | 指定相对容器的对齐规则。
    - left:设置左对齐参数。
    - right:设置右对齐参数。
    - middle:设置中间对齐的参数。
    - top:设置顶部对齐的参数。
    - bottom:设置底部对齐的参数。
    - center:设置中心对齐的参数。
    **说明:**
    - anchor:设置作为锚点的组件的id值。
    - align:设置相对于锚点组件的对齐方式。 | ## 示例 - +### 示例1 ```ts // xxx.ets @Entry @Component -struct PositionExample { - +struct PositionExample1 { build() { Column() { - Column({space: 10}) { + Column({ space: 10 }) { + // 元素内容<元素宽高,设置内容在与元素内的对齐方式 Text('align').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('top start') .align(Alignment.TopStart) @@ -39,6 +39,14 @@ struct PositionExample { .fontSize(16) .backgroundColor(0xFFE4C4) + Text('Bottom end') + .align(Alignment.BottomEnd) + .height(50) + .width('90%') + .fontSize(16) + .backgroundColor(0xFFE4C4) + + // 父容器设置direction为Direction.Auto|Ltr|不设置,子元素从左到右排列 Text('direction').fontSize(9).fontColor(0xCCCCCC).width('90%') Row() { Text('1').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3) @@ -47,6 +55,15 @@ struct PositionExample { Text('4').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C) } .width('90%') + .direction(Direction.Auto) + // 父容器设置direction为Direction.Rtl,子元素从右到左排列 + Row() { + Text('1').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3) + Text('2').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C) + Text('3').height(50).width('25%').fontSize(16).backgroundColor(0xF5DEB3) + Text('4').height(50).width('25%').fontSize(16).backgroundColor(0xD2B48C) + } + .width('90%') .direction(Direction.Rtl) } } @@ -55,54 +72,75 @@ struct PositionExample { } ``` -![zh-cn_image_0000001174264368](figures/zh-cn_image_0000001174264368.gif) +![align.png](figures/align.png) +### 示例2 ```ts // xxx.ets @Entry @Component struct PositionExample2 { - build() { Column({ space: 20 }) { + // 设置子组件左上角相对于父组件左上角的偏移位置 Text('position').fontSize(12).fontColor(0xCCCCCC).width('90%') - Row({ space: 20 }) { - Text('1').size({ width: '45%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }) .fontSize(16) - Text('2 position(25, 15)') - .size({ width: '60%', height: '30' }).backgroundColor(0xbbb2cb).border({ width: 1 }) - .fontSize(16).align(Alignment.Start) - .position({ x: 25, y: 15 }) + Row() { + Text('1').size({ width: '30%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) + Text('2 position(30, 10)') + .size({ width: '60%', height: '30' }) + .backgroundColor(0xbbb2cb) + .border({ width: 1 }) + .fontSize(16) + .align(Alignment.Start) + .position({ x: 30, y: 10 }) Text('3').size({ width: '45%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) Text('4 position(50%, 70%)') - .size({ width: '50%', height: '50' }).backgroundColor(0xbbb2cb).border({ width: 1 }).fontSize(16) + .size({ width: '50%', height: '50' }) + .backgroundColor(0xbbb2cb) + .border({ width: 1 }) + .fontSize(16) .position({ x: '50%', y: '70%' }) }.width('90%').height(100).border({ width: 1, style: BorderStyle.Dashed }) + // 相对于起点偏移,其中x为最终定位点距离起点水平方向间距,x>0往左,反之向右。 + // y为最终定位点距离起点垂直方向间距,y>0向上,反之向下 Text('markAnchor').fontSize(12).fontColor(0xCCCCCC).width('90%') Stack({ alignContent: Alignment.TopStart }) { Row() .size({ width: '100', height: '100' }) .backgroundColor(0xdeb887) - Image($r('app.media.ic_health_heart')) + Text('text') .size({ width: 25, height: 25 }) + .backgroundColor(Color.Green) .markAnchor({ x: 25, y: 25 }) - Image($r('app.media.ic_health_heart')) + Text('text') .size({ width: 25, height: 25 }) - .markAnchor({ x: 25, y: 25 }) - .position({ x: '100%', y: '100%' }) + .backgroundColor(Color.Green) + .markAnchor({ x: -100, y: -25 }) + Text('text') + .size({ width: 25, height: 25 }) + .backgroundColor(Color.Green) + .markAnchor({ x: 25, y: -25 }) }.margin({ top: 25 }).border({ width: 1, style: BorderStyle.Dashed }) + // 相对定位,x>0向右偏移,反之向左,y>0向下偏移,反之向上 Text('offset').fontSize(12).fontColor(0xCCCCCC).width('90%') Row() { Text('1').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) - Text('2\noffset(15, 15)') - .size({ width: 120, height: '50' }).backgroundColor(0xbbb2cb).border({ width: 1 }) - .fontSize(16).align(Alignment.Start) - .offset({ x: 15, y: 15 }) + Text('2 offset(15, 30)') + .size({ width: 120, height: '50' }) + .backgroundColor(0xbbb2cb) + .border({ width: 1 }) + .fontSize(16) + .align(Alignment.Start) + .offset({ x: 15, y: 30 }) Text('3').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) - Text('4\noffset(-10%, 20%)') - .size({ width: 150, height: '50' }) .backgroundColor(0xbbb2cb).border({ width: 1 }).fontSize(16) - .offset({ x: '-10%', y: '20%' }) + Text('4 offset(-10%, 20%)') + .size({ width: 100, height: '50' }) + .backgroundColor(0xbbb2cb) + .border({ width: 1 }) + .fontSize(16) + .offset({ x: '-5%', y: '20%' }) }.width('90%').height(100).border({ width: 1, style: BorderStyle.Dashed }) } .width('100%').margin({ top: 25 }) @@ -110,4 +148,4 @@ struct PositionExample2 { } ``` -![zh-cn_image_0000001174104392](figures/zh-cn_image_0000001174104392.gif) +![position.png](figures/position.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index 543af9320cab9a91270a8cc089e234af3c2c302b..92463eb228b273e59b141143d599d52b7bbafed5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -12,7 +12,7 @@ | 名称 | 参数类型 | 描述 | | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| bindMenu | Array8+ | content: [CustomBuilder](ts-types.md#custombuilder8),
    responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | ## MenuItem diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index af1f6a91733221cba91a4c988658878ae00ec49b..1883fcc9579703540203e7034d6d8005fe9df258 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -10,9 +10,9 @@ ## 属性 -| 名称 | 参数类型 | 描述 | -| ------- | ---------------------------------------------------- | ------------------------------------------------------------ | -| opacity | number \| [Resource](ts-types.md#resource) | 元素的不透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。
    **说明:**
    子组件可以继承父组件的此属性。默认值:1 | +| 名称 | 参数类型 | 描述 | +| ------- | ---------------------------------------- | ---------------------------------------- | +| opacity | number \| [Resource](ts-types.md#resource) | 元素的不透明度,取值范围为0到1,1表示不透明,0表示完全透明, 达到隐藏组件效果,但是在布局中占位。
    **说明:**
    子组件可以继承父组件的此属性。默认值:1 | ## 示例 @@ -30,6 +30,10 @@ struct OpacityExample { Text().width('90%').height(50).opacity(0.7).backgroundColor(0xAFEEEE) Text('opacity(0.4)').fontSize(9).width('90%').fontColor(0xCCCCCC) Text().width('90%').height(50).opacity(0.4).backgroundColor(0xAFEEEE) + Text('opacity(0.1)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.1).backgroundColor(0xAFEEEE) + Text('opacity(0)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0).backgroundColor(0xAFEEEE) } .width('100%') .padding({ top: 5 }) @@ -37,4 +41,4 @@ struct OpacityExample { } ``` -![zh-cn_image_0000001219662647](figures/zh-cn_image_0000001219662647.gif) +![opacity.png](figures/opacity.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md index 4a84e85fa5e5c21fc36f8362b94a69bb967fc72b..14fdb7f1a435f40f82029ed7f207d6ba4457de00 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md @@ -8,10 +8,9 @@ ## 属性 -| 名称 | 参数类型 | 描述 | -| ------- | ----------------------------- | ------------------------- | -| overlay | value: string,
    options?: {
    align?: [Alignment](ts-appendix-enums.md#alignment), 
    offset?: {
    x?: number,
    y?: number
    }
    } | 在当前组件上,增加遮罩文本,布局与当前组件相同。
    默认值:
    {
    align: Alignment.Center,
    offset: {0, 0}
    } | - +| 名称 | 参数类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| overlay | value: string,
    options?: {
    align?: [Alignment](ts-appendix-enums.md#alignment), 
    offset?: {x?: number, y?: number}
    } | {
    align: Alignment.Center,
    offset: {0, 0}
    } | 在当前组件上,增加遮罩文本。
    value: 遮罩文本内容。
    options: 文本定位,align设置文本相对于组件的方位,[offset](ts-universal-attributes-location.md)为文本基于自身左上角的偏移量。文本默认处于组件左上角。
    两者都设置时效果重叠,文本相对于组件方位定位后再基于当前位置文本的左上角进行偏移。 | ## 示例 @@ -28,7 +27,10 @@ struct OverlayExample { Column() { Image($r('app.media.img')) .width(240).height(240) - .overlay("Winter is a beautiful season, especially when it snows.", { align: Alignment.Bottom, offset: { x: 0, y: -15 } }) + .overlay("Winter is a beautiful season, especially when it snows.", { + align: Alignment.Bottom, + offset: { x: 70, y: 100 } + }) }.border({ color: Color.Black, width: 2 }) }.width('100%') }.padding({ top: 20 }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 9f9c8f42383cd699a337eb7f1f17e1a003707ebf..cb99c14a586d282f17134f82cc7c26ef405ae8dd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -1,6 +1,6 @@ # Popup控制 -设置组件点击时弹出的气泡框状态。 +给组件绑定popup弹窗,并设置弹窗内容,交互逻辑和显示状态。 > **说明:** > @@ -12,7 +12,7 @@ | 名称 | 参数类型 | 描述 | | ---------- | ------------------------------------- | --------------------------------------- | -| bindPopup | show: boolean,
    popup: PopupOptions \| CustomPopupOptions8+ | 给组件绑定Popup,点击弹出弹窗。
    show: 创建页面弹窗提示是否默认显示,默认值为false。
    popup: 配置当前弹窗提示的参数。 | +| bindPopup | show: boolean,
    popup: [PopupOptions](#popupoptions类型说明) \| [CustomPopupOptions](#custompopupoptions8类型说明)8+ | 给组件绑定Popup弹窗,设置参数show为true弹出弹框。
    show: 弹窗显示状态,默认值为false,隐藏弹窗。
    popup: 配置当前弹窗提示的参数。 | ## PopupOptions类型说明 @@ -21,6 +21,7 @@ | message | string | 是 | 弹窗信息内容。 | | placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 | | arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| showInSubWindow9+ | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 | | primaryButton | {
    value: string,
    action: () => void
    } | 否 | 第一个按钮。
    value: 弹窗里主按钮的文本。
    action: 点击主按钮的回调函数。 | | secondaryButton | {
    value: string,
    action: () => void
    } | 否 | 第二个按钮。
    value: 弹窗里辅助按钮的文本。
    action: 点击辅助按钮的回调函数。 | | onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | @@ -32,6 +33,7 @@ | builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 提示气泡内容的构造器。 | | placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。
    默认值:Placement.Bottom | | arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| showInSubWindow9+ | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 | | maskColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡遮障层的颜色。 | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 提示气泡的颜色。 | | enableArrow | boolean | 否 | 是否显示箭头。
    从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。
    默认值:true | @@ -40,81 +42,80 @@ ## 示例 - ```ts // xxx.ets @Entry @Component struct PopupExample { - @State noHandlePopup: boolean = false @State handlePopup: boolean = false @State customPopup: boolean = false + // popup构造器定义弹框内容 @Builder popupBuilder() { Row({ space: 2 }) { - Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 }) + Image($r("app.media.image")).width(24).height(24).margin({ left: -5 }) Text('Custom Popup').fontSize(10) - }.width(100).height(50).backgroundColor(Color.White) + }.width(100).height(50).padding(5) } build() { Flex({ direction: FlexDirection.Column }) { - Button('no handle popup') - .onClick(() => { - this.noHandlePopup = !this.noHandlePopup - }) - .bindPopup(this.noHandlePopup, { - message: 'content1 content1', - placementOnTop: false, - onStateChange: (e) => { - console.info(e.isVisible.toString()) - if (!e.isVisible) { - this.noHandlePopup = false - } - } - }) - .position({ x: 100, y: 50 }) - - Button('with handle popup') + // PopupOptions 类型设置弹框内容 + Button('PopupOptions') .onClick(() => { this.handlePopup = !this.handlePopup }) .bindPopup(this.handlePopup, { - message: 'content2 content2', + message: 'This is a popup with PopupOptions', placementOnTop: true, + showInSubWindow:false, primaryButton: { - value: 'ok', + value: 'confirm', action: () => { this.handlePopup = !this.handlePopup - console.info('secondaryButton click') + console.info('confirm Button click') + } + }, + // 第二个按钮 + secondaryButton: { + value: 'cancel', + action: () => { + this.handlePopup = !this.handlePopup; + console.info('cancel Button click') } }, onStateChange: (e) => { console.info(e.isVisible.toString()) + if (!e.isVisible) { + this.handlePopup = false + } } }) - .position({ x: 100, y: 200 }) + .position({ x: 100, y: 50 }) + - Button('custom popup') + // CustomPopupOptions 类型设置弹框内容 + Button('CustomPopupOptions') .onClick(() => { this.customPopup = !this.customPopup }) .bindPopup(this.customPopup, { builder: this.popupBuilder, - placement: Placement.Bottom, + placement: Placement.Top, maskColor: 0x33000000, - popupColor: Color.White, + popupColor: Color.Yellow, enableArrow: true, + showInSubWindow: false, onStateChange: (e) => { if (!e.isVisible) { this.customPopup = false } } }) - .position({ x: 100, y: 350 }) + .position({ x: 80, y: 200 }) }.width('100%').padding({ top: 5 }) } } ``` -![zh-cn_image_0000001187055946](figures/zh-cn_image_0000001187055946.gif) +![figures/popup.gif](figures/popup.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index 0626e002ac1d94606d6f4bd1531592703c6cedc0..e46f3861c8fd4a4c294a5de7ee3ceb972d701df8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -1,6 +1,6 @@ # 尺寸设置 -用于设置组件的宽高、边距等显示尺寸进行设置。 +用于设置组件的宽高、边距。 > **说明:** > @@ -18,7 +18,7 @@ | padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | 设置内边距属性。
    参数为Length类型时,四个方向内边距同时生效。
    默认值:0
    padding设置百分比时,上下左右内边距均以父容器的width作为基础值。 | | margin | [Margin](ts-types.md#margin) \| [Length](ts-types.md#length) | 设置外边距属性。
    参数为Length类型时,四个方向外边距同时生效。
    默认值:0
    margin设置百分比时,上下左右外边距均以父容器的width作为基础值。| | constraintSize | {
    minWidth?: [Length](ts-types.md#length),
    maxWidth?: [Length](ts-types.md#length),
    minHeight?: [Length](ts-types.md#length),
    maxHeight?: [Length](ts-types.md#length)
    } | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。
    默认值:
    {
    minWidth: 0,
    maxWidth: Infinity,
    minHeight: 0,
    maxHeight: Infinity
    } | -| layoutWeight | number \| string | 容器尺寸确定时,元素与兄弟节点主轴布局尺寸按照权重进行分配,忽略本身尺寸设置,表示自适应占满剩余空间。
    **说明:**
    仅在Row/Column/Flex布局中生效。
    默认值:0 | +| layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
    **说明:**
    仅在Row/Column/Flex布局中生效。| ## 示例 @@ -31,30 +31,41 @@ struct SizeExample { build() { Column({ space: 10 }) { Text('margin and padding:').fontSize(12).fontColor(0xCCCCCC).width('90%') - // 宽度80 ,高度80 ,内外边距20 Row() { + // 宽度80 ,高度80 ,外边距20(蓝色区域),内边距10(白色区域) Row() { - Row().size({ width: '100%', height: '100%' }).backgroundColor(0xAFEEEE) - }.width(80).height(80).padding(20).margin(20).backgroundColor(0xFDF5E6) - }.backgroundColor(0xFFA500) + Row().size({ width: '100%', height: '100%' }).backgroundColor(Color.Yellow) + } + .width(80) + .height(80) + .padding(10) + .margin(20) + .backgroundColor(Color.White) + }.backgroundColor(Color.Blue) + + Text('constraintSize').fontSize(12).fontColor(0xCCCCCC).width('90%') + Text('this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text.this is a Text') + .width('90%') + .constraintSize({ maxWidth: 200 }) Text('layoutWeight').fontSize(12).fontColor(0xCCCCCC).width('90%') - // 容器尺寸确定时,元素与兄弟节点主轴布局尺寸按照权重进行分配,忽略本身尺寸设置。 + // 父容器尺寸确定时,设置了layoutWeight的子元素在主轴布局尺寸按照权重进行分配,忽略本身尺寸设置。 Row() { - // 权重1 + // 权重1,占主轴剩余空间1/3 Text('layoutWeight(1)') .size({ width: '30%', height: 110 }).backgroundColor(0xFFEFD5).textAlign(TextAlign.Center) .layoutWeight(1) - // 权重2 + // 权重2,占主轴剩余空间2/3 Text('layoutWeight(2)') .size({ width: '30%', height: 110 }).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .layoutWeight(2) - // 权重默认0 + // 未设置layoutWeight属性,组件按照自身尺寸渲染 Text('no layoutWeight') .size({ width: '30%', height: 110 }).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) }.size({ width: '90%', height: 140 }).backgroundColor(0xAFEEEE) }.width('100%').margin({ top: 5 }) - }} + } +} ``` -![zh-cn_image_0000001174264384](figures/zh-cn_image_0000001174264384.gif) +![size](figures/size.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index 5de534998ef8e77e18a725472c87e5f56d8fa215..4278cb3af7cb87c09196bc9d37a7ab1adfafa8df 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -1,22 +1,23 @@ # 文本样式设置 +针对包含文本元素的组件,设置文本样式。 + > **说明:** > > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -针对包含文本元素的组件,设置文本样式。 ## 属性 | 名称 | 参数类型 | 描述 | | -----------| ---------------------------------------- | ------------------------------------ | -| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置文本颜色。 | -| fontSize | Length \| [Resource](ts-types.md#resource) | 设置文本尺寸,Length为number类型时,使用fp单位。 | -| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置文本的字体样式。
    默认值:FontStyle.Normal | +| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置字体颜色。 | +| fontSize | Length \| [Resource](ts-types.md#resource) | 设置字体大小,Length为number类型时,使用fp单位。字体默认大小10。 | +| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。
    默认值:FontStyle.Normal | | fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。
    默认值:FontWeight.Normal | -| fontFamily | string \| [Resource](ts-types.md#resource) | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。 | +| fontFamily | string \| [Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体。| ## 示例 @@ -29,40 +30,38 @@ struct TextStyleExample { build() { Column({ space: 5 }) { Text('default text') - - Text('text font color red') + Divider() + + Text('text font color red').fontColor(Color.Red) + Divider() + + Text('text font default') + Text('text font size 10').fontSize(10) + Text('text font size 10fp').fontSize('10fp') + Text('text font size 20').fontSize(20) + Divider() + + Text('text font style Italic').fontStyle(FontStyle.Italic) + Divider() + + Text('text fontWeight bold').fontWeight(700) + Text('text fontWeight lighter').fontWeight(FontWeight.Lighter) + Divider() + + Text('red 20 Italic bold text') .fontColor(Color.Red) - - Text('text font size 20') .fontSize(20) - - Text('text font style Italic') .fontStyle(FontStyle.Italic) - - Text('text fontWeight bold') - .fontWeight(700) - - Text('text fontFamily sans-serif') - .fontFamily('sans-serif') - - Text('red 20 Italic bold cursive text') - .fontColor(Color.Red) - .fontSize(20) - .fontStyle(FontStyle.Italic) - .fontWeight(700) - .fontFamily('cursive') - .textAlign(TextAlign.Center) - .width('90%') - - Text('Orange 18 Normal source-sans-pro text') + .fontWeight(FontWeight.Bold) + Divider() + + Text('Orange 18 Normal text') .fontColor(Color.Orange) .fontSize(18) .fontStyle(FontStyle.Normal) - .fontWeight(400) - .fontFamily('source-sans-pro,cursive,sans-serif') }.width('100%') } } ``` -![zh-cn_image_0000001219662673](figures/zh-cn_image_0000001219662673.png) +![textstyle](figures/textstyle.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md index fdf7314b0cb00f71a3d152dd0aa74f3293966955..ffa706268f3bd28b93edaa5944ccca29d365c4ca 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md @@ -2,6 +2,7 @@ 适用于支持通用点击事件、通用触摸事件、通用手势处理的组件。 + > **说明:** > > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 @@ -12,16 +13,16 @@ | 名称 | 参数类型 | 描述 | | -------------- | --------------------------------------------- | ----------------------------------------- | -| responseRegion | Array<Rectangle> \| Rectangle | 设置一个或多个触摸热区,包括位置和大小。
    默认值:
    {
    x:0,
    y:0,
    width:'100%',
    height:'100%'
    } | +| responseRegion | Array<[Rectangle](#rectangle对象说明)> \| [Rectangle](#rectangle对象说明) | 设置一个或多个触摸热区,包括位置和大小。
    默认触摸热区为整个组件,默认值:
    {
    x:0,
    y:0,
    width:'100%',
    height:'100%'
    } | -### Rectangle对象说明 +## Rectangle对象说明 | 名称 | 类型 | 必填 | 描述 | | ------ | ----------------------------- | -----| -------------------------------- | -| x | [Length](ts-types.md#length) | 否 | 触摸点相对于组件本身左边沿的X坐标。
    默认值:0vp | -| y | [Length](ts-types.md#length) | 否 | 触摸点相对于组件本身左边沿的Y坐标。
    默认值:0vp | -| width | [Length](ts-types.md#length) | 否 | 触摸热区范围的宽度。
    默认值:100% | -| height | [Length](ts-types.md#length) | 否 | 触摸热区范围的高度。
    默认值:100% | +| x | [Length](ts-types.md#length) | 否 | 触摸点相对于组件左上角的x轴坐标。
    默认值:0vp | +| y | [Length](ts-types.md#length) | 否 | 触摸点相对于组件左上角的y轴坐标。
    默认值:0vp | +| width | [Length](ts-types.md#length) | 否 | 触摸热区的宽度。
    默认值:'100%' | +| height | [Length](ts-types.md#length) | 否 | 触摸热区的高度。
    默认值:'100%' | > **说明:** > @@ -29,7 +30,7 @@ > > width和height只能设置正值百分比。width:'100%'表示热区宽度设置为该组件本身的宽度。比如组件本身宽度是100vp,那么'100%'表示热区宽度也为100vp。height:'100%'表示热区高度设置为该组件本身的高度。 > - > 百分比是相对于组件本身来度量的。 + > 百分比相对于组件自身宽高进行计算。 ## 示例 @@ -38,19 +39,38 @@ // xxx.ets @Entry @Component -struct ResponseRegionExample { +struct TouchTargetExample { + @State text: string = ""; + build() { - Column() { - Toggle({ type: ToggleType.Checkbox, isOn: true }) - .selectedColor(0x39a2db) - .backgroundColor(0xAFEEEE) - .responseRegion({ x: 1.0, y: 1.0, width: 400, height: 400 }) - .onChange((isOn: boolean) => { - console.info('Component status:' + isOn) - }) - }.width('100%').margin({ top: 5 }) + Column({ space: 20 }) { + Text("{x:0,y:0,width:'50%',height:'100%'}") + // 热区宽度为按钮的一半,点击右侧无响应 + Button("button1") + .responseRegion({ x: 0, y: 0, width: '50%', height: '100%' }) + .onClick(() => { + this.text = 'button1 clicked'; + }) + + // 热区宽度为按钮的一半,且右移一个按钮宽度,点击button2右侧左边,点击事件生效 + Text("{x:'100%',y:0,width:'50%',height:'100%'}") + Button("button2") + .responseRegion({ x: '100%', y: 0, width: '50%', height: '100%' }) + .onClick(() => { + this.text = 'button2 clicked'; + }) + // 热区大小为整个按钮,且下移一个按钮高度,点击button3下方按钮大小区域,点击事件生效 + Text("{x:0,y:'100%',width:'100%',height:'100%'}") + Button("button3") + .responseRegion({ x: 0, y: '100%', width: '100%', height: '100%' }) + .onClick(() => { + this.text = 'button3 clicked'; + }) + + Text(this.text).margin({ top: 50 }) + }.width('100%').margin({ top: 10 }) } } ``` -![zh-cn_image_0000001184400598](figures/zh-cn_image_0000001184400598.gif) +![touchtarget.gif](figures/touchtarget.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md index 3a3952194710ccd131beae6c95e6d6aacb5e4000..7d90b701c6991739de6f2c745e356a7f6ca3c516 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md @@ -23,20 +23,21 @@ struct VisibilityExample { build() { Column() { Column() { - Text('Visible').fontSize(9).width('90%').fontColor(0xCCCCCC) - Row().visibility(Visibility.Visible).width('90%').height(80).backgroundColor(0xAFEEEE) - - Text('None').fontSize(9).width('90%').fontColor(0xCCCCCC) // 隐藏不参与占位 + Text('None').fontSize(9).width('90%').fontColor(0xCCCCCC) Row().visibility(Visibility.None).width('90%').height(80).backgroundColor(0xAFEEEE) - Text('Hidden').fontSize(9).width('90%').fontColor(0xCCCCCC) // 隐藏参与占位 + Text('Hidden').fontSize(9).width('90%').fontColor(0xCCCCCC) Row().visibility(Visibility.Hidden).width('90%').height(80).backgroundColor(0xAFEEEE) + + // 正常显示,组件默认的显示模式 + Text('Visible').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row().visibility(Visibility.Visible).width('90%').height(80).backgroundColor(0xAFEEEE) }.width('90%').border({ width: 1 }) }.width('100%').margin({ top: 5 }) } } ``` -![zh-cn_image_0000001174104390](figures/zh-cn_image_0000001174104390.gif) +![visibility.png](figures/visibility.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md index a75a053860bbdbb099c537603fe317a00d5a1d58..60f6b667a8060ce86195496e469633dcf958602d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md @@ -1,6 +1,6 @@ # Z序控制 -组件的Z序,指明了该组件在堆叠组件中的位置。 +组件的Z序,设置组件的堆叠顺序。 > **说明:** > @@ -25,20 +25,25 @@ struct ZIndexExample { build() { Column() { Stack() { - // stack会重叠组件, 默认后定义的在最上面 - Text('first child, zIndex(2)') - .size({width: '40%', height: '30%'}).backgroundColor(0xbbb2cb) + // stack会重叠组件, 默认后定义的在最上面,具有较高zIndex值的元素在zIndex较小的元素前面 + Text('1, zIndex(2)') + .size({ width: '40%', height: '30%' }).backgroundColor(0xbbb2cb) .zIndex(2) - // 默认值0 - Text('second child, default zIndex(0)') - .size({width: '90%', height: '80%'}).backgroundColor(0xd2cab3).align(Alignment.TopStart) - Text('third child, zIndex(1)') - .size({width: '70%', height: '50%'}).backgroundColor(0xc1cbac).align(Alignment.TopStart) + Text('2, default zIndex(1)') + .size({ width: '70%', height: '50%' }).backgroundColor(0xd2cab3).align(Alignment.TopStart) .zIndex(1) + Text('3, zIndex(0)') + .size({ width: '90%', height: '80%' }).backgroundColor(0xc1cbac).align(Alignment.TopStart) }.width('100%').height(200) }.width('100%').height(200) } } ``` +Stack容器内子组件不设置zIndex的效果 + +![nozindex.png](figures/nozindex.png) + +Stack容器子组件设置zIndex后效果 + +![zindex.png](figures/zindex.png) -![zh-cn_image_0000001174582860](figures/zh-cn_image_0000001174582860.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md index fb78261211c4b65798427d16c61372b017f0c043..edee0fabe4bac1731669640c9c57586f93c7a2d3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md @@ -42,4 +42,4 @@ struct AreaExample { } ``` -![zh-cn_image_0000001189634870](figures/zh-cn_image_0000001189634870.gif) +![zh-cn_image_0000001189634870](figures/zh-cn_image_0000001189634870.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index d1442f932d74fb733e403d8b626a7fc1b648e220..33f2d964f4432eecd591abb1d4d0992328f2b0ff 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -39,7 +39,7 @@ @Entry @Component struct ClickExample { - @State text: string = ''; + @State text: string = '' build() { Column() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md index a1f8377688ccbc92894bf6cd20698688a551db1b..2caa55742494f1bcbc26afd7a90ac4b6c98b500e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -57,4 +57,4 @@ struct KeyEventExample { } ``` - ![keyEvent](figures/keyEvent.png) \ No newline at end of file + ![keyEvent](figures/keyEvent.png) diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-Account.md b/zh-cn/application-dev/reference/errorcodes/errcode-Account.md new file mode 100644 index 0000000000000000000000000000000000000000..e176a23a6f7d23a11f5a3afd3990649183c10d98 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errcode-Account.md @@ -0,0 +1,348 @@ +# Account错误码 + +以下错误码包括系统帐号和分布式帐号错误码。 + +## 12300001 系统服务异常 + +**错误信息** + +System service works abnormally. + +**可能原因** + +该错误码表示系统服务异常,可能原因如下: +1. 帐号管理服务无法正常启动。 +2. 帐号管理的IPC对象无法获取。 +3. 帐号管理依赖的其他服务无法正常启动或者IPC对象无法获取。 +4. 服务未初始化。 +5. 磁盘空间不足。 +6. 读写文件异常。 +7. 创建目录异常。 +8. 创建删除文件异常。 +9. 读写数据库异常。 + +**处理步骤** + +请稍后重试,或重启设备。 + +## 12300002 无效参数 + +**错误信息** + +Invalid parameter. + +**可能原因** + +该错误码表示传入无效的参数,可能原因如下: +1. 用户名为空。 +2. 系统帐号用户名长度大于1024。 +3. 分布式帐号用户名长度大于256。 +4. 系统帐号id小于0、小于100或大于1000。 +5. 分布式帐号id长度大于512。 +6. 分布式帐号传入不支持的事件类型。 +7. 域名为空。 +8. 域名长度大于128。 +9. 域帐号为空。 +10. 域帐号长度大于512。 +11. 约束为空。 +12. 约束长度大于128。 +13. 传入无效的认证和查询参数。 +14. 提供的系统帐号头像编码字符串长度超过4KB。 +15. 提供的分布式帐号头像编码字符串长度超过2MB。 +16. 提供非jpg和png的图片。 +17. 应用帐号名长度超过512。 +18. 鉴权类型长度超过1024。 +19. 令牌长度超过1024。 +20. 键名长度超过1024。 +21. 自定义数据值长度超过1024。 + +**处理步骤** + +请传入正确的参数。 + +## 12300003 帐号不存在 + +**错误信息** + +The account does not exist. + +**可能原因** + +该错误码表示操作的帐号不存在,可能原因如下: +1. 查询/激活/删除未创建的帐号。 +2. 查询/激活/删除已删除的帐号。 +3. 为已删除的帐号设置约束/用户名/头像。 +4. 更新未创建的帐号。 +5. 为不存在的帐号设置/取消帐号信息访问授权。 +6. 为不存在的帐号设置/删除/查询密码。 +7. 为不存在的帐号设置/删除令牌。 +8. 为不存在的帐号设置额外信息。 +9. 为不存在的帐号设置/删除凭据。 +10. 为不存在的帐号设置自定义数据。 +11. 为不存在的帐号使能分布式同步功能。 + +**处理步骤** + +请检查帐号是否存在。 + +## 12300004 操作受限帐号 + +**错误信息** + +The specified account is restricted. + +**可能原因** + +该错误码表示操作的是受限帐号,可能原因如下: +1. 删除系统保留用户。 +2. 查询系统保留用户的约束源类型。 +3. 创建id为0-100的帐号。 + +**处理步骤** + +指定id为系统保留用户,无法操作。 + +## 12300005 监听器已注册 + +**错误信息** + +The listener has been registered. + +**可能原因** + +该错误码表示监听器已注册,可能原因如下: +当前应用向系统注册一个已经注册过的监听器,无法重复注册。 + +**处理步骤** + +请取消注册,或使用未注册过的监听器重新注册。 + +## 12300006 监听器未注册 + +**错误信息** + +The Listener is not registered. + +**可能原因** + +该错误码表示监听器未注册,可能原因如下: +解注册一个未注册过的监听器。 + +**处理步骤** + +请使用注册的监听器执行解注册操作 + +## 12300007 PIN码输入器已注册 + +**错误信息** + +The PIN inputer already exists. + +**可能原因** + +该错误码表示PIN码输入器已注册,可能原因如下: +PIN码输入器已注册,解注册之前无法重复注册。 + +**处理步骤** + +PIN码输入器已存在,请勿重复操作。 + +## 12300008 帐号已存在 + +**错误信息** + +The account already exists. + +**可能原因** + +该错误码表示帐号已存在,可能原因如下: +创建已存在的帐号。 + +**处理步骤** + +请取消创建,或使用其他账户号名重试。 + +## 12300009 帐号已激活 + +**错误信息** + +The account has been activated. + +**可能原因** + +该错误码表示帐号已激活,可能原因如下: +激活已激活的帐号。 + +**处理步骤** + +当前帐号已激活,请勿重复操作。 + +## 12300010 帐号服务忙 + +**错误信息** + +The account service is busy. + +**可能原因** + +该错误码表示帐号服务忙,可能原因如下: +1. 短时间提交重复请求,如重复激活、重复设置等。 +2. 应用帐号的认证会话数量超过256,无法处理新的认证请求。 + +**处理步骤** + +请等待一段时间后重试,并降低调用频率。 + +## 12300011 帐号数量已达上限 + +**错误信息** + +The account number has reached the upper limit. + +**可能原因** + +该错误码表示帐号数量已达上限,可能原因如下: +创建系统帐号/应用帐号时,已存在1000个帐号。 + +**处理步骤** + +请删除其他帐号后再创建。 + +## 12300012 不支持多用户 + +**错误信息** + +Multi-user is not supported. + +**可能原因** + +该错误码表示不支持多用户,可能原因如下: +当前设备不支持多用户,无法创建帐号 + +**处理步骤** + +无法创建其他帐号,请取消创建 + +## 12300013 不支持的帐号类型 + +**错误信息** + +The account type is not supported. + +**可能原因** + +该错误码表示提供了不支持的帐号类型,可能原因如下: +当前设备不支持创建管理员帐号 + +**处理步骤** + +请创建非管理员帐号 + +## 12300014 可信等级不支持 + +**错误信息** + +The trust level is not supported. + +**可能原因** + +该错误码表示提供了可信等级不支持,可能原因如下: +传入系统不支持的可信等级。 + +**处理步骤** + +请输入正确的可信等级。 + +## 12300015 认证类型不支持 + +**错误信息** + +The auth type is not supported. + +**可能原因** + +该错误码表示提供了认证类型不支持,可能原因如下: +传入系统不支持的认证类型。 + +**处理步骤** + +请提供系统支持的认证类型。 + +## 12300016 认证超时 + +**错误信息** + +The auth service is timeout. + +**可能原因** + +该错误码表示认证超时,可能原因如下: +1. 认证录入超过三分钟。 +2. 认证服务因网络原因无法及时响应而超时。 + +**处理步骤** + +1. 认证录入超时,请重试。 +2. 请确认网络环境无问题后重试。 + +## 12300017 认证服务忙 + +**错误信息** + +The auth service is busy. + +**可能原因** + +该错误码表示认证服务忙,可能原因如下: +认证总数超过5个。 + +**处理步骤** + +当前认证服务忙,请稍后重试。 + +## 12300018 认证服务锁定 + +**错误信息** + +The auth service is locked. + +**可能原因** + +该错误码表示认证服务锁定,可能原因如下: +认证类型错误次数超过上限。 + +**处理步骤** + +认证错误次数超过上限,请在freezingTime之后重试。 + +## 12300019 凭据不存在 + +**错误信息** + +The credential does not exist. + +**可能原因** + +该错误码表示凭据不存在,可能原因如下: +1. 认证未录入的凭据类型。 +2. 查询未录入的凭据类型。 +3. 删除未录入的凭据类型。 + +**处理步骤** + +请确认凭据类型是否存在。 + +## 12300020 无效的contextId + +**错误信息** + +The contextId is invalid. + +**可能原因** + +该错误码表示contextId无效,可能原因如下: +传入取消的contexId未发起认证录入或已经完成。 + +**处理步骤** + +请输入正确的contextId。 diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md b/zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md new file mode 100644 index 0000000000000000000000000000000000000000..1d048f15414bf7751dc8ff7fe4e4610c1438a9aa --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md @@ -0,0 +1,257 @@ +# DistributedSchedule错误码 + +## 201 权限校验失败 + +### 错误信息 +Permission denied. + +### 可能原因 +该错误码表示权限校验失败,可能原因是未配置对应权限。 + +### 处理步骤 +配置权限ohos.permission.MANAGER_MISSIONS或ohos.permission.DISTRIBUTED_DATASYNC。 + +## 401 参数检查错误 + +### 错误信息 +The parameter check failed. + +### 可能原因 +该错误码表示入参检查错误,可能原因是callback入参检查错误。 + +### 处理步骤 +检查入参callback是否为合法值。 + +## 16600001 系统服务工作异常 + +### 错误信息 +The system ability work abnormally. + +### 可能原因 +该错误码表示系统服务工作异常,可能原因如下。 +1. DMS服务没有正常启动。 +2. DMS的binder对象无法正常获取。 +3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。 + +### 处理步骤 +系统服务内部工作异常,请稍后重试,或者重启设备尝试。 + +## 16600002 指定的token或callback未注册 + +### 错误信息 +The specified token or callback has not registered. + +### 可能原因 +该错误码可能原因是指定的token或callback未注册。 + +### 处理步骤 +请先注册token或callback。 + +## 16600003 应用注册token已达到最大次数限制 + +### 错误信息 +The number of token registration times has reached the upper limit. + +### 可能原因 +该错误码可能原因是应用注册token已达到最大次数限制。 + +### 处理步骤 +请勿频繁注册,请使用已注册的token。 + +## 16600004 指定的callback已注册 + +### 错误信息 +The specified callback has been registered. + +### 可能原因 +该错误码表示指定的callback已注册,可能原因是使用相同的callback重复注册。 + +### 处理步骤 +请勿使用相同的callback重复注册。 + +## 16300501 系统服务工作异常 + +### 错误信息 +The system ability work abnormally. + +### 可能原因 +该错误码表示系统服务工作异常,可能原因如下。 +1. DMS服务没有正常启动。 +2. DMS的binder对象无法正常获取。 +3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。 + +### 处理步骤 +系统服务内部工作异常,请稍后重试,或者重启设备尝试。 + +## 16300502 获取指定的missionId的missionInfo失败 + +### 错误信息 +Failed to get the missionInfo of the specified missionId. + +### 可能原因 +该错误码表示获取指定的missionId的missionInfo失败,可能原因如下。 +1. missionId输入错误。 +2. missionId对应的missionInfo确实不存在。 + +### 处理步骤 +请检查输入的missionId是否正确。 + +## 16300503 远端未安装应用且不支持免安装 + +### 错误信息 +The application is not installed on the remote end and installation-free is not supported. + +### 可能原因 +该错误码可能原因是远端未安装迁移应用并且不支持免安装。 + +### 处理步骤 +1. 请检查远端是否已安装需要迁移的应用。 +2. 请检查远端是否支持免安装。 + +## 16300504 远端未安装应用但支持免安装,需使用免安装标识重试 + +### 错误信息 +The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. + +### 可能原因 +该错误码可能原因是远端未安装应用但支持免安装,使用时未使用免安装的标识。 + +### 处理步骤 +请使用免安装的标识重试。 + +## 16300505 操作设备必须是迁移的应用所在的设备或需迁移到的目标设备 + +### 错误信息 +The operation device must be the device where the application to be continued is located or the target device to be continued. + +### 可能原因 +该错误码可能原因是操作设备不是迁移的应用所在的设备或需迁移到的目标设备。 + +### 处理步骤 +请检查操作设备是否是迁移的应用所在的设备或需迁移到的目标设备。 + +## 16300506 本地迁移任务已在进行中 + +### 错误信息 +The local continuation task is already in progress. + +### 可能原因 +该错误码表示本地迁移任务已在进行中,可能原因是已经发起了迁移任务还未结束。 + +### 处理步骤 +请检查是否已经发起了迁移并未结束。 + +## 3 序列化对象失败 + +### 错误信息 +Failed to flatten the object. + +### 可能原因 +该错误码表示对象序列化过程中出现错误,可能原因是系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败。 + +### 处理步骤 +请检查系统功能是否正常或者重启。 + +## 7 空对象 + +### 错误信息 +The object is null. + +### 可能原因 +该错误码表示接口依赖的服务对象或参数对象为空,可能原因如下。 +1. 入参序列化读失败。 +2. DMS服务没有正常启动或binder对象无法正常获取。 +3. DMS依赖的其他服务没有正常启动或者binder对象无法获取。 + +### 处理步骤 +1. 检查入参是否为有效合法值。 +2. 检查DMS服务是否正常启动,重新启动服务或重启设备。 +3. 检查DMS依赖的其他服务是否正常启动,重新启动服务或重启设备。 + +## 29360207 注册超出最大次数 + +### 错误信息 +The maximum number of registrations exceeded. + +### 可能原因 +该错误码可能原因是设备频繁注册,次数超出最大次数限制。 + +### 处理步骤 +重启服务并且避免频繁注册。 + +## 29360208 token未注册 + +### 错误信息 +The token has not registered. + +### 可能原因 +该错误码可能原因是未注册token。 + +### 处理步骤 +注册token并使用已注册的token。 + +## 29360209 callback已注册 + +### 错误信息 +Callback has been registered. + +### 可能原因 +该错误码能原因是指定的callback已经注册过。 + +### 处理步骤 +请勿使用相同的callback重复注册。 + +## 29360210 callback未注册 + +### 错误信息 +Callback has not been registered. + +### 可能原因 +该错误码可能原因是指定的callback未注册。 + +### 处理步骤 +注册callback并使用已注册的callback。 + +## 29360211 连接ability失败 + +### 错误信息 +Failed to connect ability. + +### 可能原因 +该错误码可能原因是指定token连接ability失败。 + +### 处理步骤 +检查token是否有效以及相应ability是否正常服务,重新启动服务或重启设备。 + +## 29360214 callback类型错误 + +### 错误信息 +The type of callback is not supported. + +### 可能原因 +该错误码表示callback类型错误,可能原因是不支持传入的callback类型。 + +### 处理步骤 +请使用系统支持的callback类型并传入。 + +## 29360215 无效的连接状态 + +### 错误信息 +Invalid continuation mode. + +### 可能原因 +该错误码表示无效的连接状态,可能原因是入参DeviceConnectState为非指定值。 + +### 处理步骤 +设置指定合法的DeviceConnectState值。 + +## 29360216 无效的流转模式 + +### 错误信息 +Invalid continuation mode. + +### 可能原因 +该错误码可能原因是入参ContinuationExtraParams.continuationMode为非指定值。 + +### 处理步骤 +设置指定合法的ContinuationExtraParams.continuationMode值。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-EnterpriseDeviceManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-EnterpriseDeviceManager.md new file mode 100644 index 0000000000000000000000000000000000000000..b1bbc7a87a1651733e3b4331c9401005732b0241 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-EnterpriseDeviceManager.md @@ -0,0 +1,118 @@ +# 企业设备管理错误码 + +## 9200001 应用没有激活成设备管理器 + +### 错误信息 +The application is not a administrator of the device. + +### 错误描述 +当应用没有激活成设备管理器时,则会产生此错误码。 + +### 可能原因 +应用没有激活设备管理器。 + +### 处理步骤 +请检查调用者是否成功激活过设备管理器,没有激活过的设备管理器的应用无法调用设备管理接口。 + +## 9200002 设备管理器权限不够 + +### 错误信息 +The administrator application does not have permission to manage the device. + +### 错误描述 +当设备管理器调用高权限接口时,则会产生此错误码。 + +### 可能原因 +激活成了DA管理器,调用了SDA管理器接口。 + +### 处理步骤 +请检查调用者是否存在越权调用,即激活的设备管理器类型和调用的API要求的管理器类型是否一致。 + +## 9200003 指定的设备管理器元能力组件无效 + +### 错误信息 +The administrator ability component is invalid. + +### 错误描述 +当应用传入参数中指定的设备管理器元能力组件无效,则会产生此错误码。 + +### 可能原因 +该错误码表示指定的设备管理器元能力组件无效,可能原因如下。 +1. 应用激活设备管理器时指定的设备管理器元能力组件不存在。 +2. 设备管理器元能力组件不是合法的企业设备管理元能力组件。 + +### 处理步骤 +1. 请检查激活时输入的设备管理器元能力组件name是否存在应用包中。 +2. 请检查企业设备管理组件是否继承企业设备管理框架定义的EnterpriseAdminExtensionAbility组件。 + +## 9200004 激活设备管理器失败 + +### 错误信息 +Failed to activate the administrator application of the device. + +### 错误描述 +当应用重复激活不同类型的设备管理器或激活多个管理器时,则会产生此错误码。 + +### 可能原因 +该错误码表示激活设备管理器失败,可能原因如下。 +1. 同时激活多个SDA设备管理器。 +2. 重复激活设备管理器,且管理器类型发生变化。 +3. 同一个应用多个设备管理器元能力组件激活。 + +### 处理步骤 +1. 检查是否激活多个SDA设备管理器,SDA设备管理器只允许激活一个。 +2. 检查指定的设备管理器是否已激活了,且重复激活时管理器类型发生变化,此时需要先去激活,再重新激活。 +3. 检查待激活的设备管理器应用中是否已有设备管理元能力组件激活过,同一个应用只允许激活一个设备管理器元能力组件 + +## 9200005 去激活设备管理器失败 + +### 错误信息 +Failed to deactivate the administrator application of the device. + +### 错误描述 +当应用没有激活过或者去激活其他设备管理器时,则会产生此错误码。 + +### 可能原因 +该错误码表示去激活设备管理器失败,可能原因如下。 +1. 去激活的设备管理器应用没有激活过。 +2. 不能去激活其他设备管理器。 + +### 处理步骤 +1. 检查去激活时设备管理应用是否激活过。 +2. 检查去激活时设备管理应用中指定设备管理元能力组件是否激活过。 +3. 检查调用者是否去激活自身,设备管理器应用不能去激活其他设备管理器应用。 + +## 9200006 指定的用户ID非法 + +### 错误信息 +The specified user ID is invalid. + +### 错误描述 +当应用调用接口设置用户策略,指定的user id不存在、或者DA,SDA管理器跨用户设置时,则会产生此错误码。 + +### 可能原因 +该错误码表示指定的用户ID非法,可能原因如下。 +1. 调用接口设置用户策略时候,指定的user id不存在。 +2. 指定的user id和调用者user id不同。DA,SDA管理器不允许跨用户设置。 + +### 处理步骤 +1. 检查去调用接口中指定的user id是否是有效的user id。 +2. 检查调用者user id和指定设置的user id是否是同一user id,非SDA模式下不允许跨用户设置策略。 + +## 9200007 系统服务工作异常 + +### 错误信息 +The system ability work abnormally. + +### 错误描述 +当企业设备管理服务异常时,则会产生此错误码。 + +### 可能原因 +该错误码表示系统服务工作异常,可能原因如下。 +1. 企业设备管理服务没有正常启动。 +2. 企业设备管理的RPC对象无法获取。 +3. 企业设备管理依赖的其他服务没有正常启动或者RPC对象无法获取。 +4. 企业设备管理运行过程中系统异常。 + +### 处理步骤 +系统服务内部工作异常,请稍后重试,或者重启设备尝试。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md new file mode 100644 index 0000000000000000000000000000000000000000..16a8cf53764e369e6b3f916063da3c10c5bb4b9c --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md @@ -0,0 +1,134 @@ +# 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 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-animator.md b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md new file mode 100644 index 0000000000000000000000000000000000000000..72848e1acab47797cb406ccda9ad01bc65b75099 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-animator.md @@ -0,0 +1,19 @@ +# 动画错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,会报此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA \ No newline at end of file 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-i18n.md b/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md new file mode 100644 index 0000000000000000000000000000000000000000..90b123f4797d90c8abdaac1b03a8a4ca23a8785d --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @@ -0,0 +1,29 @@ +# I18n错误码 + +## 890001 参数类型错误 + +### 错误信息 +Unspported para value. + +### 错误描述 +当接口传入错误的参数类型时,系统会产生此错误码。 + +### 可能原因 +该错误码表示参数错误,可能原因是传入参数的类型错误。 + +### 处理步骤 +检查参数的类型是否正确。 + +## 890002 配置项参数错误 + +### 错误信息 +Unspported option value. + +### 错误描述 +当接口的option配置参数中包含不合法的配置项时,系统会产生此错误码。 + +### 可能原因 +该错误码表示配置项参数错误,可能原因是option参数中使用了不支持的配置项。 + +### 处理步骤 +检查option参数中是否使用了不合法的配置项。 \ No newline at end of file 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-promptAction.md b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md new file mode 100644 index 0000000000000000000000000000000000000000..0bf40f83975af5027b176ab4df75b9739b33a8d7 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @@ -0,0 +1,19 @@ +# 弹窗错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,会报此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA \ 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-router.md b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md new file mode 100644 index 0000000000000000000000000000000000000000..5b459aa69f62fb17f951eba7d8b747f340130057 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-router.md @@ -0,0 +1,73 @@ +# 页面路由错误码 + +## 100001 内部错误 + +### 错误信息 + +Internal error. + +### 错误描述 + +当出现了开发者解决不了的内部异常错误,系统会产生此错误码,并描述具体是哪种内部错误。 + +### 可能原因 + +未成功获取渲染引擎,解析参数失败等。 + +### 处理步骤 + +NA + +## 100002 路由输入的uri错误 + +### 错误信息 + +Uri error. The uri of router is not exist. + +### 错误描述 + +当跳转页面输入的uri错误或者不存在,系统会产生此错误码。 + +### 可能原因 + +输入的路由uri错误或者不存在。 + +### 处理步骤 + +请检查输入的路由uri是否正确。 + +## 100003 路由压入的page过多 + +### 错误信息 + +Page stack error. The pages are pushed too much. + +### 错误描述 + +当跳转页面压入页面数超过32,系统会产生此错误码。 + +### 可能原因 + +压入pages过多。 + +### 处理步骤 + +请清除多余或无效的页面。 + +## 200002 路由输入的uri错误 + +### 错误信息 + +Uri error. The uri of router is not exist. + +### 错误描述 + +当替换页面输入的uri错误或不存在,系统会产生此错误码。 + +### 可能原因 + +输入的路由uri错误或不存在。 + +### 处理步骤 + +请检查输入的路由uri是否正确。 \ 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-sensor.md b/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md new file mode 100755 index 0000000000000000000000000000000000000000..9aa5828ffb994d2615485fb9f4de984a629a2e4f --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md @@ -0,0 +1,20 @@ +# 传感器错误码 + +## 14500101 传感器服务异常 + +### 错误信息 + +Service exception. + +### 错误描述 + +当调用sensor模块on、once、off接口时,若hdi服务异常,会报此错误码。 + +### 可能原因 + +访问hdi服务状态异常。 + +### 处理步骤 + +1. 定时重试操作,如间隔1s或者按照指数增长间隔重试。 +2. 连续重试3次不可用则停止尝试,期间可优先尝试获取器件列表方式进一步获取设备可用性。 \ 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-vibrator.md b/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md new file mode 100755 index 0000000000000000000000000000000000000000..edab04eca48ff0819392fd7563fb22e7694fbfe4 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md @@ -0,0 +1,21 @@ +# 振动错误码 + +## 14600101 操作设备失败 + +### 错误信息 + +Device operation failed. + +### 错误描述 + +当调用vibrator模块startVibration接口时,若hdi服务异常或者设备被占用,会报此错误码。 + +### 可能原因 + +1. 访问hdi服务状态异常。 +2. 当前设备被占用。 + +### 处理步骤 + +1. 间隔一段时间重试操作,或按指数增长间隔重试;连续重试3次不可用则停止尝试,期间可优先尝试获取器件列表方式进一步获取设备可用性。 +2. 设置振动优先级较低,尝试设置更高优先级。 \ No newline at end of file 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-multimodalinput.md b/zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md new file mode 100644 index 0000000000000000000000000000000000000000..124b8838ae20cea266b8e9f3bf0c20fc8c2b96ea --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md @@ -0,0 +1,82 @@ +# 多模输入子系统错误码 + +## 201 权限校验失败 + +### 错误信息 + +Permission denied. + +### 错误描述 + +当调用监听模块on和off接口时,若没有申请权限,会报此错误码。 + +### 可能原因 + + 监听、去监听鼠标和触屏事件时未配置相应的权限。 + + +### 处理步骤 + +查看权限是否已适配,具体配置方式请参考[权限申请声明](../../security/accesstoken-guidelines.md)。 + +## 401 参数检查错误 + +### 错误信息 + +The parameter invalid. + +### 错误描述 + +当调用监听模块或者键鼠穿越等其他模块接口时,若传入参数的类型或者范围不匹配,会报此错误码。 + +### 可能原因 + +1. 入参类型错误不匹配,如监听接口传入type为非string类型等。 +2. 入参范围不匹配,如插上设备信息时传入非法的deviceId。 + +### 处理步骤 + +检查入参类型和范围是否匹配。 + +## 4400001 目标设备描述符错误 + +### 错误信息 + +Incorrect descriptor for the target device. + +### 错误描述 + +当调用键鼠穿越start接口时,若设备无效,会报此错误码。 + +### 可能原因 + +1.穿越目标设备不存在(设备未组网)。 + +2.目标设备描述符为空。 + +### 处理步骤 + +1. 确认键鼠穿越目标设备是否已正确与本地设备完整组网。 +2. 正确使用穿越目标设备的设备描述符。 + +## 4400002 操作输入设备失败 + +### 错误信息 + +Failed to operate the input device. + +### 错误描述 + +当调用键鼠穿越start接口时,若穿越状态异常,会报此错误码。 + +### 可能原因 + +1. 发起键鼠穿越时,本机键鼠穿越为穿出状态。 +2. 关闭键鼠穿越时,本机键鼠穿越为自由态。 +3. 发起关闭键鼠穿越时,本机键鼠穿越状态正在切换中。 + +### 处理步骤 + +1. 发起键鼠穿越时,本机键鼠穿越状态需要为非穿出状态。 +2. 关闭键鼠穿越时,本机键鼠穿越状态需要为非自由态。 +3. 发起关闭键鼠穿越时,本机键鼠穿越状态不能处于切换中。 \ No newline at end of file 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/reference/syscap-list.md b/zh-cn/application-dev/reference/syscap-list.md index cb708020cf43693dc23122f3399c2ffe3f808a63..02d5b8465d2ef678cd2cdbecb7d85287d988cb73 100644 --- a/zh-cn/application-dev/reference/syscap-list.md +++ b/zh-cn/application-dev/reference/syscap-list.md @@ -1,180 +1,1396 @@ # SysCap列表 -SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性。开发者使用某个接口进行开发前,建议先阅读[SysCap使用指南](../quick-start/syscap.md),了解Syscap的定义和使用指导。再结合下表判断具体能力集是否支持某个设备,提高开发效率。 - -| SysCap名称 | SysCap描述 | Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| SystemCapability.ArkUI.ArkUI.Full | ArKUI标准系统 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ArkUI.ArkUI.Lite | ArkUI小型系统 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | -| SystemCapability.ArkUI.ArkUI.Napi | napi功能 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ArkUI.ArkUI.Libuv | libuv功能 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ArkUI.UiAppearance | 外观配置功能 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BundleManager.BundleFramework | 包管理服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BundleManager.DistributedBundleFramework | 分布式包管理服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BundleManager.BundleTool | 包管理命令行工具 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BundleManager.Zlib | Zlib压缩、解压缩工具 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BundleManager.PackingTool | 包管理打包、拆包工具 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | -| SystemCapability.Graphic.Graphic2D.WebGL | WebGL1.0 标准api | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Graphic.Graphic2D.WebGL2 | WebGL2.0 标准api | 是 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | -| SystemCapability.WindowManager.WindowManager.Core | 窗口管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.WindowManager.WindowManager.MutiScreen | 多屏能力 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Notification.CommonEvent | 公共事件 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Notification.Notification | 通知 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Notification.ReminderAgent | 后台代理提醒 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Notification.Emitter | 事件处理服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.IPC.Core | 进程间通信 | 是 | 否 | 是 | 是 | 是 | 是 | 是 | 否 | -| SystemCapability.Communication.SoftBus.Core | 软总线 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.Communication.NetManager.Core | 网络管理基础服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.NetManager.Extension | 网络管理扩展服务 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.NetStack | 基础网络协议栈能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.WiFi.Core | WIFI基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.WiFi.STA | WIFI STA能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.WiFi.AP.Core | WIFI AP能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.WiFi.AP.Extension | WIFI AP扩展能力 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | 是 | -| SystemCapability.Communication.WiFi.P2P | WIFI P2P能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.Bluetooth.Core | 蓝牙服务以及协议栈 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.Bluetooth.Lite | 蓝牙轻量级服务 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Communication.NFC.Core | NFC服务 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | -| SystemCapability.Communication.ConnectedTag | 有源NFC标签服务 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | -| SystemCapability.Location.Location.Core | 位置服务基础能力 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Location.Location.Geocoder | 地理编码能力 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Location.Location.Geofence | 地理围栏能力 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Location.Location.Gnss | GNSS硬件相关能力 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Location.Location.Lite | 位置服务轻设备能力 | 是 | 是 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.Core | 基本输入能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.InputDevice | 输入设备管理 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.RemoteInputDevice | 分布式输入设备管理 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.InputMonitor | 输入事件监听者 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.InputConsumer | 输入事件消费者 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.InputSimulator | 输入事件模拟者 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.MultimodalInput.Input.InputFilter | 输入事件过滤器 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.PowerManager.BatteryManager.Extension | 电池服务扩展能力 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.PowerManager.BatteryStatistics | 耗电统计 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.PowerManager.DisplayPowerManager | 显示能效管理 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.PowerManager.ThermalManager | 温控服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.PowerManager.PowerManager.Core | 系统电源管理服务核心能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.PowerManager.PowerManager.Lite | 轻设备系统电源管理服务能力 | 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | -| SystemCapability.PowerManager.BatteryManager.Core | 电池服务核心能力 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.PowerManager.BatteryManager.Lite | 轻设备电池服务能力 | 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | -| SystemCapability.PowerManager.PowerManager.Extension | 系统电源管理服务扩展能力 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.Core | 媒体基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.AudioPlayer | 媒体音频播放引擎能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.AudioRecorder | 媒体音频播录制引擎能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.VideoPlayer | 媒体视频播放引擎能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.VideoRecorder | 媒体视频录制引擎能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.CodecBase | 媒体编解码基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.AudioDecoder | 媒体音频解码能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.AudioEncoder | 媒体音频编码能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.VideoDecoder | 媒体视频解码能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.VideoEncoder | 媒体视频编码能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.Spliter | 媒体解封装能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Media.Muxer | 媒体封装能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.AVSession.Core | 媒体会话基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.AVSession.Manager | 媒体会话管理能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Core | 音频基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Renderer | 音频输出能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Capturer | 音频输入能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Device | 音频设备管理能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Volume | 音频音量管理能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Audio.Communication | 音频通信能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Camera.Core | 相机基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Camera.DistributedCore | 相机分布式能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Image.Core | 图片基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Image.ImageSource | 图片源解码解析能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Image.ImagePacker | 图片打包能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.Image.ImageReceiver | 图片接收能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.MediaLibrary.Core | 媒体库基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.MediaLibrary.SmartAlbum | 媒体库智慧相册能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Multimedia.MediaLibrary.DistributedCore | 媒体库分布式能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Telephony.CoreService | 蜂窝核心服务 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Telephony.CallManager | 通话管理服务 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Telephony.CellularCall | 蜂窝通话服务 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Telephony.CellularData | 蜂窝数据服务 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Telephony.SmsMms | 短彩信服务 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Telephony.StateRegistry | 蜂窝网络状态注册服务 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Global.I18n | 国际化 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Global.ResourceManager | 资源管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Customization.ConfigPolicy | 定制框架 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.Customization.EnterpriseDeviceManager | 企业设备管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BarrierFree.Accessibility.Core | 提供开发辅助应用的能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BarrierFree.Accessibility.Vision | 无障碍视觉辅助能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BarrierFree.Accessibility.Hearing | 无障碍听觉辅助能力 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.BarrierFree.Accessibility.Interaction | 无障碍行为辅助能力 | 是 | 否 | 否 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.ResourceSchedule.WorkScheduler | 延迟任务调度 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | 长时任务管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask | 短时任务管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ResourceSchedule.UsageStatistics.App | 应用使用信息统计 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | 应用使用活跃分组 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Utils.Lang | TS/JS语言基础库 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiLog | 流水日志 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiLogLite | 轻量级流水日志 | 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | -| SystemCapability.HiviewDFX.HiTrace | 分布式追踪 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.Hiview.FaultLogger | 事件打点 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiviewLite | 轻量级hiview服务 | 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | -| SystemCapability.HiviewDFX.HiChecker | 检测模式 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiCollie | 卡死检测 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiDumper | 系统信息导出 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiAppEvent | 应用事件打点 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiSysEvent | 系统事件打点 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.HiviewDFX.HiEventLite | 轻量级事件打点 | 否 | 是 | 否 | 否 | 否 | 否 | 否 | 是 | -| SystemCapability.HiviewDFX.HiProfiler.HiDebug | 调试调优 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Update.UpdateService | 升级服务 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.DistributedHardware.DeviceManager | 分布式设备管理 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Security.DeviceAuth | 设备互信认证 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Security.DataTransitManager | 数据传输管控策略库 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Security.DeviceSecurityLevel | 设备安全等级管理 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Security.Huks | 设备密钥管理 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.Security.AccessToken | 访问控制 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Security.Cipher | 加解密 | 否 | 否 | 否 | 否 | 否 | 否 | 是 | 否 | -| SystemCapability.Account.OsAccount | 帐号 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Account.AppAccount | 应用账号 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.UserIAM.UserAuth.Core | 统一用户认证 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.UserIAM.UserAuth.PinAuth | 口令认证 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.UserIAM.UserAuth.FaceAuth | 人脸认证 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.MiscServices.InputMethodFramework | 输入法框架 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.MiscServices.Pasteboard | 剪贴板服务 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.MiscServices.Time | 时间时区定时 | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | -| SystemCapability.MiscServices.Wallpaper | 壁纸框架 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.MiscServices.ScreenLock | 锁屏服务 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.MiscServices.Upload | 上传服务 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.MiscServices.Download | 下载服务 | 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.FileManagement.StorageService.Backup | 备份恢复 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.StorageService.SpatialStatistics | 空间统计 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.StorageService.Volume | 卷管理 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.StorageService.Encryption | 文件加密能力 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.File.FileIO | 基础文件IO接口 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.FileManagement.File.Environment | 环境相关接口 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.FileManagement.File.DistributedFile | 分布式文件扩展接口 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.AppFileService | 应用文件分享 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.FileManagement.UserFileService | 用户文件访问服务 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.USB.USBManager | usb服务 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Sensors.Sensor | 传感器服务订阅 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Sensors.MiscDevice | 小器件-振感 | 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | -| SystemCapability.Startup.SystemInfo | 系统基本信息 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.DistributedDataManager.RelationalStore.Core | 关系型数据库核心能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.RelationalStore.Synchronize | 关系型数据库分布式能力 | 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.RelationalStore.Lite | 轻量级关系型数据库 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | -| SystemCapability.DistributedDataManager.KVStore.Core | Key-Value型数据库核心能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.KVStore.Lite | 轻量级Key-Value型数据库核心能力 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | -| SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | 分布式Key-Value型数据库 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.DataObject.DistributedObject | 分布式对象 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.Preferences.Core | 偏好型数据存储核心能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.DataShare.Core | 跨进程数据共享,基础能力 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.DataShare.Consumer | 跨进程数据共享,数据消费者 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.DistributedDataManager.DataShare.Provider | 跨进程数据共享,数据生产者 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityBase | 组件运行基础数据定义,主要包括组件通信数据的载体want、系统配置定义等 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityRuntime.Core | 组件运行核心基础功能模块,包括应用初始化、无界面组件运行等; | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityRuntime.FAModel | FA模型 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityRuntime.AbilityCore | 通用组件(有界面) | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityRuntime.Mission | 任务管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.AbilityTools.AbilityAssistant | 命令行工具 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.Form | 卡片管理 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Ability.DistributedAbilityManager | 分布式流转管理(continuationManager)接口定义,支持打开互联面板、更新流转状态 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Applications.ContactsData | 联系人数据库 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Applications.Contacts | 联系人 | 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Applictaions.settings.Core | 设置API | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Test.UiTest | UI测试框架能力支持 | 是 | 否 | 否 | 是 | 是 | 否 | 否 | 否 | -| SystemCapability.Web.Webview.Core | webview组件 | 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | -| SystemCapability.Cloud.AAID | AAID管理服务 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.Cloud.OAID | OAID管理服务 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | -| SystemCapability.Cloud.VAID | VAID管理服务 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | \ No newline at end of file +SysCap,全称SystemCapability,即系统能力,指操作系统中每一个相对独立的特性。 + +开发者使用某个接口进行开发前,建议先阅读[SysCap使用指南](../quick-start/syscap.md),了解Syscap的定义和使用指导。再结合下文中的表格判断具体能力集是否支持某个设备,提高开发效率。 + +## SystemCapability.ArkUI.ArkUI.Full + +ArKUI标准系统 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ArkUI.ArkUI.Lite + +ArkUI小型系统 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | + +## SystemCapability.ArkUI.ArkUI.Napi + +napi功能 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ArkUI.ArkUI.Libuv + +libuv功能 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ArkUI.UiAppearance + +外观配置功能 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleFramework + +包管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.DistributedBundleFramework + +分布式包管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.BundleTool + +包管理命令行工具 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.Zlib + +Zlib压缩、解压缩工具 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BundleManager.PackingTool + +包管理打包、拆包工具 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 否 | + +## SystemCapability.Graphic.Graphic2D.WebGL + +WebGL1.0 标准api + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Graphic.Graphic2D.WebGL2 + +WebGL2.0 标准api + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.WindowManager.WindowManager.Core + +窗口管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.WindowManager.WindowManager.MutiScreen + +多屏能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Notification.CommonEvent + +公共事件 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Notification.Notification + +通知 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Notification.ReminderAgent + +后台代理提醒 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Notification.Emitter + +事件处理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.IPC.Core + +进程间通信 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 是 | 否 | + +## SystemCapability.Communication.SoftBus.Core + +软总线 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.Communication.NetManager.Core + +网络管理基础服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.NetManager.Extension + +网络管理扩展服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.NetStack + +基础网络协议栈能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.WiFi.Core + +WIFI基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.WiFi.STA + +WIFI STA能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.WiFi.AP.Core + +WIFI AP能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.WiFi.AP.Extension + +WIFI AP扩展能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 是 | + +## SystemCapability.Communication.WiFi.P2P + +WIFI P2P能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.Bluetooth.Core + +蓝牙服务以及协议栈 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.Bluetooth.Lite + +蓝牙轻量级服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Communication.NFC.Core + +NFC服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.Communication.ConnectedTag + +有源NFC标签服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.Location.Location.Core + +位置服务基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Location.Location.Geocoder + +地理编码能力 +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Location.Location.Geofence + +地理围栏能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Location.Location.Gnss + +GNSS硬件相关能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Location.Location.Lite + +位置服务轻设备能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.Core + +基本输入能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.InputDevice + +输入设备管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.RemoteInputDevice + +分布式输入设备管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.InputMonitor + +输入事件监听者 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.InputConsumer + +输入事件消费者 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.InputSimulator + +输入事件模拟者 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.MultimodalInput.Input.InputFilter + +输入事件过滤器 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.PowerManager.BatteryManager.Extension + +电池服务扩展能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.PowerManager.BatteryStatistics + +耗电统计 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.PowerManager.DisplayPowerManager + +显示能效管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.PowerManager.ThermalManager + +温控服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.PowerManager.PowerManager.Core + +系统电源管理服务核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.PowerManager.PowerManager.Lite + +轻设备系统电源管理服务能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | + +## SystemCapability.PowerManager.BatteryManager.Core + +电池服务核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.PowerManager.BatteryManager.Lite + +轻设备电池服务能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | + +## SystemCapability.PowerManager.PowerManager.Extension + +系统电源管理服务扩展能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.Core + +媒体基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AudioPlayer + +媒体音频播放引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AudioRecorder + +媒体音频播录制引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.VideoPlayer + +媒体视频播放引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.VideoRecorder + +媒体视频录制引擎能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.CodecBase + +媒体编解码基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AudioDecoder + +媒体音频解码能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.AudioEncoder + +媒体音频编码能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.VideoDecoder + +媒体视频解码能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.VideoEncoder + +媒体视频编码能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.Spliter + +媒体解封装能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Media.Muxer + +媒体封装能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.AVSession.Core + +媒体会话基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.AVSession.Manager + +媒体会话管理能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Core + +音频基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Renderer + +音频输出能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Capturer + +音频输入能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Device + +音频设备管理能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Volume + +音频音量管理能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Audio.Communication + +音频通信能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Camera.Core + +相机基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Camera.DistributedCore + +相机分布式能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Image.Core + +图片基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Image.ImageSource + +图片源解码解析能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Image.ImagePacker + +图片打包能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.Image.ImageReceiver + +图片接收能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.MediaLibrary.Core + +媒体库基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.MediaLibrary.SmartAlbum + +媒体库智慧相册能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Multimedia.MediaLibrary.DistributedCore + +媒体库分布式能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Telephony.CoreService + +蜂窝核心服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Telephony.CallManager + +通话管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Telephony.CellularCall + +蜂窝通话服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Telephony.CellularData + +蜂窝数据服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Telephony.SmsMms + +短彩信服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Telephony.StateRegistry + +蜂窝网络状态注册服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Global.I18n + +国际化 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Global.ResourceManager + +资源管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Customization.ConfigPolicy + +定制框架 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.Customization.EnterpriseDeviceManager + +企业设备管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BarrierFree.Accessibility.Core + +提供开发辅助应用的能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BarrierFree.Accessibility.Vision + +无障碍视觉辅助能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BarrierFree.Accessibility.Hearing + +无障碍听觉辅助能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.BarrierFree.Accessibility.Interaction + +无障碍行为辅助能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.WorkScheduler + +延迟任务调度 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + +长时任务管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + +短时任务管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.UsageStatistics.App + +应用使用信息统计 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + +应用使用活跃分组 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Utils.Lang + +TS/JS语言基础库 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiLog + +流水日志 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiLogLite + +轻量级流水日志 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | + +## SystemCapability.HiviewDFX.HiTrace + +分布式追踪 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.Hiview.FaultLogger + +事件打点 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiviewLite + +轻量级hiview服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 是 | 是 | + +## SystemCapability.HiviewDFX.HiChecker + +检测模式 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiCollie + +卡死检测 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiDumper + +系统信息导出 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiAppEvent + +应用事件打点 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiSysEvent + +系统事件打点 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.HiviewDFX.HiEventLite + +轻量级事件打点 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 是 | 否 | 否 | 否 | 否 | 否 | 是 | + +## SystemCapability.HiviewDFX.HiProfiler.HiDebug + +调试调优 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Update.UpdateService + +升级服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.DistributedHardware.DeviceManager + +分布式设备管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Security.DeviceAuth + +设备互信认证 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Security.DataTransitManager + +数据传输管控策略库 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Security.DeviceSecurityLevel + +设备安全等级管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Security.Huks + +设备密钥管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.Security.AccessToken + +访问控制 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Security.Cipher + +加解密 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 是 | 否 | + +## SystemCapability.Account.OsAccount + +帐号 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Account.AppAccount + +应用账号 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.UserIAM.UserAuth.Core + +统一用户认证 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.UserIAM.UserAuth.PinAuth + +口令认证 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.UserIAM.UserAuth.FaceAuth + +人脸认证 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.MiscServices.InputMethodFramework + +输入法框架 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.MiscServices.Pasteboard + +剪贴板服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.MiscServices.Time + +时间时区定时 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | + +## SystemCapability.MiscServices.Wallpaper + +壁纸框架 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.MiscServices.ScreenLock + +锁屏服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.MiscServices.Upload + +上传服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.MiscServices.Download + +下载服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.FileManagement.StorageService.Backup + +备份恢复 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.StorageService.SpatialStatistics + +空间统计 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.StorageService.Volume + +卷管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.StorageService.Encryption + +文件加密能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.File.FileIO + +基础文件IO接口 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.FileManagement.File.Environment + +环境相关接口 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.FileManagement.File.DistributedFile + +分布式文件扩展接口 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.AppFileService + +应用文件分享 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.FileManagement.UserFileService + +用户文件访问服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.USB.USBManager + +usb服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Sensors.Sensor + +传感器服务订阅 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Sensors.MiscDevice + +小器件-振感 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 否 | 否 | 否 | 否 | + +## SystemCapability.Startup.SystemInfo + +系统基本信息 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.DistributedDataManager.RelationalStore.Core + +关系型数据库核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.RelationalStore.Synchronize + +关系型数据库分布式能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.RelationalStore.Lite + +轻量级关系型数据库 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.DistributedDataManager.KVStore.Core + +Key-Value型数据库核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.KVStore.Lite + +轻量级Key-Value型数据库核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 否 | 否 | 否 | 否 | 否 | 否 | 否 | 否 | + +## SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +分布式Key-Value型数据库 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.DataObject.DistributedObject + +分布式对象 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.Preferences.Core + +偏好型数据存储核心能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.DataShare.Core + +跨进程数据共享,基础能力 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.DataShare.Consumer + +跨进程数据共享,数据消费者 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.DistributedDataManager.DataShare.Provider + +跨进程数据共享,数据生产者 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityBase + +组件运行基础数据定义,主要包括组件通信数据的载体want、系统配置定义等 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityRuntime.Core + +组件运行核心基础功能模块,包括应用初始化、无界面组件运行等 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityRuntime.FAModel + +FA模型 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityRuntime.AbilityCore + +通用组件(有界面) + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityRuntime.Mission + +任务管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.AbilityTools.AbilityAssistant + +命令行工具 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.Form + +卡片管理 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Ability.DistributedAbilityManager + +分布式流转管理(continuationManager)接口定义,支持打开互联面板、更新流转状态 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Applications.ContactsData + +联系人数据库 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Applications.Contacts + +联系人 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Applictaions.settings.Core + +设置API + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Test.UiTest + +UI测试框架能力支持 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 否 | 是 | 是 | 否 | 否 | 否 | + +## SystemCapability.Web.Webview.Core + +webview组件 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 否 | 是 | 是 | 是 | 是 | 否 | 否 | + +## SystemCapability.Cloud.AAID + +AAID管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.Cloud.OAID + +OAID管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | + +## SystemCapability.Cloud.VAID + +VAID管理服务 + +| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| 是 | 是 | 是 | 是 | 是 | 是 | 是 | 是 | 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/security/huks-overview.md b/zh-cn/application-dev/security/huks-overview.md index b92d9dd6e1ce19d6534b9052bbbaf1a4640198f6..0dbdb097edb71bf32738f6f26ad3b002b740e704 100755 --- a/zh-cn/application-dev/security/huks-overview.md +++ b/zh-cn/application-dev/security/huks-overview.md @@ -12,16 +12,16 @@ HUKS(OpenHarmony Universal KeyStore)向应用提供密钥库能力,包括 ## 运作机制 -HUKS对密钥的使用主要通过Init、Update、Finish操作来实现。 +HUKS对密钥的使用主要通过InitSession、UpdateSession、FinishSession操作来实现。 -- **Init操作**:读取密钥,并为其创建Session Id返回给调用者。 +- **InitSession操作**:读取密钥,并为其创建Session Id返回给调用者。 -- **Update操作**:根据Init操作获取的Session Id对数据进行分段update处理。 +- **UpdateSession操作**:根据InitSession操作获取的Session Id对数据进行分段updateSession处理。 -- **Finish操作**:当所有待处理的数据均传入HUKS后,调用Finish操作完成最终数据处理,释放资源。 +- **FinishSession操作**:当所有待处理的数据均传入HUKS后,调用FinishSession操作完成最终数据处理,释放资源。 > **须知:**
    -> 当Init、Update、Finish操作中的任一阶段发生错误时,都需要调用Abort操作来终止密钥的使用。 +> 当InitSession、UpdateSession、FinishSession操作中的任一阶段发生错误时,都需要调用AbortSession操作来终止密钥的使用。 ## 约束与限制 diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index 37e5fa2c5a0b6d8d42080d13a57abda549e98811..93151a0c682a67f4d0f661cc0f4c0ac51d3fae34 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -143,5 +143,9 @@ | ohos.permission.securityguard.REPORT_SECURITY_INFO | system_basic | system_grant | FALSE | 允许应用上报风险数据至设备风险管理平台。 | | ohos.permission.securityguard.REQUEST_SECURITY_MODEL_RESULT | system_basic | system_grant | TRUE | 允许应用获取设备风险状态。 | | ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO | system_core | system_grant | FALSE | 允许应用获取风险详细数据。 | +| ohos.permission.READ_ACCESSIBILITY_CONFIG | system_basic | system_grant | FALSE | 允许应用读取无障碍配置信息。 | +| ohos.permission.WRITE_ACCESSIBILITY_CONFIG | system_basic | system_grant | FALSE | 允许应用设置无障碍配置信息。 | | ohos.permission.ACCESS_CERT_MANAGER_INTERNAL | system_basic | system_grant | FALSE | 允许应用进行证书及凭据的安装、卸载、启用、禁用等操作。 | | ohos.permission.ACCESS_CERT_MANAGER | normal | system_grant | FALSE | 允许应用进行私有凭据的相关操作、查询证书状态等操作。 | +| ohos.permission.ACCESS_PUSH_SERVICE | system_basic | system_grant | TRUE | 允许应用访问推送服务的Ability。 | +| ohos.permission.RECEIVER_STARTUP_COMPLETED | system_basic | system_grant | FALSE | 允许应用订阅开机广播。 | \ No newline at end of file diff --git a/zh-cn/application-dev/task-management/Readme-CN.md b/zh-cn/application-dev/task-management/Readme-CN.md index 216d2ed2bdf4c7188a26b1449cc0d209861ec8db..994e21697c55f18fd58df906939975cca4f694d8 100644 --- a/zh-cn/application-dev/task-management/Readme-CN.md +++ b/zh-cn/application-dev/task-management/Readme-CN.md @@ -6,4 +6,8 @@ - 延迟任务调度 - [延迟任务调度概述](work-scheduler-overview.md) - - [延迟任务调度开发指导](work-scheduler-dev-guide.md) \ No newline at end of file + - [延迟任务调度开发指导](work-scheduler-dev-guide.md) + +- 后台代理提醒 + - [后台代理提醒开发概述](background-agent-scheduled-reminder-overview.md) + - [后台代理提醒开发指导](background-agent-scheduled-reminder-guide.md) \ No newline at end of file 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 96% 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 index f03d8f1b3ac8b36213882bcebd8a24f773022489..ca596efaaa2537e895135f474c1ab6bc2bc71619 100644 --- 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 @@ -37,9 +37,7 @@ reminderAgent:封装了发布、取消提醒类通知的方法。 import reminderAgent from '@ohos.reminderAgent'; import notification from '@ohos.notification'; export default { - // JS工程写法: - // timer: { - // eTS工程写法: + // eTS工程: let timer : reminderAgent.ReminderRequestTimer = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 10, @@ -69,9 +67,7 @@ reminderAgent:封装了发布、取消提醒类通知的方法。 日历实例定义: ```js - // JS工程写法: - // calendar: { - // eTS工程写法: + // eTS工程: let calendar : reminderAgent.ReminderRequestCalendar = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR, dateTime: { @@ -117,9 +113,7 @@ reminderAgent:封装了发布、取消提醒类通知的方法。 闹钟实例定义: ```js - // JS工程写法: - // alarm: { - // eTS工程写法: + // eTS工程: let alarm : reminderAgent.ReminderRequestAlarm = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, hour: 11, 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-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index f413d22973221a435a408b6a2cc6993ea379e1a2..5a0126b00ae83f1e41792a2d60aa5032e5131525 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -12,6 +12,8 @@ | onPageShow | 页面每次显示时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | | onPageHide | 页面每次隐藏时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | | onBackPress | 当用户点击返回按钮时触发,仅\@Entry修饰的自定义组件生效。
    - 返回true表示页面自己处理返回逻辑, 不进行页面路由。
    - 返回false表示使用默认的返回逻辑。
    - 不返回值会作为false处理。 | +| onMeasure9+ | 框架会在自定义组件确定尺寸时,将该自定义组件的子节点信息和自身的尺寸范围通过onMeasure传递给该自定义组件。不允许在onMeasure函数中改变状态变量 | +| onLayout9+ | 框架会在自定义组件布局时,将该自定义组件的子节点信息和自身的尺寸范围通过onLayout传递给该自定义组件。不允许在onLayout函数中改变状态变量 | ## 示例 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-framework-file-access-rules.md b/zh-cn/application-dev/ui/ts-framework-file-access-rules.md index 6faf3d23d106f0f7148e3a972810cb3ea17e3b96..97f9bd7e718c8e682d788137be2497aaca1c8860 100644 --- a/zh-cn/application-dev/ui/ts-framework-file-access-rules.md +++ b/zh-cn/application-dev/ui/ts-framework-file-access-rules.md @@ -7,16 +7,8 @@ - ## 示例 -``` -common -│ └─ utils -│ └─ utils.ets -└─ pages - └─ index.ets -``` -如上所示,将utils放在common中,示例中index.ets访问utils.ets文件 +示例页面位于pages目录中,在pages同级目录common中存放utils,从示例xxx.ets访问utils.ets文件方法如下: ```ts // xxx.ets import { FoodData, FoodList } from "../common/utils/utils"; @@ -72,4 +64,4 @@ export struct FoodList { } } } -``` +``` \ No newline at end of file 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-JavaScript-docs-guide.md b/zh-cn/contribute/OpenHarmony-JavaScript-docs-guide.md index 933ed40cb0d2fb30cb05bc5cd9b7a4a6a8ff186f..26f8758c05627e32a7decbdc435460b03d1a794d 100644 --- a/zh-cn/contribute/OpenHarmony-JavaScript-docs-guide.md +++ b/zh-cn/contribute/OpenHarmony-JavaScript-docs-guide.md @@ -173,9 +173,7 @@ JS API 文档模板路径:[https://](https://gitee.com/openharmony/docs/blob/m ### 内容写作 -概述模板链接:[concept-overview-template.md](template/concept-overview-template.md) - -开发指导模板链接:[guide-template.md](template/guide-template.md) +开发指南模板链接:[guide-template.md](template/guide-template.md) **每一个文档必须包含的内容**: diff --git a/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md b/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md index eb25d94f33dc08adeb1c564a88aef39fd1279397..99d4093109a8fcd7cf5ab7fd5a4fb619aa8e7041 100644 --- a/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md +++ b/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md @@ -46,15 +46,25 @@ - 校验输入只包含可接受的字符(“白名单”形式),尤其需要注意一些特殊情况下的特殊字符。 **外部数据校验原则** + **1.信任边界** + 由于外部数据不可信,因此系统在运行过程中,如果数据传输与处理跨越不同的信任边界,为了防止攻击蔓延,必须对来自信任边界外的其他模块的数据进行合法性校验。 + (a)so(或者dll)之间 + so或dll作为独立的第三方模块,用于对外导出公共的api函数,供其他模块进行函数调用。so/dll无法确定上层调用者是否传递了合法参数,因此so/dll的公共函数需要检查调用者提供参数的合法性。so/dll应该设计成低耦合、高复用性,尽管有些软件的so/dll当前设计成只在本软件中使用,但仍然应该将不同的so/dll模块视为不同的信任边界。 + (b)进程与进程之间 + 为防止通过高权限进程提权,进程与进程之间的IPC通信(包括单板之间的IPC通信、不同主机间的网络通信),应视为不同信任边界。 + (c)应用层进程与操作系统内核 + 操作系统内核具有比应用层更高的权限,内核向应用层提供的接口,应该将来自应用层的数据作为不可信数据处理。 + (d)可信执行环境内外环境 + 为防止攻击蔓延至可信执行环境,TEE、SGX等对外提供的接口,应该将来自外部的数据作为不可信数据处理。 **2.外部数据校验** @@ -2746,7 +2756,7 @@ int Encode(unsigned char *in, size_t inSize, unsigned char *out, size_t maxSize) **【描述】** -**说明:**内核 mmap接口中,经常使用remap_pfn_range()函数将设备物理内存映射到用户进程空间。如果映射起始地址等参数由用户态控制并缺少合法性校验,将导致用户态可通过映射读写任意内核地址。如果攻击者精心构造传入参数,甚至可在内核中执行任意代码。 +**说明**:内核 mmap接口中,经常使用remap_pfn_range()函数将设备物理内存映射到用户进程空间。如果映射起始地址等参数由用户态控制并缺少合法性校验,将导致用户态可通过映射读写任意内核地址。如果攻击者精心构造传入参数,甚至可在内核中执行任意代码。 **【错误代码示例】** @@ -2876,7 +2886,7 @@ ssize_t correct_write(struct file *file, const char __user *user_buf, size_t cou ## 必须对copy_from_user()拷贝长度进行校验,防止缓冲区溢出 -**说明:**内核态从用户态拷贝数据时通常使用copy_from_user()函数,如果未对拷贝长度做校验或者校验不当,会造成内核缓冲区溢出,导致内核panic或提权。 +**说明**:内核态从用户态拷贝数据时通常使用copy_from_user()函数,如果未对拷贝长度做校验或者校验不当,会造成内核缓冲区溢出,导致内核panic或提权。 **【错误代码示例】** @@ -2921,7 +2931,7 @@ static long gser_ioctl(struct file *fp, unsigned cmd, unsigned long arg) **【描述】** -**说明:**内核态使用copy_to_user()向用户态拷贝数据时,当数据未完全初始化(如结构体成员未赋值、字节对齐引起的内存空洞等),会导致栈上指针等敏感信息泄漏。攻击者可利用绕过kaslr等安全机制。 +**说明**:内核态使用copy_to_user()向用户态拷贝数据时,当数据未完全初始化(如结构体成员未赋值、字节对齐引起的内存空洞等),会导致栈上指针等敏感信息泄漏。攻击者可利用绕过kaslr等安全机制。 **【错误代码示例】** 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/concept-overview-template.md b/zh-cn/contribute/template/concept-overview-template.md deleted file mode 100644 index 9ec95b2f1ad40a317bedca1a86ff751bdb5c530a..0000000000000000000000000000000000000000 --- a/zh-cn/contribute/template/concept-overview-template.md +++ /dev/null @@ -1,111 +0,0 @@ -# 概述 - -## 基本概念 - -*【 **写作要求**】* - -*必选,描述本开发任务相关的基本概念,帮助开发者更好的理解开发任务。* *写作要求见下,完成写作后,请逐项自检*。 - -| 内容要求 | 是否满足 | -| -------- | -------- | -| 业界通用的概念不用赘述。 | | -| 注意使用业界通用术语来表达,不用开发者无法理解的内部语言。 | | - - -【写作样例】 - - -XX系统音频模块支持音频业务的开发,提供音频相关的功能,主要包括音频播放、音频采集、音量管理和短音播放等。 - - -在进行应用的开发前,开发者应了解以下基本概念: - - -- 采样 - 采样就是把模拟信号数字化的过程,所有的模拟信号都需要通过采样转换为可以用0101来表示的数字信号。 - -- 采样率 - 采样率为每秒从连续信号中提取并组成离散信号的采样次数,单位用赫兹(Hz)来表示。通常人耳能听到频率范围大约在20Hz~20kHz之间的声音。常用的音频采样频率有:8kHz、11.025kHz、22.05kHz、16kHz、37.8kHz、44.1kHz、48kHz、96kHz、192kHz等。 - -- 声道 - 声道是指声音在录制或播放时在不同空间位置采集或回放的相互独立的音频信号,所以声道数也就是声音录制时的音源数量或回放时相应的扬声器数量。 - -- 音频帧 - 音频数据是流式的,本身没有明确的一帧帧的概念,在实际的应用中,为了音频算法处理/传输的方便,一般约定俗成取2.5ms~60ms为单位的数据量为一帧音频。这个时间被称之为“采样时间”,其长度没有特别的标准,它是根据编解码器和具体应用的需求来决定的。 - - -## 运作机制 - -*【 **写作要求**】* - -*可选。如果机制比较简单,通过前面基本概念就可以说清楚,此章节可以不用提供,删除标题即可*。 - -*描述实现原理介绍机制,如关键步骤相关接口调用时机和触发时机,帮助开发者了解该功能的基本运作原理,以便更好的理解开发任务和定位问题*。 - -*写作要求见下,完成写作后,请逐项自检*。 - -| 内容要求 | 是否满足 | -| -------- | -------- | -| 仅描述开发任务相关的原理。 | | -| 尽量图文配合,一般使用时序图、流程图等形式。文字描述与图形描述匹配。 | | - -【写作样例-1】 - -- 信号量初始化,为配置的N个信号量申请内存(N值可以由用户自行配置,受内存限制),并把所有的信号量初始化成未使用,并加入到未使用链表中供系统使用。 - -- 信号量创建,从未使用的信号量链表中获取一个信号量资源,并设定初值。 - -- 信号量申请,若其计数器值大于0,则直接减1返回成功。否则任务阻塞,等待其它任务释放该信号量,等待的超时时间可设定。当任务被一个信号量阻塞时,将该任务挂到信号量等待任务队列的队尾。 - -- 信号量释放,若没有任务等待该信号量,则直接将计数器加1返回。否则唤醒该信号量等待任务队列上的第一个任务。 - -- 信号量删除,将正在使用的信号量置为未使用信号量,并挂回到未使用链表。 - -- 信号量允许多个任务在同一时刻访问同一资源,但会限制同一时刻访问此资源的最大任务数目。访问同一资源的任务数达到该资源的最大数量时,会阻塞其他试图获取该资源的任务,直到有任务释放该信号量。 - - -【写作样例-2】 - -**互斥锁运作原理** - -多任务环境下会存在多个任务访问同一公共资源的场景,而有些公共资源是非共享的,需要任务进行独占式处理。互斥锁怎样来避免这种冲突呢? - -用互斥锁处理非共享资源的同步访问时,如果有任务访问该资源,则互斥锁为加锁状态。此时其他任务如果想访问这个公共资源则会被阻塞,直到互斥锁被持有该锁的任务释放后,其他任务才能重新访问该公共资源,此时互斥锁再次上锁,如此确保同一时刻只有一个任务正在访问这个公共资源,保证了公共资源操作的完整性。 - - - -## 约束与限制 - -【写作要求】 - -*必选*。 *描述本开发任务过程中* *的约束条件,以及此操作约束带来相应的负面影响,包括但不限于如下几方面*: - -- **功能限制**: - - 功能使用范围(明确不支持的场景)。 - - 规格限制。 - -* **操作限制**: - - * 已知问题的操作。 - * 潜在风险的操作(如引起性能降低)。 - * 引起性能降低的操作。 - -写作要求见下,完成写作后,请逐项自检。 - -| 内容要求 | 是否满足 | -| -------- | -------- | -| 明确功能限制或操作限制。 | | -| 约束对指导任务开发有影响或体验有感知,否则不用体现。 | | -| 容易出错的操作在步骤里描述,不在此体现。 | | - -【**写作样例**】 - -**互斥锁的约束与限制**: - -- 两个任务不能对同一把互斥锁加锁。如果某任务对已被持有的互斥锁加锁,则该任务会被挂起,直到持有该锁的任务对互斥锁解锁,才能执行对这把互斥锁的加锁操作。 - -- 互斥锁不能在中断服务程序中使用。 - -- XXX作为实时操作系统需要保证任务调度的实时性,尽量避免任务的长时间阻塞,因此在获得互斥锁之后,应该尽快释放互斥锁。 - -- 持有互斥锁的过程中,不得再调用LOS_TaskPriSet等接口更改持有互斥锁任务的优先级。 diff --git a/zh-cn/contribute/template/errorcodes-template.md b/zh-cn/contribute/template/errorcodes-template.md new file mode 100644 index 0000000000000000000000000000000000000000..cf89d10bf10bc03086d90de584d57ce1a6cc6353 --- /dev/null +++ b/zh-cn/contribute/template/errorcodes-template.md @@ -0,0 +1,118 @@ +# xxx(模块名,与API参考title保持一致)错误码 + +> **说明:** +> +> *1、所有的写作说明,在完成写作后,都要删除。* +> +> *2、错误码文档的命名规则:统一前缀,命名格式为errorcode-xxx.md。* + +| | 说明项 | 细则 | +| ---- | ------------------------------ | ------------------------------------------------------------ | +| 1 | 错误码error.errorNumber | 按统一的错误码编号规则设计错误码ID。 | +| 2 | 错误信息error.message | **字段含义**:出现异常时,会给开发者抛出一个错误对象,对象里包括errorNumber和error.message,此处定义error.message的值,即英文错误码简述。
    **要求**:
    1.应当简洁、具体,避免过于宽泛的定义。
    2.此处英文描述必须经过翻译中心审校。在提交本错误码设计评审前,请将预期的中英文message描述提供给翻译中心,将翻译中心审校后的英文填至此处。 | +| 3 | 错误简述
    Short Description | **字段含义**:中文错误码简述。
    **要求**:
    1.与”错误信息“对应的中文简述,应当简洁、具体,避免过于宽泛的定义。 | +| 4 | 错误描述
    Description | **字段含义**:错误码详细描述,告知错误码所属的业务场景、产生位置等。
    **要求**:
    1.描述错误码所属的业务场景(比如开发xx业务、开发xx功能时)。
    2.描述出现异常的具体现象、产生位置(比如xx模块、xx类、xx接口等),辅助开发者理解和处理异常。 | +| 5 | 可能原因
    Possible Causes | **字段含义**:列举出现该异常的所有可能原因(对应该错误码的产生机制)。
    **要求**:
    1.全面、无遗漏。
    2.言简意赅。
    3.根据可能性从高到低排序。 | +| 6 | 处理步骤
    Procedure | **字段含义**:根据错误现象及可能原因,告知开发者遇到该异常时如何应对。
    **要求**:
    1.采用step样式描述处理指导。每个大步骤与可能原因一一对应,按顺序分别给出各原因对应的处理指导。大步骤下可以有子步骤。
    2.步骤要明确、具体、可执行。涉及判断的,提供明确的判断标准。
    3.对系统或业务有影响的操作,在操作前以“注意”或“警告”形式提供警示信息。具体提示要求,请参见“风格指南”中的“提示与说明”:https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/style-guide/style-guide-content-elements.md | + +## 1300001 重复操作 *(错误码number+空格+错误简述)* + +**错误信息** + +This is repeat operation. + +**错误描述** + +> **说明:** +> +> *描述**错误码所属的业务场景(比如开发xx业务、开发xx功能时)及出现异常的具体现象**,辅助开发者理解和处理异常*。 + +当对同一窗口对象存在重复操作时,系统会产生此错误码。 + +**可能原因** + +> **说明:** +> +> *列举出现该异常的所有可能原因(对应该错误码的产生机制)。* +> +> *1.全面、无遗漏。* +> +> *2.言简意赅。* +> +> *3.根据可能性从高到低排序。* + +1. 重复创建已创建的窗口。 + +2. xxx。 + +**处理步骤** + +> **说明:** +> +> *根据错误现象及可能原因,告知开发者遇到该异常时如何应对。* +> +> *1.采用step样式描述处理指导。**每个大步骤与可能原因一一对应**,按顺序分别给出各原因对应的处理指导。**大步骤下可以有子步骤**。* +> +> *2.步骤要**明确、具体、可执行。涉及判断的,提供明确的判断标准**。* +> +> *3.对系统或业务有影响的操作,在操作前以“注意”或“警告”形式提供警示信息。具体提示要求,请参见“风格指南”中的“提示与说明”:https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/style-guide/style-guide-content-elements.md* + +1. 检查该窗口是否已创建。 + + xxx。 + + ``` + uth([in] String appId, [in] IHwShareCallback callback); + int shareFaInfo([in] PacMapEx pacMapEx); + } + ``` + +2. xxx。 + + a. xxx。 + + ``` + uth([in] String appId, [in] IHwShareCallback callback); + int shareFaInfo([in] PacMapEx pacMapEx); + } + ``` + + b. xxx。 + +## 1300002 窗口状态异常 + +**错误信息** + +xxx + +**错误描述** + +xxx + +**可能原因** + +1. xxx + +**处理步骤** + +1. 检查该窗口是否已创建。 + + xxx。 + + ``` + uth([in] String appId, [in] IHwShareCallback callback); + int shareFaInfo([in] PacMapEx pacMapEx); + } + ``` + +2. xxx。 + + a. xxx。 + + ``` + uth([in] String appId, [in] IHwShareCallback callback); + int shareFaInfo([in] PacMapEx pacMapEx); + } + ``` + + b. xxx。 \ No newline at end of file diff --git a/zh-cn/contribute/template/js-template.md b/zh-cn/contribute/template/js-template.md index 05fe7ca32ad5e0a02e227090e86039f41e0214a6..127e95f17fb7f03c1c555ef6ef8a019cfd3ee788 100644 --- a/zh-cn/contribute/template/js-template.md +++ b/zh-cn/contribute/template/js-template.md @@ -155,6 +155,15 @@ import call from '@ohos.telephony.call'; | string | 返回值描述。取到返回值之后,可以用来做什么。 | | Promise\> | 返回值描述。Promise写法参考总体写作说明第14项。 | +**错误码**:(可选,如不涉及可删除) + +以下错误码的详细介绍请参见[ohos.window(窗口)错误码]()。*(链接到对应模块的“错误码参考”文档)* + +| 错误码ID | 错误信息(此处仅提供错误抛出的关键信息) | +| -------- | ---------------------------------------- | +| 1300001 | This is repeat operation. | +| 1300002 | This window state is abnormally. | + **示例:** ```js 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/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index eab525eca520337d2a0ee458a9fb919ecb54b5dd..4d91198caa68f0429f228338a0943d074ae4b1b3 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -66,5 +66,6 @@ - 参考 - [常见问题-设备开发](faqs/Readme-CN.md) - [HDI接口参考](reference/hdi-apis/Readme-CN.md) + - [CMSIS API参考](reference/kernel/cmsis/Readme-CN.md) - 贡献 - [参与贡献](../contribute/贡献文档.md) \ No newline at end of file diff --git a/zh-cn/device-dev/device-dev-guide.md b/zh-cn/device-dev/device-dev-guide.md index 8bcd5350656f5567c701c910c08dd4baa70cc783..29273529556c779558fa807f53c64d14704ced30 100644 --- a/zh-cn/device-dev/device-dev-guide.md +++ b/zh-cn/device-dev/device-dev-guide.md @@ -41,7 +41,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按 | 进阶开发 | 结合系统能力开发智能设备 | - [WLAN连接类产品](guide/device-wlan-led-control.md)
    - [带屏摄像头类产品](guide/device-camera-control-overview.md) | | 移植适配 | - 针对特定芯片做移植适配
    - 对三方库进行移植适配
    - 三方厂商移植案例
    | - [轻量系统芯片移植指导](porting/porting-minichip-overview.md)
    - [小型系统芯片移植指导](porting/porting-smallchip-prepare-needs.md)
    - [轻量和小型系统三方库移植指导](porting/porting-thirdparty-overview.md)
    - [带屏解决方案之恒玄芯片移植案例](porting/porting-bes2600w-on-minisystem-display-demo.md)
    - [Combo解决方案之ASR芯片移植案例](porting/porting-asr582x-combo-demo.md)
    - [物联网解决方案之芯海cst85芯片移植案例](porting/porting-cst85f01-combo-demo.md)
    - [轻量系统STM32F407芯片移植案例](porting/porting-stm32f407-on-minisystem-eth.md)
    - [Combo解决方案之W800芯片移植案例](porting/porting-w800-combo-demo.md)
    - [小型设备STM32MP1芯片移植案例](porting/porting-stm32mp15xx-on-smallsystem.md) | | 贡献组件 | 为OpenHarmony贡献功能组件 | - [HPM Part 介绍](hpm-part/hpm-part-about.md)
    - [HPM Part 开发指导](hpm-part/hpm-part-development.md)
    - [HPM Part 参考](hpm-part/hpm-part-reference.md) | -| 参考 | 为开发者提供常见的问题解答和HDI接口参考 | - [常见问题](faqs/faqs-overview.md)
    - [HDI接口参考](reference/hdi-apis/Readme-CN.md) | +| 参考 | 为开发者提供常见的问题解答、HDI接口参考和CMSIS API参考 | - [常见问题](faqs/faqs-overview.md)
    - [HDI接口参考](reference/hdi-apis/Readme-CN.md)- [CMSIS API参考](reference/kernel/cmsis/Readme-CN.md) | **表 2** 标准系统开发指导(参考内存≥128MiB) | 学习路径 | 开发者业务 | 相关文档 | 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-20220915140627223.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png index 5d27f2620ca837e6b90416e16aa7456919762104..0555592c3d2e17c7b2b9a25faca5a830a2ac026c 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220915140627223.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930113757464.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930113757464.png new file mode 100644 index 0000000000000000000000000000000000000000..642e0f6c3f63238df8b6d49ea59b9b7f8c0eb01e Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930113757464.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png new file mode 100644 index 0000000000000000000000000000000000000000..4a959db1206c500c0ee61e1548ffa4c94565d104 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221009112548444.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221009112548444.png new file mode 100644 index 0000000000000000000000000000000000000000..0c4e83fda3b7ea5f356dfb96950b14180b087afb Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221009112548444.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011143924648.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011143924648.png new file mode 100644 index 0000000000000000000000000000000000000000..814ed3eb64440da9ace8078af96dc482414277db Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011143924648.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144751355.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144751355.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d9f869ca11b3392e3decea6a088d5c1c30562c Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144751355.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144901470.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144901470.png new file mode 100644 index 0000000000000000000000000000000000000000..ed37db7e5114559964e9a444da5feebccd1c1c8c Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011144901470.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145157288.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145157288.png new file mode 100644 index 0000000000000000000000000000000000000000..85141c17d324aa8919820d180e40544e8702275c Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145157288.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145430048.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145430048.png new file mode 100644 index 0000000000000000000000000000000000000000..12f145f1bc435ce223f22ab3670c0d7e6b556aa3 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145430048.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145616293.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145616293.png new file mode 100644 index 0000000000000000000000000000000000000000..19f4ef10ba4b468b1595322a5753fa08faf77ff8 Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011145616293.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150018915.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150018915.png new file mode 100644 index 0000000000000000000000000000000000000000..ac135d89a0537931f97065e391b52841233d63ae Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150018915.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150215316.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150215316.png new file mode 100644 index 0000000000000000000000000000000000000000..dcec5b12141732bfb03988b00ad150a70d26ea8a Binary files /dev/null and b/zh-cn/device-dev/kernel/figures/zh-cn_image-20221011150215316.png differ 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/kernel/kernel-standard-newip.md b/zh-cn/device-dev/kernel/kernel-standard-newip.md index 760a5518e4b94816b90df5be4ad83404583155f6..c507257656f86fa1c9dcd862e22ba78ae9433940 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-newip.md +++ b/zh-cn/device-dev/kernel/kernel-standard-newip.md @@ -28,10 +28,14 @@ NewIP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33% ## 可变长报头格式 -NewIP灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识NewIP灵活极简报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示特定目标特性的存在性。 +NewIP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识NewIP灵活极简报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示特定目标特性的存在性。 ![zh-cn_image-20220915140627223](figures/zh-cn_image-20220915140627223.png) +NewIP Eth灵活极简报文头如下图所示,通过Eth头中的EtherType = 0xEADD标识NewIP灵活极简报文。 + +![zh-cn_image-20220930113757464](figures/zh-cn_image-20220930113757464.png) + 1) Dispatch:指示封装子类,数值0b0表示其为极简封装子类,长度为1比特;(0b表示后面数值为二进制)。 2) Bitmap:变长,Bitmap默认为紧跟在Dispatch有效位后面的7比特,Bitmap字段长度可持续扩展。Bitmap最后一位置0表示Bitmap结束,最后一位置1表示Bitmap向后扩展1 Byte,直至最后一位置0。 @@ -244,9 +248,43 @@ struct sockaddr_nin { }; ``` +## NewIP开发说明 + +目前只在OpenHarmony Linux-5.10内核支持NewIP内核协议栈,只能在用户态人工配置NewIP地址和路由到内核,两台设备可以通过路由器WiFi连接,也可以通过Eth网线直接连接。如果想配置NewIP地址和路由后自动切换到NewIP内核协议栈通信,应用可以参考下面蓝框中描述。 + +![zh-cn_image-20221009112548444](figures/zh-cn_image-20221009112548444.png) + +上图中NewIP地址,路由配置程序可以参考[代码仓examples代码](https://gitee.com/openharmony-sig/communication_sfc_newip/tree/master/examples),根据CPU硬件差异更改Makefile中CC定义编译成二级制文件后推送到开发板,参考上图命令给设备配置NewIP地址和路由。 + +| 文件名 | 功能 | +| ------------------ | ------------------------------------------------------ | +| nip_addr.c | NewIP可变长地址配置demo代码(可配置任意有效NewIP地址) | +| nip_route.c | NewIP路由配置demo代码(可配置任意有效NewIP地址) | +| check_nip_enable.c | 获取本机NewIP能力 | + +设备1上查看NewIP地址和路由: + +```sh +# cat /proc/net/nip_addr +01 wlan0 +# cat /proc/net/nip_route +02 ff09 1 wlan0 # 到设备2的路由 +01 01 2149580801 wlan0 # 本机自发自收路由 +``` + +设备2上查看NewIP地址和路由: + +```sh +# cat /proc/net/nip_addr +02 wlan0 +# cat /proc/net/nip_route +01 ff09 1 wlan0 # 到设备1的路由 +02 02 2149580801 wlan0 # 本机自发自收路由 +``` + ## NewIP收发包代码示例 -NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,NewIP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony-sig/communication_sfc_newip/tree/master/examples)。 +NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,NewIP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony-sig/communication_sfc_newip/tree/master/examples)。demo代码内配置固定地址和路由,执行编译后二进制程序时不需要人工指定地址和路由。 | 文件名 | 功能 | | --------------------- | ----------------------------- | @@ -262,15 +300,15 @@ NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如 ![zh-cn_image-20220915165414926](figures/zh-cn_image-20220915165414926.png) -1、将demo代码拷贝到Linux编译机上,make clean,make all编译demo代码。 +1. 将demo代码拷贝到Linux编译机上,make clean,make all编译demo代码。 -2、将编译生成二级制文件上传到设备1,设备2。 +2. 将编译生成二级制文件上传到设备1,设备2。 -3、执行“ifconfig xxx up”开启网卡设备,xxx表示网卡名,比如eth0,wlan0。 +3. 执行“ifconfig xxx up”开启网卡设备,xxx表示网卡名,比如eth0,wlan0。 -4、在设备1的sh下执行“./nip_addr_cfg_demo server”给服务端配置0xDE00(2字节)变长地址,在设备2的sh下执行“./nip_addr_cfg_demo client”给客户端配置0x50(1字节)变长地址,通过“cat /proc/net/nip_addr”查看内核地址配置结果。 +4. 在设备1的sh下执行“./nip_addr_cfg_demo server”给服务端配置0xDE00(2字节)变长地址,在设备2的sh下执。行“./nip_addr_cfg_demo client”给客户端配置0x50(1字节)变长地址,通过“cat /proc/net/nip_addr”查看内核地址配置结果。 -5、在设备1的sh下执行“./nip_route_cfg_demo server”给服务端配置路由,在设备2的sh下执行“./nip_route_cfg_demo client”给客户端配置路由,通过“cat /proc/net/nip_route”查看内核路由配置结果。 +5. 在设备1的sh下执行“./nip_route_cfg_demo server”给服务端配置路由,在设备2的sh下执行“./nip_route_cfg_demo client”给客户端配置路由,通过“cat /proc/net/nip_route”查看内核路由配置结果。 以上步骤操作完成后,可以进行UDP/TCP收发包,收发包demo默认使用上面步骤中配置的地址和路由。 @@ -343,5 +381,59 @@ allow thread_xxx thread_xxx:socket { create bind connect listen accept read writ allowxperm thread_xxx thread_xxx:socket ioctl { 0x8933 0x8916 0x890B }; ``` +## WireShark报文解析模板 + +Wireshark默认报文解析规则无法解析NewIP报文,在WireShark配置中添加NewIP报文解析模板可以实现NewIP报文解析,[NewIP报文解析模板](https://gitee.com/openharmony-sig/communication_sfc_newip/blob/master/tools/wireshark_cfg_for_newip.lua)详见代码仓。 + +报文解析模板配置文件的方法: + +依次单击 Help -> About Wireshark -> Folders,打开Global Configuration目录,编辑init.lua文件。在末尾添加dofile(DATA_DIR..”newip.lua”),其中DATA_DIR即为newip.lua插件所在路径。 + +![zh-cn_image-20220930141628922](figures/zh-cn_image-20220930141628922.png) + +NewIP报文解析模板添加样例: + +``` +NewIP报文解析模板存放路径: +D:\tools\WireShark\wireshark_cfg_for_newip.lua + +WireShark配置文件路径: +C:\Program Files\Wireshark\init.lua + +在init.lua文件最后增加下面配置(window 11) +dofile("D:\\tools\\WireShark\\wireshark_cfg_for_newip.lua") +``` + +### 报文解析样例 + +#### ND请求 + +NewIP邻居发现请求报文格式如下,NewIP极简报文头包含1字节的bitmap(0x76),bitmap标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。NewIP ND请求报文包含报文类型,操作码,校验和和请求地址。 + +![zh-cn_image-20221011144901470](figures/zh-cn_image-20221011144901470.png) + +![zh-cn_image-20221011143924648](figures/zh-cn_image-20221011143924648.png) + +#### ND应答 + +NewIP邻居发现应答报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。NewIP ND应答报文包含报文类型,操作码,校验和和邻居MAC地址长度,邻居MAC地址。 + +![zh-cn_image-20221011145157288](figures/zh-cn_image-20221011145157288.png) + +![zh-cn_image-20221011144751355](figures/zh-cn_image-20221011144751355.png) + +#### TCP握手 + +TCP三次握手SYN报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 + +![image-20221011150018915](figures/zh-cn_image-20221011150018915.png) + +![image-20221011145430048](figures/zh-cn_image-20221011145430048.png) + +#### TCP数据包 + +TCP数据格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 +![image-20221011150215316](figures/zh-cn_image-20221011150215316.png) +![image-20221011145616293](figures/zh-cn_image-20221011145616293.png) 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/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md old mode 100755 new mode 100644 index d6fee427c72b22dd221450e614be3617ed952815..3aca6a69afabb10c047aed0b228025b0f4c283b4 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -91,7 +91,7 @@ - [DFX概述](subsys-dfx-overview.md) - [HiLog开发指导](subsys-dfx-hilog-rich.md) - [HiLog_Lite开发指导](subsys-dfx-hilog-lite.md) - - [HiTrace开发指导](subsys-dfx-hitrace.md) + - [HiTraceChain开发指导](subsys-dfx-hitracechain.md) - [HiCollie开发指导](subsys-dfx-hicollie.md) - HiSysEvent开发指导 - [HiSysEvent概述](subsys-dfx-hisysevent-overview.md) 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-hitrace.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md similarity index 51% rename from zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md rename to zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md index 498881fd5cad8a390f6a0bf5100959d2610f29b6..1c2cdf491de1474253287ada866d2de343d83553 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -1,13 +1,13 @@ -# HiTrace开发指导 +# HiTraceChain开发指导 ## 概述 -HiTrace主要是对于跨设备/跨进程/跨线程的业务流程,通过相同的traceid在整个业务流程中传递,将流程处理过程中的调用关系、各种输出信息关联和展现出来,帮助使用者分析、定位问题和系统调优。 +HiTraceChain主要是对于跨设备/跨进程/跨线程的业务流程,通过相同的traceid在整个业务流程中传递,将流程处理过程中的调用关系、各种输出信息关联和展现出来,帮助使用者分析、定位问题和系统调优。 ## 应用场景 -HiTrace在产品中应用场景如下,包括: +HiTraceChain在产品中应用场景如下,包括: - 端侧业务流程信息(日志、事件等)关联、上报 @@ -15,14 +15,14 @@ HiTrace在产品中应用场景如下,包括: - IDE对业务流程详细信息、耗时分布进行调试,辅助系统调优 - **图1** HiTrace应用场景 + **图1** HiTraceChain应用场景 ![zh-cn_image_0000001216312860](figures/zh-cn_image_0000001216312860.png) ### 业务使用示例 **图2** 业务调用流程图(跨设备、跨进程同步调用) - + ![zh-cn_image_0000001216632830](figures/zh-cn_image_0000001216632830.png) 1. 调试时展示业务流程中的调用关系,进行关键路径分析、功能依赖分析,确定各调用点耗时、调用频率,提前发现性能瓶颈点。 @@ -30,7 +30,7 @@ HiTrace在产品中应用场景如下,包括: **图3** 业务调用流程序列图 ![zh-cn_image_0000001216792790](figures/zh-cn_image_0000001216792790.png) - + **图4** 业务调用流程性能耗时分布 ![zh-cn_image_0000001261272659](figures/zh-cn_image_0000001261272659.png) @@ -39,75 +39,75 @@ HiTrace在产品中应用场景如下,包括: ## 接口说明 -HiTrace提供C++、C接口。上层业务主要使用HiTrace跟踪启动、结束接口。 +HiTraceChain提供C++、C接口。上层业务主要使用HiTraceChain跟踪启动、结束接口。 -HiTrace实现在C层,主要原理是在一次业务调用流程中,利用通信传递traceid,在业务处理前将traceid设置到当前线程的TLS(Thread Local Storage)中,业务处理结束清除当前线程的TLS;这样的话,在业务处理中可以从当前线程的上下文TLS取到traceid,自动附加到日志、事件信息中。 +HiTraceChain实现在C层,主要原理是在一次业务调用流程中,利用通信传递traceid,在业务处理前将traceid设置到当前线程的TLS(Thread Local Storage)中,业务处理结束清除当前线程的TLS;这样的话,在业务处理中可以从当前线程的上下文TLS取到traceid,自动附加到日志、事件信息中。 ### 接口形式对比 **表1** C++、C的函数接口 -| | **C++** | **C** | +| | **C++** | **C** | | -------- | -------- | -------- | -| **类** | **函数** | **函数** | -| HiTrace | HiTraceId Begin(const std::string& name, int flags) | HiTraceIdStruct HiTraceBegin(const char\* name, int flags) | -| | void End(const HiTraceId& id) | void HiTraceEnd(const HiTraceIdStruct\* pId) | -| | HiTraceId GetId(); | HiTraceIdStruct HiTraceGetId() | -| | void SetId(const HiTraceId& id) | void HiTraceSetId(const HiTraceIdStruct\* pId) | -| | void ClearId() | void HiTraceClearId() | -| | HiTraceId CreateSpan() | HiTraceIdStruct HiTraceCreateSpan() | -| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceTracepoint(HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | -| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | -| HiTraceId | HiTraceId(); | void HiTraceInitId(HiTraceIdStruct\* pId) | -| | HiTraceId(const uint8_t\* pIdArray, int len) | HiTraceIdStruct HiTraceBytesToId(const uint8_t\* pIdArray, int len) | -| | bool IsValid() | int HiTraceIsValid(const HiTraceIdStruct\* pId) | -| | bool IsFlagEnabled(HiTraceFlag flag) | int HiTraceIsFlagEnabled(const HiTraceIdStruct\* pId, HiTraceFlag flag) | -| | void EnableFlag(HiTraceFlag flag) | void HiTraceEnableFlag(HiTraceIdStruct\* pId, HiTraceFlag flag) | -| | int GetFlags() | int HiTraceGetFlags(const HiTraceIdStruct\* pId) | -| | void SetFlags(int flags) | void HiTraceSetFlags(HiTraceIdStruct\* pId, int flags) | -| | uint64_t GetChainId() | uint64_t HiTraceGetChainId(const HiTraceIdStruct\* pId) | -| | void SetChainId(uint64_t chainId) | void HiTraceSetChainId(HiTraceIdStruct\* pId, uint64_t chainId) | -| | uint64_t GetSpanId() | uint64_t HiTraceGetSpanId(const HiTraceIdStruct\* pId) | -| | void SetSpanId(uint64_t spanId) | void HiTraceSetSpanId(HiTraceIdStruct\* pId, uint64_t spanId) | -| | uint64_t GetParentSpanId() | uint64_t HiTraceGetParentSpanId(const HiTraceIdStruct\* pId) | -| | void SetParentSpanId(uint64_t parentSpanId) | void HiTraceSetParentSpanId(HiTraceIdStruct\* pId, uint64_t parentSpanId) | -| | int ToBytes(uint8_t\* pIdArray, int len) | int HiTraceIdToBytes(const HiTraceIdStruct_ pId, uint8_t_ pIdArray, int len) | +| **类** | **函数** | **函数** | +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | HiTraceIdStruct HiTraceChainBegin(const char\* name, int flags) | +| | void End(const HiTraceId& id) | void HiTraceChainEnd(const HiTraceIdStruct\* pId) | +| | HiTraceId GetId(); | HiTraceIdStruct HiTraceChainGetId() | +| | void SetId(const HiTraceId& id) | void HiTraceChainSetId(const HiTraceIdStruct\* pId) | +| | void ClearId() | void HiTraceChainClearId() | +| | HiTraceId CreateSpan() | HiTraceIdStruct HiTraceChainCreateSpan() | +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceChainTracepoint(HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | void HiTraceChainTracepointEx(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceIdStruct_ pId, const char_ fmt, ...) | +| HiTraceId | HiTraceId(); | void HiTraceChainInitId(HiTraceIdStruct\* pId) | +| | HiTraceId(const uint8_t\* pIdArray, int len) | HiTraceIdStruct HiTraceChainBytesToId(const uint8_t\* pIdArray, int len) | +| | bool IsValid() | int HiTraceChainIsValid(const HiTraceIdStruct\* pId) | +| | bool IsFlagEnabled(HiTraceFlag flag) | int HiTraceChainIsFlagEnabled(const HiTraceIdStruct\* pId, HiTraceFlag flag) | +| | void EnableFlag(HiTraceFlag flag) | void HiTraceChainEnableFlag(HiTraceIdStruct\* pId, HiTraceFlag flag) | +| | int GetFlags() | int HiTraceChainGetFlags(const HiTraceIdStruct\* pId) | +| | void SetFlags(int flags) | void HiTraceChainSetFlags(HiTraceIdStruct\* pId, int flags) | +| | uint64_t GetChainId() | uint64_t HiTraceChainGetChainId(const HiTraceIdStruct\* pId) | +| | void SetChainId(uint64_t chainId) | void HiTraceChainSetChainId(HiTraceIdStruct\* pId, uint64_t chainId) | +| | uint64_t GetSpanId() | uint64_t HiTraceChainGetSpanId(const HiTraceIdStruct\* pId) | +| | void SetSpanId(uint64_t spanId) | void HiTraceChainSetSpanId(HiTraceIdStruct\* pId, uint64_t spanId) | +| | uint64_t GetParentSpanId() | uint64_t HiTraceChainGetParentSpanId(const HiTraceIdStruct\* pId) | +| | void SetParentSpanId(uint64_t parentSpanId) | void HiTraceChainSetParentSpanId(HiTraceIdStruct\* pId, uint64_t parentSpanId) | +| | int ToBytes(uint8_t\* pIdArray, int len) | int HiTraceChainIdToBytes(const HiTraceIdStruct_ pId, uint8_t_ pIdArray, int len) | ### 接口功能参数 **表2** C++接口说明函数参数和功能 -| **类** | **方法** | **描述** | +| **类** | **方法** | **描述** | | -------- | -------- | -------- | -| HiTrace | HiTraceId Begin(const std::string& name, int flags) | 功能:启动HiTrace跟踪、生成HiTraceId对象并设置到当前线程TLS中。
    输入参数:
    - name:业务流程名称。
    - flags:跟踪指示位,可以组合使用,具体含义为:
      - HITRACE_FLAG_INCLUDE_ASYNC:同时跟踪同步调用和异步调用,缺省只跟踪同步调用。
      - HITRACE_FLAG_DONOT_CREATE_SPAN:不创建子分支,缺省创建子分支。
      - HITRACE_FLAG_TP_INFO:输出tracepoint信息,缺省不输出。
      - HITRACE_FLAG_NO_BE_INFO:不输出起始、结束信息,缺省输出。
      - HITRACE_FLAG_DONOT_ENABLE_LOG:不与日志关联输出,缺省关联。
      - HITRACE_FLAG_FAULT_TRIGGER:故障触发的跟踪,缺省为正常启动的。
      - HITRACE_FLAG_D2D_TP_INFO:输出设备间tracepoint信息,缺省不输出。
      - HITRACE_FLAG_DEFAULT: 缺省标志。
    - 输出参数:无
    - 返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。
    注意:嵌套启动跟踪时,内层启动调用返回无效对象。 | -| | void End(const HiTraceId& id) | 功能:根据Begin返回的HiTraceId停止HiTrace跟踪;清除当前线程TLS中HiTraceId内容。
    输入参数:
    - id:HiTraceId对象。
    输出参数:无。
    返回值:无。 | -| | HiTraceId GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:当前线程上下文的HiTraceId对象。 | -| | void SetId(const HiTraceId& id) | 功能:设置HiTraceId对象内容到当前线程TLS中。
    输入参数:
    - id:HiTraceId对象。
    输出参数:无。
    返回值:无。 | -| | void ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:无。 | -| | HiTraceId CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。
    输入参数:无。
    输出参数:无。
    返回值:当前分支ID。 | -| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据埋点信息类型输出HiTrace埋点信息,包括时间戳、子分支HiTraceId对象信息。
    输入参数:
    - type:埋点信息类型,具体为
      - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
      - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
      - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
      - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
      - HITRACE_TP_GENERAL:普通输出信息。
    - id:当前子分支id。
    - fmt:格式化变参描述字符串。
    - args:变参。
    输出参数:无。
    返回值:无。 | -| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据通信模式、埋点信息类型输出HiTrace埋点信息,包括时间戳、子分支HiTraceId对象信息。
    输入参数:
    - mode:通信模式,具体为
      - HITRACE_CM_DEFAULT:未指定通信模式。
      - HITRACE_CM_THREAD:线程间通信。
      - HITRACE_CM_PROCESS:进程间通信。
      - HITRACE_CM_DEVICE:设备间通信。
    - type:埋点信息类型,具体为
      - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
      - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
      - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
      - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
      - HITRACE_TP_GENERAL:普通输出信息。
    - id:当前子分支id。
    - fmt:格式化变参描述字符串。
    - args:变参。
    输出参数:无。
    返回值:无。 | -| HiTraceId | HiTraceId(); | 功能:缺省构造函数,生成无效HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:无。 | -| | HiTraceId(const uint8_t\* pIdArray, int len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。
    输入参数:
    - pIdArray:字节数组指针。
    - len:字节数组长度。
    输出参数:无。
    返回值:无。 | -| | bool IsValid() | 功能:HiTraceId对象是否有效。
    输入参数:无。
    输出参数:无。
    返回值:true 有效;false 无效。 | -| | bool IsFlagEnabled(HiTraceFlag flag) | 功能:HiTraceId对象的某标志是否置位。
    输入参数:
    - flag:跟踪指示位,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:true 该标志置位;false 该标志未置位。 | -| | void EnableFlag(HiTraceFlag flag) | 功能:设置某跟踪标志位到HiTraceId对象中。
    输入参数:
    - flag:跟踪指示位,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:无。 | -| | int GetFlags() | 功能:获取HiTraceId对象中设置的标志位。
    输入参数:无。
    输出参数:无。
    返回值:跟踪指示位组合,具体含义见Begin函数中的定义。 | -| | void SetFlags(int flags) | 功能:设置跟踪标志位到HiTraceId对象中。
    输入参数:
    - flags:跟踪指示位组合,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:无。 | -| | uint64_t GetChainId() | 功能:获取跟踪链ID。
    输入参数:无。
    输出参数:无。
    返回值:跟踪链ID。 | -| | void SetChainId(uint64_t chainId) | 功能:设置跟踪链ID到HiTraceId对象中。
    输入参数:
    - chainId:跟踪链ID。
    输出参数:无。
    返回值:无。 | -| | uint64_t GetSpanId() | 接口功能:获取当前HiTraceId对象中的分支ID。
    输入参数:无。
    输出参数:无。
    返回值:当前分支ID。 | -| | void SetSpanId(uint64_t spanId) | 功能:设置分支ID到HiTraceId对象中。
    输入参数:
    - spanId:分支ID。
    输出参数:无。
    返回值:无。 | -| | uint64_t GetParentSpanId() | 功能:获取当前HiTraceId对象中的父分支ID。
    输入参数:无。
    输出参数:无。
    返回值:父分支ID。 | -| | void SetParentSpanId(uint64_t parentSpanId) | 功能:设置父分支ID到HiTraceId对象中。
    输入参数:
    - parentSpanId:父分支ID。
    输出参数:无。
    返回值:无。 | -| | int ToBytes(uint8_t\* pIdArray, int len) | 功能:将HiTraceId对象转换为字节数组,便于缓存或者通信传递。
    输入参数:
    - pIdArray:字节数组指针,数组长度至少为HITRACE_ID_LEN。
    - len: 字节数组长度
    输出参数:
    - pIdArray:字节数组指针,对象有效时存储转换后的对象数据。
    返回值:0 转换失败; &gt;0 有效对象转换数组长度。 | +| HiTraceChain | HiTraceId Begin(const std::string& name, int flags) | 功能:启动HiTraceChain跟踪、生成HiTraceId对象并设置到当前线程TLS中。
    输入参数:
    - name:业务流程名称。
    - flags:跟踪指示位,可以组合使用,具体含义为:
      - HITRACE_FLAG_INCLUDE_ASYNC:同时跟踪同步调用和异步调用,缺省只跟踪同步调用。
      - HITRACE_FLAG_DONOT_CREATE_SPAN:不创建子分支,缺省创建子分支。
      - HITRACE_FLAG_TP_INFO:输出tracepoint信息,缺省不输出。
      - HITRACE_FLAG_NO_BE_INFO:不输出起始、结束信息,缺省输出。
      - HITRACE_FLAG_DONOT_ENABLE_LOG:不与日志关联输出,缺省关联。
      - HITRACE_FLAG_FAULT_TRIGGER:故障触发的跟踪,缺省为正常启动的。
      - HITRACE_FLAG_D2D_TP_INFO:输出设备间tracepoint信息,缺省不输出。
      - HITRACE_FLAG_DEFAULT: 缺省标志。
    - 输出参数:无
    - 返回值:启动跟踪超过返回有效HiTraceId对象,否则返回无效对象。
    注意:嵌套启动跟踪时,内层启动调用返回无效对象。 | +| | void End(const HiTraceId& id) | 功能:根据Begin返回的HiTraceId停止HiTraceChain跟踪;清除当前线程TLS中HiTraceId内容。
    输入参数:
    - id:HiTraceId对象。
    输出参数:无。
    返回值:无。 | +| | HiTraceId GetId(); | 功能:从当前线程TLS中获取HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:当前线程上下文的HiTraceId对象。 | +| | void SetId(const HiTraceId& id) | 功能:设置HiTraceId对象内容到当前线程TLS中。
    输入参数:
    - id:HiTraceId对象。
    输出参数:无。
    返回值:无。 | +| | void ClearId() | 功能:清除当前线程TLS中的HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:无。 | +| | HiTraceId CreateSpan() | 接口功能:获取当前HiTraceId对象中的分支ID。
    输入参数:无。
    输出参数:无。
    返回值:当前分支ID。 | +| | void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
    输入参数:
    - type:埋点信息类型,具体为
      - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
      - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
      - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
      - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
      - HITRACE_TP_GENERAL:普通输出信息。
    - id:当前子分支id。
    - fmt:格式化变参描述字符串。
    - args:变参。
    输出参数:无。
    返回值:无。 | +| | void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char\* fmt, ...) | 功能:根据通信模式、埋点信息类型输出HiTraceChain埋点信息,包括时间戳、子分支HiTraceId对象信息。
    输入参数:
    - mode:通信模式,具体为
      - HITRACE_CM_DEFAULT:未指定通信模式。
      - HITRACE_CM_THREAD:线程间通信。
      - HITRACE_CM_PROCESS:进程间通信。
      - HITRACE_CM_DEVICE:设备间通信。
    - type:埋点信息类型,具体为
      - HITRACE_TP_CS:Client Send,同步/异步通信客户端发送信息。
      - HITRACE_TP_SR:Server Receive, 同步/异步通信服务端接收信息。
      - HITRACE_TP_SS:Server Send,同步通信服务端发送响应信息。
      - HITRACE_TP_CR:Client Receive,同步通信客户端接收响应信息。
      - HITRACE_TP_GENERAL:普通输出信息。
    - id:当前子分支id。
    - fmt:格式化变参描述字符串。
    - args:变参。
    输出参数:无。
    返回值:无。 | +| HiTraceId | HiTraceId(); | 功能:缺省构造函数,生成无效HiTraceId对象。
    输入参数:无。
    输出参数:无。
    返回值:无。 | +| | HiTraceId(const uint8_t\* pIdArray, int len) | 功能:构造函数,根据字节数组创建跟踪HiTraceId对象。
    输入参数:
    - pIdArray:字节数组指针。
    - len:字节数组长度。
    输出参数:无。
    返回值:无。 | +| | bool IsValid() | 功能:HiTraceId对象是否有效。
    输入参数:无。
    输出参数:无。
    返回值:true 有效;false 无效。 | +| | bool IsFlagEnabled(HiTraceFlag flag) | 功能:HiTraceId对象的某标志是否置位。
    输入参数:
    - flag:跟踪指示位,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:true 该标志置位;false 该标志未置位。 | +| | void EnableFlag(HiTraceFlag flag) | 功能:设置某跟踪标志位到HiTraceId对象中。
    输入参数:
    - flag:跟踪指示位,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:无。 | +| | int GetFlags() | 功能:获取HiTraceId对象中设置的标志位。
    输入参数:无。
    输出参数:无。
    返回值:跟踪指示位组合,具体含义见Begin函数中的定义。 | +| | void SetFlags(int flags) | 功能:设置跟踪标志位到HiTraceId对象中。
    输入参数:
    - flags:跟踪指示位组合,具体含义见Begin函数中的定义。
    输出参数:无。
    返回值:无。 | +| | uint64_t GetChainId() | 功能:获取跟踪链ID。
    输入参数:无。
    输出参数:无。
    返回值:跟踪链ID。 | +| | void SetChainId(uint64_t chainId) | 功能:设置跟踪链ID到HiTraceId对象中。
    输入参数:
    - chainId:跟踪链ID。
    输出参数:无。
    返回值:无。 | +| | uint64_t GetSpanId() | 接口功能:获取当前HiTraceId对象中的分支ID。
    输入参数:无。
    输出参数:无。
    返回值:当前分支ID。 | +| | void SetSpanId(uint64_t spanId) | 功能:设置分支ID到HiTraceId对象中。
    输入参数:
    - spanId:分支ID。
    输出参数:无。
    返回值:无。 | +| | uint64_t GetParentSpanId() | 功能:获取当前HiTraceId对象中的父分支ID。
    输入参数:无。
    输出参数:无。
    返回值:父分支ID。 | +| | void SetParentSpanId(uint64_t parentSpanId) | 功能:设置父分支ID到HiTraceId对象中。
    输入参数:
    - parentSpanId:父分支ID。
    输出参数:无。
    返回值:无。 | +| | int ToBytes(uint8_t\* pIdArray, int len) | 功能:将HiTraceId对象转换为字节数组,便于缓存或者通信传递。
    输入参数:
    - pIdArray:字节数组指针,数组长度至少为HITRACE_ID_LEN。
    - len: 字节数组长度
    输出参数:
    - pIdArray:字节数组指针,对象有效时存储转换后的对象数据。
    返回值:0 转换失败; &gt;0 有效对象转换数组长度。 | ## 通信调用处理 -业务使用时跨设备/跨进程/跨线程的调用是通过通信机制实现的,HiTrace需要通信机制传递traceid。 +业务使用时跨设备/跨进程/跨线程的调用是通过通信机制实现的,HiTraceChain需要通信机制传递traceid。 OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid。 @@ -158,47 +158,47 @@ OpenHarmony系统内置部分通信机制(如ZIDL)已经支持传递traceid ### C++接口实例 1. 源代码开发 - 在类定义头文件或者类实现源文件中,包含hitrace头文件: + 在类定义头文件或者类实现源文件中,包含hitracechain头文件: ``` - #include "hitrace/trace.h" + #include "hitrace/tracechain.h" ``` 在业务类实现源文件中使用(启动/结束跟踪): - + ``` using namespace OHOS::HiviewDFX; - HiTraceId traceId = HiTrace::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + auto traceId = HiTraceChain::Begin("MyServiceFlow", HITRACE_FLAG_DEFAULT); ...... - HiTrace::End(traceId); + HiTraceChain::End(traceId); ``` 2. 编译设置,在BUILD.gn里增加子系统SDK依赖: - + ``` - external_deps = [ "hiviewdfx:libhitrace" ] + external_deps = [ "hiviewdfx:libhitracechain" ] ``` ### C接口实例 1. 源代码开发 - 在源文件中,包含hitrace头文件: + 在源文件中,包含hitracechain头文件: ``` - #include "hitrace/trace.h" + #include "hitrace/tracechain.h" ``` 在业务类实现源文件中使用(启动/结束跟踪): - + ``` - HiTraceIdStruct traceId = HiTraceBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); + HiTraceIdStruct traceId = HiTraceChainBegin("MyServiceFlow", HITRACE_FLAG_DEFAULT); ...... - HiTraceEnd(traceId); + HiTraceChainEnd(traceId); ``` 2. 编译设置,在BUILD.gn里增加子系统SDK依赖: - + ``` - external_deps = [ "hiviewdfx:libhitrace" ] + external_deps = [ "hiviewdfx:libhitracechain" ] ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md new file mode 100644 index 0000000000000000000000000000000000000000..43eb7d21472cf8206f517711046af4786a327516 --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -0,0 +1,347 @@ +# HiTraceMeter概述 + +## 简介 + +HiTraceMeter在OpenHarmony中,为开发者提供业务流程调用链跟踪的维测接口。通过使用该接口所提供的功能,可以帮助开发者迅速获取指定业务流程调用链的运行日志、定位跨设备/跨进程/跨线程的故障问题。HiTraceMeter用来支持用户态的打点,采集用户态和内核态的trace数据,从而进行性能跟踪与分析的系统。 + +## 基本概念 + +HiTraceMeter系统主要分为三部分: +- JS/C++应用打点API; +- Trace数据采集命令行工具; +- Trace数据图形分析工具。 + +其中,前两者运行在设备端侧,图形工具运行在PC主机侧。打点API部分提供了C++和JS接口,供开发过程中打点使用,打点用于产生Trace数据流,是抓Trace数据的基础条件。 + +命令行工具用于采集Trace数据,用来抓取Trace数据流并保存到文本文件。 + +Trace数据分析可以在图形工具中人工分析,也可以使用分析脚本自动化分析,Trace分析工具以Trace命令行工具的采集结果数据文件为输入。 + + HiTraceMeter跟踪数据使用类别分类,类别分类称作Trace Tag或Trace Category,一般一个端侧软件子系统对应一个Tag。该Tag在打点API中以类别Tag参数传入。Trace命令行工具采集跟踪数据时,只采集Tag类别选项指定的跟踪数据。应用程序跟踪数据标签都是属于APP Tag,从而JS接口不需要输入tag参数。目前HiTraceMeter支持的Trace Tag表如下(可在hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) 中查看): + +```cpp +constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled. +constexpr uint64_t HITRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled. +constexpr uint64_t HITRACE_TAG_DLP_CREDENTIAL = (1ULL << 21); // This tag is dlp credential service. +constexpr uint64_t HITRACE_TAG_ACCESS_CONTROL = (1ULL << 22); // This tag is access control tag. +constexpr uint64_t HITRACE_TAG_NET = (1ULL << 23); // Net tag. +constexpr uint64_t HITRACE_TAG_NWEB = (1ULL << 24); // NWeb tag. +constexpr uint64_t HITRACE_TAG_HUKS = (1ULL << 25); // This tag is huks. +constexpr uint64_t HITRACE_TAG_USERIAM = (1ULL << 26); // This tag is useriam. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_AUDIO = (1ULL << 27); // Distributed audio tag. +constexpr uint64_t HITRACE_TAG_DLSM = (1ULL << 28); // device security level tag. +constexpr uint64_t HITRACE_TAG_FILEMANAGEMENT = (1ULL << 29); // filemanagement tag. +constexpr uint64_t HITRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag. +constexpr uint64_t HITRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag. +constexpr uint64_t HITRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag. +constexpr uint64_t HITRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag. +constexpr uint64_t HITRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag. +constexpr uint64_t HITRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag. +constexpr uint64_t HITRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag. +constexpr uint64_t HITRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag. +constexpr uint64_t HITRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag. +constexpr uint64_t HITRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag. +constexpr uint64_t HITRACE_TAG_MISC = (1ULL << 41); // Notification module tag. +constexpr uint64_t HITRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag. +constexpr uint64_t HITRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag. +constexpr uint64_t HITRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag. +constexpr uint64_t HITRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag. +constexpr uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag. +constexpr uint64_t HITRACE_TAG_ARK = (1ULL << 47); // ARK tag. +constexpr uint64_t HITRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag. +constexpr uint64_t HITRACE_TAG_ACCOUNT_MANAGER = (1ULL << 49); // account manager tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCREEN = (1ULL << 50); // Distributed screen tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_CAMERA = (1ULL << 51); // Distributed camera tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK = (1ULL << 52); // Distributed hardware fwk tag. +constexpr uint64_t HITRACE_TAG_GLOBAL_RESMGR = (1ULL << 53); // Global resource manager tag. +constexpr uint64_t HITRACE_TAG_DEVICE_MANAGER = (1ULL << 54); // Distributed hardware devicemanager tag. +constexpr uint64_t HITRACE_TAG_SAMGR = (1ULL << 55); // SA tag. +constexpr uint64_t HITRACE_TAG_POWER = (1ULL << 56); // power manager tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCHEDULE = (1ULL << 57); // Distributed schedule tag. +constexpr uint64_t HITRACE_TAG_DEVICE_PROFILE = (1ULL << 58); // device profile tag. +constexpr uint64_t HITRACE_TAG_DISTRIBUTED_INPUT = (1ULL << 59); // Distributed input tag. +constexpr uint64_t HITRACE_TAG_BLUETOOTH = (1ULL << 60); // bluetooth tag. +constexpr uint64_t HITRACE_TAG_ACCESSIBILITY_MANAGER = (1ULL << 61); // accessibility manager tag. +constexpr uint64_t HITRACE_TAG_APP = (1ULL << 62); // App tag. + +constexpr uint64_t HITRACE_TAG_LAST = HITRACE_TAG_APP; +constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization. +constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST); +``` + +## 实现原理 + +HiTraceMeter主要提供抓取用户态和内核态Trace数据的命令行工具,提供用户态打点的innerkits接口(c++)和kits接口(js),HiTraceMeter基于内核ftrace提供的用户态打点的扩展,利用ftrace的trace_marker节点,将用户空间通过打点接口写入的数据写进内核循环buffer缓冲区。其基本架构图如下: + + + +![输入图片说明](figures/HiTraceMeter.png) + + + + +## 约束与限制 + +- HiTraceMeter所有功能与接口的实现都依赖于内核提供的ftrace功能,ftrace 是内核提供的一个 framework,采用 plugin 的方式支持开发人员添加更多种类的 trace 功能,因此使用HiTraceMeter之前要使能 ftrace,否则HiTraceMeter的功能无法使用(目前大部分Linux内核默认使能了ftrace,关于ftrace的详细介绍可查看内核ftrace相关资料 + [ftrace相关资料](https://blog.csdn.net/Luckiers/article/details/124646205) )。 +- HiTraceMeter仅限小型系统、标准系统下使用。 + + + +# HiTraceMeter开发指导 + +HiTraceMeter分为JS/C++应用打点API与数据采集命令行工具hitrace,下面分别介绍接口和命令行工具。 + + + + +## 场景介绍 + +在实际开发过程中,开发者可能会遇到app卡顿或者在代码调试过程中需要查看代码调用流程,HiTraceMeter接口提供了相应的接口来跟踪程序延时和代码调用流程,分析性能问题。 + +## 接口说明 + +C++接口仅系统开发者使用,JS(目前暂未开放js接口)应用开发者可以略过本节。标准系统上接口描述如下(hitrace_meter.h [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h) ): + +**表 1** 同步接口 + +| Sync 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参数用于限流,使用默认值即可。 + +**表 2** 异步接口 + +| Async trace | 功能描述 |参数说明 | +| ------------------------------------------------------------ | ------------- |------------- | +| 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。 | + + + +异步接口StartAsyncTrace和FinishAsyncTrace的跟踪数据匹配时,使用参数中的value和taskId配对匹配,可以不按顺序使用,主要用于异步场景。在C++程序中,使用异步跟踪的场景很少。 + +**表 3** 计数器接口 + +| Counter Trace | 功能描述 |参数说明 | +| ------------------------------------------------------------ | --------- |--------- | +| void CountTrace(uint64_t label, const std::string& name, int64_t); | 计数trace |label: Trace category。
    name: Trace的名称,IDE中会以此字段展示这段Trace。 | + + +## 开发步骤 +1. 编译依赖添加,需要修改的编译配置文件base\hiviewdfx\hitrace\cmd\BUILD.gn 。 + + ``` + external_deps = [ "hitrace_native:hitrace_meter"] + ``` +2. 头文件依赖添加。 + + ```cpp + #include "hitrace_meter.h"//接口函数定义头文件 + ``` + +3. 接口调用示例。 + + + ```cpp + #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; + } + + ``` + +4. 使用方法,打点编译部署完成后,运行下面命令行来抓取Trace。然后在端侧shell里运行应用,可以抓取到Trace数据。 + + ``` + hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace + ``` + + 抓取之后的数据可以在smartperf中"Open trace file"或者直接拖入图形区打开,关于smartperf的详细介绍可查看 [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf) 。 + +## 调测验证 + +以下为一个demo调试过程,该demo使用了同步接口中的StartTrace和FinishTrace。 + +1. 编写测试代码hitrace_example.cpp( [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) ),将使用到的接口加入代码: + + ```cpp + int main() + { + thread t1(ThreadFunc1); + t1.join(); + + StartTrace(LABEL, "testStart"); + sleep(SLEEP_ONE_SECOND); + + StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // 打印起始点 + FuncA(); + FinishTrace(LABEL); + sleep(SLEEP_TWO_SECOND); + + thread t2(ThreadFunc2); + t2.join(); + + StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND); + FuncB(); + FinishTrace(LABEL);// 打印结束点 + sleep(SLEEP_TWO_SECOND); + + sleep(SLEEP_ONE_SECOND); + FinishTrace(LABEL); + FuncC(); + + return 0; + } + ``` + +2. 修改gn编译文件并编译,编译配置文件路径base\hiviewdfx\hitrace\cmd\BUILD.gn 。 + + ``` + ohos_executable("hitrace_example") { + sources = [ "example/hitrace_example.cpp" ] + + external_deps = [ "hitrace_native:hitrace_meter" ] + + subsystem_name = "hiviewdfx" + part_name = "hitrace_native" + } + + group("hitrace_target") { + deps = [ + ":hitrace", + ":hitrace_example", + ] + } + ``` + +3. 将编译出来的hitrace_example可执行文件放到设备中的/system/bin目录下,在shell中执行hitrace_example。 + + ``` + <...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart + <...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart + <...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650| + <...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111 + <...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart + <...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650| + <...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1 + <...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2 + <...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3 + <...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4 + <...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5 + <...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925 + <...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641 + ``` + + + +# HiTraceMeter命令行工具使用指导 + +HiTraceMeter提供了可执行的二进制程序hitrace,设备刷openharmony后直接在shell中运行以下命令,抓取内核运行的数据,当前支持的操作如下: + +**表 4** 命令行列表 + +| Option | Description | +| ------------------------------ | ------------------------------------------------------------ | +| -h,--help | 查看option帮助 | +| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB | +| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 | +| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot | +| --trace_begin | 启动抓trace | +| --trace_dump | 将数据输出到指定位置(默认控制台) | +| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) | +| -l,--list_categories | 输出手机能支持的trace模块 | +| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) | +| -o filename,--output filename | 指定输出的目标文件名称 | +| -z | 抓取trace后进行压缩 | + +以下是常用hitrace命令示例,供开发者参考: + +- 查询支持的label。 + + ``` + hitrace -l + ``` + + 或者 + + ``` + hitrace --list_categories + ``` + + +- 设置4M缓存,抓取10秒,抓取label为ability的trace信息。 + + ``` + hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` + + +- 设置trace的输出时钟为mono。 + + ``` + hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` + + +- 抓取trace后进行压缩。 + + ``` + hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace + ``` + + + +# 常见问题 + +### hitrace抓数据不全或者没抓到数据 + +#### 现象描述 + + 执行hitrace命令抓数据不全或者没抓到数据。 + +#### 解决方法 + + 参数-t 时间设置过小或者-b缓冲区buffer设置过小导致数据丢失,可设置-t 60,-b 204800扩大抓trace时间和缓冲区buffer解决。 + + + +# 参考 + +更多关于HiTraceMeter的详细内容请参考:[hiviewdfx_hitrace: A Lightweight Distributed Tracing | 轻量级的分布式调用链跟踪 (gitee.com)](https://gitee.com/openharmony/hiviewdfx_hitrace) 。 + diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md old mode 100755 new mode 100644 index 6f258b47c5f8a1ca074ebf3252efbceb3c8a5381..f1c06a3c423a210fc491f7fe9c994ff242146cc9 --- a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md @@ -9,7 +9,7 @@ - HiLog流水日志,轻量系统类设备(参考内存≥128KiB)、小型系统类设备(参考内存≥1MiB)、标准系统类设备(参考内存≥128MB)适用。 -- HiTrace分布式跟踪,标准系统类设备(参考内存≥128MiB)适用。 +- HiTraceChain分布式跟踪,标准系统类设备(参考内存≥128MiB)适用。 - HiCollie卡死故障检测,标准系统类设备(参考内存≥128MiB)适用。 @@ -45,3 +45,4 @@ **系统事件:** 是OpenHarmony系统某种状态产生的一种标识,通过定义各种事件用于分析系统的状态变化情况。 + 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/readme/ARK-Runtime-Subsystem-zh.md b/zh-cn/readme/ARK-Runtime-Subsystem-zh.md index ed7dadfeebf8e3b6d52151abf6331bcb7eb13035..219299721d153e1bef8724a85e7ca96145e7dcec 100644 --- a/zh-cn/readme/ARK-Runtime-Subsystem-zh.md +++ b/zh-cn/readme/ARK-Runtime-Subsystem-zh.md @@ -12,13 +12,13 @@ ArkCompiler JS Runtime分成两个部分,分别是JS编译工具链与JS运行时。JS工具链将JS源码编译成方舟字节码\(ArkCompiler Bytecode\),JS运行时负责执行生成的方舟字节码\(后续如无特殊说明,字节码特指方舟字节码\)。 -图1 JS编译工具链架构: +**图1** JS编译工具链架构: ![](figures/zh-cn_image_ark_frontend.png) ArkCompiler JS Runtime的源码编译器接收JS源码的输入,再由ts2abc(将JavaScript文件转换为字节码的工具)生成abc文件。 -图2 JS运行时\(Ark-JS-Runtime\)架构: +**图2** JS运行时\(Ark-JS-Runtime\)架构: ![](figures/zh-cn_image_ark-js-arch.png) @@ -73,9 +73,9 @@ JS Runtime主要由四个子系统组成: ``` /ark -├── js_runtime # JS运行时组件 -├── runtime_core # 运行时公共组件 -└── ts2abc # JS语言的前端工具 +├── ets_runtime # JS运行时组件 +├── runtime_core # 运行时公共组件 +└── ets_frontend # JS语言的前端工具 ``` ## 使用指南 @@ -84,8 +84,8 @@ JS Runtime主要由四个子系统组成: ## 相关仓 -[ark\_runtime\_core](https://gitee.com/openharmony/ark_runtime_core) +[arkcompiler\_runtime\_core](https://gitee.com/openharmony/arkcompiler_runtime_core) -[ark\_js\_runtime](https://gitee.com/openharmony/ark_js_runtime) +[arkcompiler\_ets\_runtime](https://gitee.com/openharmony/arkcompiler_ets_runtime) -[ark\_ts2abc](https://gitee.com/openharmony/ark_ts2abc) +[arkcompiler\_ets\_frontend](https://gitee.com/openharmony/arkcompiler_ets_frontend) \ No newline at end of file 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/readme/figures/build_framework_ZN.png b/zh-cn/readme/figures/build_framework_ZN.png new file mode 100644 index 0000000000000000000000000000000000000000..c969b8364b42e032465e94a0d10ad602c77c715e Binary files /dev/null and b/zh-cn/readme/figures/build_framework_ZN.png differ diff --git "a/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" index c1985c112ff950f188a2c5ede068828ec7db7b11..f55f7079d0f5b2fe5787fbc248913a71dc6c2fbd 100644 --- "a/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\274\226\350\257\221\346\236\204\345\273\272\345\255\220\347\263\273\347\273\237.md" @@ -6,7 +6,7 @@ - 根据产品配置可以按照组件组装打包产品需要的能力。 -## 基本概念 +## 简介 在了解编译构建子系统的能力前,应了解如下基本概念: @@ -31,6 +31,51 @@ ninja是一个专注于速度的小型构建系统。 +## 目录 + +```text +/build # 编译构建主目录 + +├── __pycache__ +├── build_scripts/ # 编译相关的python脚本 +├── common/ +├── config/ # 编译相关的配置项 +├── core +│ ├── gn/ # 编译入口BUILD.gn配置 +│ └── build_scripts/ +├── docs +├── gn_helpers.py* +├── lite/ # hb和preloader入口 +├── misc/ +├── ohos # OpenHarmony编译打包流程配置 +│ ├── kits # kits编译打包模板和处理流程 +│ ├── ndk # ndk模板和处理流程 +│ ├── notice # notice模板和处理流程 +│ ├── packages # 版本打包模板和处理流程 +│ ├── sa_profile # sa模板和处理流程 +│ ├── sdk # sdk模板和处理流程,包括sdk中包含的模块配置 +│ └── testfwk # 测试相关的处理 +├── ohos.gni* # 汇总了常用的gni文件,方便各个模块一次性import +├── ohos_system.prop +├── ohos_var.gni* +├── prebuilts_download.sh* # 预编译脚本 +├── print_python_deps.py* +├── scripts/ +├── subsystem_config.json +├── subsystem_config_example.json +├── templates/ # c/c++编译模板定义 +├── test.gni* +├── toolchain # 编译工具链配置 +├── tools # 常用工具 +├── version.gni +├── zip.py* +``` + + +**图 1** 编译构建子系统架构图 +![](figures/build_framework_ZN.png "编译构建子系统架构图") + + ## 运作机制 OpenHarmony侧的编译构建流程主要包括以下三个步骤: @@ -51,9 +96,7 @@ OpenHarmony侧的编译构建流程主要包括以下三个步骤: ## 相关仓 -**编译构建子系统** - -[build\_lite](https://gitee.com/openharmony/build_lite) +[build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README_zh.md) -[build](https://gitee.com/openharmony/build) +[build](https://gitee.com/openharmony/build/blob/master/README_zh.md) diff --git "a/zh-cn/readme/\347\275\221\347\273\234\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\275\221\347\273\234\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" index 2603d7dac1e653453732807e44956fdd6097c254..5a138c74e854c22b2dd9589b4903f830b9de762c 100644 --- "a/zh-cn/readme/\347\275\221\347\273\234\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\275\221\347\273\234\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" @@ -3,7 +3,7 @@ ## 简介 -网络管理子系统,作为设备联网的必备组件,提供了对不同类型网络连接的统一管理、流量管理、策略管理、网络共享,并提供了网络协议栈能力。应用可以通过调用API来获取数据网络的连接信息,查询和订阅数据网络的连接状态,网络流量数据,网路策略以及网络共享等,并可通过网络协议栈进行数据传输。 +网络管理子系统,作为设备联网的必备组件,提供了对不同类型网络连接的统一管理、流量管理、策略管理、网络共享,并提供了网络协议栈能力。应用可以通过调用API来获取数据网络的连接信息,查询和订阅数据网络的连接状态,网络流量数据,网络策略以及网络共享等,并可通过网络协议栈进行数据传输。 下图所示为网络管理子系统架构图。各个部件主要作用如下: @@ -67,7 +67,7 @@ foundation/communication/ conn.unregister((err, data) => {}); ``` -### 网路共享 +### 网络共享 1. 从@ohos.net.sharing中导入sharing命名空间。 2. 设定共享类型 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-beta2/readme.md b/zh-cn/release-notes/api-change/v3.2-beta2/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..8476b049c4b72aa66a01b0a2f14ead8c112afcec --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/readme.md @@ -0,0 +1,35 @@ +# Readme + +本目录记录了OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本的API变化,包括新增、变更、废弃、删除。 + +- JS API差异报告 + - [元能力](js-apidiff-ability.md) + - [无障碍](js-apidiff-accessibility.md) + - [帐号](js-apidiff-account.md) + - [ArkUI](js-apidiff-arkui.md) + - [包管理](js-apidiff-bundle.md) + - [基础通信](js-apidiff-communicate.md) + - [公共基础库](js-apidiff-compiler-and-runtime.md) + - [DFX](js-apidiff-dfx.md) + - [分布式数据管理](js-apidiff-distributed-data.md) + - [事件通知](js-apidiff-event-and-notification.md) + - [文件管理](js-apidiff-file-management.md) + - [位置服务](js-apidiff-geolocation.md) + - [全球化](js-apidiff-global.md) + - [图形图像](js-apidiff-graphic.md) + - [Misc](js-apidiff-misc.md) + - [多模输入](js-apidiff-multi-modal-input.md) + - [多媒体](js-apidiff-multimedia.md) + - [资源调度](js-apidiff-resource-scheduler.md) + - [安全](js-apidiff-security.md) + - [泛Sensor](js-apidiff-sensor.md) + - [分布式软总线](js-apidiff-soft-bus.md) + - [测试框架](js-apidiff-unitest.md) + - [升级服务](js-apidiff-update.md) + - [USB服务](js-apidiff-usb.md) + - [用户身份认证](js-apidiff-user-authentication.md) + - [Web](js-apidiff-web.md) + - [窗口管理](js-apidiff-window.md) +- 变更说明 + - [3.2 beta2相对3.2 beta1变更详细说明](changelog-v3.2-beta2.md) + - [OpenHarmony启用应用沙箱机制-适配指导](application-sandbox-adaptation-guide.md) 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/js-apidiff-ability.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..6534f50cb897a8d9f41d55ec99a548e76b711de4 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-ability.md @@ -0,0 +1,106 @@ +# 元能力子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,元能力子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| abilityDelegator | AbilityDelegator | waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void;
    waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback\): void;
    waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise\; | 新增 | +| abilityDelegator | AbilityDelegator | removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void;
    removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; | 新增 | +| abilityDelegator | AbilityDelegator | addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\): void;
    addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; | 新增 | +| abilityStageMonitor | AbilityStageMonitor | srcEntrance: string; | 新增 | +| abilityStageMonitor | AbilityStageMonitor | moduleName: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly iconIndex: number; | 新增 | +| applicationInfo | ApplicationInfo | readonly labelIndex: number; | 新增 | +| ApplicationStateObserver | ApplicationStateObserver | onProcessStateChanged(processData: ProcessData): void; | 新增 | +| context | Context | getExternalCacheDir(callback: AsyncCallback\): void
    getExternalCacheDir(): Promise\; | 新增 | +| lifecycle | LifecycleForm | onShare?(formId: string): {[key: string]: any}; | 新增 | +| MissionListener | MissionListener | onMissionClosed(mission: number): void; | 新增 | +| ohos.ability.wantConstant | Action | DLP_PARAMS_INDEX = "ohos.dlp.params.index" | 新增 | +| ohos.ability.wantConstant | Action | DLP_PARAMS_ABILITY_NAME = "ohos.dlp.params.abilityName" | 新增 | +| ohos.ability.wantConstant | Action | DLP_PARAMS_MODULE_NAME = "ohos.dlp.params.moduleName" | 新增 | +| ohos.ability.wantConstant | Action | DLP_PARAMS_BUNDLE_NAME = "ohos.dlp.params.bundleName" | 新增 | +| ohos.ability.wantConstant | Action | DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox" | 新增 | +| ohos.ability.wantConstant | Action | ACTION_MARKET_CROWDTEST = "ohos.want.action.marketCrowdTest" | 新增 | +| ohos.ability.wantConstant | Action | ACTION_MARKET_DOWNLOAD = "ohos.want.action.marketDownload" | 新增 | +| ohos.abilityAccessCtrl | PermissionStateChangeInfo | permissionName: string; | 新增 | +| ohos.abilityAccessCtrl | PermissionStateChangeInfo | tokenID: number; | 新增 | +| ohos.abilityAccessCtrl | PermissionStateChangeInfo | change: PermissionStateChangeType; | 新增 | +| ohos.abilityAccessCtrl | PermissionStateChangeType | PERMISSION_GRANTED_OPER = 1 | 新增 | +| ohos.abilityAccessCtrl | PermissionStateChangeType | PERMISSION_REVOKED_OPER = 0 | 新增 | +| ohos.abilityAccessCtrl | AtManager | off(type: 'permissionStateChange', tokenIDList: Array\, permissionNameList: Array\, callback?: Callback\): void; | 新增 | +| ohos.abilityAccessCtrl | AtManager | on(type: 'permissionStateChange', tokenIDList: Array\, permissionNameList: Array\, callback: Callback\): void; | 新增 | +| ohos.abilityAccessCtrl | AtManager | getVersion(): Promise\; | 新增 | +| ohos.application.Ability | Ability | onMemoryLevel(level: AbilityConstant.MemoryLevel): void; | 新增 | +| ohos.application.AbilityConstant | WindowMode | WINDOW_MODE_FLOATING = 102 | 新增 | +| ohos.application.AbilityConstant | WindowMode | WINDOW_MODE_SPLIT_SECONDARY = 101 | 新增 | +| ohos.application.AbilityConstant | WindowMode | WINDOW_MODE_SPLIT_PRIMARY = 100 | 新增 | +| ohos.application.AbilityConstant | WindowMode | WINDOW_MODE_FULLSCREEN = 1 | 新增 | +| ohos.application.AbilityConstant | WindowMode | WINDOW_MODE_UNDEFINED = 0 | 新增 | +| ohos.application.AbilityConstant | MemoryLevel | MEMORY_LEVEL_CRITICAL = 2 | 新增 | +| ohos.application.AbilityConstant | MemoryLevel | MEMORY_LEVEL_LOW = 1 | 新增 | +| ohos.application.AbilityConstant | MemoryLevel | MEMORY_LEVEL_MODERATE = 0 | 新增 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void; | 新增 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void; | 新增 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void; | 新增 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void; | 新增 | +| ohos.application.AbilityStage | AbilityStage | onMemoryLevel(level: AbilityConstant.MemoryLevel): void; | 新增 | +| ohos.application.appManager | ProcessState | STATE_DESTROY | 新增 | +| ohos.application.appManager | ProcessState | STATE_BACKGROUND | 新增 | +| ohos.application.appManager | ProcessState | STATE_ACTIVE | 新增 | +| ohos.application.appManager | ProcessState | STATE_FOREGROUND | 新增 | +| ohos.application.appManager | ProcessState | STATE_CREATE | 新增 | +| ohos.application.appManager | ApplicationState | STATE_DESTROY | 新增 | +| ohos.application.appManager | ApplicationState | STATE_BACKGROUND | 新增 | +| ohos.application.appManager | ApplicationState | STATE_ACTIVE | 新增 | +| ohos.application.appManager | ApplicationState | STATE_FOREGROUND | 新增 | +| ohos.application.appManager | ApplicationState | STATE_CREATE | 新增 | +| ohos.application.Configuration | Configuration | hasPointerDevice?: boolean; | 新增 | +| ohos.application.context | AreaMode | EL2 = 1 | 新增 | +| ohos.application.context | AreaMode | EL1 = 0 | 新增 | +| ohos.application.formError | FormError | ERR_DISTRIBUTED_SCHEDULE_FAILED = 37 | 新增 | +| ohos.application.FormExtension | FormExtension | onShare?(formId: string): {[key: string]: any}; | 新增 | +| ohos.application.formHost | formHost | function shareForm(formId: string, deviceId: string, callback: AsyncCallback\): void;
    function shareForm(formId: string, deviceId: string): Promise\; | 新增 | +| ohos.application.formInfo | VisibilityType | FORM_INVISIBLE: number | 新增 | +| ohos.application.formInfo | VisibilityType | FORM_VISIBLE: number, | 新增 | +| ohos.application.formInfo | FormDimension | Dimension_2_1 | 新增 | +| ohos.application.formInfo | FormDimension | Dimension_4_4 | 新增 | +| ohos.application.formInfo | FormDimension | Dimension_2_4 | 新增 | +| ohos.application.formInfo | FormDimension | Dimension_2_2 | 新增 | +| ohos.application.formInfo | FormDimension | Dimension_1_2 = 1 | 新增 | +| ohos.application.formInfo | FormParam | DEVICE_ID_KEY = "ohos.extra.param.key.device_id" | 新增 | +| ohos.application.formInfo | FormParam | ABILITY_NAME_KEY = "ohos.extra.param.key.ability_name" | 新增 | +| ohos.application.formInfo | FormParam | BUNDLE_NAME_KEY = "ohos.extra.param.key.bundle_name" | 新增 | +| ohos.application.quickFixManager | quickFixManager | function getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\): void;
    function getApplicationQuickFixInfo(bundleName: string): Promise\; | 新增 | +| ohos.application.quickFixManager | quickFixManager | function applyQuickFix(hapModuleQuickFixFiles: Array\, callback: AsyncCallback\): void;
    function applyQuickFix(hapModuleQuickFixFiles: Array\): Promise\; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly hapModuleQuickFixInfo: Array\; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly quickFixVersionName: string; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly quickFixVersionCode: number; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly bundleVersionName: string; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly bundleVersionCode: number; | 新增 | +| ohos.application.quickFixManager | ApplicationQuickFixInfo | readonly bundleName: string; | 新增 | +| ohos.application.quickFixManager | HapModuleQuickFixInfo | readonly quickFixFilePath: string; | 新增 | +| ohos.application.quickFixManager | HapModuleQuickFixInfo | readonly originHapHash: string; | 新增 | +| ohos.application.quickFixManager | HapModuleQuickFixInfo | readonly moduleName: string; | 新增 | +| ProcessData | ProcessData | isKeepAlive: boolean; | 新增 | +| ProcessData | ProcessData | isContinuousTask: boolean; | 新增 | +| ProcessData | ProcessData | state: number; | 新增 | +| ServiceExtensionContext | ServiceExtensionContext | startAbilityByCall(want: Want): Promise\; | 新增 | +| ohos.ability.wantConstant | Action | ACTION_MARKER_DOWNLOAD = "ohos.want.action.marketDownload" | 删除 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityWindowStageDestroy(ability: Ability): void; | 删除 | +| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityWindowStageCreate(ability: Ability): void; | 删除 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | getType?(uri: string, callback: AsyncCallback\): void; | 删除 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | openFile?(uri: string, mode: string, callback: AsyncCallback\): void; | 删除 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\>): void; | 删除 | +| applicationInfo | ApplicationInfo | readonly iconId: string; | 废弃 | +| applicationInfo | ApplicationInfo | readonly labelId: string; | 废弃 | +| want | Want | entities?: Array\; | 废弃 | +| want | Want | parameters?: {[key: string]: any}; | 废弃 | +| want | Want | action?: string; | 废弃 | +| want | Want | flags?: number; | 废弃 | +| want | Want | type?: string; | 废弃 | +| want | Want | uri?: string; | 废弃 | +| want | Want | abilityName?: string; | 废弃 | +| want | Want | bundleName?: string; | 废弃 | +| want | Want | deviceId?: string; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-accessibility.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-accessibility.md new file mode 100644 index 0000000000000000000000000000000000000000..5ac8a37598fca9dbc2d9303fd9f5f125eceddf81 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-accessibility.md @@ -0,0 +1,31 @@ +# 无障碍子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,无障碍子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| AccessibilityExtensionContext | AccessibilityExtensionContext | injectGesture(gesturePath: GesturePath): Promise\;
    injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void; | 新增 | +| ohos.accessibility.config | Config | off(callback?: Callback\): void; | 新增 | +| ohos.accessibility.config | Config | on(callback: Callback\): void; | 新增 | +| ohos.accessibility.config | Config | get(): Promise\;
    get(callback: AsyncCallback\): void; | 新增 | +| ohos.accessibility.config | Config | set(value: T): Promise\;
    set(value: T, callback: AsyncCallback\): void; | 新增 | +| ohos.accessibility.config | config | function off(type: 'enableAbilityListsStateChanged', callback?: Callback\): void; | 新增 | +| ohos.accessibility.config | config | function on(type: 'enableAbilityListsStateChanged', callback: Callback\): void; | 新增 | +| ohos.accessibility.config | config | function disableAbility(name: string): Promise\;
    function disableAbility(name: string, callback: AsyncCallback\): void; | 新增 | +| ohos.accessibility.config | config | function enableAbility(name: string, capability: Array\): Promise\;
    function enableAbility(name: string, capability: Array\, callback: AsyncCallback\): void; | 新增 | +| ohos.accessibility.config | config | var captionsStyle: Config\; | 新增 | +| ohos.accessibility.config | config | var captions: Config\; | 新增 | +| ohos.accessibility.config | config | var shortkeyTarget: Config\; | 新增 | +| ohos.accessibility.config | config | var shortkey: Config\; | 新增 | +| ohos.accessibility.config | config | var mouseAutoClick: Config\; | 新增 | +| ohos.accessibility.config | config | var mouseKey: Config\; | 新增 | +| ohos.accessibility.config | config | var brightnessDiscount: Config\; | 新增 | +| ohos.accessibility.config | config | var animationOff: Config\; | 新增 | +| ohos.accessibility.config | config | var contentTimeout: Config\; | 新增 | +| ohos.accessibility.config | config | var daltonizationColorFilter: Config\; | 新增 | +| ohos.accessibility.config | config | var invertColor: Config\; | 新增 | +| ohos.accessibility.config | config | var highContrastText: Config\; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | gestureInject(gesturePath: GesturePath, listener: Callback\): Promise\;
    gestureInject(gesturePath: GesturePath, listener: Callback\, callback: AsyncCallback\): void; | 删除 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | setEventTypeFilter(type: Array\): Promise\;
    setEventTypeFilter(type: Array\, callback: AsyncCallback\): boolean; | 删除 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-account.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-account.md new file mode 100644 index 0000000000000000000000000000000000000000..53a1ba205678dec59b23fe3f0d0bf2359c9c7c23 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-account.md @@ -0,0 +1,10 @@ +# 帐号子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,帐号子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.account.appAccount | AppAccountManager | getAssociatedDataSync(name: string, key: string): string; | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-arkui.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-arkui.md new file mode 100644 index 0000000000000000000000000000000000000000..e019a23130dbda6c965a4d63d53e40bc8ce7801b --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-arkui.md @@ -0,0 +1,131 @@ +# ArkUI子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,ArkUI子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ArkUI | WebAttribute | onClientAuthenticationRequest(callback: (event: {handler : ClientAuthenticationHandler, host : string, port : number, keyTypes : Array\, issuers : Array\}) => void): WebAttribute; | 新增 | +| ArkUI | WebAttribute | onSslErrorEventReceive(callback: (event: { handler: SslErrorHandler, error: SslError }) => void): WebAttribute; | 新增 | +| ArkUI | WebAttribute | onScroll(callback: (event: {xOffset: number, yOffset: number}) => void): WebAttribute; | 新增 | +| ArkUI | WebAttribute | onSearchResultReceive(callback: (event?: {activeMatchOrdinal: number, numberOfMatches: number, isDoneCounting: boolean}) => void): WebAttribute | 新增 | +| ArkUI | WebAttribute | mediaPlayGestureAccess(access: boolean): WebAttribute; | 新增 | +| ArkUI | WebAttribute | onContextMenuShow(callback: (event?: { param: WebContextMenuParam, result: WebContextMenuResult }) => boolean): WebAttribute; | 新增 | +| ArkUI | WebAttribute | onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void): WebAttribute; | 新增 | +| ArkUI | WebAttribute | textZoomRatio(textZoomRatio: number): WebAttribute; | 新增 | +| ArkUI | WebController | clearClientAuthenticationCache(): void; | 新增 | +| ArkUI | WebController | clearSslCache(): void; | 新增 | +| ArkUI | WebController | searchNext(forward: boolean): void; | 新增 | +| ArkUI | WebController | clearMatches(): void; | 新增 | +| ArkUI | WebController | searchAllAsync(searchString: string): void; | 新增 | +| ArkUI | WebController | postMessage(options: { message: WebMessageEvent, uri: string}): void; | 新增 | +| ArkUI | WebController | createWebMessagePorts(): Array\; | 新增 | +| ArkUI | WebContextMenuResult | copyImage(): void; | 新增 | +| ArkUI | WebContextMenuResult | closeContextMenu(): void; | 新增 | +| ArkUI | WebContextMenuResult | constructor(); | 新增 | +| ArkUI | WebContextMenuParam | existsImageContents(): boolean; | 新增 | +| ArkUI | WebContextMenuParam | getSourceUrl(): string; | 新增 | +| ArkUI | WebContextMenuParam | getUnfilterendLinkUrl(): string; | 新增 | +| ArkUI | WebContextMenuParam | getLinkUrl(): string; | 新增 | +| ArkUI | WebContextMenuParam | y(): number; | 新增 | +| ArkUI | WebContextMenuParam | x(): number; | 新增 | +| ArkUI | WebContextMenuParam | constructor(); | 新增 | +| ArkUI | PermissionRequest | grant(resources: Array\): void; | 新增 | +| ArkUI | PermissionRequest | getAccessibleResource(): Array\; | 新增 | +| ArkUI | PermissionRequest | getOrigin(): string; | 新增 | +| ArkUI | PermissionRequest | deny(): void; | 新增 | +| ArkUI | PermissionRequest | constructor(); | 新增 | +| ArkUI | ProtectedResourceType | MidiSysex = "TYPE_MIDI_SYSEX" | 新增 | +| ArkUI | ClientAuthenticationHandler | ignore(): void; | 新增 | +| ArkUI | ClientAuthenticationHandler | cancel(): void; | 新增 | +| ArkUI | ClientAuthenticationHandler | confirm(priKeyFile : string, certChainFile : string): void; | 新增 | +| ArkUI | ClientAuthenticationHandler | constructor(); | 新增 | +| ArkUI | SslErrorHandler | handleCancel(): void; | 新增 | +| ArkUI | SslErrorHandler | handleConfirm(): void; | 新增 | +| ArkUI | SslErrorHandler | constructor(); | 新增 | +| ArkUI | SslError | Untrusted | 新增 | +| ArkUI | SslError | DateInvalid | 新增 | +| ArkUI | SslError | HostMismatch | 新增 | +| ArkUI | SslError | Invalid | 新增 | +| ArkUI | WebMessageEvent | setPorts(ports: Array\): void; | 新增 | +| ArkUI | WebMessageEvent | getPorts(): Array\; | 新增 | +| ArkUI | WebMessageEvent | setData(data: string): void; | 新增 | +| ArkUI | WebMessageEvent | getData(): string; | 新增 | +| ArkUI | WebMessageEvent | constructor(); | 新增 | +| ArkUI | WebMessagePort | onMessageEvent(callback: (result: string) => void): void; | 新增 | +| ArkUI | WebMessagePort | postMessageEvent(message: WebMessageEvent): void; | 新增 | +| ArkUI | WebMessagePort | close(): void; | 新增 | +| ArkUI | WebMessagePort | constructor(); | 新增 | +| ArkUI | ColorFilter | constructor(value: number[]); | 新增 | +| ArkUI | TextInputAttribute | style(value: TextInputStyle): TextInputAttribute; | 新增 | +| ArkUI | TextInputStyle | Inline | 新增 | +| ArkUI | TextInputStyle | Default | 新增 | +| ArkUI | TabsAttribute | barPosition(value: BarPosition): TabsAttribute; | 新增 | +| ArkUI | SideBarContainerAttribute | sideBarPosition(value: SideBarPosition): SideBarContainerAttribute; | 新增 | +| ArkUI | SideBarPosition | End | 新增 | +| ArkUI | SideBarPosition | Start | 新增 | +| ArkUI | WindowAnimationTarget | readonly missionId: number; | 新增 | +| ArkUI | PanelAttribute | onHeightChange(callback: (value: number) => void): PanelAttribute; | 新增 | +| ArkUI | PanelAttribute | backgroundMask(color: ResourceColor): PanelAttribute; | 新增 | +| ArkUI | ListItemGroupAttribute | divider(value: {strokeWidth: Length;color?: ResourceColor;startMargin?: Length;endMargin?: Length;} \| null,): ListItemGroupAttribute; | 新增 | +| ArkUI | ListItemGroupInterface | (options?: ListItemGroupOptions): ListItemGroupAttribute; | 新增 | +| ArkUI | ListItemGroupOptions | space?: number \| string; | 新增 | +| ArkUI | ListItemGroupOptions | footer?: CustomBuilder; | 新增 | +| ArkUI | ListItemGroupOptions | header?: CustomBuilder; | 新增 | +| ArkUI | ListItemAttribute | swipeAction(value: SwipeActionOptions): ListItemAttribute; | 新增 | +| ArkUI | SwipeActionOptions | edgeEffect?: SwipeEdgeEffect; | 新增 | +| ArkUI | SwipeActionOptions | end?: CustomBuilder; | 新增 | +| ArkUI | SwipeActionOptions | start?: CustomBuilder; | 新增 | +| ArkUI | SwipeEdgeEffect | None | 新增 | +| ArkUI | SwipeEdgeEffect | Spring | 新增 | +| ArkUI | ListAttribute | sticky(value: StickyStyle): ListAttribute; | 新增 | +| ArkUI | StickyStyle | Footer = 2 | 新增 | +| ArkUI | StickyStyle | Header = 1 | 新增 | +| ArkUI | StickyStyle | None = 0 | 新增 | +| ArkUI | ImageAttribute | copyOption(value: CopyOptions): ImageAttribute; | 新增 | +| ArkUI | ImageAttribute | colorFilter(value: ColorFilter): ImageAttribute; | 新增 | +| ArkUI | GutterOption | y?: Length \| GridRowSizeOption | 新增 | +| ArkUI | GutterOption | x?: Length \| GridRowSizeOption, | 新增 | +| ArkUI | FormDimension | Dimension_2_1 | 新增 | +| ArkUI | HitTestMode | None | 新增 | +| ArkUI | HitTestMode | Transparent | 新增 | +| ArkUI | HitTestMode | Block | 新增 | +| ArkUI | HitTestMode | Default | 新增 | +| ArkUI | CopyOptions | LocalDevice = 2 | 新增 | +| ArkUI | CopyOptions | InApp = 1 | 新增 | +| ArkUI | CopyOptions | None = 0 | 新增 | +| ArkUI | Color | Transparent | 新增 | +| ArkUI | CommonMethod | focusOnTouch(value: boolean): T; | 新增 | +| ArkUI | CommonMethod | groupDefaultFocus(value: boolean): T; | 新增 | +| ArkUI | CommonMethod | defaultFocus(value: boolean): T; | 新增 | +| ArkUI | CommonMethod | hitTestBehavior(value: HitTestMode): T; | 新增 | +| ArkUI | CustomPopupOptions | arrowOffset?: Length; | 新增 | +| ArkUI | PopupOptions | arrowOffset?: Length; | 新增 | +| ArkUI | focusControl | function requestFocus(value: string): boolean; | 新增 | +| basic | BusinessError | data?: T; | 新增 | +| canvaspattern | CanvasPattern | setTransform(transform?: Matrix2D): void; | 新增 | +| canvaspattern | Matrix2D | scaleX?: number; | 新增 | +| canvaspattern | Matrix2D | rotateY?: number; | 新增 | +| canvaspattern | Matrix2D | rotateX?: number; | 新增 | +| canvaspattern | Matrix2D | scaleY?: number; | 新增 | +| canvaspattern | Matrix2D | translateX?: number; | 新增 | +| canvaspattern | Matrix2D | translateY?: number; | 新增 | +| canvaspattern | Matrix2D | identity(): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | invert(): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | multiply(other?: Matrix2D): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | rotate(rx?: number, ry?: number): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | translate(tx?: number, ty?: number): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | scale(sx?: number, sy?: number): Matrix2D; | 新增 | +| canvaspattern | Matrix2D | constructor(); | 新增 | +| ohos.curves | curves | function responsiveSpringMotion(response?: number, dampingFraction?: number, overlapDuration?: number): ICurve; | 新增 | +| ohos.curves | curves | function springMotion(response?: number, dampingFraction?: number, overlapDuration?: number): ICurve; | 新增 | +| ArkUI | CanvasPattern | setTransform(transform?: Matrix2D): void; | 删除 | +| ArkUI | GetterOption | y?: Length \| GridRowSizeOption | 删除 | +| ArkUI | GetterOption | x?: Length \| GridRowSizeOption, | 删除 | +| ArkUI | CopyOption | CrossDevice = 2 | 删除 | +| ArkUI | CopyOption | LocalDevice = 1 | 删除 | +| ArkUI | CopyOption | InApp = 0 | 删除 | +| ArkUI | WebAttribute | textZoomAtio(textZoomAtio: number): WebAttribute; | 废弃 | +| ArkUI | CommonMethod | touchable(value: boolean): T; | 废弃 | +| system.app | App | static requestFullWindow(options?: RequestFullWindowOptions): void; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-battery.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-battery.md new file mode 100644 index 0000000000000000000000000000000000000000..7cc610cb724ef4aaa126750f3f4781028cc5de96 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-battery.md @@ -0,0 +1,39 @@ +# 电源服务子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,电源服务子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| system.battery | Battery | static getStatus(options?: GetStatusOptions): void; | 废弃 | +| system.battery | GetStatusOptions | complete?: () => void; | 废弃 | +| system.battery | GetStatusOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.battery | GetStatusOptions | success?: (data: BatteryResponse) => void; | 废弃 | +| system.battery | BatteryResponse | level: number; | 废弃 | +| system.battery | BatteryResponse | charging: boolean; | 废弃 | +| system.brightness | Brightness | static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; | 废弃 | +| system.brightness | Brightness | static setMode(options?: SetBrightnessModeOptions): void; | 废弃 | +| system.brightness | Brightness | static getMode(options?: GetBrightnessModeOptions): void; | 废弃 | +| system.brightness | Brightness | static setValue(options?: SetBrightnessOptions): void; | 废弃 | +| system.brightness | Brightness | static getValue(options?: GetBrightnessOptions): void; | 废弃 | +| system.brightness | SetKeepScreenOnOptions | complete?: () => void | 废弃 | +| system.brightness | SetKeepScreenOnOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.brightness | SetKeepScreenOnOptions | success?: () => void; | 废弃 | +| system.brightness | SetKeepScreenOnOptions | keepScreenOn: boolean; | 废弃 | +| system.brightness | SetBrightnessModeOptions | complete?: () => void | 废弃 | +| system.brightness | SetBrightnessModeOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.brightness | SetBrightnessModeOptions | success?: () => void; | 废弃 | +| system.brightness | SetBrightnessModeOptions | mode: number; | 废弃 | +| system.brightness | GetBrightnessModeOptions | complete?: () => void; | 废弃 | +| system.brightness | GetBrightnessModeOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.brightness | GetBrightnessModeOptions | success?: (data: BrightnessModeResponse) => void; | 废弃 | +| system.brightness | BrightnessModeResponse | mode: number; | 废弃 | +| system.brightness | SetBrightnessOptions | complete?: () => void | 废弃 | +| system.brightness | SetBrightnessOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.brightness | SetBrightnessOptions | success?: () => void; | 废弃 | +| system.brightness | SetBrightnessOptions | value: number; | 废弃 | +| system.brightness | GetBrightnessOptions | complete?: () => void; | 废弃 | +| system.brightness | GetBrightnessOptions | fail?: (data: string, code: number) => void; | 废弃 | +| system.brightness | GetBrightnessOptions | success?: (data: BrightnessResponse) => void; | 废弃 | +| system.brightness | BrightnessResponse | value: number; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-bundle.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-bundle.md new file mode 100644 index 0000000000000000000000000000000000000000..ffd13f792eafa28b59fc94e5dd9ac76f09f1c17c --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-bundle.md @@ -0,0 +1,14 @@ +# 包管理子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,包管理子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| dispatchInfo | DispatchInfo | readonly version: string; | 新增 | +| ohos.bundle | bundle | function getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo;
    function getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo; | 新增 | +| ohos.bundle | bundle | function getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number) : ApplicationInfo;
    function getApplicationInfoSync(bundleName: string, bundleFlags: number) : ApplicationInfo; | 新增 | +| ohos.bundle | ExtensionAbilityType | PREVIEW = 14 | 新增 | +| ohos.bundle | ExtensionAbilityType | THUMBNAIL = 13 | 新增 | +| dispatchInfo | DispatchInfo | readonly verison: string; | 删除 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-communicate.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-communicate.md new file mode 100644 index 0000000000000000000000000000000000000000..51530a735786f5f5c88c8fa1e7da4b6a26c9292e --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-communicate.md @@ -0,0 +1,12 @@ +# 基础通信子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,基础通信子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.wifi | wifi | function off(type: "deviceConfigChange", callback?: Callback\): void; | 新增 | +| ohos.wifi | wifi | function on(type: "deviceConfigChange", callback: Callback\): void; | 新增 | +| ohos.wifi | wifi | function removeUntrustedConfig(config: WifiDeviceConfig): Promise\;
    function removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback\): void; | 废弃 | +| ohos.wifi | wifi | function addUntrustedConfig(config: WifiDeviceConfig): Promise\;
    function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback\): void; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-compiler-and-runtime.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-compiler-and-runtime.md new file mode 100644 index 0000000000000000000000000000000000000000..d86006f3549140fbc034a1100d514f917651bba8 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-compiler-and-runtime.md @@ -0,0 +1,93 @@ +# 公共基础库子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,公共基础库子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.buffer | Blob | text(): Promise\; | 新增 | +| ohos.buffer | Blob | slice(start?: number, end?: number, type?: string): Blob; | 新增 | +| ohos.buffer | Blob | arrayBuffer(): Promise\; | 新增 | +| ohos.buffer | Blob | type: string; | 新增 | +| ohos.buffer | Blob | size: number; | 新增 | +| ohos.buffer | Blob | constructor(sources: string[] \| ArrayBuffer[] \| TypedArray[] \| DataView[] \| Blob[] , options?: Object); | 新增 | +| ohos.buffer | Buffer | writeUIntLE(value: number, offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | writeUIntBE(value: number, offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | writeUInt32LE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeUInt32BE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeUInt16LE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeUInt16BE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeUInt8(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeIntLE(value : number, offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | writeIntBE(value: number, offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | writeInt32LE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeInt32BE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeInt16LE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeInt16BE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeInt8(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeFloatLE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeFloatBE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeDoubleLE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeDoubleBE(value: number, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeBigUInt64LE(value: bigint, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeBigUInt64BE(value: bigint, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeBigInt64LE(value: bigint, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | writeBigInt64BE(value: bigint, offset?: number): number; | 新增 | +| ohos.buffer | Buffer | write(str: string, offset?: number, length?: number, encoding?: string): number; | 新增 | +| ohos.buffer | Buffer | toString(encoding?: string, start?: number, end?: number): string; | 新增 | +| ohos.buffer | Buffer | toJSON(): Object; | 新增 | +| ohos.buffer | Buffer | swap64(): Buffer; | 新增 | +| ohos.buffer | Buffer | swap32(): Buffer; | 新增 | +| ohos.buffer | Buffer | swap16(): Buffer; | 新增 | +| ohos.buffer | Buffer | subarray(start?: number, end?: number): Buffer; | 新增 | +| ohos.buffer | Buffer | readUIntLE(offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | readUIntBE(offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | readUInt32LE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readUInt32BE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readUInt16LE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readUInt16BE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readUInt8(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readIntLE(offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | readIntBE(offset: number, byteLength: number): number; | 新增 | +| ohos.buffer | Buffer | readInt32LE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readInt32BE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readInt16LE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readInt16BE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readInt8(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readFloatLE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readFloatBE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readDoubleLE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readDoubleBE(offset?: number): number; | 新增 | +| ohos.buffer | Buffer | readBigUInt64LE(offset?: number): bigint; | 新增 | +| ohos.buffer | Buffer | readBigUInt64BE(offset?: number): bigint; | 新增 | +| ohos.buffer | Buffer | readBigInt64LE(offset?: number): bigint; | 新增 | +| ohos.buffer | Buffer | readBigInt64BE(offset?: number): bigint; | 新增 | +| ohos.buffer | Buffer | lastIndexOf(value: string \| number \| Buffer \| Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; | 新增 | +| ohos.buffer | Buffer | entries(): IterableIterator\<[number, number]>; | 新增 | +| ohos.buffer | Buffer | values(): IterableIterator\; | 新增 | +| ohos.buffer | Buffer | keys(): IterableIterator\; | 新增 | +| ohos.buffer | Buffer | indexOf(value: string \| number \| Buffer \| Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; | 新增 | +| ohos.buffer | Buffer | includes(value: string \| number \| Buffer \| Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean; | 新增 | +| ohos.buffer | Buffer | equals(otherBuffer: Uint8Array \| Buffer): boolean; | 新增 | +| ohos.buffer | Buffer | copy(target: Buffer \| Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; | 新增 | +| ohos.buffer | Buffer | compare(target: Buffer \| Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 \| 0 \| 1; | 新增 | +| ohos.buffer | Buffer | fill(value: string \| Buffer \| Uint8Array \| number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer; | 新增 | +| ohos.buffer | Buffer | byteOffset: number; | 新增 | +| ohos.buffer | Buffer | buffer: ArrayBuffer; | 新增 | +| ohos.buffer | Buffer | length: number; | 新增 | +| ohos.buffer | buffer | function transcode(source: Buffer \| Uint8Array, fromEnc: string, toEnc: string): Buffer; | 新增 | +| ohos.buffer | buffer | function compare(buf1: Buffer \| Uint8Array, buf2: Buffer \| Uint8Array): -1 \| 0 \| 1; | 新增 | +| ohos.buffer | buffer | function isEncoding(encoding: string):boolean; | 新增 | +| ohos.buffer | buffer | function isBuffer(obj: Object): boolean; | 新增 | +| ohos.buffer | buffer | function from(array: number[]): Buffer;
    function from(arrayBuffer: ArrayBuffer \| SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
    function from(buffer: Buffer \| Uint8Array): Buffer;
    function from(object: Object, offsetOrEncoding: number \| string, length: number): Buffer;
    function from(string: String, encoding?: BufferEncoding): Buffer; | 新增 | +| ohos.buffer | buffer | function concat(list: Buffer[] \| Uint8Array[], totalLength?: number): Buffer; | 新增 | +| ohos.buffer | buffer | function byteLength(string: string \| Buffer \| TypedArray \| DataView \| ArrayBuffer \| SharedArrayBuffer, encoding?: BufferEncoding): number; | 新增 | +| ohos.buffer | buffer | function allocUninitialized(size: number): Buffer; | 新增 | +| ohos.buffer | buffer | function allocUninitializedFromPool(size: number): Buffer; | 新增 | +| ohos.buffer | buffer | function alloc(size: number, fill?: string \| Buffer \| number, encoding?: BufferEncoding): Buffer; | 新增 | +| ohos.util | TextDecoder | decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string; | 新增 | +| ohos.util | util | function parseUUID(uuid: string): Uint8Array; | 新增 | +| ohos.util | util | function randomBinaryUUID(entropyCache?: boolean): Uint8Array; | 新增 | +| ohos.util | util | function randomUUID(entropyCache?: boolean): string; | 新增 | +| ohos.worker | DedicatedWorkerGlobalScope | postMessage(messageObject: Object, transfer: Transferable[]): void;
    postMessage(messageObject: Object, options?: PostMessageOptions): void;
    postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-dfx.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-dfx.md new file mode 100644 index 0000000000000000000000000000000000000000..ac68953113e186ae058d415b344c356020d76a3b --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-dfx.md @@ -0,0 +1,32 @@ +# DFX子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,DFX子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.hiAppEvent | hiAppEvent | function clearData(): void; | 新增 | +| ohos.hiAppEvent | hiAppEvent | function removeWatcher(watcher: Watcher): void; | 新增 | +| ohos.hiAppEvent | hiAppEvent | function addWatcher(watcher: Watcher): AppEventPackageHolder; | 新增 | +| ohos.hiAppEvent | Watcher | onTrigger?: (curRow: number, curSize:number, holder:AppEventPackageHolder) => void; | 新增 | +| ohos.hiAppEvent | Watcher | appEventFilters?: AppEventFilter[]; | 新增 | +| ohos.hiAppEvent | Watcher | triggerCondition?: TriggerCondition; | 新增 | +| ohos.hiAppEvent | Watcher | name: string; | 新增 | +| ohos.hiAppEvent | AppEventFilter | eventTypes?: EventType[]; | 新增 | +| ohos.hiAppEvent | AppEventFilter | domain: string; | 新增 | +| ohos.hiAppEvent | TriggerCondition | timeOut?: number; | 新增 | +| ohos.hiAppEvent | TriggerCondition | size?: number; | 新增 | +| ohos.hiAppEvent | TriggerCondition | row?: number; | 新增 | +| ohos.hiAppEvent | AppEventPackageHolder | takeNext(): AppEventPackage; | 新增 | +| ohos.hiAppEvent | AppEventPackageHolder | setSize(size: number): void; | 新增 | +| ohos.hiAppEvent | AppEventPackageHolder | constructor(watcherName: string); | 新增 | +| ohos.hiAppEvent | AppEventPackage | data: string[]; | 新增 | +| ohos.hiAppEvent | AppEventPackage | size: number; | 新增 | +| ohos.hiAppEvent | AppEventPackage | row: number; | 新增 | +| ohos.hiAppEvent | AppEventPackage | packageId: number; | 新增 | +| ohos.hiAppEvent | AppEventInfo | params: object; | 新增 | +| ohos.hiAppEvent | AppEventInfo | eventType: EventType; | 新增 | +| ohos.hiAppEvent | AppEventInfo | name: string; | 新增 | +| ohos.hiAppEvent | AppEventInfo | domain: string; | 新增 | +| ohos.hiAppEvent | hiAppEvent | function write(eventName: string, eventType: EventType, keyValues: object): Promise\;
    function write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback\): void;
    function write(info: AppEventInfo): Promise\;
    function write(info: AppEventInfo, callback: AsyncCallback\): void; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-data.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-data.md new file mode 100644 index 0000000000000000000000000000000000000000..f5ac052ea5242d7f3ffa8c2022f649ec92dc133b --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-data.md @@ -0,0 +1,17 @@ +# 分布式数据管理子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,分布式数据管理子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.data.distributedData | KVStore | deleteBackup(files:Array\, callback: AsyncCallback\>):void;
    deleteBackup(files:Array\): Promise\>; | 新增 | +| ohos.data.distributedData | KVStore | restore(file:string, callback: AsyncCallback\):void;
    restore(file:string): Promise\; | 新增 | +| ohos.data.distributedData | KVStore | backup(file:string, callback: AsyncCallback\):void;
    backup(file:string): Promise\; | 新增 | +| ohos.data.rdb | StoreConfig | encrypt?: boolean; | 新增 | +| ohos.data.rdb | RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array\, callback: AsyncCallback\): void;
    remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array\): Promise\; | 新增 | +| ohos.data.rdb | RdbStore | batchInsert(table: string, values: Array\, callback: AsyncCallback\): void;
    batchInsert(table: string, values: Array\): Promise\; | 新增 | +| ohos.data.dataShare | DataShareHelper | getFileTypes(uri: string, mimeTypeFilter:string, callback: AsyncCallback\>): void;
    getFileTypes(uri: string, mimeTypeFilter: string): Promise\>; | 删除 | +| ohos.data.dataShare | DataShareHelper | getType(uri: string, callback: AsyncCallback\): void;
    getType(uri: string): Promise\; | 删除 | +| ohos.data.dataShare | DataShareHelper | openFile(uri: string, mode: string, callback: AsyncCallback\): void;
    openFile(uri: string, mode: string): Promise\; | 删除 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-hardware.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-hardware.md new file mode 100644 index 0000000000000000000000000000000000000000..87f783bd828d34bc518e245d14ab4adfcd9e8f90 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-distributed-hardware.md @@ -0,0 +1,19 @@ +# 分布式硬件子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,分布式硬件子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.distributedHardware.deviceManager | DeviceManager | off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceManager | on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceManager | off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceManager | on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceManager | unPublishDeviceDiscovery(publishId: number): void; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceManager | publishDeviceDiscovery(publishInfo: PublishInfo): void; | 新增 | +| ohos.distributedHardware.deviceManager | PublishInfo | ranging : boolean; | 新增 | +| ohos.distributedHardware.deviceManager | PublishInfo | freq: ExchangeFreq; | 新增 | +| ohos.distributedHardware.deviceManager | PublishInfo | mode: DiscoverMode; | 新增 | +| ohos.distributedHardware.deviceManager | PublishInfo | publishId: number; | 新增 | +| ohos.distributedHardware.deviceManager | DeviceInfo | range: number; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-event-and-notification.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-event-and-notification.md new file mode 100644 index 0000000000000000000000000000000000000000..da6438700a7a56380269f2207295a56a4bdaeacc --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-event-and-notification.md @@ -0,0 +1,18 @@ +# 事件通知子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,事件通知子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.commonEvent | Support | COMMON_EVENT_QUICK_FIX_APPLY_RESULT = "usual.event.QUICK_FIX_APPLY_RESULT" | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_USB_PORT_CHANGED = "usual.event.hardware.usb.action.USB_PORT_CHANGED" | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE" | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_PACKAGE_CACHE_CLEARED = "usual.event.PACKAGE_CACHE_CLEARED" | 新增 | +| ohos.notification | RemoveReason | CANCEL_REASON_REMOVE = 2 | 新增 | +| ohos.notification | RemoveReason | CLICK_REASON_REMOVE = 1 | 新增 | +| ohos.notification | notification | function getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): void;
    function getSyncNotificationEnabledWithoutApp(userId: number): Promise\; | 新增 | +| ohos.notification | notification | function setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\): void;
    function setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\; | 新增 | +| ohos.notification | notification | function getSyncNotificationEnabledForUninstallApp(userId: number, callback: AsyncCallback\): void;
    function getSyncNotificationEnabledForUninstallApp(userId: number): Promise\; | 删除 | +| ohos.notification | notification | function setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean, callback: AsyncCallback\): void;
    function setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean): Promise\; | 删除 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-file-management.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-file-management.md new file mode 100644 index 0000000000000000000000000000000000000000..e143ee571b2245a6c722c4f7b6071b48376ecfce --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-file-management.md @@ -0,0 +1,153 @@ +# 文件管理子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,文件管理子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.data.fileAccess | FileAccessHelper | getRoots(): Promise\;
    getRoots(callback:AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | access(sourceFileUri: string) : Promise\;
    access(sourceFileUri: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | rename(uri: string, displayName: string) : Promise\;
    rename(uri: string, displayName: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | move(sourceFile: string, destFile: string) : Promise\;
    move(sourceFile: string, destFile: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | delete(uri: string) : Promise\;
    delete(uri: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | mkDir(parentUri: string, displayName: string) : Promise\;
    mkDir(parentUri: string, displayName: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | createFile(uri: string, displayName: string) : Promise\;
    createFile(uri: string, displayName: string, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | FileAccessHelper | openFile(uri: string, flags: OPENFLAGS) : Promise\;
    openFile(uri: string, flags: OPENFLAGS, callback: AsyncCallback\) : void; | 新增 | +| ohos.data.fileAccess | OPENFLAGS | WRITE_READ = 0o2 | 新增 | +| ohos.data.fileAccess | OPENFLAGS | WRITE = 0o1 | 新增 | +| ohos.data.fileAccess | OPENFLAGS | READ = 0o0 | 新增 | +| ohos.data.fileAccess | RootIterator | next(): {value: RootInfo, done: boolean} | 新增 | +| ohos.data.fileAccess | RootInfo | scanFile(filter?: Filter): FileIterator; | 新增 | +| ohos.data.fileAccess | RootInfo | listFile(filter?: Filter): FileIterator; | 新增 | +| ohos.data.fileAccess | RootInfo | deviceFlags: number; | 新增 | +| ohos.data.fileAccess | RootInfo | displayName: string; | 新增 | +| ohos.data.fileAccess | RootInfo | uri: string; | 新增 | +| ohos.data.fileAccess | RootInfo | deviceType: number; | 新增 | +| ohos.data.fileAccess | FileIterator | next(): {value: FileInfo, done: boolean} | 新增 | +| ohos.data.fileAccess | FileInfo | scanFile(filter?: Filter): FileIterator; | 新增 | +| ohos.data.fileAccess | FileInfo | listFile(filter?: Filter): FileIterator; | 新增 | +| ohos.data.fileAccess | FileInfo | mimeType: string; | 新增 | +| ohos.data.fileAccess | FileInfo | mtime: number; | 新增 | +| ohos.data.fileAccess | FileInfo | size: number; | 新增 | +| ohos.data.fileAccess | FileInfo | mode: number; | 新增 | +| ohos.data.fileAccess | FileInfo | fileName: string; | 新增 | +| ohos.data.fileAccess | FileInfo | uri: string; | 新增 | +| ohos.data.fileAccess | fileAccess | createFileAccessHelper(context: Context): FileAccessHelper;
    createFileAccessHelper(context: Context, wants: Array\): FileAccessHelper; | 新增 | +| ohos.data.fileAccess | fileAccess | getFileAccessAbilityInfo(callback: AsyncCallback\>): void;
    getFileAccessAbilityInfo(): Promise\>; | 新增 | +| ohos.fileExtensionInfo | DocumentFlag | const SUPPORTS_WRITE = 0b1000; | 新增 | +| ohos.fileExtensionInfo | DocumentFlag | const SUPPORTS_READ = 0b100; | 新增 | +| ohos.fileExtensionInfo | DocumentFlag | const REPRESENTS_DIR = 0b10; | 新增 | +| ohos.fileExtensionInfo | DocumentFlag | const REPRESENTS_FILE = 0b1; | 新增 | +| ohos.fileExtensionInfo | DeviceFlag | const SUPPORTS_WRITE = 0b10; | 新增 | +| ohos.fileExtensionInfo | DeviceFlag | const SUPPORTS_READ = 0b1; | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_EXTERNAL_CLOUD | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_EXTERNAL_USB | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_EXTERNAL_MTP | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_NETWORK_NEIGHBORHOODS | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_SHARED_TERMINAL | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_SHARED_DISK | 新增 | +| ohos.fileExtensionInfo | DeviceType | DEVICE_LOCAL_DISK = 1 | 新增 | +| ohos.filemanagement.userfile_manager | VirtualAlbum | getFileAssets(type: Array\, options: MediaFetchOptions, callback: AsyncCallback\): void;
    getFileAssets(type: Array\, options: MediaFetchOptions): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | VirtualAlbumType | TYPE_TRASH | 新增 | +| ohos.filemanagement.userfile_manager | VirtualAlbumType | TYPE_FAVORITE | 新增 | +| ohos.filemanagement.userfile_manager | PeerInfo | readonly isOnline: boolean; | 新增 | +| ohos.filemanagement.userfile_manager | PeerInfo | readonly networkId: string; | 新增 | +| ohos.filemanagement.userfile_manager | PeerInfo | readonly deviceName: string; | 新增 | +| ohos.filemanagement.userfile_manager | Size | height: number; | 新增 | +| ohos.filemanagement.userfile_manager | Size | width: number; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | release(callback: AsyncCallback\): void;
    release(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getAllPeers(callback: AsyncCallback\>): void;
    getAllPeers(): Promise\>; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getActivePeers(callback: AsyncCallback\>): void;
    getActivePeers(): Promise\>; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getPrivateAlbum(type: VirtualAlbumType, callback: AsyncCallback\>): void;
    getPrivateAlbum(type: VirtualAlbumType): Promise\>; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getAlbums(type: Array\, options: MediaFetchOptions, callback: AsyncCallback\>): void;
    getAlbums(type: Array\, options: MediaFetchOptions): Promise\>; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | deleteAsset(uri: string, callback: AsyncCallback\): void;
    deleteAsset(uri: string): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback\): void;
    createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getFileAssets(type: Array\, options: MediaFetchOptions, callback: AsyncCallback\): void;
    getFileAssets(type: Array\, options: MediaFetchOptions): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | UserFileManager | getPublicDirectory(type: DirectoryType, callback: AsyncCallback\): void;
    getPublicDirectory(type: DirectoryType): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_DOWNLOAD | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_DOCUMENTS | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_AUDIO | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_IMAGE | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_VIDEO | 新增 | +| ohos.filemanagement.userfile_manager | DirectoryType | DIR_CAMERA = 0 | 新增 | +| ohos.filemanagement.userfile_manager | Album | getFileAssets(type: Array\, callback: AsyncCallback\): void;
    getFileAssets(type: Array\, options: MediaFetchOptions, callback: AsyncCallback\): void;
    getFileAssets(type: Array\, options?: MediaFetchOptions): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | Album | commitModify(callback: AsyncCallback\): void;
    commitModify(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | Album | readonly coverUri: string; | 新增 | +| ohos.filemanagement.userfile_manager | Album | readonly relativePath: string; | 新增 | +| ohos.filemanagement.userfile_manager | Album | readonly count: number; | 新增 | +| ohos.filemanagement.userfile_manager | Album | readonly dateModified: number; | 新增 | +| ohos.filemanagement.userfile_manager | Album | readonly albumUri: string; | 新增 | +| ohos.filemanagement.userfile_manager | Album | albumName: string; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | getPositionObject(index: number, callback: AsyncCallback\): void;
    getPositionObject(index: number): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | getLastObject(callback: AsyncCallback\): void;
    getLastObject(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | getNextObject(callback: AsyncCallback\): void;
    getNextObject(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | getFirstObject(callback: AsyncCallback\): void;
    getFirstObject(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | close(): void; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | isAfterLast(): boolean; | 新增 | +| ohos.filemanagement.userfile_manager | FetchFileResult | getCount(): number; | 新增 | +| ohos.filemanagement.userfile_manager | MediaFetchOptions | selectionArgs: Array\; | 新增 | +| ohos.filemanagement.userfile_manager | MediaFetchOptions | selections: string; | 新增 | +| ohos.filemanagement.userfile_manager | AlbumKey | DATE_MODIFIED = "date_modified" | 新增 | +| ohos.filemanagement.userfile_manager | AlbumKey | DATE_ADDED = "date_added" | 新增 | +| ohos.filemanagement.userfile_manager | AlbumKey | DISPLAY_NAME = "display_name" | 新增 | +| ohos.filemanagement.userfile_manager | AlbumKey | RELATIVE_PATH = "relative_path" | 新增 | +| ohos.filemanagement.userfile_manager | AlbumKey | URI = "uri" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | DATE_TAKEN = "date_taken" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | HEIGHT = "height" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | WIDTH = "width" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | DURATION = "duration" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | TITLE = "title" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | DATE_MODIFIED = "date_modified" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | DATE_ADDED = "date_added" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | DISPLAY_NAME = "display_name" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | RELATIVE_PATH = "relative_path" | 新增 | +| ohos.filemanagement.userfile_manager | ImageVideoKey | URI = "uri" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | DURATION = "duration" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | AUDIOALBUM = "audio_album" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | ARTIST = "artist" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | TITLE = "title" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | DATE_MODIFIED = "date_modified" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | DATE_ADDED = "date_added" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | DISPLAY_NAME = "display_name" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | RELATIVE_PATH = "relative_path" | 新增 | +| ohos.filemanagement.userfile_manager | AudioKey | URI = "uri" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | TITLE = "title" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | DATE_MODIFIED = "date_modified" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | DATE_ADDED = "date_added" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | DISPLAY_NAME = "display_name" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | RELATIVE_PATH = "relative_path" | 新增 | +| ohos.filemanagement.userfile_manager | FileKey | URI = "uri" | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | isTrash(callback: AsyncCallback\): void;
    isTrash():Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | trash(isTrash: boolean, callback: AsyncCallback\): void;
    trash(isTrash: boolean): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | isFavorite(callback: AsyncCallback\): void;
    isFavorite():Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | favorite(isFavorite: boolean, callback: AsyncCallback\): void;
    favorite(isFavorite: boolean): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | getThumbnail(callback: AsyncCallback\): void;
    getThumbnail(size: Size, callback: AsyncCallback\): void;
    getThumbnail(size?: Size): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | close(fd: number, callback: AsyncCallback\): void;
    close(fd: number): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | open(mode: string, callback: AsyncCallback\): void;
    open(mode: string): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | commitModify(callback: AsyncCallback\): void;
    commitModify(): Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | isDirectory(callback: AsyncCallback\): void;
    isDirectory():Promise\; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | displayName: string; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | readonly mediaType: MediaType; | 新增 | +| ohos.filemanagement.userfile_manager | FileAsset | readonly uri: string; | 新增 | +| ohos.filemanagement.userfile_manager | MediaType | AUDIO | 新增 | +| ohos.filemanagement.userfile_manager | MediaType | VIDEO | 新增 | +| ohos.filemanagement.userfile_manager | MediaType | IMAGE | 新增 | +| ohos.filemanagement.userfile_manager | MediaType | FILE = 0 | 新增 | +| ohos.filemanagement.userfile_manager | userfile_manager | getUserFileMgr(): UserFileManager;
    getUserFileMgr(context: Context): UserFileManager; | 新增 | +| ohos.document | document | show(uri: string, type: string): Promise\;
    show(uri: string, type: string, callback: AsyncCallback\): void; | 废弃 | +| ohos.document | document | choose(types?: string[]): Promise\;
    choose(callback: AsyncCallback\): void;
    choose(types: string[], callback: AsyncCallback\): void; | 废弃 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-global.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-global.md new file mode 100644 index 0000000000000000000000000000000000000000..83224d9afa369278044569f741b6cacce1648a74 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-global.md @@ -0,0 +1,30 @@ +# 全球化子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,全球化子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.i18n | Unicode | static getType(char: string): string; | 新增 | +| ohos.i18n | Unicode | static isUpperCase(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isLowerCase(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isLetter(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isIdeograph(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isRTL(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isWhitespace(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isSpaceChar(char: string): boolean; | 新增 | +| ohos.i18n | Unicode | static isDigit(char: string): boolean; | 新增 | +| ohos.i18n | I18NUtil | static getDateOrder(locale: string): string; | 新增 | +| ohos.i18n | I18NUtil | static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; | 新增 | +| ohos.i18n | Util | getDateOrder(locale: string): string; | 删除 | +| ohos.i18n | Character | getType(char: string): string; | 废弃 | +| ohos.i18n | Character | isUpperCase(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isLowerCase(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isLetter(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isIdeograph(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isRTL(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isWhitespace(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isSpaceChar(char: string): boolean; | 废弃 | +| ohos.i18n | Character | isDigit(char: string): boolean; | 废弃 | +| ohos.i18n | Util | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; | 废弃 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-graphic.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-graphic.md new file mode 100644 index 0000000000000000000000000000000000000000..3e3644d0290747884fd1388db3c50b3912a8a618 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-graphic.md @@ -0,0 +1,26 @@ +# 图形图像子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,图形图像子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.graphics.colorSpaceManager | colorSpaceManager | function create(colorSpaceName: ColorSpace): ColorSpaceManager;
    function create(primaries: ColorSpacePrimaries, gamma: number): ColorSpaceManager; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpaceManager | getGamma(): number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpaceManager | getWhitePoint(): Array\; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpaceManager | getColorSpaceName(): ColorSpace; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | whitePointY: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | whitePointX: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | blueY: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | blueX: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | greenY: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | greenX: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | redY: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpacePrimaries | redX: number; | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | CUSTOM = 5 | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | SRGB = 4 | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | DISPLAY_P3 = 3 | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | DCI_P3 = 2 | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | ADOBE_RGB_1998 = 1 | 新增 | +| ohos.graphics.colorSpaceManager | ColorSpace | UNKNOWN = 0 | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-misc.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-misc.md new file mode 100644 index 0000000000000000000000000000000000000000..9cddb7b6a91f4c4690d310eaa4ac6335865313d9 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-misc.md @@ -0,0 +1,76 @@ +# 杂散软件服务子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,杂散软件服务子系统的API变更如下: + +## 接口变更 + +| 模块名 | 方法/事件名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.inputmethod | InputMethodController | hideSoftKeyboard(callback: AsyncCallback\): void;
    hideSoftKeyboard():Promise\; | 新增 | +| ohos.inputmethod | InputMethodController | showSoftKeyboard(callback: AsyncCallback\): void;
    showSoftKeyboard():Promise\; | 新增 | +| ohos.inputmethod | inputMethod | getCurrentInputMethod(): InputMethodProperty; | 新增 | +| ohos.inputmethodengine | TextInputClient | moveCursor(direction: number, callback: AsyncCallback\): void;
    moveCursor(direction: number): Promise\; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | off(type: 'setCallingWindow', callback: (wid:number) => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | on(type: 'setCallingWindow', callback: (wid:number) => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | off(type: 'inputStop', callback: () => void): void; | 新增 | +| ohos.inputmethodengine | InputMethodEngine | on(type: 'inputStop', callback: () => void): void; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const CURSOR_RIGHT: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const CURSOR_LEFT: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const CURSOR_DOWN: number; | 新增 | +| ohos.inputmethodengine | inputMethodEngine | const CURSOR_UP: number; | 新增 | +| ohos.inputmethodextensionability | InputMethodExtensionAbility | onDestroy(): void; | 新增 | +| ohos.inputmethodextensionability | InputMethodExtensionAbility | onCreate(want: Want): void; | 新增 | +| ohos.inputmethodextensionability | InputMethodExtensionAbility | context: InputMethodExtensionContext; | 新增 | +| ohos.inputmethodextensioncontext | InputMethodExtensionContext | terminateSelf(callback: AsyncCallback\): void;
    terminateSelf(): Promise\; | 新增 | +| ohos.inputmethodextensioncontext | InputMethodExtensionContext | startAbility(want: Want, callback: AsyncCallback\): void;
    startAbility(want: Want, options: StartOptions, callback: AsyncCallback\): void;
    startAbility(want: Want, options?: StartOptions): Promise\; | 新增 | +| ohos.pasteboard | PasteData | setProperty(property: PasteDataProperty): void; | 新增 | +| ohos.pasteboard | PasteData | getPrimaryPixelMap(): image.PixelMap; | 新增 | +| ohos.pasteboard | PasteData | addPixelMapRecord(pixelMap: image.PixelMap): void; | 新增 | +| ohos.pasteboard | PasteDataRecord | data: { [mimeType: string]: ArrayBuffer } | 新增 | +| ohos.pasteboard | PasteDataRecord | pixelMap: image.PixelMap; | 新增 | +| ohos.pasteboard | PasteDataProperty | shareOption: ShareOption; | 新增 | +| ohos.pasteboard | ShareOption | CrossDevice | 新增 | +| ohos.pasteboard | ShareOption | LocalDevice | 新增 | +| ohos.pasteboard | ShareOption | InApp | 新增 | +| ohos.pasteboard | pasteboard | createRecord(mimeType: string, value: ArrayBuffer):PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | createPixelMapRecord(pixelMap: image.PixelMap):PasteDataRecord; | 新增 | +| ohos.pasteboard | pasteboard | createData(mimeType: string, value: ArrayBuffer): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | createPixelMapData(pixelMap: image.PixelMap): PasteData; | 新增 | +| ohos.pasteboard | pasteboard | const MIMETYPE_PIXELMAP: string; | 新增 | +| ohos.request | UploadTask | off(type:'complete' \| 'fail', callback?: Callback\>): void; | 新增 | +| ohos.request | UploadTask | off(type:'complete' \| 'fail', callback?: Callback\>): void; | 新增 | +| ohos.request | UploadTask | on(type:'complete' \| 'fail', callback: Callback\>): void; | 新增 | +| ohos.request | UploadTask | on(type:'complete' \| 'fail', callback: Callback\>): void; | 新增 | +| ohos.request | TaskState | message: string; | 新增 | +| ohos.request | TaskState | responseCode: number; | 新增 | +| ohos.request | TaskState | path: string; | 新增 | +| ohos.request | DownloadConfig | background?: boolean; | 新增 | +| ohos.screenLock | screenLock | onSystemEvent(callback: Callback\): boolean; | 新增 | +| ohos.screenLock | SystemEvent | params: string | 新增 | +| ohos.screenLock | SystemEvent | eventType: EventType, | 新增 | +| ohos.screenLock | screenLock | lockScreen(callback: AsyncCallback\): void;
    lockScreen():Promise\; | 新增 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | off(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation' \| 'screenlockEnabled' \| 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'screenlockEnabled', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginSleep' \| 'endSleep' \| 'changeUser', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | +| ohos.screenLock | screenLock | on(type: 'beginWakeUp' \| 'endWakeUp' \| 'beginScreenOn' \| 'endScreenOn' \| 'beginScreenOff' \| 'endScreenOff' \| 'unlockScreen' \| 'beginExitAnimation', callback: Callback\): void; | 删除 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multi-modal-input.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multi-modal-input.md new file mode 100644 index 0000000000000000000000000000000000000000..f578265bdd2d7ef8b6fff0def0fc69c1933a94d0 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multi-modal-input.md @@ -0,0 +1,65 @@ +# 多模输入子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,多模输入子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | off(type: 'cooperation', callback?: AsyncCallback\): void; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | on(type: 'cooperation', callback: AsyncCallback\<{ deviceDescriptor: string, eventMsg: EventMsg }>): void; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | getState(deviceDescriptor: string, callback: AsyncCallback\<{ state: boolean }>): void;
    getState(deviceDescriptor: string): Promise\<{ state: boolean }>; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | stop(callback: AsyncCallback\): void;
    stop(): Promise\; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback\): void;
    start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | inputDeviceCooperate | enable(enable: boolean, callback: AsyncCallback\): void;
    enable(enable: boolean): Promise\; | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | EventMsg | MSG_COOPERATE_STATE_OFF = 501 | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | EventMsg | MSG_COOPERATE_STATE_ON = 500 | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | EventMsg | MSG_COOPERATE_INFO_FAIL = 202 | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | EventMsg | MSG_COOPERATE_INFO_SUCCESS = 201 | 新增 | +| ohos.multimodalInput.inputDeviceCooperate | EventMsg | MSG_COOPERATE_INFO_START = 200 | 新增 | +| ohos.multimodalInput.pointer | pointer | isPointerVisible(callback: AsyncCallback\): void;
    isPointerVisible(): Promise\; | 新增 | +| ohos.multimodalInput.pointer | pointer | setPointerVisible(visible: boolean, callback: AsyncCallback\): void;
    setPointerVisible(visible: boolean): Promise\; | 新增 | +| ohos.multimodalInput.pointer | pointer | getPointerStyle(windowId: number, callback: AsyncCallback\): void;
    getPointerStyle(windowId: number): Promise\; | 新增 | +| ohos.multimodalInput.pointer | pointer | setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\): void;
    setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise\; | 新增 | +| ohos.multimodalInput.pointer | pointer | getPointerSpeed(callback: AsyncCallback\): void;
    getPointerSpeed(): Promise\; | 新增 | +| ohos.multimodalInput.pointer | pointer | setPointerSpeed(speed: number, callback: AsyncCallback\): void;
    setPointerSpeed(speed: number): Promise\; | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_SOUTH_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_SOUTH_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_NORTH_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_NORTH_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_NORTH_SOUTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_NORTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_SOUTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MIDDLE_BTN_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | ZOOM_OUT | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | ZOOM_IN | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | TEXT_CURSOR | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | SCREENSHOT_CURSOR | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | SCREENSHOT_CHOOSE | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | RESIZE_UP_DOWN | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | RESIZE_LEFT_RIGHT | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | MOVE | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | HELP | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | HAND_POINTING | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | HAND_OPEN | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | HAND_GRABBING | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | COLOR_SUCKER | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | CURSOR_FORBID | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | CURSOR_COPY | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | CROSS | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH_WEST_SOUTH_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH_EAST_SOUTH_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | SOUTH_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | SOUTH_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH_WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH_SOUTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | WEST_EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | NORTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | SOUTH | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | WEST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | EAST | 新增 | +| ohos.multimodalInput.pointer | PointerStyle | DEFAULT | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multimedia.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multimedia.md new file mode 100644 index 0000000000000000000000000000000000000000..4b4517ad55d8cb1a6f172772c645d6683e0a4695 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-multimedia.md @@ -0,0 +1,165 @@ +# 媒体子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,媒体子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.multimedia.audio | VolumeEvent | networkId: string; | 新增 | +| ohos.multimedia.audio | VolumeEvent | volumeGroupId: number; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly volumeGroupId: number; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly interruptGroupId: number; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly networkId: string; | 新增 | +| ohos.multimedia.audio | VolumeGroupInfo | readonly type: ConnectType; | 新增 | +| ohos.multimedia.audio | VolumeGroupInfo | readonly groupName: string; | 新增 | +| ohos.multimedia.audio | VolumeGroupInfo | readonly mappingId: number; | 新增 | +| ohos.multimedia.audio | VolumeGroupInfo | readonly groupId: number; | 新增 | +| ohos.multimedia.audio | VolumeGroupInfo | readonly networkId: string; | 新增 | +| ohos.multimedia.audio | ConnectType | CONNECT_TYPE_DISTRIBUTED = 2 | 新增 | +| ohos.multimedia.audio | ConnectType | CONNECT_TYPE_LOCAL = 1 | 新增 | +| ohos.multimedia.audio | AudioGroupManager | isMute(volumeType: AudioVolumeType, callback: AsyncCallback\): void;
    isMute(volumeType: AudioVolumeType): Promise\; | 新增 | +| ohos.multimedia.audio | AudioGroupManager | mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void;
    mute(volumeType: AudioVolumeType, mute: boolean): Promise\; | 新增 | +| ohos.multimedia.audio | AudioGroupManager | getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback\): void;
    getMaxVolume(volumeType: AudioVolumeType): Promise\; | 新增 | +| ohos.multimedia.audio | AudioGroupManager | getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback\): void;
    getMinVolume(volumeType: AudioVolumeType): Promise\; | 新增 | +| ohos.multimedia.audio | AudioGroupManager | getVolume(volumeType: AudioVolumeType, callback: AsyncCallback\): void;
    getVolume(volumeType: AudioVolumeType): Promise\; | 新增 | +| ohos.multimedia.audio | AudioGroupManager | setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback\): void;
    setVolume(volumeType: AudioVolumeType, volume: number): Promise\; | 新增 | +| ohos.multimedia.audio | AudioRoutingManager | selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback\): void;
    selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise\; | 新增 | +| ohos.multimedia.audio | AudioRoutingManager | selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback\): void;
    selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise\; | 新增 | +| ohos.multimedia.audio | AudioRoutingManager | off(type: 'deviceChange', callback?: Callback\): void; | 新增 | +| ohos.multimedia.audio | AudioRoutingManager | on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback\): void; | 新增 | +| ohos.multimedia.audio | AudioRoutingManager | getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback\): void;
    getDevices(deviceFlag: DeviceFlag): Promise\; | 新增 | +| ohos.multimedia.audio | AudioManager | getRoutingManager(callback: AsyncCallback\): void;
    getRoutingManager(): Promise\; | 新增 | +| ohos.multimedia.audio | AudioManager | getGroupManager(groupId: number, callback: AsyncCallback\): void;
    getGroupManager(groupId: number): Promise\; | 新增 | +| ohos.multimedia.audio | AudioManager | getVolumeGroups(networkId: string, callback: AsyncCallback\): void;
    getVolumeGroups(networkId: string): Promise\; | 新增 | +| ohos.multimedia.audio | AudioRendererFilter | rendererId?: number; | 新增 | +| ohos.multimedia.audio | AudioRendererFilter | rendererInfo?: AudioRendererInfo; | 新增 | +| ohos.multimedia.audio | AudioRendererFilter | uid: number; | 新增 | +| ohos.multimedia.audio | DeviceType | DEFAULT = 1000 | 新增 | +| ohos.multimedia.audio | DeviceFlag | ALL_DISTRIBUTED_DEVICES_FLAG = 12 | 新增 | +| ohos.multimedia.audio | DeviceFlag | DISTRIBUTED_INPUT_DEVICES_FLAG = 8 | 新增 | +| ohos.multimedia.audio | DeviceFlag | DISTRIBUTED_OUTPUT_DEVICES_FLAG = 4 | 新增 | +| ohos.multimedia.audio | DeviceFlag | NONE_DEVICES_FLAG = 0 | 新增 | +| ohos.multimedia.audio | audio | const LOCAL_NETWORK_ID: string; | 新增 | +| ohos.multimedia.image | PixelMapFormat | BGRA_8888 = 4 | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'availableBitratesCollect', callback: (bitrates: Array\) => void): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'availableBitratesCollected', callback: (bitrates: Array\) => void): void | 删除 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_TV | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_CAR | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_WATCH | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_TABLET | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_PHONE | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_LAPTOP | 废弃 | +| ohos.multimedia.mediaLibrary | DeviceType | TYPE_UNKNOWN = 0 | 废弃 | +| ohos.multimedia.mediaLibrary | PeerInfo | readonly isOnline: boolean; | 废弃 | +| ohos.multimedia.mediaLibrary | PeerInfo | readonly deviceType: DeviceType; | 废弃 | +| ohos.multimedia.mediaLibrary | PeerInfo | readonly networkId: string; | 废弃 | +| ohos.multimedia.mediaLibrary | PeerInfo | readonly deviceName: string; | 废弃 | +| ohos.multimedia.mediaLibrary | Size | height: number; | 废弃 | +| ohos.multimedia.mediaLibrary | Size | width: number; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | release(callback: AsyncCallback\): void;
    release(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getAllPeers(callback: AsyncCallback\>): void;
    getAllPeers(): Promise\>; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getActivePeers(callback: AsyncCallback\>): void;
    getActivePeers(): Promise\>; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getAlbums(options: MediaFetchOptions, callback: AsyncCallback\>): void;
    getAlbums(options: MediaFetchOptions): Promise\>; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | deleteAsset(uri: string, callback: AsyncCallback\): void;
    deleteAsset(uri: string): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback\): void;
    createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\): void; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\): void;
    getFileAssets(options: MediaFetchOptions): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaLibrary | getPublicDirectory(type: DirectoryType, callback: AsyncCallback\): void;
    getPublicDirectory(type: DirectoryType): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_DOWNLOAD | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_DOCUMENTS | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_AUDIO | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_IMAGE | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_VIDEO | 废弃 | +| ohos.multimedia.mediaLibrary | DirectoryType | DIR_CAMERA = 0 | 废弃 | +| ohos.multimedia.mediaLibrary | Album | getFileAssets(callback: AsyncCallback\): void;
    getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\): void;
    getFileAssets(options?: MediaFetchOptions): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | commitModify(callback: AsyncCallback\): void;
    commitModify(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly coverUri: string; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly relativePath: string; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly count: number; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly dateModified: number; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly albumUri: string; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | albumName: string; | 废弃 | +| ohos.multimedia.mediaLibrary | Album | readonly albumId: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getAllObject(callback: AsyncCallback\>): void;
    getAllObject(): Promise\>; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getPositionObject(index: number, callback: AsyncCallback\): void;
    getPositionObject(index: number): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getLastObject(callback: AsyncCallback\): void;
    getLastObject(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getNextObject(callback: AsyncCallback\): void;
    getNextObject(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getFirstObject(callback: AsyncCallback\): void;
    getFirstObject(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | close(): void; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | isAfterLast(): boolean; | 废弃 | +| ohos.multimedia.mediaLibrary | FetchFileResult | getCount(): number; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | extendArgs?: string; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | networkId?: string; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | uri?: string; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | order?: string; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | selectionArgs: Array\; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaFetchOptions | selections: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | ALBUM_NAME = "bucket_display_name" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | ALBUM_ID = "bucket_id" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | ORIENTATION = "orientation" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | HEIGHT = "height" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | WIDTH = "width" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | DURATION = "duration" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | AUDIOALBUM = "audio_album" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | ARTIST = "artist" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | TITLE = "title" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_TAKEN = "date_taken" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_MODIFIED = "date_modified" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | DATE_ADDED = "date_added" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | SIZE = "size" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | MEDIA_TYPE = "media_type" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | MIME_TYPE = "mime_type" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | PARENT = "parent" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | DISPLAY_NAME = "display_name" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | RELATIVE_PATH = "relative_path" | 废弃 | +| ohos.multimedia.mediaLibrary | FileKey | ID = "file_id" | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | isTrash(callback: AsyncCallback\): void;
    isTrash():Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | trash(isTrash: boolean, callback: AsyncCallback\): void;
    trash(isTrash: boolean): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | isFavorite(callback: AsyncCallback\): void;
    isFavorite():Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | favorite(isFavorite: boolean, callback: AsyncCallback\): void;
    favorite(isFavorite: boolean): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | getThumbnail(callback: AsyncCallback\): void;
    getThumbnail(size: Size, callback: AsyncCallback\): void;
    getThumbnail(size?: Size): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | close(fd: number, callback: AsyncCallback\): void;
    close(fd: number): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | open(mode: string, callback: AsyncCallback\): void;
    open(mode: string): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | commitModify(callback: AsyncCallback\): void;
    commitModify(): Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | isDirectory(callback: AsyncCallback\): void;
    isDirectory():Promise\; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumName: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumUri: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly albumId: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly duration: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | orientation: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly height: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly width: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly audioAlbum: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly artist: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateTaken: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateModified: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly dateAdded: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly size: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly parent: number; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | relativePath: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | title: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | displayName: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly mediaType: MediaType; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly mimeType: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly uri: string; | 废弃 | +| ohos.multimedia.mediaLibrary | FileAsset | readonly id: number; | 废弃 | +| ohos.multimedia.mediaLibrary | MediaType | AUDIO | 废弃 | +| ohos.multimedia.mediaLibrary | MediaType | VIDEO | 废弃 | +| ohos.multimedia.mediaLibrary | MediaType | IMAGE | 废弃 | +| ohos.multimedia.mediaLibrary | MediaType | FILE = 0 | 废弃 | +| ohos.multimedia.mediaLibrary | mediaLibrary | getMediaLibrary(): MediaLibrary;
    getMediaLibrary(context: Context): MediaLibrary; | 废弃 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-resource-scheduler.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-resource-scheduler.md new file mode 100644 index 0000000000000000000000000000000000000000..b1e7c330bb232fd32840b2d8608e85965ca38091 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-resource-scheduler.md @@ -0,0 +1,24 @@ +# 资源调度子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,资源调度子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | reason: string; | 新增 | +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | isProcess?: boolean; | 新增 | +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | isPersist?: boolean; | 新增 | +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | timeOut: number; | 新增 | +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | isApply: boolean; | 新增 | +| ohos.backgroundTaskManager | EfficiencyResourcesRequest | resourceTypes: number; | 新增 | +| ohos.backgroundTaskManager | ResourceType | AUDIO = 1 << 6 | 新增 | +| ohos.backgroundTaskManager | ResourceType | GPS = 1 << 5 | 新增 | +| ohos.backgroundTaskManager | ResourceType | BLUETOOTH = 1 << 4 | 新增 | +| ohos.backgroundTaskManager | ResourceType | WORK_SCHEDULER = 1 << 3 | 新增 | +| ohos.backgroundTaskManager | ResourceType | TIMER = 1 << 2 | 新增 | +| ohos.backgroundTaskManager | ResourceType | COMMON_EVENT = 1 << 1 | 新增 | +| ohos.backgroundTaskManager | ResourceType | CPU = 1 | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | resetAllEfficiencyResources(): void; | 新增 | +| ohos.backgroundTaskManager | backgroundTaskManager | applyEfficiencyResources(request: EfficiencyResourcesRequest): boolean; | 新增 | +| ohos.workScheduler | WorkInfo | parameters?: {[key: string]: any}; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-security.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-security.md new file mode 100644 index 0000000000000000000000000000000000000000..2b152783a53ea2eef95277dba25c98f1a904c93a --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-security.md @@ -0,0 +1,163 @@ +# 安全子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,安全子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.privacyManager | ActiveChangeResponse | activeStatus: PermissionActiveStatus; | 新增 | +| ohos.privacyManager | ActiveChangeResponse | deviceId: string; | 新增 | +| ohos.privacyManager | ActiveChangeResponse | permissionName: string; | 新增 | +| ohos.privacyManager | ActiveChangeResponse | tokenId: number; | 新增 | +| ohos.privacyManager | PermissionActiveStatus | PERM_ACTIVE_IN_BACKGROUND = 2 | 新增 | +| ohos.privacyManager | PermissionActiveStatus | PERM_ACTIVE_IN_FOREGROUND = 1 | 新增 | +| ohos.privacyManager | PermissionActiveStatus | PERM_INACTIVE = 0 | 新增 | +| ohos.privacyManager | privacyManager | off(type: 'activeStateChange', permissionNameList: Array\, callback?: Callback\): void; | 新增 | +| ohos.privacyManager | privacyManager | on(type: 'activeStateChange', permissionNameList: Array\, callback: Callback\): void; | 新增 | +| ohos.privacyManager | privacyManager | stopUsingPermission(tokenID: number, permissionName: string): Promise\;
    stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback\): void; | 新增 | +| ohos.privacyManager | privacyManager | startUsingPermission(tokenID: number, permissionName: string): Promise\;
    startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback\): void; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createCertChainValidator(algorithm :string) : CertChainValidator; | 新增 | +| ohos.security.cryptoFramework | CertChainValidator | readonly algorithm : string; | 新增 | +| ohos.security.cryptoFramework | CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback\) : void;
    validate(certChain : CertChainData) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : void;
    createX509Crl(inStream : EncodingBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getSignatureAlgParams() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getSignatureAlgOid() : string; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getSignatureAlgName() : string; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getSignature() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getTbsInfo(callback : AsyncCallback\) : void;
    getTbsInfo() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getRevokedCerts(callback : AsyncCallback\>) : void;
    getRevokedCerts() : Promise\>; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\) : void;
    getRevokedCertWithCert(cert : X509Cert) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback\) : void;
    getRevokedCert(serialNumber : number) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getNextUpdate() : string; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getLastUpdate() : string; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getIssuerName() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getVersion() : number; | 新增 | +| ohos.security.cryptoFramework | X509Crl | verify(key : PubKey, callback : AsyncCallback\) : void;
    verify(key : PubKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getEncoded(callback : AsyncCallback\) : void;
    getEncoded() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Crl | getType() : string; | 新增 | +| ohos.security.cryptoFramework | X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback\) : void;
    isRevoked(cert : X509Cert) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509CrlEntry | getRevocationDate(callback : AsyncCallback\) : void;
    getRevocationDate() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509CrlEntry | getCertIssuer(callback : AsyncCallback\) : void;
    getCertIssuer() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509CrlEntry | getSerialNumber() : number; | 新增 | +| ohos.security.cryptoFramework | X509CrlEntry | getEncoded(callback : AsyncCallback\) : void;
    getEncoded() : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : void;
    createX509Cert(inStream : EncodingBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getIssuerAltNames() : DataArray; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSubjectAltNames() : DataArray; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getBasicConstraints() : number; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getExtKeyUsage() : DataArray; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getKeyUsage() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSignatureAlgParams() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSignatureAlgOid() : string; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSignatureAlgName() : string; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSignature() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getNotAfterTime() : string; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getNotBeforeTime() : string; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSubjectName() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getIssuerName() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getSerialNumber() : number; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getVersion() : number; | 新增 | +| ohos.security.cryptoFramework | X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback\) : void;
    checkValidityWithDate(date: string) : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getPublicKey(callback : AsyncCallback\) : void;
    getPublicKey() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Cert | getEncoded(callback : AsyncCallback\) : void;
    getEncoded() : Promise\; | 新增 | +| ohos.security.cryptoFramework | X509Cert | verify(key : PubKey, callback : AsyncCallback\) : void;
    verify(key : PubKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createKeyAgreement(algName : string) : KeyAgreement; | 新增 | +| ohos.security.cryptoFramework | KeyAgreement | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | KeyAgreement | generateSecret(priKey : PriKey, pubKey : PubKey, callback : AsyncCallback\) : void;
    generateSecret(priKey : PriKey, pubKey : PubKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createVerify(algName : string) : Verify; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createSign(algName : string) : Sign; | 新增 | +| ohos.security.cryptoFramework | Verify | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Verify | verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\) : void;
    verify(data : DataBlob, signatureData : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Verify | update(data : DataBlob, callback : AsyncCallback\) : void;
    update(data : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Verify | init(pubKey : PubKey, callback : AsyncCallback\) : void;
    init(pubKey : PubKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Sign | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Sign | sign(data : DataBlob, callback : AsyncCallback\) : void;
    sign(data : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Sign | update(data : DataBlob, callback : AsyncCallback\) : void;
    update(data : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Sign | init(priKey : PriKey, callback : AsyncCallback\) : void;
    init(priKey : PriKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createCipher(transformation : string) : Cipher; | 新增 | +| ohos.security.cryptoFramework | Cipher | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Cipher | doFinal(data : DataBlob, callback : AsyncCallback\) : void;
    doFinal(data : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Cipher | update(data : DataBlob, callback : AsyncCallback\) : void;
    update(data : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Cipher | init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallback\) : void;
    init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createMd(algName : string) : Md; | 新增 | +| ohos.security.cryptoFramework | Md | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Md | getMdLength() : number; | 新增 | +| ohos.security.cryptoFramework | Md | digest(callback : AsyncCallback\) : void;
    digest() : Promise\; | 新增 | +| ohos.security.cryptoFramework | Md | update(input : DataBlob, callback : AsyncCallback\) : void;
    update(input : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createMac(algName : string) : Mac; | 新增 | +| ohos.security.cryptoFramework | Mac | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Mac | getMacLength() : number; | 新增 | +| ohos.security.cryptoFramework | Mac | doFinal(callback : AsyncCallback\) : void;
    doFinal() : Promise\; | 新增 | +| ohos.security.cryptoFramework | Mac | update(input : DataBlob, callback : AsyncCallback\) : void;
    update(input : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Mac | init(key : SymKey, callback : AsyncCallback\) : void;
    init(key : SymKey) : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createSymKeyGenerator(algName : string) : SymKeyGenerator; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createAsyKeyGenerator(algName : string) : AsyKeyGenerator; | 新增 | +| ohos.security.cryptoFramework | SymKeyGenerator | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | SymKeyGenerator | convertKey(key : DataBlob, callback : AsyncCallback\) : void;
    convertKey(key : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | SymKeyGenerator | generateSymKey(callback : AsyncCallback\) : void;
    generateSymKey() : Promise\; | 新增 | +| ohos.security.cryptoFramework | AsyKeyGenerator | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\) : void;
    convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | AsyKeyGenerator | generateKeyPair(callback : AsyncCallback\) : void;
    generateKeyPair() : Promise\; | 新增 | +| ohos.security.cryptoFramework | cryptoFramework | createRandom() : Random; | 新增 | +| ohos.security.cryptoFramework | Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void;
    setSeed(seed : DataBlob) : Promise\; | 新增 | +| ohos.security.cryptoFramework | Random | generateRandom(len : number, callback: AsyncCallback\) : void;
    generateRandom(len : number) : Promise\; | 新增 | +| ohos.security.cryptoFramework | KeyPair | readonly pubKey : PubKey; | 新增 | +| ohos.security.cryptoFramework | KeyPair | readonly priKey : PriKey; | 新增 | +| ohos.security.cryptoFramework | PriKey | clearMem() : void; | 新增 | +| ohos.security.cryptoFramework | SymKey | clearMem() : void; | 新增 | +| ohos.security.cryptoFramework | Key | readonly algName : string; | 新增 | +| ohos.security.cryptoFramework | Key | readonly format : string; | 新增 | +| ohos.security.cryptoFramework | Key | getEncoded() : DataBlob; | 新增 | +| ohos.security.cryptoFramework | CryptoMode | DECRYPT_MODE = 1 | 新增 | +| ohos.security.cryptoFramework | CryptoMode | ENCRYPT_MODE = 0 | 新增 | +| ohos.security.cryptoFramework | CcmParamsSpec | authTag : DataBlob; | 新增 | +| ohos.security.cryptoFramework | CcmParamsSpec | aad : DataBlob; | 新增 | +| ohos.security.cryptoFramework | CcmParamsSpec | iv : DataBlob; | 新增 | +| ohos.security.cryptoFramework | GcmParamsSpec | authTag : DataBlob; | 新增 | +| ohos.security.cryptoFramework | GcmParamsSpec | aad : DataBlob; | 新增 | +| ohos.security.cryptoFramework | GcmParamsSpec | iv : DataBlob; | 新增 | +| ohos.security.cryptoFramework | IvParamsSpec | iv : DataBlob; | 新增 | +| ohos.security.cryptoFramework | ParamsSpec | algoName : string; | 新增 | +| ohos.security.cryptoFramework | CertChainData | encodingFormat: EncodingFormat; | 新增 | +| ohos.security.cryptoFramework | CertChainData | count : number; | 新增 | +| ohos.security.cryptoFramework | CertChainData | data: Uint8Array; | 新增 | +| ohos.security.cryptoFramework | EncodingBlob | encodingFormat : EncodingFormat; | 新增 | +| ohos.security.cryptoFramework | EncodingBlob | data : Uint8Array; | 新增 | +| ohos.security.cryptoFramework | EncodingFormat | FORMAT_PEM = 1 | 新增 | +| ohos.security.cryptoFramework | EncodingFormat | FORMAT_DER = 0 | 新增 | +| ohos.security.cryptoFramework | DataArray | data : Array\; | 新增 | +| ohos.security.cryptoFramework | DataBlob | data : Uint8Array; | 新增 | +| ohos.security.cryptoFramework | Result | ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE = 17630007 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_KEYUSAGE_NO_CERTSIGN = 17630006 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 17630005 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_CERT_HAS_EXPIRED = 17630004 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_CERT_NOT_YET_VALID = 17630003 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_CERT_SIGNATURE_FAILURE = 17630002 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_CRYPTO_OPERATION = 17630001 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_EXTERNAL_ERROR = 17620002 | 新增 | +| ohos.security.cryptoFramework | Result | ERR_OUT_OF_MEMORY = 17620001 | 新增 | +| ohos.security.cryptoFramework | Result | NOT_SUPPORT = 801 | 新增 | +| ohos.security.cryptoFramework | Result | INVALID_PARAMS = 401 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_CHALLENGE_POS = HuksTagType.HUKS_TAG_TYPE_UINT | 310 | +| ohos.security.huks | HuksTag | HUKS_TAG_CHALLENGE_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 309 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_SECURE_SIGN_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 308 | +| ohos.security.huks | HuksTag | HUKS_TAG_KEY_AUTH_ACCESS_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 307 | +| ohos.security.huks | HuksSecureSignType | HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 | 新增 | +| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_3 | 新增 | +| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_2 | 新增 | +| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_1 | 新增 | +| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_0 = 0 | 新增 | +| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_NONE = 2 | 新增 | +| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_CUSTOM = 1 | 新增 | +| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_NORMAL = 0 | 新增 | +| ohos.security.huks | HuksAuthAccessType | HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 \<\< 1 | 新增 | +| ohos.security.huks | HuksAuthAccessType | HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 \<\< 0 | 新增 | +| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_PIN = 1 \<\< 2 | 新增 | +| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_FACE = 1 \<\< 1 | 新增 | +| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 \<\< 0 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_DEVICE_NO_CREDENTIAL = -44 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_KEY_AUTH_FAILED = -43 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_USER_AUTH_TYPE_NOT_SUPPORT = -42 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_GET_USERIAM_AUTHINFO_FAILED = -41 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_GET_USERIAM_SECINFO_FAILED = -40 | 新增 | +| ohos.security.huks | huks | attestKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void;
    attestKey(keyAlias: string, options: HuksOptions) : Promise\; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-sensor.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-sensor.md new file mode 100644 index 0000000000000000000000000000000000000000..8bf5bfe7ce266ea4997ed87603958532b5f7ca81 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-sensor.md @@ -0,0 +1,15 @@ +# 泛Sensor子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,泛Sensor子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.vibrator | VibratePreset | count: number; | 新增 | +| ohos.vibrator | VibratePreset | effectId: string; | 新增 | +| ohos.vibrator | VibratePreset | type: "preset"; | 新增 | +| ohos.vibrator | VibrateTime | duration: number; | 新增 | +| ohos.vibrator | VibrateTime | type: "time"; | 新增 | +| ohos.vibrator | VibrateAttribute | usage: Usage, | 新增 | +| ohos.vibrator | VibrateAttribute | id?: number, | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-soft-bus.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-soft-bus.md new file mode 100644 index 0000000000000000000000000000000000000000..a8cece584d4cd9b7cf4109888fbfcdd97448f3e7 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-soft-bus.md @@ -0,0 +1,10 @@ +# 分布式软总线子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,分布式软总线子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.rpc | RemoteObject | onRemoteRequestEx(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean \| Promise\; | 新增 | +| ohos.rpc | RemoteObject | onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; | 废弃 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-telephony.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-telephony.md new file mode 100644 index 0000000000000000000000000000000000000000..93f67d7229ba5866173b06b7c031e4168f341253 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-telephony.md @@ -0,0 +1,26 @@ +# 电话服务子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,电话服务子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.telephony.data | data | getDefaultCellularDataSlotIdSync(): number; | 新增 | +| ohos.telephony.radio | ImsServiceType | TYPE_SMS | 新增 | +| ohos.telephony.radio | ImsServiceType | TYPE_UT | 新增 | +| ohos.telephony.radio | ImsServiceType | TYPE_VIDEO | 新增 | +| ohos.telephony.radio | ImsServiceType | TYPE_VOICE | 新增 | +| ohos.telephony.radio | ImsRegInfo | imsRegTech: ImsRegTech; | 新增 | +| ohos.telephony.radio | ImsRegInfo | imsRegState: ImsRegState; | 新增 | +| ohos.telephony.radio | ImsRegTech | REGISTRATION_TECH_NR | 新增 | +| ohos.telephony.radio | ImsRegTech | REGISTRATION_TECH_IWLAN | 新增 | +| ohos.telephony.radio | ImsRegTech | REGISTRATION_TECH_LTE | 新增 | +| ohos.telephony.radio | ImsRegTech | REGISTRATION_TECH_NONE | 新增 | +| ohos.telephony.radio | ImsRegState | IMS_REGISTERED | 新增 | +| ohos.telephony.radio | ImsRegState | IMS_UNREGISTERED | 新增 | +| ohos.telephony.radio | radio | off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback\): void; | 新增 | +| ohos.telephony.radio | radio | on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback\): void; | 新增 | +| ohos.telephony.radio | radio | getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback\): void;
    getImsRegInfo(slotId: number, imsType: ImsServiceType): Promise\; | 新增 | +| ohos.telephony.sim | sim | getOpName(slotId: number, callback: AsyncCallback\): void;
    getOpName(slotId: number): Promise\; | 新增 | +| ohos.telephony.sim | sim | getOpKey(slotId: number, callback: AsyncCallback\): void;
    getOpKey(slotId: number): Promise\; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-unitest.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-unitest.md new file mode 100644 index 0000000000000000000000000000000000000000..75619e2cc31744019699fce7358c01d63edd782a --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-unitest.md @@ -0,0 +1,24 @@ +# 测试框架子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,测试框架子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.uitest | PointerMatrix | setPoint(finger: number, step: number, point: Point):void; | 新增 | +| ohos.uitest | PointerMatrix | static create(fingers: number, steps: number):PointerMatrix; | 新增 | +| ohos.uitest | UiDriver | injectMultiPointerAction(pointers: PointerMatrix, speed?: number):Promise\; | 新增 | +| ohos.uitest | UiDriver | fling(from: Point, to: Point, stepLen: number, speed: number):Promise\; | 新增 | +| ohos.uitest | UiDriver | waitForIdle(idleTime: number, timeout: number):Promise\; | 新增 | +| ohos.uitest | UiDriver | pressHome():Promise\; | 新增 | +| ohos.uitest | UiDriver | wakeUpDisplay():Promise\; | 新增 | +| ohos.uitest | UiDriver | getDisplayDensity():Promise\; | 新增 | +| ohos.uitest | UiDriver | getDisplaySize():Promise\; | 新增 | +| ohos.uitest | UiDriver | setDisplayRotationEnabled(enabled:boolean):Promise\; | 新增 | +| ohos.uitest | UiDriver | getDisplayRotation():Promise\; | 新增 | +| ohos.uitest | UiDriver | setDisplayRotation(rotation: DisplayRotation):Promise\; | 新增 | +| ohos.uitest | DisplayRotation | ROTATION_270 | 新增 | +| ohos.uitest | DisplayRotation | ROTATION_180 | 新增 | +| ohos.uitest | DisplayRotation | ROTATION_90 | 新增 | +| ohos.uitest | DisplayRotation | ROTATION_0 | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-update.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-update.md new file mode 100644 index 0000000000000000000000000000000000000000..22f30d1db8d13549eed542a68ec9c28cd3d753ef --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-update.md @@ -0,0 +1,22 @@ +# 升级服务子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,升级服务子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.update | Order | INSTALL_AND_APPLY = 6 | 新增 | +| ohos.update | Order | DOWNLOAD_AND_INSTALL = 3 | 新增 | +| ohos.update | NetType | CELLULAR_AND_WIFI = 7 | 新增 | +| ohos.update | NetType | WIFI = 6 | 新增 | +| ohos.update | DescriptionFormat | SIMPLIFIED = 1 | 新增 | +| ohos.update | DescriptionFormat | STANDARD = 0 | 新增 | +| ohos.update | ComponentDescription | descriptionInfo: DescriptionInfo; | 新增 | +| ohos.update | ComponentDescription | componentId: string; | 新增 | +| ohos.update | DescriptionOptions | language: string; | 新增 | +| ohos.update | DescriptionOptions | format: DescriptionFormat; | 新增 | +| ohos.update | VersionComponent | componentId: string; | 新增 | +| ohos.update | Updater | getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback>): void;
    getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise>; | 新增 | +| ohos.update | Updater | getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback>): void;
    getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise>; | 新增 | +| ohos.update | BusinessSubType | PARAM = 2 | 删除 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-web.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-web.md new file mode 100644 index 0000000000000000000000000000000000000000..7097dcf3efd9acc0c77b867236052a5792ac760b --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-web.md @@ -0,0 +1,51 @@ +# Web子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,Web子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.web.webview | WebCookieManager | static deleteSessionCookie(): void; | 新增 | +| ohos.web.webview | WebCookieManager | static deleteEntireCookie(): void; | 新增 | +| ohos.web.webview | WebCookieManager | static existCookie(): boolean; | 新增 | +| ohos.web.webview | WebCookieManager | static putAcceptThirdPartyCookieEnabled(accept: boolean): void; | 新增 | +| ohos.web.webview | WebCookieManager | static isThirdPartyCookieAllowed(): boolean; | 新增 | +| ohos.web.webview | WebCookieManager | static putAcceptCookieEnabled(accept: boolean): void; | 新增 | +| ohos.web.webview | WebCookieManager | static isCookieAllowed(): boolean; | 新增 | +| ohos.web.webview | WebCookieManager | static saveCookieAsync(): Promise\;
    static saveCookieAsync(callback: AsyncCallback\): void; | 新增 | +| ohos.web.webview | WebCookieManager | static saveCookieSync(): boolean; | 新增 | +| ohos.web.webview | WebCookieManager | static setCookie(url: string, value: string): boolean; | 新增 | +| ohos.web.webview | WebCookieManager | static getCookie(url: string): string; | 新增 | +| ohos.web.webview | GeolocationPermissions | static getStoredGeolocation() : Promise\>;
    static getStoredGeolocation(callback : AsyncCallback\>): void; | 新增 | +| ohos.web.webview | GeolocationPermissions | static getAccessibleGeolocation(origin: string): Promise\;
    static getAccessibleGeolocation(origin: string, callback: AsyncCallback\): void; | 新增 | +| ohos.web.webview | GeolocationPermissions | static deleteAllGeolocation(): void; | 新增 | +| ohos.web.webview | GeolocationPermissions | static deleteGeolocation(origin: string): void; | 新增 | +| ohos.web.webview | GeolocationPermissions | static allowGeolocation(origin: string): void; | 新增 | +| ohos.web.webview | WebAsyncController | storeWebArchive(baseName: string, autoName: boolean): Promise\;
    storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback\): void; | 新增 | +| ohos.web.webview | WebAsyncController | constructor(controller: WebController); | 新增 | +| ohos.web.webview | WebDataBase | static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; | 新增 | +| ohos.web.webview | WebDataBase | static getHttpAuthCredentials(host: string, realm: string): Array\; | 新增 | +| ohos.web.webview | WebDataBase | static deleteHttpAuthCredentials(): void; | 新增 | +| ohos.web.webview | WebDataBase | static existHttpAuthCredentials(): boolean; | 新增 | +| ohos.web.webview | WebStorage | static getOriginUsage(origin : string) : Promise\ ;
    static getOriginUsage(origin : string, callback : AsyncCallback\) : void; | 新增 | +| ohos.web.webview | WebStorage | static getOriginQuota(origin : string) : Promise\;
    static getOriginQuota(origin : string, callback : AsyncCallback\) : void; | 新增 | +| ohos.web.webview | WebStorage | static getOrigins() : Promise\>;
    static getOrigins(callback: AsyncCallback\>) : void; | 新增 | +| ohos.web.webview | WebStorage | static deleteOrigin(origin : string): void; | 新增 | +| ohos.web.webview | WebStorage | static deleteAllData() : void; | 新增 | +| ohos.web.webview | WebStorageOrigin | quota: number; | 新增 | +| ohos.web.webview | WebStorageOrigin | usage: number; | 新增 | +| ohos.web.webview | WebStorageOrigin | origin: string; | 新增 | +| ohos.web | WebDataBase | static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; | 删除 | +| ohos.web | WebDataBase | static getHttpAuthCredentials(host: string, realm: string): Array\; | 删除 | +| ohos.web | WebDataBase | static deleteHttpAuthCredentials(): void; | 删除 | +| ohos.web | WebDataBase | static existHttpAuthCredentials(): boolean; | 删除 | +| ohos.web | WebStorage | static getOriginUsage(origin : string) : Promise\ ;
    static getOriginUsage(origin : string, callback : AsyncCallback\) : void; | 删除 | +| ohos.web | WebStorage | static getOriginQuota(origin : string) : Promise\;
    static getOriginQuota(origin : string, callback : AsyncCallback\) : void; | 删除 | +| ohos.web | WebStorage | static getOrigins() : Promise\>;
    static getOrigins(callback: AsyncCallback\>) : void; | 删除 | +| ohos.web | WebStorage | static deleteOrigin(origin : string): void; | 删除 | +| ohos.web | WebStorage | static deleteAllData() : void; | 删除 | +| ohos.web | WebStorageOrigin | quota: number; | 删除 | +| ohos.web | WebStorageOrigin | usage: number; | 删除 | +| ohos.web | WebStorageOrigin | origin: string; | 删除 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-window.md b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-window.md new file mode 100644 index 0000000000000000000000000000000000000000..99abe11c702ec90978a1e0e6e2cc7d949b302f4f --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/js-apidiff-window.md @@ -0,0 +1,72 @@ +# 窗口管理子系统JS API变更 + +OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,窗口管理子系统的API变更如下: + +## 接口变更 + +| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | +|---|---|---|---| +| ohos.animation.windowAnimationManager | WindowAnimationController | onWindowAnimationTargetsUpdate(fullScreenWindowTarget: WindowAnimationTarget, floatingWindowTargets: Array\): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationTarget | readonly missionId: number; | 新增 | +| ohos.animation.windowAnimationManager | windowAnimationManager | minimizeWindowWithAnimation(windowTarget: WindowAnimationTarget, callback: AsyncCallback\): void;
    minimizeWindowWithAnimation(windowTarget: WindowAnimationTarget): Promise\; | 新增 | +| ohos.display | Display | getCutoutInfo(callback: AsyncCallback\): void;
    getCutoutInfo(): Promise\; | 新增 | +| ohos.display | CutoutInfo | readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects; | 新增 | +| ohos.display | CutoutInfo | readonly boundingRects: Array\; | 新增 | +| ohos.display | WaterfallDisplayAreaRects | readonly bottom: Rect; | 新增 | +| ohos.display | WaterfallDisplayAreaRects | readonly top: Rect; | 新增 | +| ohos.display | WaterfallDisplayAreaRects | readonly right: Rect; | 新增 | +| ohos.display | WaterfallDisplayAreaRects | readonly left: Rect; | 新增 | +| ohos.display | Rect | height: number; | 新增 | +| ohos.display | Rect | width: number; | 新增 | +| ohos.display | Rect | top: number; | 新增 | +| ohos.display | Rect | left: number; | 新增 | +| ohos.display | display | hasPrivateWindow(displayId: number): boolean; | 新增 | +| ohos.window | Window | setCornerRadius(cornerRadius: number): void; | 新增 | +| ohos.window | Window | setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void; | 新增 | +| ohos.window | Window | setBackdropBlurStyle(blurStyle: BlurStyle): void; | 新增 | +| ohos.window | Window | setBackdropBlur(radius: number): void; | 新增 | +| ohos.window | Window | setBlur(radius: number): void; | 新增 | +| ohos.window | Window | getTransitionController(): TransitionController; | 新增 | +| ohos.window | Window | translate(translateOptions: TranslateOptions): void; | 新增 | +| ohos.window | Window | rotate(rotateOptions: RotateOptions): void; | 新增 | +| ohos.window | Window | scale(scaleOptions: ScaleOptions): void; | 新增 | +| ohos.window | Window | opacity(opacity: number): void; | 新增 | +| ohos.window | Window | snapshot(callback: AsyncCallback\): void;
    snapshot(): Promise\; | 新增 | +| ohos.window | Window | setSnapshotSkip(isSkip: boolean): void; | 新增 | +| ohos.window | Window | setWakeUpScreen(wakeUp: boolean): void; | 新增 | +| ohos.window | Window | bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback\): Promise\;
    bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback\, callback: AsyncCallback\): void; | 新增 | +| ohos.window | Window | off(type: 'dialogTargetTouch', callback?: Callback\): void; | 新增 | +| ohos.window | Window | on(type: 'dialogTargetTouch', callback: Callback\): void; | 新增 | +| ohos.window | Window | off(type: 'screenshot', callback?: Callback\): void; | 新增 | +| ohos.window | Window | on(type: 'screenshot', callback: Callback\): void; | 新增 | +| ohos.window | Window | showWithAnimation(callback: AsyncCallback\): void;
    showWithAnimation(): Promise\; | 新增 | +| ohos.window | Window | hideWithAnimation(callback: AsyncCallback\): void;
    hideWithAnimation(): Promise\; | 新增 | +| ohos.window | BlurStyle | THICK | 新增 | +| ohos.window | BlurStyle | REGULAR | 新增 | +| ohos.window | BlurStyle | THIN | 新增 | +| ohos.window | BlurStyle | OFF | 新增 | +| ohos.window | TransitionController | animationForHidden(context: TransitionContext): void; | 新增 | +| ohos.window | TransitionController | animationForShown(context: TransitionContext): void; | 新增 | +| ohos.window | TransitionContext | completeTransition(isCompleted: boolean): void; | 新增 | +| ohos.window | TransitionContext | toWindow: Window | 新增 | +| ohos.window | TranslateOptions | z?: number; | 新增 | +| ohos.window | TranslateOptions | y?: number; | 新增 | +| ohos.window | TranslateOptions | x?: number; | 新增 | +| ohos.window | RotateOptions | pivotY?: number; | 新增 | +| ohos.window | RotateOptions | pivotX?: number; | 新增 | +| ohos.window | RotateOptions | z?: number; | 新增 | +| ohos.window | RotateOptions | y?: number; | 新增 | +| ohos.window | RotateOptions | x?: number; | 新增 | +| ohos.window | ScaleOptions | pivotY?: number; | 新增 | +| ohos.window | ScaleOptions | pivotX?: number; | 新增 | +| ohos.window | ScaleOptions | y?: number; | 新增 | +| ohos.window | ScaleOptions | x?: number; | 新增 | +| ohos.window | WindowProperties | id: number | 新增 | +| ohos.window | WindowType | TYPE_SCREENSHOT | 新增 | +| ohos.window | WindowType | TYPE_DIALOG | 新增 | +| ohos.window | WindowType | TYPE_FLOAT_CAMERA | 新增 | +| ohos.screen | Orientation | SENSOR_HORIZONTAL = 7 | 删除 | +| ohos.screen | Orientation | SENSOR_VERTICAL = 6 | 删除 | +| ohos.screen | Orientation | SENSOR = 5 | 删除 | +| ohos.window | Window | setWindowType(type: WindowType): Promise\;
    setWindowType(type: WindowType, callback: AsyncCallback\): void; | 废弃 | +| ohos.window | WindowProperties | isRoundCorner: boolean | 废弃 | 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 new file mode 100644 index 0000000000000000000000000000000000000000..c2f939199d3257e650eb48736ec275e72a3fad6c --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta3/readme.md @@ -0,0 +1,33 @@ +# Readme + +本目录记录了OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本的API变化,包括新增、变更、废弃、删除。 + +- JS API差异报告 + - [元能力](js-apidiff-ability.md) + - [无障碍](js-apidiff-accessibility.md) + - [帐号](js-apidiff-account.md) + - [ArkUI](js-apidiff-arkui.md) + - [电源管理](js-apidiff-battery.md) + - [包管理](js-apidiff-bundle.md) + - [基础通信](js-apidiff-communicate.md) + - [公共基础库](js-apidiff-compiler-and-runtime.md) + - [DFX](js-apidiff-dfx.md) + - [分布式数据管理](js-apidiff-distributed-data.md) + - [分布式硬件](js-apidiff-distributed-hardware.md) + - [事件通知](js-apidiff-event-and-notification.md) + - [文件管理](js-apidiff-file-management.md) + - [全球化](js-apidiff-global.md) + - [图形图像](js-apidiff-graphic.md) + - [Misc](js-apidiff-misc.md) + - [多模输入](js-apidiff-multi-modal-input.md) + - [多媒体](js-apidiff-multimedia.md) + - [资源调度](js-apidiff-resource-scheduler.md) + - [安全](js-apidiff-security.md) + - [泛Sensor](js-apidiff-sensor.md) + - [分布式软总线](js-apidiff-soft-bus.md) + - [电话服务](js-apidiff-telephony.md) + - [测试框架](js-apidiff-unitest.md) + - [升级服务](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 c70f36e9a26d351ddda95f6fcc4d2211aae092a3..50ce7f0dfc23de70e0de59450db04c3bdfdf2fd7 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -30,7 +30,36 @@ - [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md) - API差异报告 - + - OpenHarmony 3.2 Beta3 + - JS API差异报告 + - [元能力](release-notes/api-change/v3.2-beta3/js-apidiff-ability.md) + - [无障碍](release-notes/api-change/v3.2-beta3/js-apidiff-accessibility.md) + - [帐号](release-notes/api-change/v3.2-beta3/js-apidiff-account.md) + - [ArkUI](release-notes/api-change/v3.2-beta3/js-apidiff-arkui.md) + - [电源管理](release-notes/api-change/v3.2-beta3/js-apidiff-battery.md) + - [包管理](release-notes/api-change/v3.2-beta3/js-apidiff-bundle.md) + - [基础通信](release-notes/api-change/v3.2-beta3/js-apidiff-communicate.md) + - [公共基础库](release-notes/api-change/v3.2-beta3/js-apidiff-compiler-and-runtime.md) + - [DFX](release-notes/api-change/v3.2-beta3/js-apidiff-dfx.md) + - [分布式数据管理](release-notes/api-change/v3.2-beta3/js-apidiff-distributed-data.md) + - [分布式硬件](release-notes/api-change/v3.2-beta3/js-apidiff-distributed-hardware.md) + - [事件通知](release-notes/api-change/v3.2-beta3/js-apidiff-event-and-notification.md) + - [文件管理](release-notes/api-change/v3.2-beta3/js-apidiff-file-management.md) + - [全球化](release-notes/api-change/v3.2-beta3/js-apidiff-global.md) + - [图形图像](release-notes/api-change/v3.2-beta3/js-apidiff-graphic.md) + - [Misc](release-notes/api-change/v3.2-beta3/js-apidiff-misc.md) + - [多模输入](release-notes/api-change/v3.2-beta3/js-apidiff-multi-modal-input.md) + - [多媒体](release-notes/api-change/v3.2-beta3/js-apidiff-multimedia.md) + - [资源调度](release-notes/api-change/v3.2-beta3/js-apidiff-resource-scheduler.md) + - [安全](release-notes/api-change/v3.2-beta3/js-apidiff-security.md) + - [泛Sensor](release-notes/api-change/v3.2-beta3/js-apidiff-sensor.md) + - [分布式软总线](release-notes/api-change/v3.2-beta3/js-apidiff-soft-bus.md) + - [电话服务](release-notes/api-change/v3.2-beta3/js-apidiff-telephony.md) + - [测试框架](release-notes/api-change/v3.2-beta3/js-apidiff-unitest.md) + - [升级服务](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) @@ -80,7 +109,6 @@ - [多模输入](release-notes/api-change/v3.2-beta1/js-apidiff-multi-modal-input.md) - [多媒体](release-notes/api-change/v3.2-beta1/js-apidiff-multimedia.md) - [资源调度](release-notes/api-change/v3.2-beta1/js-apidiff-resource-scheduler.md) - - [分布式软总线](release-notes/api-change/v3.2-beta1/js-apidiff-soft-bus.md) - [测试框架](release-notes/api-change/v3.2-beta1/js-apidiff-unitest.md) - [Web](release-notes/api-change/v3.2-beta1/js-apidiff-web.md) - [窗口管理](release-notes/api-change/v3.2-beta1/js-apidiff-window.md) @@ -127,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)