diff --git a/CODEOWNERS b/CODEOWNERS index 81d411b4860e6baaff515d258356e6c6e84b2a56..291454354a636a6bef1d2a605c5cb9c8acd92bc5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -155,9 +155,9 @@ zh-cn/application-dev/work-scheduler/ @HelloCrease zh-cn/application-dev/internationalization/ @HelloCrease zh-cn/application-dev/device/usb-overview.md @ge-yafang zh-cn/application-dev/device/usb-guidelines.md @ge-yafang -zh-cn/application-dev/device/device-location-overview.md @zengyawen -zh-cn/application-dev/device/device-location-info.md @zengyawen -zh-cn/application-dev/device/device-location-geocoding.md @zengyawen +zh-cn/application-dev/device/device-location-overview.md @RayShih +zh-cn/application-dev/device/device-location-info.md @RayShih +zh-cn/application-dev/device/device-location-geocoding.md @RayShih zh-cn/application-dev/device/sensor-overview.md @HelloCrease zh-cn/application-dev/device/sensor-guidelines.md @HelloCrease zh-cn/application-dev/device/vibrator-overview.md @HelloCrease @@ -181,7 +181,7 @@ zh-cn/application-dev/napi/drawing-guidelines.md @ge-yafang zh-cn/application-dev/napi/rawfile-guidelines.md @HelloCrease zh-cn/application-dev/reference/js-service-widget-ui/ @HelloCrease zh-cn/application-dev/faqs/ @zengyawen -zh-cn/application-dev/file-management/ @qinxiaowang +zh-cn/application-dev/file-management/ @zengyawen zh-cn/application-dev/application-test/ @HelloCrease zh-cn/application-dev/device-usage-statistics/ @HelloCrease @@ -212,7 +212,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 @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen 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 @@ -239,13 +239,13 @@ zh-cn/application-dev/reference/apis/js-apis-system-storage.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-settings.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-data-resultset.md @ge-yafang -zh-cn/application-dev/reference/apis/js-apis-document.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-environment.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-fileio.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-filemanager.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-statfs.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-document.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-environment.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-fileio.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-filemanager.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-statfs.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-contact.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-call.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-observer.md @zengyawen @@ -302,38 +302,38 @@ zh-cn/application-dev/reference/apis/js-apis-vibrator.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-appAccount.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-osAccount.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-convertxml.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-process.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-uri.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-url.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-util.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-arraylist.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-deque.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-hashmap.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-hashset.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-list.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-plainarray.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-queue.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-stack.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-treemap.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-treeset.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-vector.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-worker.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-xml.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-testRunner.md @HelloCrease +zh-cn/application-dev/reference/apis/js-apis-convertxml.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-process.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-uri.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-url.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-util.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-arraylist.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-deque.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-hashmap.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-hashset.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-list.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-plainarray.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-queue.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-stack.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-treemap.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-treeset.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-vector.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-worker.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-xml.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-testRunner.md @RayShih +zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-uitest.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-hisysevent.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-animator.md @HelloCrease @qieqiewl @tomatodevboy @niulihua -zh-cn/application-dev/reference/apis/js-apis-uiappearance.md @HelloCrease @qieqiewl @tomatodevboy @niulihua zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-buffer.md @ge-yafang zh-cn/application-dev/reference/apis/development-intro.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md @RayShih zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md @RayShih @@ -366,7 +366,7 @@ zh-cn/application-dev/reference/apis/js-apis-mouseevent.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-nfcController.md @RayShih zh-cn/application-dev/reference/apis/js-apis-nfctech.md @RayShih zh-cn/application-dev/reference/apis/js-apis-pointer.md @HelloCrease -zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-system-app.md @RayShih @shuaytao @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-system-battery.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @RayShih @@ -374,7 +374,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-system-device.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @zengyawen -zh-cn/application-dev/reference/apis/js-apis-system-file.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-system-file.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-system-location.md @RayShih zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md @HelloCrease @qieqiewl @tomatodevboy @niulihua zh-cn/application-dev/reference/apis/js-apis-system-network.md @zengyawen @@ -390,8 +390,8 @@ zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md @RayShih zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @RayShih @shuaytao @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-bundle-PackInfo.md @RayShih @shuaytao @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md @HelloCrease -zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @qinxiaowang -zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @qinxiaowang +zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @zengyawen +zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-net-policy.md @zengyawen zh-cn/application-dev/reference/apis/js-apis-net-sharing.md @zengyawen @@ -450,16 +450,6 @@ zh-cn/application-dev/reference/apis/js-apis-formprovider.md @RayShih @littlejer zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-inputmethod-framework.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errcode-usb.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-display.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-distributed-data_object.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @ge-yafang -zh-cn/application-dev/reference/errorcodes/errorcode-window.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-application-quickFixManager.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-missionManager.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen @@ -470,3 +460,63 @@ zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @RaySh zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingzhen +zh-cn/application-dev/reference/errorcodes/errorcode-ability.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-access-token.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-accessibility.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-account.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-animator.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-audio.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-avsession.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-batteryStatistics.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-brightness.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-buffer.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-colorspace-manager.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-containers.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-data-rdb.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-datashare.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-device-manager.md @qinxiaowang +zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-display.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-geoLocationManager.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-hiappevent.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-hisysevent.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-hiviewdfx-hidebug.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-i18n.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-nfc.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-pasteboard.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-power.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-preferences.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-promptAction.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-request.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-router.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-rpc.md @qinxiaowang +zh-cn/application-dev/reference/errorcodes/errorcode-runninglock.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-sensor.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-thermal.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-uitest.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-universal.md @RayShih +zh-cn/application-dev/reference/errorcodes/errorcode-update.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-usb.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md @zengyawen +zh-cn/application-dev/reference/errorcodes/errorcode-vibrator.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-webview.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-window.md @ge-yafang +zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md @HelloCrease +zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md @RayShih diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md index d5cd52e64ed5064ded90efea7d60898e1c2ee96c..17fd6b5eb780f656ada33e94a6d1584ebbc55e5c 100644 --- a/en/application-dev/ability/context-userguide.md +++ b/en/application-dev/ability/context-userguide.md @@ -96,13 +96,13 @@ Obtain the context by calling **context.getApplicationContext()** in **Ability** **Example** ```javascript -import AbilityStage from "@ohos.application.AbilityStage"; +import Ability from "@ohos.application.Ability"; var lifecycleid; -export default class MyAbilityStage extends AbilityStage { +export default class MainAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MainAbility onCreate") let AbilityLifecycleCallback = { onAbilityCreate(ability){ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); @@ -141,11 +141,11 @@ export default class MyAbilityStage extends AbilityStage { // 2. Use applicationContext to register and listen for the ability lifecycle in the application. lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); - } + }, onDestroy() { let applicationContext = this.context.getApplicationContext(); applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); }); } } @@ -211,7 +211,13 @@ export default class MainAbility extends Ability { let context = this.context; console.log("[Demo] MainAbility bundleName " + context.abilityInfo.bundleName) - windowStage.setUIContent(this.context, "pages/index", null) + windowStage.loadContent("pages/index", (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)) + }); } onWindowStageDestroy() { @@ -237,7 +243,7 @@ For details, see [FormExtensionContext](../reference/apis/js-apis-formextensionc ### Obtaining the Context on an ArkTS Page -In the stage model, in the `onWindowStageCreate` lifecycle of an ability, you can call `SetUIContent` of `WindowStage` to load an ArkTS page. In some scenarios, you need to obtain the context on the page to call related APIs. +In the stage model, in the onWindowStageCreate lifecycle of an ability, you can call **SetUIContent** of **WindowStage** to load an ArkTS page. In some scenarios, you need to obtain the context on the page to call related APIs. **How to Obtain** @@ -245,7 +251,7 @@ Use the API described in the table below to obtain the context associated with a | API | Description | | :------------------------------------ | :--------------------------- | -| getContext(component: Object): Object | Obtains the `Context` object associated with a component on the page.| +| getContext(component: Object): Object | Obtains the **Context** object associated with a component on the page.| **Example** diff --git a/en/application-dev/ability/fa-dataability.md b/en/application-dev/ability/fa-dataability.md index 36eda5d9210681106a9476bdc87de28f4d06406c..e3fd895c2a3530aa0f8aa85919657a62f3f72c06 100644 --- a/en/application-dev/ability/fa-dataability.md +++ b/en/application-dev/ability/fa-dataability.md @@ -32,19 +32,19 @@ Example URIs: **Table 1** Data ability lifecycle APIs |API|Description| |:------|:------| -|onInitialized?(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).| -|update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.| -|query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.| -|delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.| -|normalizeUri?(uri: string, callback: AsyncCallback\): void|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.| -|batchInsert?(uri: string, valueBuckets: Array\, callback: AsyncCallback\): void|Inserts multiple data records into the database.| -|denormalizeUri?(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| -|insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.| -|openFile?(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.| -|getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\>): void|Obtains the MIME type of a file.| -|getType?(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.| -|executeBatch?(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.| -|call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.| +|onInitialized(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).| +|update(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.| +|query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.| +|delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.| +|normalizeUri(uri: string, callback: AsyncCallback\): void|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.| +|batchInsert(uri: string, valueBuckets: Array\, callback: AsyncCallback\): void|Inserts multiple data records into the database.| +|denormalizeUri(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| +|insert(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.| +|openFile(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.| +|getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback\>): void|Obtains the MIME type of a file.| +|getType(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.| +|executeBatch(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.| +|call(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.| ## How to Develop @@ -55,6 +55,7 @@ Example URIs: The following code snippet shows how to create a Data ability: ```javascript + import featureAbility from '@ohos.ability.featureAbility' import dataAbility from '@ohos.data.dataAbility' import dataRdb from '@ohos.data.rdb' @@ -66,7 +67,8 @@ Example URIs: export default { onInitialized(abilityInfo) { console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName) - dataRdb.getRdbStore(STORE_CONFIG, 1, (err, store) => { + let context = featureAbility.getContext() + dataRdb.getRdbStore(context, STORE_CONFIG, 1, (err, store) => { console.info('DataAbility getRdbStore callback') store.executeSql(SQL_CREATE_TABLE, []) rdbStore = store diff --git a/en/application-dev/ability/fa-formability.md b/en/application-dev/ability/fa-formability.md index c1cadebe652dbd9f195e96ed1dec221df0eff849..377d5e4b8faeda387f4eda5a6506d103c3d76395 100644 --- a/en/application-dev/ability/fa-formability.md +++ b/en/application-dev/ability/fa-formability.md @@ -1,49 +1,49 @@ # FA Widget Development ## Widget Overview -A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application. +A widget is a set of UI components that display important information or operations specific to an application. It provides users with direct access to a desired application service, without the need to open the application first. -A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive functions such as opening a UI page or sending a message. +A widget usually appears as a part of the UI of another application (which currently can only be a system application) and provides basic interactive features such as opening a UI page or sending a message. -Basic concepts: -- Widget provider: an atomic service that controls what and how content is displayed in a widget and interacts with users. -- Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application. -- Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update. +Before you get started, it would be helpful if you have a basic understanding of the following concepts: +- Widget provider: an atomic service that provides the widget content to display and controls how widget components are laid out and how they interact with users. +- Widget host: an application that displays the widget content and controls the widget location. +- Widget Manager: a resident agent that provides widget management features such as periodic widget updates. > **NOTE** > -> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated. +> The widget host and provider do not need to be running all the time. The Widget Manager will start the widget provider to obtain widget information when a widget is added, deleted, or updated. -You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager. +You only need to develop the widget provider. The system automatically handles the work of the widget host and Widget Manager. -The widget provider controls the widget content to display, component layout, and click events bound to components. +The widget provider controls the widget content to display, the layout of components used in the widget, and click events bound to the components. ## Development Overview -In FA widget development, you need to carry out the following operations as a widget provider based on the [Feature Ability (FA) model](fa-brief.md). +Carry out the following operations to develop the widget provider based on the [FA model](fa-brief.md): -- Develop the lifecycle callbacks in **LifecycleForm**. -- Create a **FormBindingData** instance. -- Update a widget through **FormProvider**. -- Develop the widget UI pages. +1. Implement lifecycle callbacks by using the **LifecycleForm** APIs. +2. Create a **FormBindingData** instance. +3. Update a widget by using the **FormProvider** APIs. +4. Develop the widget UI pages. ## Available APIs -The table below describes the lifecycle callbacks provided in **LifecycleForm**. +The table below describes the **LifecycleForm** APIs, which represent the lifecycle callbacks of a widget (known as a **Form** instance). **Table 1** LifecycleForm APIs | API | Description | | :----------------------------------------------------------- | :------------------------------------------- | -| onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a **Form** instance (widget) has been created. | +| onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a widget has been created. | | onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.| | onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. | | onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. | | onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. | -| onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. | -| onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a widget. | +| onDestroy(formId: string): void | Called to notify the widget provider that a widget has been destroyed. | +| onAcquireFormState?(want: Want): formInfo.FormState | Called to instruct the widget provider to receive the status query result of a widget. | -For details about the **FormProvider** APIs, see [FormProvider](../reference/apis/js-apis-formprovider.md). +The table below describes the **FormProvider** APIs. For details, see [FormProvider](../reference/apis/js-apis-formprovider.md). **Table 2** FormProvider APIs @@ -56,9 +56,9 @@ For details about the **FormProvider** APIs, see [FormProvider](../reference/api ## How to Develop -### Creating LifecycleForm +### Implementing Lifecycle Callbacks -To create a widget in the FA model, you need to implement the lifecycles of **LifecycleForm**. The sample code is as follows: +To create an FA widget, you need to implement lifecycle callbacks using the **LifecycleForm** APIs. The sample code is as follows: 1. Import the required modules. @@ -68,7 +68,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li import formProvider from '@ohos.application.formProvider' ``` -2. Implement the lifecycle callbacks of **LifecycleForm**. +2. Implement lifecycle callbacks for the widget. ```javascript export default { @@ -87,7 +87,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li console.log('FormAbility onCastToNormal'); }, onUpdate(formId) { - // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. + // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host. console.log('FormAbility onUpdate'); let obj = { "title": "titleOnUpdate", @@ -119,19 +119,19 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li ### Configuring the Widget Configuration File -Configure the **config.json** file for the widget. +The widget configuration file is named **config.json**. Find the **config.json** file for the widget and edit the file depending on your need. -- The **js** module in the **config.json** file provides the JavaScript resources of the widget. The internal structure is described as follows: +- The **js** module in the **config.json** file provides JavaScript resources of the widget. The internal structure is described as follows: | Field| Description | Data Type| Default | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | | name | Name of a JavaScript component. The default value is **default**. | String | No | | pages | Route information about all pages in the JavaScript component, including the page path and page name. The value is an array, in which each element represents a page. The first element in the array represents the home page of the JavaScript FA.| Array | No | | window | Window-related configurations. | Object | Yes | - | type | Type of the JavaScript component. Available values are as follows:
**normal**: indicates that the JavaScript component is an application instance.
**form**: indicates that the JavaScript component is a widget instance.| String | Yes (initial value: **normal**)| + | type | Type of the JavaScript component.
**normal**: indicates an application instance.
**form**: indicates a widget instance.| String | Yes (initial value: **normal**)| | mode | Development mode of the JavaScript component. | Object | Yes (initial value: left empty) | - A configuration example is as follows: + Example configuration: ```json "js": [{ @@ -145,27 +145,27 @@ Configure the **config.json** file for the widget. }] ``` -- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal structure is described as follows: +- The **abilities** module in the **config.json** file corresponds to **LifecycleForm** of the widget. The internal structure is described as follows: | Field | Description | Data Type | Default | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) | | isDefault | Whether the widget is a default one. Each ability has only one default widget.
**true**: The widget is the default one.
**false**: The widget is not the default one.| Boolean | No | - | type | Type of the widget. Available values are as follows:
**JS**: indicates a JavaScript-programmed widget. | String | No | - | colorMode | Color mode of the widget. Available values are as follows:
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)| - | supportDimensions | Grid styles supported by the widget. Available values are as follows:
**1 * 2**: indicates a grid with one row and two columns.
**2 * 2**: indicates a grid with two rows and two columns.
**2 * 4**: indicates a grid with two rows and four columns.
**4 * 4**: indicates a grid with four rows and four columns.| String array| No | + | type | Type of the widget.
**JS**: indicates a JavaScript-programmed widget. | String | No | + | colorMode | Color mode of the widget.
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)| + | supportDimensions | Grid styles supported by the widget.
**1 * 2**: indicates a grid with one row and two columns.
**2 * 2**: indicates a grid with two rows and two columns.
**2 * 4**: indicates a grid with two rows and four columns.
**4 * 4**: indicates a grid with four rows and four columns.| String array| No | | defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No | - | updateEnabled | Whether the widget can be updated periodically. Available values are as follows:
**true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended.
**false**: The widget cannot be updated periodically.| Boolean | No | - | scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute.
This parameter has a lower priority than **updateDuration**. If both are specified, the value specified by **updateDuration** is used.| String | Yes (initial value: **0:0**) | - | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.
This parameter has a higher priority than **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| Number | Yes (initial value: **0**) | + | updateEnabled | Whether the widget can be updated periodically.
**true**: The widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** takes precedence over **scheduledUpdateTime**.
**false**: The widget cannot be updated periodically.| Boolean | No | + | scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute.
**updateDuration** takes precedence over **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| String | Yes (initial value: **0:0**) | + | updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.
**updateDuration** takes precedence over **scheduledUpdateTime**. If both are specified, the value specified by **updateDuration** is used.| Number | Yes (initial value: **0**) | | formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) | | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) | | jsComponentName | Component name of the widget. The value is a string with a maximum of 127 bytes. | String | No | | metaData | Metadata of the widget. This field contains the array of the **customizeData** field. | Object | Yes (initial value: left empty) | | customizeData | Custom information about the widget. | Object array | Yes (initial value: left empty) | - A configuration example is as follows: + Example configuration: ```json "abilities": [{ @@ -197,7 +197,7 @@ Configure the **config.json** file for the widget. ### Persistently Storing Widget Data -Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget. +A widget provider is usually started when it is needed to provide information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget. ```javascript onCreate(want) { @@ -219,35 +219,35 @@ Mostly, the widget provider is started only when it needs to obtain information } ``` -You should override **onDestroy** to delete widget data. +You should override **onDestroy** to implement widget data deletion. ```javascript onDestroy(formId) { console.log('FormAbility onDestroy'); - // You need to implement the code for deleting the persistent widget instance. + // You need to implement the code for deleting the persistent widget data. // The deleteFormInfo API is not implemented here. deleteFormInfo(formId); } ``` -For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). +For details about how to implement persistence data storage, see [Lightweight Data Store Development](../database/database-preference-guidelines.md). -Note that the **Want** passed by the widget host to the widget provider contains a flag that indicates whether the requested widget is a temporary one. +The **Want** passed by the widget host to the widget provider contains a flag that specifies whether the requested widget is normal or temporary. -- Normal widget: a widget that will be persistently used by the widget host +- Normal widget: a widget persistently used by the widget host -- Temporary widget: a widget that is temporarily used by the widget host +- Temporary widget: a widget temporarily used by the widget host -Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets. +Data of a temporary widget will be deleted on the Widget Manager if the widget framework is killed and restarted. The widget provider, however, is not notified of the deletion and still keeps the data. Therefore, the widget provider needs to clear the data of temporary widgets proactively if the data has been kept for a long period of time. If the widget host has converted a temporary widget into a normal one, the widget provider should change the widget data from temporary storage to persistent storage. Otherwise, the widget data may be deleted by mistake. ### Updating Widget Data -When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows: +When an application initiates a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows: ```javascript onUpdate(formId) { - // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update. + // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host. console.log('FormAbility onUpdate'); let obj = { "title": "titleOnUpdate", @@ -267,9 +267,9 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme > **NOTE** > -> Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI. +> Only the JavaScript-based web-like development paradigm is supported when developing the widget UI. - - In the HML file: + - HML file: ```html
@@ -284,7 +284,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
``` - - In the CSS file: + - CSS file: ```css .container { @@ -325,7 +325,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme } ``` - - In the JSON file: + - JSON file: ```json { "data": { @@ -352,18 +352,18 @@ Now you've got a widget shown below. You can set router and message events for components on a widget. The router event applies to ability redirection, and the message event applies to custom click events. The key steps are as follows: -1. Set **onclick** in the HML file to **routerEvent** or **messageEvent**, depending on the **actions** settings in the JSON file. +1. Set the **onclick** field in the HML file to **routerEvent** or **messageEvent**, depending on the **actions** settings in the JSON file. 2. For the router event, set the following attributes: - - **action**: **"router"**. + - **action**: **router**, which indicates a router event. - **abilityName**: target ability name, for example, **com.example.entry.MainAbility**, which is the default main ability name in DevEco Studio for the FA model. - **params**: custom parameters of the target ability. Set them as required. The value can be obtained from **parameters** in **want** used for starting the target ability. For example, in the lifecycle function **onCreate** of the main ability in the FA model, **featureAbility.getWant()** can be used to obtain **want** and its **parameters** field. 3. For the message event, set the following attributes: - - **action**: **"message"**. + - **action**: **message**, which indicates a message event. - **params**: custom parameters of the message event. Set them as required. The value can be obtained from **message** in the widget lifecycle function **onEvent**. The code snippet is as follows: - - In the HML file: + - HML file: ```html
@@ -378,7 +378,7 @@ The code snippet is as follows:
``` - - In the JSON file: + - JSON file: ```json { "data": { diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 3457aa29249a7c569053a09b6374cf03ce0d8868..d09585b25531556cfbee2ab5cbd45c72191aa8a4 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -1,6 +1,6 @@ # Ability Development ## When to Use -Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the `module.json5` and `app.json5` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic: +Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the **module.json5** and **app.json5** files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic: - Create an ability that supports screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes. - Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page. - Call abilities. For details, see [Call Development](stage-call.md). @@ -8,15 +8,15 @@ Ability development in the [stage model](stage-brief.md) is significantly differ - Continue the ability on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md). ### Launch Type -An ability can be launched in the **standard**, **singleton**, or **specified** mode, as configured by `launchType` in the `module.json5` file. Depending on the launch type, the action performed when the ability is started differs, as described below. +An ability can be launched in the **standard**, **singleton**, or **specified** mode, as configured by **launchType** in the **module.json5** file. Depending on the launch type, the action performed when the ability is started differs, as described below. | Launch Type | Description |Action | | ----------- | ------- |---------------- | -| standard | Standard mode. | A new instance is started each time an ability starts.| -| singleton | Singleton mode. | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.| +| standard | Standard mode | A new instance is started each time an ability starts.| +| singleton | Singleton mode | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.| | specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.| -By default, the singleton mode is used. The following is an example of the `module.json5` file: +By default, the singleton mode is used. The following is an example of the **module.json5** file: ```json { "module": { @@ -30,7 +30,7 @@ By default, the singleton mode is used. The following is an example of the `modu ``` ## Creating an Ability ### Available APIs -The table below describes the APIs provided by the `AbilityStage` class, which has the `context` attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). +The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). **Table 1** AbilityStage APIs |API|Description| @@ -39,7 +39,7 @@ The table below describes the APIs provided by the `AbilityStage` class, which h |onAcceptWant(want: Want): string|Called when a specified ability is started.| |onConfigurationUpdated(config: Configuration): void|Called when the global configuration is updated.| -The table below describes the APIs provided by the `Ability` class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). +The table below describes the APIs provided by the **Ability** class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). **Table 2** Ability APIs @@ -47,19 +47,19 @@ The table below describes the APIs provided by the `Ability` class. For details |:------|:------| |onCreate(want: Want, param: AbilityConstant.LaunchParam): void|Called when an ability is created.| |onDestroy(): void|Called when the ability is destroyed.| -|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a `WindowStage` is created for the ability. You can use the `window.WindowStage` APIs to implement operations such as page loading.| -|onWindowStageDestroy(): void|Called when the `WindowStage` is destroyed for the ability.| +|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a **WindowStage** is created for the ability. You can use the **window.WindowStage** APIs to implement operations such as page loading.| +|onWindowStageDestroy(): void|Called when the **WindowStage** is destroyed for the ability.| |onForeground(): void|Called when the ability is switched to the foreground.| |onBackground(): void|Called when the ability is switched to the background.| -|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Called when the ability launch type is set to `singleton`.| +|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Called when the ability launch type is set to **singleton**.| |onConfigurationUpdated(config: Configuration): void|Called when the configuration of the environment where the ability is running is updated.| ### Implementing AbilityStage and Ability Lifecycle Callbacks -To create Page abilities for an application in the stage model, you must implement the `AbilityStage` class and ability lifecycle callbacks, and use the `Window` APIs to set the pages. The sample code is as follows: -1. Import the `AbilityStage` module. +To create Page abilities for an application in the stage model, you must implement the **AbilityStage** class and ability lifecycle callbacks, and use the **Window** class to set the pages. The sample code is as follows: +1. Import the **AbilityStage** module. ``` import AbilityStage from "@ohos.application.AbilityStage" ``` -2. Implement the `AbilityStage` class. The default relative path generated by the APIs is **entry\src\main\ets\Application\AbilityStage.ts**. +2. Implement the **AbilityStage** class. The default relative path generated by the APIs is **entry\src\main\ets\Application\AbilityStage.ts**. ```ts export default class MyAbilityStage extends AbilityStage { onCreate() { @@ -67,13 +67,13 @@ To create Page abilities for an application in the stage model, you must impleme } } ``` -3. Import the `Ability` module. +3. Import the **Ability** module. ```js import Ability from '@ohos.application.Ability' ``` -4. Implement the lifecycle callbacks of the `Ability` class. The default relative path generated by the APIs is **entry\src\main\ets\MainAbility\MainAbility.ts**. +4. Implement the lifecycle callbacks of the **Ability** class. The default relative path generated by the APIs is **entry\src\main\ets\MainAbility\MainAbility.ts**. - In the `onWindowStageCreate(windowStage)` API, use `loadContent` to set the application page to be loaded. For details about how to use the `Window` APIs, see [Window Development](../windowmanager/application-window-stage.md). + In the **onWindowStageCreate(windowStage)** API, use **loadContent** to set the application page to be loaded. For details about how to use the **Window** APIs, see [Window Development](../windowmanager/application-window-stage.md). ```ts export default class MainAbility extends Ability { onCreate(want, launchParam) { @@ -108,9 +108,9 @@ To create Page abilities for an application in the stage model, you must impleme } ``` ### Obtaining AbilityStage and Ability Configurations -Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. +Both the **AbilityStage** and **Ability** classes have the **context** attribute. An application can obtain the context of an **Ability** instance through **this.context** to obtain the configuration details. -The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows: +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute in the **AbilityStage** class. The sample code is as follows: ```ts import AbilityStage from "@ohos.application.AbilityStage" @@ -130,7 +130,7 @@ export default class MyAbilityStage extends AbilityStage { } ``` -The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `Ability` class. The sample code is as follows: +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute in the **Ability** class. The sample code is as follows: ```ts import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { @@ -149,9 +149,9 @@ export default class MainAbility extends Ability { } ``` ### Requesting Permissions -If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the respective permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json5`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permission for calendar access as an example. +If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the respective permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in **module.json5**, and use the **requestPermissionsFromUser** API to request the permission from consumers in the form of a dialog box. The following uses the permission for calendar access as an example. -Declare the required permission in the `module.json5` file. +Declare the required permission in the **module.json5** file. ```json "requestPermissions": [ { @@ -170,13 +170,13 @@ context.requestPermissionsFromUser(permissions).then((data) => { }) ``` ### Notifying of Environment Changes -Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by configuration items in **Settings** or icons in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md). +Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by configuration items in **Settings** or icons in **Control Panel**. The ability configuration is specific to a single **Ability** instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md). -For an application in the stage model, when the configuration changes, its abilities are not restarted, but the `onConfigurationUpdated(config: Configuration)` callback is triggered. If the application needs to perform processing based on the change, you can overwrite `onConfigurationUpdated`. Note that the `Configuration` object in the callback contains all the configurations of the current ability, not only the changed configurations. +For an application in the stage model, when the configuration changes, its abilities are not restarted, but the **onConfigurationUpdated(config: Configuration)** callback is triggered. If the application needs to perform processing based on the change, you can overwrite **onConfigurationUpdated**. Note that the **Configuration** object in the callback contains all the configurations of the current ability, not only the changed configurations. -The following example shows the implementation of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed. +The following example shows the implementation of the **onConfigurationUpdated** callback in the **AbilityStage** class. The callback is triggered when the system language and color mode are changed. ```ts -import Ability from '@ohos.application.Ability' +import AbilityStage from '@ohos.application.AbilityStage' import ConfigurationConstant from '@ohos.application.ConfigurationConstant' export default class MyAbilityStage extends AbilityStage { @@ -188,7 +188,7 @@ export default class MyAbilityStage extends AbilityStage { } ``` -The following example shows the implementation of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change. +The following example shows the implementation of the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change. ```ts import Ability from '@ohos.application.Ability' import ConfigurationConstant from '@ohos.application.ConfigurationConstant' @@ -209,7 +209,7 @@ export default class MainAbility extends Ability { ``` ## Starting an Ability ### Available APIs -The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes as well as the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). +The **Ability** class has the **context** attribute, which belongs to the **AbilityContext** class. The **AbilityContext** class has the **abilityInfo**, **currentHapModuleInfo**, and other attributes as well as the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). **Table 3** AbilityContext APIs |API|Description| @@ -223,7 +223,7 @@ The `Ability` class has the `context` attribute, which belongs to the `AbilityCo |startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the execution result and account ID.| |startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the execution result and account ID.| ### Starting an Ability on the Same Device -An application can obtain the context of an `Ability` instance through `this.context` and then use the `startAbility` API in the `AbilityContext` class to start the ability. The ability can be started by specifying `Want`, `StartOptions`, and `accountId`, and the operation result can be returned using a callback or `Promise` instance. The sample code is as follows: +An application can obtain the context of an **Ability** instance through **this.context** and then use the **startAbility** API in the **AbilityContext** class to start the ability. The ability can be started by specifying **Want**, **StartOptions**, and **accountId**, and the operation result can be returned using a callback or **Promise** instance. The sample code is as follows: ```ts let context = this.context var want = { @@ -239,7 +239,7 @@ context.startAbility(want).then(() => { ``` ### Starting an Ability on a Remote Device ->This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications. +>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. In the cross-device scenario, you must specify the ID of the remote device. The sample code is as follows: ```ts let context = this.context @@ -254,7 +254,7 @@ context.startAbility(want).then(() => { console.error("Failed to start remote ability with error: " + JSON.stringify(error)) }) ``` -Obtain the ID of a specified device from `DeviceManager`. The sample code is as follows: +Obtain the ID of a specified device from **DeviceManager**. The sample code is as follows: ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; function getRemoteDeviceId() { @@ -271,11 +271,11 @@ function getRemoteDeviceId() { } } ``` -Request the permission `ohos.permission.DISTRIBUTED_DATASYNC` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions). +Request the permission **ohos.permission.DISTRIBUTED_DATASYNC** from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](#requesting-permissions). ### Starting an Ability with the Specified Page -If the launch type of an ability is set to `singleton` and the ability has been started, the `onNewWant` callback is triggered when the ability is started again. You can pass start options through the `want`. For example, to start an ability with the specified page, use the `uri` or `parameters` parameter in the `want` to pass the page information. Currently, the ability in the stage model cannot directly use the `router` capability. You must pass the start options to the custom component and invoke the `router` method to display the specified page during the custom component lifecycle management. The sample code is as follows: +If the launch type of an ability is set to **singleton** and the ability has been started, the **onNewWant** callback is triggered when the ability is started again. You can pass start options through the **want**. For example, to start an ability with the specified page, use the **uri** or **parameters** parameter in the **want** to pass the page information. Currently, the ability in the stage model cannot directly use the **router** capability. You must pass the start options to the custom component and invoke the **router** method to display the specified page during the custom component lifecycle management. The sample code is as follows: -When using `startAbility` to start an ability again, use the `uri` parameter in the `want` to pass the page information. +When using **startAbility** to start an ability again, use the **uri** parameter in the **want** to pass the page information. ```ts async function reStartAbility() { try { @@ -291,7 +291,7 @@ async function reStartAbility() { } ``` -Obtain the `want` parameter that contains the page information from the `onNewWant` callback of the ability. +Obtain the **want** parameter that contains the page information from the **onNewWant** callback of the ability. ```ts import Ability from '@ohos.application.Ability' @@ -302,7 +302,7 @@ export default class MainAbility extends Ability { } ``` -Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI. +Obtain the **want** parameter that contains the page information from the custom component and process the route based on the URI. ```ts import router from '@ohos.router' @@ -315,7 +315,7 @@ struct Index { console.info('Index onPageShow') let newWant = globalThis.newWant if (newWant.hasOwnProperty("uri")) { - router.push({ uri: newWant.uri }); + router.push({ url: newWant.uri }); globalThis.newWant = undefined } } diff --git a/en/application-dev/device-usage-statistics/Readme-EN.md b/en/application-dev/device-usage-statistics/Readme-EN.md index 75cfad35e1f36bfe07f0cb408c936f87e0ee520a..ccdf5a72d692b5e5e62a906819de1d6681ccfacf 100644 --- a/en/application-dev/device-usage-statistics/Readme-EN.md +++ b/en/application-dev/device-usage-statistics/Readme-EN.md @@ -1,4 +1,5 @@ # Device Usage Statistics - [Device Usage Statistics Overview](device-usage-statistics-overview.md) -- [Device Usage Statistics Development](device-usage-statistics-dev-guide.md) +- [Device Usage Statistics Development](device-usage-statistics-use-guide.md) + diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md deleted file mode 100644 index 60aa41fedd15531c583c48200eddc3c91e5a8fde..0000000000000000000000000000000000000000 --- a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ /dev/null @@ -1,440 +0,0 @@ -# Device Usage Statistics Development - -## When to Use - -With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and bundle group. -The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported. - -## Available APIs -Import the **stats** package to implement registration: -```js -import stats from '@ohos.bundleState'; -``` - -**Table 1** Major APIs for device usage statistics - -| API| Description| -| -------- | -------- | -| function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of all applications based on the specified start time and end time.| -| function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void | Queries the application usage duration statistics based on the specified start time and end time.| -| function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of this application based on the specified start time and end time.| -| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).| -| function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.| -| function queryAppUsagePriorityGroup(): Promise<number>; | Queries the priority group of this application. This API uses a promise to return the result.| -| function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. | -| function getRecentlyUsedModules(callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains a maximum of 1000 FA usage records. | -| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**, which cannot exceed 1000.| -| function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries the number of notifications from all applications based on the specified start time and end time.| -| function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.| -| function queryAppUsagePriorityGroup(bundleName : string, callback: AsyncCallback<number>): void | Queries the priority group of the application specified by **bundleName**. This API uses an asynchronous callback to return the result.| -| function queryAppUsagePriorityGroup(bundleName? : string): Promise<number>; | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.| -| function setBundleGroup(bundleName : string, newGroup: GroupType, callback: AsyncCallback>boolean>): void | Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.| -| function setBundleGroup(bundleName : string, newGroup : GroupType): Promise>boolean>; | Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.| -| function registerGroupCallBack(groupCallback: Callback>BundleActiveGroupCallbackInfo>, callback: AsyncCallback>boolean>): void | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result.| -| function registerGroupCallBack(groupCallback: Callback>BundleActiveGroupCallbackInfo>): Promise>boolean>; | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses a promise to return the result.| -| function unRegisterGroupCallBack(callback: AsyncCallback>boolean>): void | Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.| -| function unRegisterGroupCallBack(): Promise>boolean>; | Deregisters the callback for application group changes. This API uses a promise to return the result.| - -## How to Develop - -1. Configure the device usage statistics permission in the **config.json** file. - - ```json - "module": { - "package": "com.example.deviceUsageStatistics", - ..., - "reqPermissions": [ - { - "name": "ohos.permission.BUNDLE_ACTIVE_INFO" - } - ] - } - ``` - -2. Query events of all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryBundleActiveStates(0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); - } - }).catch(err => { - console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i])); - } - } - }); - ``` - -3. Query the application usage duration statistics based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryBundleStateInfos(0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); - let i = 1; - for (let key in res){ - console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i); - console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); - i++; - } - }).catch(err => { - console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.'); - let i = 1; - for(let key in res){ - console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i); - console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key])); - i++; - } - } - }); - ``` - -4. Query events of this application based on the specified start time and end time. This requires no permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryCurrentBundleActiveStates(0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); - } - }).catch(err => { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i])); - } - } - }); - ``` - -5. Query the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually). This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); - } - }).catch(err => { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i])); - } - } - }); - ``` - -6. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryAppUsagePriorityGroup().then(res => { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); - }); - - // Callback mode - stats.queryAppUsagePriorityGroup((err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); - } - }); - ``` - -7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file. A third-party application can only check the idle status of itself. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.isIdleState("com.ohos.camera").then(res => { - console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.isIdleState("com.ohos.camera", (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); - } - }); - ``` - -8. Obtain the number of FA usage records specified by **maxNum**. If **maxNum** is not specified, the default value **1000** is used. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.getRecentlyUsedModules(1000).then(res => { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i])); - } - }).catch(err=> { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); - }); - - // Promise mode when maxNum is not specified - stats.getRecentlyUsedModules().then(res => { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i])); - } - }).catch( err=> { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.getRecentlyUsedModules(1000, (err, res) => { - if(err) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i])); - } - } - }); - - // Asynchronous callback mode when maxNum is not specified - stats.getRecentlyUsedModules((err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.'); - for (let i = 0; i < res.length; i++) { - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1)); - console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i])); - } - } - }); - ``` - -9. Query the number of notifications from all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryAppNotificationNumber(0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.'); - console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryAppNotificationNumber(0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback success.'); - console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback result ' + JSON.stringify(res)); - } - }); - ``` - -10. Query statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode - stats.queryBundleActiveEventStates(0, 20000000000000).then(res => { - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.'); - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code); - }); - - // Asynchronous callback mode - stats.queryBundleActiveEventStates(0, 20000000000000, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback success.'); - console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback result ' + JSON.stringify(res)); - } - }); - ``` - -11. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file. Query the priority group of a specified application. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file. - - ```js - import stats from '@ohos.bundleState' - - // Promise mode when bundleName is not specified - stats.queryAppUsagePriorityGroup().then(res => { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); - }); - - // Asynchronous callback mode when bundleName is not specified - stats.queryAppUsagePriorityGroup((err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); - } - }); - let bundleName = "com.ohos.camera"; - // Promise mode when bundleName is specified - stats.queryAppUsagePriorityGroup(bundleName).then(res => { - console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch(err => { - console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code); - }); - - // Asynchronous callback mode when bundleName is specified - stats.queryAppUsagePriorityGroup(bundleName, (err, res) => { - if (err) { - console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res)); - } - }); - ``` - -11. Set the group for the application specified by **bundleName**. - - ```javascript - import stats from '@ohos.bundleState' - - // Promise mode - stats.setBundleGroup(this.bundleName, this.newGroup).then(() => { - console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.'); - }).catch( err => { - console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code); - }); - // Asynchronous callback mode - stats.setBundleGroup(this.bundleName, this.newGroup, (err) => { - if (err) { - console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.'); - } - }); - ``` - -12. Register a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. - - ```javascript - import stats from '@ohos.bundleState' - - // Promise mode - let onBundleGroupChanged = (err,res) => { - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName); - }; - stats.registerGroupCallBack(onBundleGroupChanged).then(() => { - console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.'); - }).catch(err => { - console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code); - }); - // Asynchronous callback mode - let onBundleGroupChanged = (err,res) => { - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName); - }; - stats.registerGroupCallBack(onBundleGroupChanged, (err) => { - if (err) { - console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.'); - } - }); - ``` - -13. Deregister the callback for application group changes. - - ```javascript - import stats from '@ohos.bundleState' - - // Promise mode - stats.unRegisterGroupCallBack().then(() => { - console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.'); - }).catch(err => { - console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code); - }); - // Asynchronous callback mode - stats.unRegisterGroupCallBack((err) => { - if (err) { - console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.'); - } - }); - ``` - diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..45255f18ee313ad96d072e42f620b219315a8adf --- /dev/null +++ b/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md @@ -0,0 +1,534 @@ +# Device Usage Statistics Development (API Version 9) + +## When to Use + +With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and application group. +The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported. + +## Available APIs +Import the **stats** package to implement registration: +```js +import usageStatistics from '@ohos.resourceschedule.usageStatistics'; +``` + +**Table 1** Major APIs for device usage statistics + +| API| Description| +| -------- | -------- | +| function queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void | Queries events of all applications based on the specified start time and end time.| +| function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<BundleStatsMap>): void | Queries the application usage duration statistics based on the specified start time and end time.| +| function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback<Array<BundleEvents>>): void | Queries events of this application based on the specified start time and end time.| +| function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStatsInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).| +| function queryAppGroup(callback: AsyncCallback<number>): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.| +| function queryAppGroup(): Promise<number>; | Queries the priority group of this application. This API uses a promise to return the result.| +| function queryAppGroup(bundleName : string, callback: AsyncCallback<number>): void | Queries the priority group of the application specified by **bundleName**. This API uses an asynchronous callback to return the result.| +| function queryAppGroup(bundleName : string): Promise<number>; | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.| +| function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. | +| function queryModuleUsageRecords(callback: AsyncCallback<HapModuleInfo>): void | Obtains a maximum of 1000 FA usage records.| +| function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<HapModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**, which cannot exceed 1000.| +| function queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void | Queries the number of notifications from all applications based on the specified start time and end time.| +| function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Array<DeviceEventStats>>): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.| +| function setAppGroup(bundleName : string, newGroup: GroupType, callback: AsyncCallback>boolean>): void | Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.| +| function setAppGroup(bundleName : string, newGroup : GroupType): Promise>boolean>; | Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.| +| function registerAppGroupCallBack(groupCallback: Callback>AppGroupCallbackInfo>, callback: AsyncCallback>boolean>): void | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result.| +| function registerAppGroupCallBack(groupCallback: Callback>AppGroupCallbackInfo>): Promise>boolean>; | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses a promise to return the result.| +| function unregisterAppGroupCallBack(callback: AsyncCallback>boolean>): void | Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.| +| function unregisterAppGroupCallBack(): Promise>boolean>; | Deregisters the callback for application group changes. This API uses a promise to return the result.| + +## How to Develop + +1. Before obtaining the device usage statistics, check whether the **ohos.permission.BUNDLE_ACTIVE_INFO** permission is configured. For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md). + +2. Query events of all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryBundleEvents(0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryBundleEvents promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleEvents promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleEvents promise result ' + JSON.stringify(res[i])); + } + }).catch( err => { + console.log('BUNDLE_ACTIVE queryBundleEvents promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleEvents throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryBundleEvents(0, 20000000000000, (err, res) => { + if (err) { + console.log('BUNDLE_ACTIVE queryBundleEvents callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryBundleEvents callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleEvents callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleEvents callback result ' + JSON.stringify(res[i])); + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleEvents throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +3. Query the application usage duration statistics based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryBundleStatsInfos(0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise success.'); + let i = 1; + for(let key in res){ + console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise result ' + JSON.stringify(res[key])); + i++; + } + }).catch( err => { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryBundleStatsInfos(0, 20000000000000, (err, res) => { + if (err) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback success.'); + let i = 1; + for(let key in res){ + console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStatsInfos callback result ' + JSON.stringify(res[key])); + i++; + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfos throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +4. Query events of this application based on the specified start time and end time. This requires no permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryCurrentBundleEvents(0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise result ' + JSON.stringify(res[i])); + } + }).catch( err => { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryCurrentBundleEvents(0, 20000000000000, (err, res) => { + if (err) { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents callback result ' + JSON.stringify(res[i])); + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryCurrentBundleEvents throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +5. Query the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually). This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryBundleStatsInfoByInterval(0, 0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise result ' + JSON.stringify(res[i])); + } + }).catch( err => { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryBundleStatsInfoByInterval(0, 0, 20000000000000, (err, res) => { + if (err) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval callback result ' + JSON.stringify(res[i])); + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryBundleStatsInfoByInterval throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +6. Query the priority group of the current application. This requires no permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryAppGroup().then( res => { + console.log('BUNDLE_ACTIVE queryAppGroup promise succeeded. result: ' + JSON.stringify(res)); + }).catch( err => { + console.log('BUNDLE_ACTIVE queryAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Callback mode + try{ + usageStatistics.queryAppGroup((err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryAppGroup callback succeeded. result: ' + JSON.stringify(res)); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured. A third-party application can only check the idle status of itself. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.isIdleState("com.ohos.camera").then( res => { + console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); + }).catch( err => { + console.log('BUNDLE_ACTIVE isIdleState promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE isIdleState throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.isIdleState("com.ohos.camera", (err, res) => { + if (err) { + console.log('BUNDLE_ACTIVE isIdleState callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); + } + }); + } catch(error) { + console.log('BUNDLE_ACTIVE isIdleState throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +8. Obtain the number of FA usage records specified by **maxNum**. If **maxNum** is not specified, the default value **1000** is used. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryModuleUsageRecords(1000).then( res => { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise succeeded'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise result ' + JSON.stringify(res[i])); + } + }).catch( err=> { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Promise mode when maxNum is not specified + try{ + usageStatistics.queryModuleUsageRecords().then( res => { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise succeeded'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise result ' + JSON.stringify(res[i])); + } + }).catch( err=> { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryModuleUsageRecords(1000, (err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback succeeded.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback result ' + JSON.stringify(res[i])); + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode when maxNum is not specified + try{ + usageStatistics.queryModuleUsageRecords((err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback succeeded.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryModuleUsageRecords callback result ' + JSON.stringify(res[i])); + } + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +9. Query the number of notifications from all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryNotificationEventStats(0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryNotificationEventStats promise success.'); + console.log('BUNDLE_ACTIVE queryNotificationEventStats promise result ' + JSON.stringify(res)); + }).catch( err=> { + console.log('BUNDLE_ACTIVE queryNotificationEventStats promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryNotificationEventStats throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryNotificationEventStats(0, 20000000000000, (err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryNotificationEventStats callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryNotificationEventStats callback success.'); + console.log('BUNDLE_ACTIVE queryNotificationEventStats callback result ' + JSON.stringify(res)); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryNotificationEventStats throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +10. Query statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + try{ + usageStatistics.queryDeviceEventStats(0, 20000000000000).then( res => { + console.log('BUNDLE_ACTIVE queryDeviceEventStates promise success.'); + console.log('BUNDLE_ACTIVE queryDeviceEventStates promise result ' + JSON.stringify(res)); + }).catch( err=> { + console.log('BUNDLE_ACTIVE queryDeviceEventStats promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryDeviceEventStats throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + try{ + usageStatistics.queryDeviceEventStats(0, 20000000000000, (err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryDeviceEventStats callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryDeviceEventStats callback success.'); + console.log('BUNDLE_ACTIVE queryDeviceEventStats callback result ' + JSON.stringify(res)); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryDeviceEventStats throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +11. Query the priority group of the application specified by **bundleName**. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```js + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode when bundleName is specified + let bundleName = "com.ohos.camera"; + try{ + usageStatistics.queryAppGroup(bundleName).then( res => { + console.log('BUNDLE_ACTIVE queryAppGroup promise succeeded. result: ' + JSON.stringify(res)); + }).catch( err => { + console.log('BUNDLE_ACTIVE queryAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode when bundleName is specified + let bundleName = "com.ohos.camera"; + try{ + usageStatistics.queryAppGroup(bundleName, (err, res) => { + if(err) { + console.log('BUNDLE_ACTIVE queryAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE queryAppGroup callback succeeded. result: ' + JSON.stringify(res)); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +12. Set the priority group of for application specified by **bundleName**. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```javascript + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + let bundleName = "com.example.deviceUsageStatistics"; + let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; + + try{ + usageStatistics.setAppGroup(bundleName, newGroup).then( () => { + console.log('BUNDLE_ACTIVE setAppGroup promise succeeded.'); + }).catch( err => { + console.log('BUNDLE_ACTIVE setAppGroup promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE setAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + let bundleName = "com.example.deviceUsageStatistics"; + let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; + + try{ + usageStatistics.setAppGroup(bundleName, newGroup, (err) => { + if(err) { + console.log('BUNDLE_ACTIVE setAppGroup callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE setAppGroup callback succeeded.'); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE setAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +13. Register a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```javascript + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // Promise mode + let onBundleGroupChanged = (res) =>{ + console.log('BUNDLE_ACTIVE registerAppGroupCallBack RegisterGroupCallBack callback success.'); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appOldGroup is : ' + res.appOldGroup); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appNewGroup is : ' + res.appNewGroup); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result changeReason is : ' + res.changeReason); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result userId is : ' + res.userId); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result bundleName is : ' + res.bundleName); + }; + try{ + usageStatistics.registerAppGroupCallBack(onBundleGroupChanged).then( () => { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack promise succeeded.'); + }).catch( err => { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // Asynchronous callback mode + let onBundleGroupChanged = (err, res) =>{ + console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appOldGroup is : ' + res.appOldGroup); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result appNewGroup is : ' + res.appNewGroup); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result changeReason is : ' + res.changeReason); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result userId is : ' + res.userId); + console.log('BUNDLE_ACTIVE registerAppGroupCallBack result bundleName is : ' + res.bundleName); + }; + try{ + usageStatistics.registerAppGroupCallBack(onBundleGroupChanged, err => { + if(err) { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack callback success.'); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE registerAppGroupCallBack throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` + +14. Deregister the callback for application group changes. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. + + ```javascript + import usageStatistics from '@ohos.resourceschedule.usageStatistics' + + // promise + try{ + usageStatistics.unregisterAppGroupCallBack().then( () => { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack promise succeeded.'); + }).catch( err => { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); + } catch (error) { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack throw error, code is: ' + error.code + ',message is: ' + error.message); + } + + // callback + try{ + usageStatistics.unregisterAppGroupCallBack(err => { + if(err) { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack callback success.'); + } + }); + } catch (error) { + console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack throw error, code is: ' + error.code + ',message is: ' + error.message); + } + ``` \ No newline at end of file diff --git a/en/application-dev/napi/drawing-guidelines.md b/en/application-dev/napi/drawing-guidelines.md index 7cbf0e3d9e10bb6d8d346e8f6a9910771c523434..1355a27dcf7fb5e54a283ccd5c39a4f1b19de381 100644 --- a/en/application-dev/napi/drawing-guidelines.md +++ b/en/application-dev/napi/drawing-guidelines.md @@ -4,11 +4,11 @@ The Native Drawing module provides APIs for drawing 2D graphics and text. The following scenarios are common for drawing development: * Drawing 2D graphics -* Drawing and painting text +* Drawing text drawing ## Available APIs -| API| Description| +| API| Description| | -------- | -------- | | OH_Drawing_BitmapCreate (void) | Creates a bitmap object.| | OH_Drawing_BitmapBuild (OH_Drawing_Bitmap *, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat *) | Initializes the width and height of a bitmap object and sets the pixel format for the bitmap.| @@ -19,7 +19,7 @@ The Native Drawing module provides APIs for drawing 2D graphics and text. The fo | OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas *, const OH_Drawing_Path *) | Draws a path.| | OH_Drawing_PathCreate (void) | Creates a path object.| | OH_Drawing_PathMoveTo (OH_Drawing_Path *, float x, float y) | Sets the start point of a path.| -| OH_Drawing_PathLineTo (OH_Drawing_Path *, float x, float y) | Draws a line segment from the last point of a path to the target point. | +| OH_Drawing_PathLineTo (OH_Drawing_Path *, float x, float y) | Draws a line segment from the last point of a path to the target point.| | OH_Drawing_PathClose (OH_Drawing_Path *) | Closes a path. A line segment from the start point to the last point of the path is added.| | OH_Drawing_PenCreate (void) | Creates a pen object.| | OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen *, bool) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency.| @@ -138,7 +138,7 @@ The following steps describe how to use the canvas and brush of the Native Drawi OH_Drawing_BitmapDestory(cBitmap); ``` -## Development Procedure for Text Drawing and Display +## Development Procedure for Text Drawing The following steps describe how to use the text drawing and display feature of the Native Drawing module. 1. **Create a canvas and a bitmap.** @@ -196,7 +196,8 @@ The following steps describe how to use the text drawing and display feature of // Set the maximum width. double maxWidth = 800.0; OH_Drawing_TypographyLayout(typography, maxWidth); - // Set the start position for text display. + // Set the start position for drawing the text on the canvas. double position[2] = {10.0, 15.0}; + // Draw the text on the canvas. OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]); ``` diff --git a/en/application-dev/napi/native-window-guidelines.md b/en/application-dev/napi/native-window-guidelines.md index b92ccc54234c9162dad4b35242dcf9d992e5eeec..a71a261c8d2dc6cee74e79deff99d50814a00007 100644 --- a/en/application-dev/napi/native-window-guidelines.md +++ b/en/application-dev/napi/native-window-guidelines.md @@ -1,107 +1,99 @@ -# NativeWindow Development +# Native Window Development ## When to Use -`NativeWindow` is a local platform window of OpenHarmony. It provides APIs for you to create a native window from `Surface`, create a native window buffer from `SurfaceBuffer`, and request and flush a buffer. +**NativeWindow** is a local platform-based window of OpenHarmony that represents the producer of a graphics queue. It provides APIs for you to create a native window from **Surface**, create a native window buffer from **SurfaceBuffer**, and request and flush a buffer. The following scenarios are common for native window development: -* Drawing content using native C++ code and displaying the content on the screen -* Requesting and flushing a buffer when adapting to EGL `eglswapbuffer` +* Request a graphics buffer by using the NAPI provided by **NativeWindow**, write the produced graphics content to the buffer, and flush the buffer to the graphics queue. +* Request and flush a buffer when adapting to the **eglswapbuffer** interface at the EGL. ## Available APIs | API| Description| | -------- | -------- | -| OH_NativeWindow_CreateNativeWindowFromSurface (void \*pSurface) | Creates a `NativeWindow` instance. A new `NativeWindow` instance is created each time this function is called.| -| OH_NativeWindow_DestroyNativeWindow (struct NativeWindow \*window) | Decreases the reference count of a `NativeWindow` instance by 1 and, when the reference count reaches 0, destroys the instance.| -| OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void \*pSurfaceBuffer) | Creates a `NativeWindowBuffer` instance. A new `NativeWindowBuffer` instance is created each time this function is called.| -| OH_NativeWindow_DestroyNativeWindowBuffer (struct NativeWindowBuffer \*buffer) | Decreases the reference count of a `NativeWindowBuffer` instance by 1 and, when the reference count reaches 0, destroys the instance.| -| OH_NativeWindow_NativeWindowRequestBuffer (struct NativeWindow \*window struct NativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a `NativeWindowBuffer` through a `NativeWindow` instance for content production.| -| OH_NativeWindow_NativeWindowFlushBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the `NativeWindowBuffer` filled with the content to the buffer queue through a `NativeWindow` instance for content consumption.| -| OH_NativeWindow_NativeWindowCancelBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer) | Returns the `NativeWindowBuffer` to the buffer queue through a `NativeWindow` instance, without filling in any content. The `NativeWindowBuffer` can be used for another request.| -| OH_NativeWindow_NativeWindowHandleOpt (struct NativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format.| -| OH_NativeWindow_GetBufferHandleFromNative (struct NativeWindowBuffer \*buffer) | Obtains the pointer to a `BufferHandle` of a `NativeWindowBuffer` instance.| +| OH_NativeWindow_CreateNativeWindowFromSurface (void \*pSurface) | Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called.| +| OH_NativeWindow_DestroyNativeWindow (OHNativeWindow \*window) | Decreases the reference count of a **NativeWindow** instance by 1 and, when the reference count reaches 0, destroys the instance.| +| OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void \*pSurfaceBuffer) | Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called.| +| OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer \*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.| +| OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production.| +| OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption.| +| OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request.| +| OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format.| +| OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer \*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance.| | OH_NativeWindow_NativeObjectReference (void \*obj) | Adds the reference count of a native object.| | OH_NativeWindow_NativeObjectUnreference (void \*obj) | Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object.| | OH_NativeWindow_GetNativeObjectMagic (void \*obj) | Obtains the magic ID of a native object.| - +| OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow \*window, uint32_t sequence, OHScalingMode scalingMode) | Sets the scaling mode of the native window.| +| OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow \*window, uint32_t sequence, int32_t size, const OHHDRMetaData \*metaData) | Sets the HDR static metadata of the native window.| +| OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow \*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | Sets the HDR static metadata set of the native window.| +| OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow \*window, const OHExtDataHandle \*handle) | Sets the tunnel handle to the native window.| ## How to Develop -The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to draw content using native C++ code and display the content on the screen. - -1. Define an `XComponent` of the `texture` type in `index.ets` for content display. - ```js - XComponent({ id: 'xcomponentId', type: 'texture', libraryname: 'nativerender'}) - .borderColor(Color.Red) - .borderWidth(5) - .onLoad(() => {}) - .onDestroy(() => {}) - ``` - -2. Obtain an `OH_NativeXComponent` instance (named `nativeXComponent` in this example) by calling `napi_get_named_property`, and obtain a `NativeWindow` instance by registering the callback of the `OH_NativeXComponent` instance. +The following describes how to use the NAPI provided by **NativeWindow** to request a graphics buffer, write the produced graphics content to the buffer, and flush the buffer to the graphics queue. +1. Obtain a **NativeWindow** instance. For example, use **Surface** to create a **NativeWindow** instance. ```c++ - // Define a NAPI instance. - napi_value exportInstance = nullptr; - // Define an OH_NativeXComponent instance. - OH_NativeXComponent *nativeXComponent = nullptr; - // Use the OH_NATIVE_XCOMPONENT_OBJ export instance. - napi_getname_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance); - // Convert the NAPI instance to the OH_NativeXComponent instance. - napi_unwarp(env, exportInstance, reinterpret_cast(&nativeXComponent)); + sptr cSurface = Surface::CreateSurfaceAsConsumer(); + sptr listener = new BufferConsumerListenerTest(); + cSurface->RegisterConsumerListener(listener); + sptr producer = cSurface->GetProducer(); + sptr pSurface = Surface::CreateSurfaceAsProducer(producer); + OHNativeWindow* nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface); ``` -3. Define the callback `OnSurfaceCreated`. During the creation of a `Surface`, the callback is used to initialize the rendering environment, for example, the `Skia` rendering environment, and write the content to be displayed to `NativeWindow`. - +2. Set the attributes of a native window buffer by using **OH_NativeWindow_NativeWindowHandleOpt**. ```c++ - void OnSurfaceCreatedCB(NativeXComponent* component, void* window) { - // Obtain the width and height of the native window. - uint64_t width_ = 0, height_ = 0; - OH_NativeXComponent_GetXComponentSize(nativeXComponent, window, &width_, &height_); - // Convert void* into a NativeWindow instance. NativeWindow is defined in native_window/external_window.h. - NativeWindow* nativeWindow_ = (NativeWindow*)(window); - - // Set or obtain the NativeWindow attributes by calling OH_NativeWindow_NativeWindowHandleOpt. - // 1. Use SET_USAGE to set the usage attribute of the native window, for example, to HBM_USE_CPU_READ. - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_USAGE, HBM_USE_CPU_READ | HBM_USE_CPU_WRITE |HBM_USE_MEM_DMA); - // 2. Use SET_BUFFER_GEOMETRY to set the width and height attributes of the native window. - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_); - // 3. Use SET_FORMAT to set the format attribute of the native window, for example, to PIXEL_FMT_RGBA_8888. - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGBA_8888); - // 4. Use SET_STRIDE to set the stride attribute of the native window. - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, 0x8); - - // Obtain the NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer. - struct NativeWindowBuffer* buffer = nullptr; - int fenceFd; - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &fenceFd); - - // Obtain the buffer handle by calling OH_NativeWindow_GetNativeBufferHandleFromNative. - BufferHandle* bufferHandle = OH_NativeWindow_GetNativeBufferHandleFromNative(buffer); + // Set the read and write scenarios of the native window buffer. + int code = SET_USAGE; + int32_t usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA; + int32_t ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, usage); + // Set the width and height of the native window buffer. + code = SET_BUFFER_GEOMETRY; + int32_t width = 0x100; + int32_t height = 0x100; + ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); + // Set the step of the native window buffer. + code = SET_STRIDE; + int32_t stride = 0x8; + ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, stride); + // Set the format of the native window buffer. + code = SET_FORMAT; + int32_t format = PIXEL_FMT_RGBA_8888; + ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, format); + ``` - // Create a Skia bitmap using BufferHandle. - SkBitmap bitmap; - SkImageInfo imageInfo = ... - bitmap.setInfo(imageInfo, bufferHandle->stride); - bitmap.setPixels(bufferHandle->virAddr); - // Create Skia Canvas and write the content to the native window. - ... +3. Request a native window buffer from the graphics queue. + ```c++ + struct NativeWindowBuffer* buffer = nullptr; + int fenceFd; + // Obtain the NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer. + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &fenceFd); + // Obtain the buffer handle by calling OH_NativeWindow_GetNativeBufferHandleFromNative. + BufferHandle* bufferHandle = OH_NativeWindow_GetNativeBufferHandleFromNative(buffer); + ``` - // After the write operation is complete, flush the buffer by using OH_NativeWindow_NativeWindowFlushBuffer so that the data is displayed on the screen. - Region region{nullptr, 0}; - OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, fenceFd, region) +4. Write the produced content to the native window buffer. + ```c++ + auto image = static_cast(buffer->sfbuffer->GetVirAddr()); + static uint32_t value = 0x00; + value++; + + uint32_t *pixel = static_cast(image); + for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + *pixel++ = value; + } } ``` -4. Register the callback `OnSurfaceCreated` by using `OH_NativeXComponent_RegisterCallback`. +5. Flush the native window buffer to the graphics queue. ```c++ - OH_NativeXComponent_Callback &callback_; - callback_->OnSurfaceCreated = OnSurfaceCreatedCB; - callback_->OnSurfaceChanged = OnSurfaceChangedCB; - callback_->OnSurfaceDestoryed = OnSurfaceDestoryedCB; - callback_->DispatchTouchEvent = DispatchTouchEventCB; - OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_) + // Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the native window buffer are changed. + Region region{nullptr, 0}; + // Flush the buffer to the consumer through OH_NativeWindow_NativeWindowFlushBuffer, for example, by displaying it on the screen. + OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, fenceFd, region); ``` diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index 0a7533ea2389f74866ced1742937daeffe134fcc..64e2d51d737e740216286689bab453b583daeddc 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -2,11 +2,12 @@ - Getting Started - [Preparations](start-overview.md) - - [Getting Started with eTS in Stage Model](start-with-ets-stage.md) - - [Getting Started with eTS in FA Model](start-with-ets-fa.md) + - [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md) + - [Getting Started with ArkTS in FA Model](start-with-ets-fa.md) - [Getting Started with JavaScript in FA Model](start-with-js-fa.md) - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](package-structure.md) - [Application Package Structure Configuration File (Stage Model)](stage-structure.md) - [SysCap](syscap.md) - [HarmonyAppProvision Configuration File](app-provision-structure.md) + diff --git a/en/application-dev/quick-start/figures/create-resource-file-1.png b/en/application-dev/quick-start/figures/create-resource-file-1.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d82caac558cd58b78aba3014b6ac60148f6bc8 Binary files /dev/null and b/en/application-dev/quick-start/figures/create-resource-file-1.png differ diff --git a/en/application-dev/quick-start/figures/create-resource-file-2.png b/en/application-dev/quick-start/figures/create-resource-file-2.png new file mode 100644 index 0000000000000000000000000000000000000000..b4d23e8dc15bafbb08ca691575ce2ea9fe989e91 Binary files /dev/null and b/en/application-dev/quick-start/figures/create-resource-file-2.png differ diff --git a/en/application-dev/quick-start/figures/create-resource-file-3.png b/en/application-dev/quick-start/figures/create-resource-file-3.png new file mode 100644 index 0000000000000000000000000000000000000000..566653c5e49753e1f04d0d6b5b5c3e931f4354b5 Binary files /dev/null and b/en/application-dev/quick-start/figures/create-resource-file-3.png differ diff --git a/en/application-dev/quick-start/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md new file mode 100644 index 0000000000000000000000000000000000000000..ada7d231b599c48ece21b100deaf044627a4dde4 --- /dev/null +++ b/en/application-dev/quick-start/resource-categories-and-access.md @@ -0,0 +1,283 @@ +# Resource Categories and Access + +## Resource Categories + +Resource files used during application development must be stored in specified directories for management. + +### resources Directory + +The **resources** directory consists of three types of sub-directories: the **base** sub-directory, qualifiers sub-directories, and the **rawfile** sub-directory. The common resource files used across projects in the stage model are stored in the **resources** directory under **AppScope**. + + Example of the **resources** directory: + +``` +resources +|---base // Default directory +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---en_GB-vertical-car-mdpi // Example of a qualifiers sub-directory, which needs to be created on your own +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---rawfile +``` + +**Table 1** Classification of the resources directory + +| Category | base Sub-directory | Qualifiers Sub-directory | rawfile Sub-directory | +| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| Structure| The **base** sub-directory is a default directory. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced.
Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories).| You need to create qualifiers sub-directories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).
Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** sub-directory will not be matched based on the device status.| +| Compilation| Resource files in the sub-directory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | +| Reference| Resource files in the sub-directory are referenced based on the resource type and resource name. | Resource files in the sub-directory are referenced based on the resource type and resource name. | Resource files in the sub-directory are referenced based on the file path and file name. | + + +### Qualifiers Sub-directories + +The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). Before creating a qualifiers sub-directory, familiarize yourself with the directory naming conventions and the rules for matching qualifiers sub-directories and the device status. + +**Naming Conventions for Qualifiers Sub-directories** + +- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density**. You can select one or multiple qualifiers to name your sub-directory based on your application scenarios and device characteristics. + +- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (\-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. + +- Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched. + +**Table 2** Requirements for qualifier values + +| Qualifier Type | Description and Value Range | +| ----------- | ---------------------------------------- | +| MCC&MNC| Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).| +| Language | Indicates the language used by the device. The value consists of two or three lowercase letters. For example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).| +| Text | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).| +| Country/Region | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).| +| Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation| +| Device type | Indicates the device type. The value can be:
- **car**: head unit
- **tv**: smart TV
- **wearable**: smart wearable| +| Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode| +| Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: medium-scale screen density (Medium-scale Dots Per Inch), applicable to DPI whose value is (120, 160] device.
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| + +**Rules for Matching Qualifiers Sub-directories and Device Resources** + +- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density. + +- If the qualifiers sub-directories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the sub-directories can be used for matching the device resources. For example, the qualifiers sub-directory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**. + + +### Resource Group Sub-directories + +You can create resource group sub-directories (including element, media, and profile) in the **base** and qualifiers sub-directories to store resource files of specific types. + + + **Table 3** Resource group sub-directories + +| Resource Group Sub-directory | Description | Resource File | +| ------- | ---------------------------------------- | ---------------------------------------- | +| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | +| rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. | + +**Media Resource Types** + +**Table 4** Image resource types + +| Format | File Name Extension| +| ---- | ----- | +| JPEG | .jpg | +| PNG | .png | +| GIF | .gif | +| SVG | .svg | +| WEBP | .webp | +| BMP | .bmp | + +**Table 5** Audio and video resource types + +| Format | File Name Extension | +| ------------------------------------ | --------------- | +| H.263 | .3gp
.mp4 | +| H.264 AVC
Baseline Profile (BP) | .3gp
.mp4 | +| MPEG-4 SP | .3gp | +| VP8 | .webm
.mkv | + +**Resource File Examples** + +The content of the **color.json** file is as follows: + + +```json +{ + "color": [ + { + "name": "color_hello", + "value": "#ffff0000" + }, + { + "name": "color_world", + "value": "#ff0000ff" + } + ] +} +``` + +The content of the **float.json** file is as follows: + + +```json +{ + "float":[ + { + "name":"font_hello", + "value":"28.0fp" + }, + { + "name":"font_world", + "value":"20.0fp" + } + ] +} +``` + +The content of the **string.json** file is as follows: + + +```json +{ + "string":[ + { + "name":"string_hello", + "value":"Hello" + }, + { + "name":"string_world", + "value":"World" + }, + { + "name":"message_arrive", + "value":"We will arrive at %s." + } + ] +} +``` + +The content of the **plural.json** file is as follows: + + +```json +{ + "plural":[ + { + "name":"eat_apple", + "value":[ + { + "quantity":"one", + "value":"%d apple" + }, + { + "quantity":"other", + "value":"%d apples" + } + ] + } + ] +} +``` + +## Resource Access + +### Application Resources + +**Creating a Resource File** + +You can create a sub-directory and its files under the **resources** directory based on the preceding descriptions of the qualifiers sub-directories and resource group sub-directories. + +DevEco Studio provides a wizard for you to create resource directories and resource files. + +- Creating a Resource Directory and Resource File + + Right-click the **resources** directory and choose **New > Resource File**. + + If no qualifier is selected, the file is created in a resource type sub-directory under **base**. If one or more qualifiers are selected, the system automatically generates a sub-directory and creates the file in this sub-directory. + + The created sub-directory is automatically named in the format of **Qualifiers.Resource type**. For example, if you create a sub-directory by setting **Orientation** to **Vertical** and **Resource type** to **Graphic**, the system automatically generates a sub-directory named **vertical.graphic**. + + ![create-resource-file-1](figures/create-resource-file-1.png) + +- Creating a Resource Directory + + Right-click the **resources** directory and choose **New > Resource Directory**. This operation creates a sub-directory only. + + Select a resource group type and set qualifiers. Then the system automatically generates the sub-directory name. The sub-directory is automatically named in the format of **Qualifiers.Resource group**. For example, if you create a sub-directory by setting **Orientation** to **Vertical** and **Resource type** to **Graphic**, the system automatically generates a sub-directory named **vertical.graphic**. + + ![create-resource-file-2](figures/create-resource-file-2.png) + +- Creating a Resource File + + Right-click a sub-directory under **resources** and choose **New > *XXX* Resource File**. This operation creates a resource file under this sub-directory. + + For example, you can create an element resource file in the **element** sub-directory. + + ![create-resource-file-3](figures/create-resource-file-3.png) + +**Accessing Application Resources** + +To reference an application resource in a project, use the **"$r('app.type.name')"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. + +When referencing resources in the **rawfile** sub-directory, use the **"$rawfile('filename')"** format. Wherein, **filename** indicates the relative path of a file in the **rawfile** directory, which must contain the file name extension in the file name and cannot start with a slash (/). + +> **NOTE** +> +> Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined. +> +> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API. + +In the **.ets** file, you can use the resources defined in the **resources** directory. + +```ts +Text($r('app.string.string_hello')) + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.string.string_world')) + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d. + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Image($r('app.media.my_background_image')) // Reference media resources. + +Image($rawfile('test.png')) // Reference an image in the rawfile directory. + +Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile directory. +``` + +### System Resources + +System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. + + +To reference a system resource, use the **"$r('sys.type.resource_id')"** format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID. + +```ts +Text('Hello') + .fontColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize($r('sys.float.ohos_id_text_size_headline1')) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) +Image($r('sys.media.ohos_app_icon')) + .border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) + .margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) + .height(200) + .width(300) +``` diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md index 23af935c5cbb2d66a60ccec431a1737fb9ffb741..acdbb71b9d95a55985923127259030a110e0e78c 100644 --- a/en/application-dev/quick-start/start-overview.md +++ b/en/application-dev/quick-start/start-overview.md @@ -1,4 +1,4 @@ -# Preparations +# Before You Start This document is intended for novices at developing OpenHarmony applications. It will introduce you to the OpenHarmony project directory structure and application development process, by walking you through a stripped-down, real-world example – building two pages and implementing redirection between them. The following figure shows how the pages look on the DevEco Studio Previewer. @@ -16,11 +16,11 @@ Before you begin, there are two basic concepts that will help you better underst OpenHarmony provides a UI development framework, known as ArkUI. ArkUI provides a full range of capabilities you may need for application UI development, ranging from components to layout calculation, animation, UI interaction, and drawing capabilities. -ArkUI comes with two development paradigms: JavaScript-based web-like development paradigm (web-like development paradigm for short) and TypeScript-based declarative development paradigm (declarative development paradigm for short). You can choose whichever development paradigm that aligns with your practice. +ArkUI comes with two development paradigms: ArkTS-based declarative development paradigm (declarative development paradigm for short) and JavaScript-compatible web-like development paradigm (web-like development paradigm for short). You can choose whichever development paradigm that aligns with your practice. | **Development Paradigm**| **Programming Language**| **UI Update Mode**| **Applicable To**| **Intended Audience**| | -------- | -------- | -------- | -------- | -------- | -| Declarative development paradigm| Extended TypeScript (eTS)| Data-driven| Applications involving technological sophistication and teamwork| Mobile application and system application developers| +| Declarative development paradigm| ArkTS| Data-driven| Applications involving technological sophistication and teamwork| Mobile application and system application developers| | Web-like development paradigm| JavaScript| Data-driven| Applications and service widgets with simple UIs| Frontend web developers| For more details, see [UI Development](../ui/arkui-overview.md). @@ -36,7 +36,7 @@ The ability framework model has two forms: - **Stage model**: introduced since API version 9. For details, see [Stage Model Overview](../ability/stage-brief.md). -The project directory structure of the FA model is different from that of the stage model. The stage model only works with the eTS programming language. +The project directory structure of the FA model is different from that of the stage model. The stage model only works with the ArkTS programming language. For details about the differences between the FA model and stage model, see [Ability Framework Overview](../ability/ability-brief.md). @@ -45,8 +45,8 @@ This document provides an ability with two pages. For more information about abi ## Tool Preparation -1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download). +1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio). 2. Install DevEco Studio and configure the development environment. For details, see [Setting Up the Development Environment](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443). -When you are done, follow the instructions in [Getting Started with eTS in Stage Model](start-with-ets-stage.md), [Getting Started with eTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md). +When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md), [Getting Started with ArkTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md). diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md index 03ed574bb99bcd65cecf0c6ca4710ab2271db9d3..bfdba0a22aed7271b316ba4ab02b7155e85ac5a9 100644 --- a/en/application-dev/quick-start/start-with-ets-fa.md +++ b/en/application-dev/quick-start/start-with-ets-fa.md @@ -1,9 +1,9 @@ -# Getting Started with eTS in FA Model +# Getting Started with ArkTS in FA Model > **NOTE** > -> To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later. +> To use ArkTS, your DevEco Studio must be V3.0.0.601 Beta1 or later. > > For best possible results, use [DevEco Studio V3.0.0.993](https://developer.harmonyos.com/cn/develop/deveco-studio#download) for your development. @@ -37,7 +37,7 @@ - **src > main > ets > MainAbility > pages**: pages contained in **MainAbility**. - **src > main > ets > MainAbility > pages > index.ets**: the first page in the **pages** list, also referred to as the entry to the application. - **src > main > ets > MainAbility > app.ets**: ability lifecycle file. - - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource File Categories](../ui/ui-ts-basic-resource-file-categories.md). + - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories). - **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details about the configuration file, see [Application Package Structure Configuration File (FA Model)](package-structure.md). - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation. @@ -52,7 +52,6 @@ 1. Use the **\** component. After the project synchronization is complete, choose **entry** > **src** > **main** > **ets** > **MainAbility** > **pages** in the **Project** window and open the **index.ets** file. You can see that the file contains a **\** component. The sample code in the **index.ets** file is shown below: - ```ts // index.ets @@ -78,7 +77,6 @@ 2. Add a **\ diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md index aa97784b94fe7147ad513fcb3c88b9c174cf0632..c7b1564625c586cff13822fc2eedfc85f6745ad7 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md @@ -75,10 +75,10 @@ ```html
- + contentBox - + borderBox
diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index 7785dfd52b5e5c8a026ecc5882d2c6751e28abb3..0921eaa35c63df9e8d52346c054c573921438b6c 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -59,12 +59,12 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage ```js // xxx.js -import router from '@system.router'; +import router from '@ohos.router'; export default { jump() { router.push({ // 路径要与config.json配置里面的相同 - uri: 'pages/detailpage', + url: 'pages/detailpage', }); }, } @@ -92,7 +92,7 @@ export default { ```js // xxx.js -import router from '@system.router'; +import router from '@ohos.router'; export default { jumpBack() { router.back(); @@ -138,7 +138,7 @@ source_page包含顶部内容以及卡片列表,点击卡片可以跳转到tar MAIN TITLE - + {{$item.title}} @@ -147,19 +147,19 @@ source_page包含顶部内容以及卡片列表,点击卡片可以跳转到tar ```js // xxx.js -import router from '@system.router' +import router from '@ohos.router' export default { data: { list: [] }, onInit() { for(var i = 0; i < 10; i++) { - var item = { uri: "pages/card_transition/target_page/index", + var item = { url: "pages/card_transition/target_page/index", title: "this is title" + i, id: "item_" + i } this.list.push(item); } }, - jumpPage(id, uri) { + jumpPage(id, url) { var cardId = this.$element(id).ref; - router.push({ uri: uri, params : { ref : cardId } }); + router.push({ url: url, params : { ref : cardId } }); } } ``` @@ -167,6 +167,8 @@ export default { ```css /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; align-items: center; background-color: #ABDAFF; @@ -197,6 +199,8 @@ export default { ```css /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; align-items: center; background-color: #EBFFD7; @@ -255,14 +259,14 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 ```css // xxx.js - import router from '@system.router'; + import router from '@ohos.router'; export default { data: { - + }, jump() { router.push({ - uri:'pages/transition2/transition2' + url:'pages/transition2/transition2' }) } } @@ -286,13 +290,13 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transition-duration: 5s; transition-timing-function: friction; } - + @keyframes go_page { from { opacity: 0; transform: translate(0px) rotate(60deg) scale(1.0); } - + to { opacity: 1; transform: translate(100px) rotate(360deg) scale(1.0); @@ -303,7 +307,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 opacity: 1; transform: translate(200px) rotate(60deg) scale(2); } - + to { opacity: 0; transform: translate(200px) rotate(360deg) scale(2); @@ -324,10 +328,10 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 ```js // xxx.js - import router from '@system.router'; + import router from '@ohos.router'; export default { data: { - + }, jumpBack() { router.back() @@ -344,7 +348,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 width: 100%; height: 100%; } - + .move_page { width: 100px; height: 100px; @@ -354,7 +358,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transition-duration: 5s; transition-timing-function: ease; } - + @keyframes go_page { from { opacity: 0; @@ -365,7 +369,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transform:translate(100px) rotate(180deg) scale(2.0); } } - + @keyframes exit_page { from { opacity: 1; diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md index 0d51d6238b8e1434efadbde33b288a87ee950d88..8f81b0178ddf9d7d0d2c3a6bc1137c14e1dc74dc 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md @@ -247,21 +247,23 @@ ```html
-
+
``` ```css - /* xxx.css */ - .container { - flex-direction: column; - } - .content{ - width: 200px; - height: 200px; - background-color: red; - } + /* xxx.css */ + .container { + flex-direction: column; + width: 100%; + height: 100%; + } + .content { + width: 200px; + height: 200px; + background-color: red; + } ``` ```js @@ -285,7 +287,7 @@ prompt.showToast({ message: 'End Drag' }) - }, + } } ``` @@ -358,8 +360,8 @@ ```html
-
+
``` @@ -371,12 +373,13 @@ justify-content: center; align-items: center; width: 454px; - height: 454px;} - .content{ + height: 454px; + } + .content { width: 400px; height: 400px; background-color: aqua; - margin:30px + margin: 30px; } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md index d5ca0fc58411acef62562fb9d23aec49b3921d14..cb67d43c6f9fddd4f47d72911bc3cc580086c759 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md @@ -111,22 +111,6 @@
``` - -```js -// index.js -export default { - data: { - todolist: [{ - title: '刷题', - date: '2021-12-31 10:00:00' - }, { - title: '看电影', - date: '2021-12-31 20:00:00' - }], - }, -} -``` - ```css /* index.css */ .container { @@ -152,4 +136,21 @@ export default { } ``` +```js +// index.js +export default { + data: { + todolist: [{ + title: '刷题', + date: '2021-12-31 10:00:00' + }, { + title: '看电影', + date: '2021-12-31 20:00:00' + }], + }, +} +``` + + + ![zh-cn_image_0000001185033226](figures/zh-cn_image_0000001185033226.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md index 47cfbf39da7cbadfc63acc8b9fe5b131e06303b3..2e9d58638dcbc075fcec859de6cfc0fa72ac3d0b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md @@ -3,7 +3,7 @@ > **说明:** > 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -气泡指示。在点击绑定的控件后会弹出相应的气泡提示来引导用户进行操作。 +气泡指示。给控件绑定气泡弹窗,并在点击控件或者调用气泡弹窗显示方法后弹出相应的气泡提示来引导用户进行操作。 ## 权限列表 @@ -21,10 +21,10 @@ | 名称 | 类型 | 默认值 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -------- | -| target | string | - | 是 | 目标元素的id属性值,不支持动态切换。 | -| placement | string | bottom | 否 | 弹出窗口位置。可选值为:
- left:位于目标元素左边;
- right:位于目标元素右边;
- top:位于目标元素上边;
- bottom:位于目标元素下边;
- topLeft:位于目标元素左上角;
- topRight:位于目标元素右上角;
- bottomLeft:位于目标元素左下角;
- bottomRight:位于目标元素右下角。 | +| target | string | - | 是 | popup绑定目标元素的id属性值,不支持动态切换。 | +| placement | string | bottom | 否 | popup相对于目标元素的位置。可选值为:
- left:位于目标元素左边;
- right:位于目标元素右边;
- top:位于目标元素上边;
- bottom:位于目标元素下边;
- topLeft:位于目标元素左上角;
- topRight:位于目标元素右上角;
- bottomLeft:位于目标元素左下角;
- bottomRight:位于目标元素右下角。 | | keepalive5+ | boolean | false | 否 | 设置当前popup是否需要保留。设置为true时,点击屏幕区域或者页面切换气泡不会消失,需调用气泡组件的hide方法才可让气泡消失;设置为false时,点击屏幕区域或者页面切换气泡会自动消失。 | -| clickable5+ | boolean | true | 否 | popup是否使用点击弹窗,当设置为false时,只支持方法调用显示。 | +| clickable5+ | boolean | true | 否 | popup是否支持点击目标元素弹窗,当设置为false时,只支持方法调用显示弹窗。 | | arrowoffset5+ | <length> | 0 | 否 | popup箭头在弹窗处的偏移,默认居中,正值按照语言方向进行偏移,负值相反。 | > **说明:** @@ -61,7 +61,7 @@ | 名称 | 参数 | 描述 | | -------- | -------- | -------- | | show5+ | - | 弹出气泡提示。 | -| hide5+ | - | 取消气泡提示。 | +| hide5+ | - | 隐藏气泡提示。 | > **说明:** > 1. popup气泡弹窗属性、样式均不支持动态更新。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md index fb64a4993038739c4ac20656a8bb298fbfe0f101..08011bdf1d4bb1e15445410a74a3b90a1f664f18 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md @@ -22,9 +22,9 @@ | 名称 | 类型 | 默认值 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -------- | | offset | <length> | - | 否 | 刷新组件静止时距离父组件顶部的距离。 | -| refreshing | boolean | false | 否 | 用于标识刷新组件当前是否正在刷新。 | +| refreshing | boolean | false | 否 | 标识刷新组件当前是否正在刷新。 | | type | string | auto | 否 | 设置组件刷新时的动效。两个可选值,不支持动态修改。
- auto: 默认效果,列表界面拉到顶后,列表不移动,下拉后有转圈弹出。
- pulldown: 列表界面拉到顶后,可以继续往下滑动一段距离触发刷新,刷新完成后有回弹效果(如果子组件含有list,防止下拉效果冲突,需将list的scrolleffect设置为no)。 | -| lasttime | boolean | false | 否 | 是否显示上次更新时间,字符串格式为:“上次更新时间:XXXX ”,XXXX 按照时间日期显示规范显示,不可动态修改(建议type为pulldown时使用,固定距离位于内容下拉区域底部,使用时注意offset属性设置,防止出现重叠)。 | +| lasttime | boolean | false | 否 | 设置是否显示上次更新时间,字符串格式为:“上次更新时间:XXXX ”,XXXX 按照时间日期显示规范显示,不可动态修改(建议type为pulldown时使用,固定距离位于内容下拉区域底部,使用时注意offset属性设置,防止出现重叠)。 | | timeoffset6+ | <length> | - | 否 | 设置更新时间距离父组件顶部的距离。 | | friction | number | 42 | 否 | 下拉摩擦系数,取值范围:0-100,数值越大refresh组件跟手性高,数值越小refresh跟手性低。 | @@ -35,8 +35,8 @@ | 名称 | 类型 | 默认值 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -------- | -| background-color | <color> | white
| 否 | 用于设置刷新组件的背景颜色。 | -| progress-color | <color> | black
| 否 | 用于设置刷新组件的loading颜色。 | +| background-color | <color> | white
| 否 | 设置刷新组件的背景颜色。 | +| progress-color | <color> | black
| 否 | 设置刷新组件的loading图标颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md index a026e81bd9e1646cb37f4f6fdbbebe8104e99ebb..75c4249b57fe899efe5110456a38cf8948f5dff1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md @@ -25,7 +25,7 @@ | 名称 | 类型 | 默认值 | 描述 | | ----- | ------ | ---- | ------------------------------ | -| index | number | - | 设置步骤导航器步骤显示第几个stepper-item子组件。 | +| index | number | 0 | 设置步骤导航器步骤显示第几个stepper-item子组件,默认显示第一个stepper-item。 | ## 样式 @@ -42,9 +42,9 @@ | 名称 | 参数 | 描述 | | ------ | ---------------------------------------- | ---------------------------------------- | -| finish | 无 | 当步骤导航器最后一个步骤完成时触发该事件。 | -| skip | 无 | 当通过setNextButtonStatus方法设置当前步骤导航器可跳过时,点击右侧跳过按钮触发该事件。 | -| change | { prevIndex:prevIndex, index: index} | 当步骤导航器点击左边或者右边文本按钮进行步骤切换时触发该事件,prevIndex表示老步骤的序号,index表示新步骤的序号。 | +| finish | 无 | 当步骤导航器最后一个步骤完成时,触发该事件。 | +| skip | 无 | 当前步骤导航器下一步按钮状态为skip,即可跳过时,点击右侧跳过按钮触发该事件。 | +| change | { prevIndex:prevIndex, index: index} | 当用户点击步骤导航器的左边或者右边按钮进行步骤切换时触发该事件,prevIndex表示老步骤的序号,index表示新步骤的序号。 | | next | { index:index, pendingIndex: pendingIndex } | 当用户点击下一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将要跳转的序号,该事件有返回值,返回值格式为:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改下一个步骤使用哪个stepper-item子组件。 | | back | { index:index, pendingIndex: pendingIndex } | 当用户点击上一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将要跳转的序号,该事件有返回值,返回值格式为Object:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改上一个步骤使用哪个stepper-item子组件。 | @@ -55,7 +55,7 @@ | 名称 | 参数 | 描述 | | ------------------- | ---------------------------------------- | ---------------------------------------- | -| setNextButtonStatus | { status: string, label: label } | 设置当前步骤导航器下一步文本按钮的状态,参数中status类型为string,可选值为:
- normal:正常状态,下一步文本按钮正常显示,可点击进入下一个步骤;
- disabled:不可用状态,下一步文本按钮灰度显示,不可点击进入下一个步骤;
- waiting:等待状态,下一步文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。
- skip:跳过状态,下一步文本按钮显示跳过按钮,点击时会跳过剩下步骤。 | +| setNextButtonStatus | { status: string, label: label } | 设置当前步骤中下一步按钮的文本与状态,参数中label为指定按钮文本,status指定按钮状态,status可选值为:
- normal:正常状态,下一步文本按钮正常显示,可点击进入下一个步骤;
- disabled:不可用状态,下一步文本按钮灰度显示,不可点击进入下一个步骤;
- waiting:等待状态,下一步文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。
- skip:跳过状态,下一步文本按钮显示跳过按钮,点击时会跳过剩下步骤。 | ## 示例 @@ -63,24 +63,25 @@ ```html
- - -
- First screen + + +
+ Page One +
-
- -
- Second screen + +
+ Page Two +
-
- -
- Third screen + +
+ Page Three +
-
@@ -89,32 +90,48 @@ ```css /* xxx.css */ .container { - margin-top: 20px; flex-direction: column; align-items: center; - height: 300px; + height: 100%; + width: 100%; + background-color: #f7f7f7; } - -.stepperItem { +.stepper{ + width: 100%; + height: 100%; +} +.stepper-item { width: 100%; + height: 100%; flex-direction: column; align-items: center; } - -.stepperItemContent { - font-size: 50px; - justify-content: center; +.item{ + width: 90%; + height: 86%; + margin-top: 80px; + background-color: white; + border-radius: 60px; + flex-direction: column; + align-items: center; + padding-top: 160px; +} +text { + font-size: 78px; + color: #182431; + opacity: 0.4; } - .button { - width: 60%; - margin-top: 30px; + width: 40%; + margin-top: 100px; justify-content: center; } ``` ```js // xxx.js +import prompt from '@system.prompt'; + export default { data: { label_1: @@ -138,7 +155,7 @@ export default { }, setRightButton(e) { this.$element('mystepper').setNextButtonStatus({ - status: 'skip', label: 'SKIP' + status: 'waiting', label: 'SKIP' }); }, nextclick(e) { @@ -152,8 +169,23 @@ export default { pendingIndex: e.pendingIndex } return index; + }, + statuschange(e) { + prompt.showToast({ + message: '上一步序号' + e.prevIndex + '当前序号' + e.index + }) + }, + finish() { + prompt.showToast({ + message: '最后一步已完成' + }) + }, + skip() { + prompt.showToast({ + message: 'skip触发' + }) } } ``` -![zh-cn_image_0000001127125114](figures/zh-cn_image_0000001127125114.gif) +![](figures/stepper.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md index 2838eae60518a05eda6e5077893106735b5778cc..9ddc7a88e7e07f1f3040784dab60e46828a04794 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md @@ -38,10 +38,8 @@ export default { console.log("组件创建") }, onAttached() { - this.value = "组件挂载" - }, - onDetached() { - this.value = "组件卸载" + this.value = "组件挂载", + console.log("组件挂载") }, onShow() { console.log("Page显示") diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md index 8949e3981cddff96318eb7a61b8fd802cd93ba29..f5bee524836e80401f3304708ae53233e1697b3d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md @@ -37,7 +37,7 @@ - + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md index 972fd27969efe8ad2ffa71b35e0be846f244695b..c431b6fc33c8a437929f724246b53f7e5c0b459b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md @@ -193,6 +193,7 @@ transform动效,支持的组件范围: dur="3s" repeatCount="indefinite"> + animate-transform diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md index 410178c1966080c4153b4f1172d495ff5d0a787b..10e0739fa5645a7ac50e9114c148816a4b12850b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md @@ -97,9 +97,9 @@ textpath与tspan组合示例与效果图
- + - + This is TextPath. This is tspan onTextPath. Let's play. @@ -117,11 +117,11 @@ textpath与tspan组合示例与效果图
- + - + This is TextPath. This is first tspan. This is second tspan. @@ -172,10 +172,10 @@ textpath与tspan组合属性动画与效果图
- + - + This is TextPath. tspan attribute x|rotate @@ -209,11 +209,11 @@ textpath与tspan组合属性动画与效果图
- - + This is TextPath. tspan attribute fill|fill-opacity @@ -247,11 +247,11 @@ textpath与tspan组合属性动画与效果图
- - + This is TextPath. tspan attribute stroke 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 3fa8f6e43b7c1a789255a82c614f3d686cd608e7..c421df5965f3a0a3f1490230e926fef0bef8d542 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -2,167 +2,167 @@ - [组件导读](ts-components-summary.md) - 组件通用信息 - - 通用事件 - - [点击事件](ts-universal-events-click.md) - - [触摸事件](ts-universal-events-touch.md) - - [挂载卸载事件](ts-universal-events-show-hide.md) - - [拖拽事件](ts-universal-events-drag-drop.md) - - [按键事件](ts-universal-events-key.md) - - [焦点事件](ts-universal-focus-event.md) - - [鼠标事件](ts-universal-mouse-key.md) - - [组件区域变化事件](ts-universal-component-area-change-event.md) - - [组件可见区域变化事件](ts-universal-component-visible-area-change-event.md) - - 通用属性 - - [尺寸设置](ts-universal-attributes-size.md) - - [位置设置](ts-universal-attributes-location.md) - - [布局约束](ts-universal-attributes-layout-constraints.md) - - [Flex布局](ts-universal-attributes-flex-layout.md) - - [边框设置](ts-universal-attributes-border.md) - - [图片边框设置](ts-universal-attributes-border-image.md) - - [背景设置](ts-universal-attributes-background.md) - - [透明度设置](ts-universal-attributes-opacity.md) - - [显隐控制](ts-universal-attributes-visibility.md) - - [禁用控制](ts-universal-attributes-enable.md) - - [浮层](ts-universal-attributes-overlay.md) - - [Z序控制](ts-universal-attributes-z-order.md) - - [图形变换](ts-universal-attributes-transformation.md) - - [图像效果](ts-universal-attributes-image-effect.md) - - [形状裁剪](ts-universal-attributes-sharp-clipping.md) - - [文本样式设置](ts-universal-attributes-text-style.md) - - [栅格设置](ts-universal-attributes-grid.md) - - [颜色渐变](ts-universal-attributes-gradient-color.md) - - [Popup控制](ts-universal-attributes-popup.md) - - [Menu控制](ts-universal-attributes-menu.md) - - [点击控制](ts-universal-attributes-click.md) - - [焦点控制](ts-universal-attributes-focus.md) - - [悬浮态效果](ts-universal-attributes-hover-effect.md) - - [组件标识](ts-universal-attributes-component-id.md) - - [触摸热区设置](ts-universal-attributes-touch-target.md) - - [多态样式](ts-universal-attributes-polymorphic-style.md) - - [触摸测试控制](ts-universal-attributes-hit-test-behavior.md) - - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) - - [分布式迁移标识](ts-universal-attributes-restoreId.md) - - 手势处理 - - [绑定手势方法](ts-gesture-settings.md) - - 基础手势 - - [TapGesture](ts-basic-gestures-tapgesture.md) - - [LongPressGesture](ts-basic-gestures-longpressgesture.md) - - [PanGesture](ts-basic-gestures-pangesture.md) - - [PinchGesture](ts-basic-gestures-pinchgesture.md) - - [RotationGesture](ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](ts-basic-gestures-swipegesture.md) - - [组合手势](ts-combined-gestures.md) + - 通用事件 + - [点击事件](ts-universal-events-click.md) + - [触摸事件](ts-universal-events-touch.md) + - [挂载卸载事件](ts-universal-events-show-hide.md) + - [拖拽事件](ts-universal-events-drag-drop.md) + - [按键事件](ts-universal-events-key.md) + - [焦点事件](ts-universal-focus-event.md) + - [鼠标事件](ts-universal-mouse-key.md) + - [组件区域变化事件](ts-universal-component-area-change-event.md) + - [组件可见区域变化事件](ts-universal-component-visible-area-change-event.md) + - 通用属性 + - [尺寸设置](ts-universal-attributes-size.md) + - [位置设置](ts-universal-attributes-location.md) + - [布局约束](ts-universal-attributes-layout-constraints.md) + - [Flex布局](ts-universal-attributes-flex-layout.md) + - [边框设置](ts-universal-attributes-border.md) + - [图片边框设置](ts-universal-attributes-border-image.md) + - [背景设置](ts-universal-attributes-background.md) + - [透明度设置](ts-universal-attributes-opacity.md) + - [显隐控制](ts-universal-attributes-visibility.md) + - [禁用控制](ts-universal-attributes-enable.md) + - [浮层](ts-universal-attributes-overlay.md) + - [Z序控制](ts-universal-attributes-z-order.md) + - [图形变换](ts-universal-attributes-transformation.md) + - [图像效果](ts-universal-attributes-image-effect.md) + - [形状裁剪](ts-universal-attributes-sharp-clipping.md) + - [文本样式设置](ts-universal-attributes-text-style.md) + - [栅格设置](ts-universal-attributes-grid.md) + - [颜色渐变](ts-universal-attributes-gradient-color.md) + - [Popup控制](ts-universal-attributes-popup.md) + - [Menu控制](ts-universal-attributes-menu.md) + - [点击控制](ts-universal-attributes-click.md) + - [焦点控制](ts-universal-attributes-focus.md) + - [悬浮态效果](ts-universal-attributes-hover-effect.md) + - [组件标识](ts-universal-attributes-component-id.md) + - [触摸热区设置](ts-universal-attributes-touch-target.md) + - [多态样式](ts-universal-attributes-polymorphic-style.md) + - [触摸测试控制](ts-universal-attributes-hit-test-behavior.md) + - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) + - [分布式迁移标识](ts-universal-attributes-restoreId.md) + - 手势处理 + - [绑定手势方法](ts-gesture-settings.md) + - 基础手势 + - [TapGesture](ts-basic-gestures-tapgesture.md) + - [LongPressGesture](ts-basic-gestures-longpressgesture.md) + - [PanGesture](ts-basic-gestures-pangesture.md) + - [PinchGesture](ts-basic-gestures-pinchgesture.md) + - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) + - [组合手势](ts-combined-gestures.md) - 基础组件 - - [Blank](ts-basic-components-blank.md) - - [Button](ts-basic-components-button.md) - - [Checkbox](ts-basic-components-checkbox.md) - - [CheckboxGroup](ts-basic-components-checkboxgroup.md) - - [DataPanel](ts-basic-components-datapanel.md) - - [DatePicker](ts-basic-components-datepicker.md) - - [Divider](ts-basic-components-divider.md) - - [Gauge](ts-basic-components-gauge.md) - - [Image](ts-basic-components-image.md) - - [ImageAnimator](ts-basic-components-imageanimator.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) - - [Marquee](ts-basic-components-marquee.md) - - [Navigation](ts-basic-components-navigation.md) - - [NavRouter](ts-basic-components-navrouter.md) - - [NavDestination](ts-basic-components-navdestination.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - - [Progress](ts-basic-components-progress.md) - - [QRCode](ts-basic-components-qrcode.md) - - [Radio](ts-basic-components-radio.md) - - [Rating](ts-basic-components-rating.md) - - [RemoteWindow](ts-basic-components-remotewindow.md) - - [RichText](ts-basic-components-richtext.md) - - [ScrollBar](ts-basic-components-scrollbar.md) - - [Search](ts-basic-components-search.md) - - [Select](ts-basic-components-select.md) - - [Slider](ts-basic-components-slider.md) - - [Span](ts-basic-components-span.md) - - [Stepper](ts-basic-components-stepper.md) - - [StepperItem](ts-basic-components-stepperitem.md) - - [Text](ts-basic-components-text.md) - - [TextArea](ts-basic-components-textarea.md) - - [TextClock](ts-basic-components-textclock.md) - - [TextInput](ts-basic-components-textinput.md) - - [TextPicker](ts-basic-components-textpicker.md) - - [TextTimer](ts-basic-components-texttimer.md) - - [TimePicker](ts-basic-components-timepicker.md) - - [Toggle](ts-basic-components-toggle.md) - - [Web](ts-basic-components-web.md) - - [XComponent](ts-basic-components-xcomponent.md) + - [Blank](ts-basic-components-blank.md) + - [Button](ts-basic-components-button.md) + - [Checkbox](ts-basic-components-checkbox.md) + - [CheckboxGroup](ts-basic-components-checkboxgroup.md) + - [DataPanel](ts-basic-components-datapanel.md) + - [DatePicker](ts-basic-components-datepicker.md) + - [Divider](ts-basic-components-divider.md) + - [Gauge](ts-basic-components-gauge.md) + - [Image](ts-basic-components-image.md) + - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Marquee](ts-basic-components-marquee.md) + - [Navigation](ts-basic-components-navigation.md) + - [NavRouter](ts-basic-components-navrouter.md) + - [NavDestination](ts-basic-components-navdestination.md) + - [PatternLock](ts-basic-components-patternlock.md) + - [PluginComponent](ts-basic-components-plugincomponent.md) + - [Progress](ts-basic-components-progress.md) + - [QRCode](ts-basic-components-qrcode.md) + - [Radio](ts-basic-components-radio.md) + - [Rating](ts-basic-components-rating.md) + - [RemoteWindow](ts-basic-components-remotewindow.md) + - [RichText](ts-basic-components-richtext.md) + - [ScrollBar](ts-basic-components-scrollbar.md) + - [Search](ts-basic-components-search.md) + - [Select](ts-basic-components-select.md) + - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) + - [Stepper](ts-basic-components-stepper.md) + - [StepperItem](ts-basic-components-stepperitem.md) + - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextClock](ts-basic-components-textclock.md) + - [TextInput](ts-basic-components-textinput.md) + - [TextPicker](ts-basic-components-textpicker.md) + - [TextTimer](ts-basic-components-texttimer.md) + - [TimePicker](ts-basic-components-timepicker.md) + - [Toggle](ts-basic-components-toggle.md) + - [Web](ts-basic-components-web.md) + - [XComponent](ts-basic-components-xcomponent.md) - 容器组件 - - [AbilityComponent](ts-container-ability-component.md) - - [AlphabetIndexer](ts-container-alphabet-indexer.md) - - [Badge](ts-container-badge.md) - - [Column](ts-container-column.md) - - [ColumnSplit](ts-container-columnsplit.md) - - [Counter](ts-container-counter.md) - - [Flex](ts-container-flex.md) - - [FlowItem](ts-container-flowitem.md) - - [GridContainer](ts-container-gridcontainer.md) - - [GridCol](ts-container-gridcol.md) - - [GridRow](ts-container-gridrow.md) - - [Grid](ts-container-grid.md) - - [GridItem](ts-container-griditem.md) - - [List](ts-container-list.md) - - [ListItem](ts-container-listitem.md) - - [ListItemGroup](ts-container-listitemgroup.md) - - [Navigator](ts-container-navigator.md) - - [Panel](ts-container-panel.md) - - [Refresh](ts-container-refresh.md) - - [RelativeContainer](ts-container-relativecontainer.md) - - [Row](ts-container-row.md) - - [RowSplit](ts-container-rowsplit.md) - - [Scroll](ts-container-scroll.md) - - [SideBarContainer](ts-container-sidebarcontainer.md) - - [Stack](ts-container-stack.md) - - [Swiper](ts-container-swiper.md) - - [Tabs](ts-container-tabs.md) - - [TabContent](ts-container-tabcontent.md) - - [WaterFlow](ts-container-waterflow.md) + - [AbilityComponent](ts-container-ability-component.md) + - [AlphabetIndexer](ts-container-alphabet-indexer.md) + - [Badge](ts-container-badge.md) + - [Column](ts-container-column.md) + - [ColumnSplit](ts-container-columnsplit.md) + - [Counter](ts-container-counter.md) + - [Flex](ts-container-flex.md) + - [FlowItem](ts-container-flowitem.md) + - [GridContainer](ts-container-gridcontainer.md) + - [GridCol](ts-container-gridcol.md) + - [GridRow](ts-container-gridrow.md) + - [Grid](ts-container-grid.md) + - [GridItem](ts-container-griditem.md) + - [List](ts-container-list.md) + - [ListItem](ts-container-listitem.md) + - [ListItemGroup](ts-container-listitemgroup.md) + - [Navigator](ts-container-navigator.md) + - [Panel](ts-container-panel.md) + - [Refresh](ts-container-refresh.md) + - [RelativeContainer](ts-container-relativecontainer.md) + - [Row](ts-container-row.md) + - [RowSplit](ts-container-rowsplit.md) + - [Scroll](ts-container-scroll.md) + - [SideBarContainer](ts-container-sidebarcontainer.md) + - [Stack](ts-container-stack.md) + - [Swiper](ts-container-swiper.md) + - [Tabs](ts-container-tabs.md) + - [TabContent](ts-container-tabcontent.md) + - [WaterFlow](ts-container-waterflow.md) - 媒体组件 - - [Video](ts-media-components-video.md) + - [Video](ts-media-components-video.md) - 绘制组件 - - [Circle](ts-drawing-components-circle.md) - - [Ellipse](ts-drawing-components-ellipse.md) - - [Line](ts-drawing-components-line.md) - - [Polyline](ts-drawing-components-polyline.md) - - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) - - [Rect](ts-drawing-components-rect.md) - - [Shape](ts-drawing-components-shape.md) + - [Circle](ts-drawing-components-circle.md) + - [Ellipse](ts-drawing-components-ellipse.md) + - [Line](ts-drawing-components-line.md) + - [Polyline](ts-drawing-components-polyline.md) + - [Polygon](ts-drawing-components-polygon.md) + - [Path](ts-drawing-components-path.md) + - [Rect](ts-drawing-components-rect.md) + - [Shape](ts-drawing-components-shape.md) - 画布组件 - - [Canvas](ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) - - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) - - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) - - [ImageData对象](ts-components-canvas-imagedata.md) - - [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md) - - [Path2D对象](ts-components-canvas-path2d.md) - - [Lottie](ts-components-canvas-lottie.md) + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) + - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) + - [ImageData对象](ts-components-canvas-imagedata.md) + - [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md) + - [Path2D对象](ts-components-canvas-path2d.md) + - [Lottie](ts-components-canvas-lottie.md) - 动画 - - [属性动画](ts-animatorproperty.md) - - [显式动画](ts-explicit-animation.md) - - 转场动画 - - [页面间转场](ts-page-transition-animation.md) - - [组件内转场](ts-transition-animation-component.md) - - [共享元素转场](ts-transition-animation-shared-elements.md) - - [路径动画](ts-motion-path-animation.md) + - [属性动画](ts-animatorproperty.md) + - [显式动画](ts-explicit-animation.md) + - 转场动画 + - [页面间转场](ts-page-transition-animation.md) + - [组件内转场](ts-transition-animation-component.md) + - [共享元素转场](ts-transition-animation-shared-elements.md) + - [路径动画](ts-motion-path-animation.md) - 全局UI方法 - - 弹窗 - - [警告弹窗](ts-methods-alert-dialog-box.md) - - [列表选择弹窗](ts-methods-action-sheet.md) - - [自定义弹窗](ts-methods-custom-dialog-box.md) - - [日期选择弹窗](ts-methods-datepicker-dialog.md) - - [时间选择弹窗](ts-methods-timepicker-dialog.md) - - [文本选择弹窗](ts-methods-textpicker-dialog.md) - - [菜单](ts-methods-menu.md) + - 弹窗 + - [警告弹窗](ts-methods-alert-dialog-box.md) + - [列表选择弹窗](ts-methods-action-sheet.md) + - [自定义弹窗](ts-methods-custom-dialog-box.md) + - [日期选择弹窗](ts-methods-datepicker-dialog.md) + - [时间选择弹窗](ts-methods-timepicker-dialog.md) + - [文本选择弹窗](ts-methods-textpicker-dialog.md) + - [菜单](ts-methods-menu.md) - [应用级变量的状态管理](ts-state-management.md) - [像素单位](ts-pixel-units.md) - [枚举说明](ts-appendix-enums.md) - [类型说明](ts-types.md) - 已停止维护的组件 - - [GridContainer(栅格)](ts-container-gridcontainer.md) \ No newline at end of file + - [GridContainer(栅格)](ts-container-gridcontainer.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/badge.png b/zh-cn/application-dev/reference/arkui-ts/figures/badge.png index 0041374b52a2be5a93f620dabed0cba74990ee6f..5d581ea7dc579a7fae5c15ba14cefdcabbe84116 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/badge.png and b/zh-cn/application-dev/reference/arkui-ts/figures/badge.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 new file mode 100644 index 0000000000000000000000000000000000000000..1458d8a2c4069bcfabab2eefd6b0f6ffd57535d6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/checkboxGroup.gif 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 deleted file mode 100644 index 7042b41c96d5eca395d4ac035fefb7d55347535d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup1.png and /dev/null 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 deleted file mode 100644 index 7d7a2b901873cf2daedd412b96508b6c40aa0244..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup2.png and /dev/null 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 deleted file mode 100644 index 53988fae3e8f660fd8411ef44bfa2dc983886a5e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/checkboxgroup3.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/dataPanel.PNG b/zh-cn/application-dev/reference/arkui-ts/figures/dataPanel.PNG new file mode 100644 index 0000000000000000000000000000000000000000..572a8f5aea5b655fe1aba5e3d416e22df591a411 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/dataPanel.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/marquee.gif b/zh-cn/application-dev/reference/arkui-ts/figures/marquee.gif new file mode 100644 index 0000000000000000000000000000000000000000..09dfce671ee1788ac1de7d629ae7fb2406b2ec3f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/marquee.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/rating.gif b/zh-cn/application-dev/reference/arkui-ts/figures/rating.gif new file mode 100644 index 0000000000000000000000000000000000000000..58cab3e9455db71825d0533d5619a2e12f8b0975 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/rating.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/select.png b/zh-cn/application-dev/reference/arkui-ts/figures/select.png index 2672d45f3ed5685aa6f350c2cade469c065a13af..4464b2ca81dfba5f8f334d4cb76d9213b873eb00 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/select.png and b/zh-cn/application-dev/reference/arkui-ts/figures/select.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/stepper.gif b/zh-cn/application-dev/reference/arkui-ts/figures/stepper.gif new file mode 100644 index 0000000000000000000000000000000000000000..03c2354e7cab3ad876f70e1c46ec1c05e437de95 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/stepper.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/tabContent.gif b/zh-cn/application-dev/reference/arkui-ts/figures/tabContent.gif deleted file mode 100644 index 088045f41a884700791adf9fd6709f239c3269c0..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/tabContent.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/tabContent1.gif b/zh-cn/application-dev/reference/arkui-ts/figures/tabContent1.gif new file mode 100644 index 0000000000000000000000000000000000000000..4a278ae098837a2d809b600dcd621ecf83085ede Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/tabContent1.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/tabContent2.gif b/zh-cn/application-dev/reference/arkui-ts/figures/tabContent2.gif new file mode 100644 index 0000000000000000000000000000000000000000..b88d171c0dcf285a40833b9cc73056def5fe3f8b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/tabContent2.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/tabs2.gif b/zh-cn/application-dev/reference/arkui-ts/figures/tabs2.gif new file mode 100644 index 0000000000000000000000000000000000000000..2aff91bd668c3b444bd98089181d5af52e51d3d1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/tabs2.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/textArea.gif b/zh-cn/application-dev/reference/arkui-ts/figures/textArea.gif index 52253c3693b7626a5959a2e88e4744d01b80d057..8755838d74172fea4d02464a9a78afcec4fd8ed7 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/textArea.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/textArea.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/toggle.gif b/zh-cn/application-dev/reference/arkui-ts/figures/toggle.gif new file mode 100644 index 0000000000000000000000000000000000000000..9e61885c0442bc826d0c7b5f95875eda4211d2aa Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/toggle.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001118642902.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001118642902.png deleted file mode 100644 index 36eab44e87c075e01baa66bfc48a86ba703b7835..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001118642902.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104402.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104402.gif deleted file mode 100644 index f6b7ae5ac2bf443574de54cd4df472a8f0cd1aba..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174104402.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264360.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264360.gif deleted file mode 100644 index 49a1503a776598da93f4089bb079c61125a71a2e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264360.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422898.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422898.png deleted file mode 100644 index 1dc7d8d7beda862221b05a9247723a3f74bf323d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422898.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422926.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422926.png index f2deeb8445fe0f3b66d2b0facbf9e0f0ed9911ca..eee85cabf8cd66d840f9579e0b60973a50fa550d 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422926.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422926.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001192655288.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001192655288.gif index 7ed4e908925042a11312dd27aa1c28e8c91d8d8c..bb7ff3b8360cc9a8a33b4c8e6d7a050846b05f69 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001192655288.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001192655288.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.PNG b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.PNG new file mode 100644 index 0000000000000000000000000000000000000000..45034a371010069dfb9bec4c5495ebe1b1417fa8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.PNG differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352454.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352454.png deleted file mode 100644 index 50726d3e461d7a5dbfec674899fee603aaf41bee..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352454.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662645.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662645.png deleted file mode 100644 index 747b8f915f2d40803ce6a7937de1add5deb8e640..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662645.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662659.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662659.gif deleted file mode 100644 index 49922f7f7d934216dcbf8837c697d13063d101a4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219662659.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744181.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744181.png deleted file mode 100644 index 605c0a1ddc0e2bace2e4c9a23fc2391af9ebf5bf..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744181.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864131.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864131.png deleted file mode 100644 index 5c0ada67867ec3765eeb53af5c62369762d0bac4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864131.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg deleted file mode 100644 index e5af4f50ebd9bdab6af30219f30fdf948a019a52..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg and /dev/null 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 deleted file mode 100644 index 3696c7f08f6c7ef551d16da53ca167ddb8b6a5fa..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777778.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777778.png index 19e99b9ef490fff79e64e33192c97c1a39c6edf9..d8b4daf029b147778486f659934b2ea67234924e 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777778.png and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777778.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index dfaa799f790726acbca0a5bb892d93a95b674498..9d1669047af57332bf85b5a6122bd183ed2b49e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -37,7 +37,7 @@ Checkbox(options?: {name?: string, group?: string }) | 名称 | 功能描述 | | ----------| -------- | -|onChange(callback: (value: boolean) => void) | 当选中状态发生变化时,触发该回调。
- value为true时,表示已选中。
- value为false时,表示未选中。 | +|onChange(callback: (value: boolean) => void) | 当选中状态发生变化时,触发该回调。(只有手动触发且Checkbox状态改变时才会触发onChange回调)
- value为true时,表示已选中。
- value为false时,表示未选中。 | ## 示例 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 b7e2b5b79c41424ebb53a396dc9a84bab6088a1a..df19c5e7c4a4781734ad174552f239fe63219a81 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 @@ -39,7 +39,7 @@ CheckboxGroup(options?: { group?: string }) | 名称 | 功能描述 | | -------- | -------- | -| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult对象说明)) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。| +| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult对象说明)) => void ) |CheckboxGroup的选中状态或群组内的Checkbox的选中状态发生变化时,触发回调。(只有手动触发且Checkbox或CheckboxGroup状态改变时才会触发onChange回调)| ## CheckboxGroupResult对象说明 | 名称 | 类型 | 描述 | @@ -69,51 +69,45 @@ struct CheckboxExample { // 全选按钮 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { CheckboxGroup({ group: 'checkboxGroup' }) - .selectedColor(0xed6f21) + .selectedColor('#007DFF') .onChange((itemName: CheckboxGroupResult) => { console.info("checkbox group content" + JSON.stringify(itemName)) }) - Text('Select All').fontSize(20) + Text('Select All').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) } // 选项1 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) - .selectedColor(0x39a2db) + .selectedColor('#007DFF') .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) - Text('Checkbox1').fontSize(20) - } + Text('Checkbox1').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) // 选项2 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) - .selectedColor(0x39a2db) + .selectedColor('#007DFF') .onChange((value: boolean) => { console.info('Checkbox2 change is' + value) }) - Text('Checkbox2').fontSize(20) - } + Text('Checkbox2').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) // 选项3 Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) - .selectedColor(0x39a2db) + .selectedColor('#007DFF') .onChange((value: boolean) => { console.info('Checkbox3 change is' + value) }) - Text('Checkbox3').fontSize(20) - } + Text('Checkbox3').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) } } } } ``` -多选框组三种状态图示: - -![](figures/checkboxgroup1.png) - -![](figures/checkboxgroup2.png) - -![](figures/checkboxgroup3.png) +![checkboxGroup](figures/checkboxGroup.gif) 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 bcabffd14afc2f668cb5e6c15571fe572eb05ac3..6a5255d7214d07b6804f30510c8a59b513167cd3 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 @@ -28,9 +28,9 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) ## DataPanelType枚举说明 -| 名称 | 描述 | +| 名称 | 描述 | | -------| ------------ | -| Line | 线型数据面板。 | +| Line | 线型数据面板。 | | Circle | 环形数据面板。 | @@ -41,18 +41,46 @@ DataPanel(options:{values: number[], max?: number, type?: DataPanelType}) @Entry @Component struct DataPanelExample { - public values1: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10] + public valueArr: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10] build() { Column({ space: 5 }) { - Text('Circle').fontSize(9).fontColor(0xCCCCCC).margin({ top: 20, right: '80%' }) - DataPanel({ values: this.values1, max: 100, type: DataPanelType.Circle }).width(200).height(200) - - Text('Line').fontSize(9).fontColor(0xCCCCCC).margin({ bottom: 20, right: '80%' }) - DataPanel({ values: this.values1, max: 100, type: DataPanelType.Line }).width(300).height(10) + Row() { + Stack() { + DataPanel({ values: [25], max: 100, type: DataPanelType.Circle }).width(168).height(168) + Column() { + Text('30').fontSize(35).fontColor('#182431') + Text('1.0.0').fontSize(9.33).lineHeight(12.83).fontWeight(500).opacity(0.6) + } + + Text('%') + .fontSize(9.33) + .lineHeight(12.83) + .fontWeight(500) + .opacity(0.6) + .position({ x: 104.42, y: 78.17 }) + }.margin({ right: 44 }) + + Stack() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Circle }).width(168).height(168) + Column() { + Text('75').fontSize(35).fontColor('#182431') + Text('已使用98GB/128GB').fontSize(8.17).lineHeight(11.08).fontWeight(500).opacity(0.6) + } + + Text('%') + .fontSize(9.33) + .lineHeight(12.83) + .fontWeight(500) + .opacity(0.6) + .position({ x: 104.42, y: 78.17 }) + } + }.margin({ bottom: 59 }) + + DataPanel({ values: this.valueArr, max: 100, type: DataPanelType.Line }).width(300).height(10) }.width('100%').margin({ top: 5 }) } } ``` -![zh-cn_image_0000001236876377](figures/zh-cn_image_0000001236876377.jpg) +![dataPanel](figures/dataPanel.PNG) 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 cdf957e31d7c9494de9168b6c0b3655473f2574a..46f2ac309214572ce06ddc33505ff882353ff43d 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 @@ -41,28 +41,61 @@ Divider() @Component struct DividerExample { build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Column() { + // 使用横向分割线场景 Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC) - Row().width('100%').height(40).backgroundColor(0xF1F3F5) - Divider() - Row().width('100%').height(40).backgroundColor(0xF1F3F5) - - // 纵向分割线 + List() { + ForEach([1, 2, 3], (item) => { + ListItem() { + Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) + }.width(244).height(48) + }, item => item.toString()) + }.padding({ left: 24, bottom: 8 }) + + Divider().strokeWidth(8).color('#F1F3F5') + List() { + ForEach([4, 5], (item) => { + ListItem() { + Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) + }.width(244).height(48) + }, item => item.toString()) + }.padding({ left: 24, top: 8 }) + + // 使用纵向分割线场景 Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC) - Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) { - Text('bravery') - Divider().vertical(true).margin(20).height(15) - Text('effort') - Divider().vertical(true).margin(20).height(15) - 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) - Row().width('100%').height(40).backgroundColor(0xF1F3F5) - }.width('100%').height(350).padding({ left: 35, right: 35, top: 35 }) + Column() { + Column() { + Row().width(288).height(64).backgroundColor('#30C9F0').opacity(0.3) + Row() { + Button('Button') + .width(136) + .height(22) + .fontSize(16) + .fontColor('#007DFF') + .fontWeight(500) + .backgroundColor(Color.Transparent) + Divider().vertical(true).height(22).color('#182431').opacity(0.6).margin({ left: 8, right: 8 }) + Button('Button') + .width(136) + .height(22) + .fontSize(16) + .fontColor('#007DFF') + .fontWeight(500) + .backgroundColor(Color.Transparent) + }.margin({ top: 17 }) + } + .width(336) + .height(152) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .padding(24) + } + .width('100%') + .height(168) + .backgroundColor('#F1F3F5') + .justifyContent(FlexAlign.Center) + .margin({ top: 8 }) + }.width('100%').padding({ top: 24 }) } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md index 49a706f9c80c44662155f825375837736d10b9ce..abad3103f7e525eba3beb9e9d6f4d9163b8950b9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md @@ -3,6 +3,7 @@ 用于显示加载动效的组件。 > **说明:** +> > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md index e1bb411247a8294c28d38942e88233195671fbab..bb26b0a9af1b258a36a7ca6c5eef246fd8274740 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -51,10 +51,10 @@ Marquee(value: { start: boolean, step?: number, loop?: number, fromStart?: boole @Component struct MarqueeExample { @State start: boolean = false - @State fromStart: boolean = true - @State step: number = 50 - @State loop: number = 3 - @State src: string = "Running Marquee starts rolling" + private fromStart: boolean = true + private step: number = 50 + private loop: number = Infinity + private src: string = "Running Marquee starts rolling" build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -65,29 +65,31 @@ struct MarqueeExample { fromStart: this.fromStart, src: this.src }) - .width(400) - .fontColor(Color.White) - .fontSize(50) - .allowScale(false) - .fontWeight(FontWeight.Bold) - .backgroundColor(Color.Black) - .margin({bottom:40}) + .width(360) + .height(80) + .fontColor('#FFFFFF') + .fontSize(48) + .fontWeight(700) + .backgroundColor('#182431') + .margin({ bottom: 40 }) .onStart(() => { - console.log('Marquee animation complete onStart') + console.info('Marquee animation complete onStart') }) .onBounce(() => { - console.log('Marquee animation complete onBounce') + console.info('Marquee animation complete onBounce') }) .onFinish(() => { - console.log('Marquee animation complete onFinish') + console.info('Marquee animation complete onFinish') }) - Button('start') - .onClick(() => { - this.start = true - }) - .width(200) - .height(60) - .margin({bottom:20}) + Button('Start') + .onClick(() => { + this.start = true + }) + .width(120) + .height(40) + .fontSize(16) + .fontWeight(500) + .backgroundColor('#007DFF') } .width('100%') .height('100%') @@ -95,4 +97,4 @@ struct MarqueeExample { } ``` -![zh-cn_image_0000001193499234](figures/zh-cn_image_0000001193499234.gif) +![marquee](figures/marquee.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index 69a4680cbbbc930a8f69485fc2f03ef6342457a6..9fad298ffe627e1c9c8d2f9cb9fc1ac1a0f6589e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -25,7 +25,7 @@ Navigation() | -------------- | ---------------------------------------- | ---------------------------------------- | | title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle类型说明)9+ \| [NavigationCustomTitle](#navigationcustomtitle类型说明)9+ | 页面标题。 | | subTitledeprecated | string | 页面副标题。从API Version 9开始废弃,建议使用title代替。 | -| menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面右上角菜单。 | +| menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面右上角菜单。使用Array<[NavigationMenuItem](#navigationmenuitem类型说明)> 写法时,竖屏最多支持显示3个图标,横屏最多支持显示5个图标,多余的图标会被放入自动生成的更多图标。 | | titleMode | [NavigationTitleMode](#navigationtitlemode枚举说明) | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | | toolBar | [object](#object类型说明) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | | hideToolBar | boolean | 隐藏工具栏。
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | @@ -119,143 +119,114 @@ Navigation() @Component struct NavigationExample { private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - @State hideBar: boolean = true - - @Builder NavigationTitle() { - Column() { - Text('title') - .width(80) - .height(60) - .fontColor(Color.Blue) - .fontSize(30) - } - .onClick(() => { - console.log("title") - }) - } - - @Builder NavigationMenus() { - Row() { - Image('images/add.png') - .width(25) - .height(25) - Image('comment/more.png') - .width(25) - .height(25) - .margin({ left: 30 }) - }.width(100) - } - - build() { - Column() { - Navigation() { - Search({ value: '', placeholder: "" }).width('85%').margin(26) - List({ space: 5, initialIndex: 0 }) { - ForEach(this.arr, (item) => { - ListItem() { - Text('' + item) - .width('90%') - .height(80) - .backgroundColor('#3366CC') - .borderRadius(15) - .fontSize(16) - .textAlign(TextAlign.Center) - }.editable(true) - }, item => item) - } - .listDirection(Axis.Vertical) - .height(300) - .margin({ top: 10, left: 18 }) - .width('100%') - - Button(this.hideBar ? "tool bar" : "hide bar") - .onClick(() => { - this.hideBar = !this.hideBar - }) - .margin({ left: 135, top: 60 }) - } - .title(this.NavigationTitle) - .subTitle('subtitle') - .menus(this.NavigationMenus) - .titleMode(NavigationTitleMode.Free) - .hideTitleBar(false) - .hideBackButton(false) - .onTitleModeChange((titleModel: NavigationTitleMode) => { - console.log('titleMode') - }) - .toolBar({ items: [ - { value: 'app', icon: 'images/grid.svg', action: () => { - console.log("app") - } }, - { value: 'add', icon: 'images/add.svg', action: () => { - console.log("add") - } }, - { value: 'collect', icon: 'images/collect.svg', action: () => { - console.log("collect") - } }] }) - .hideToolBar(this.hideBar) - } - } -} -``` - -![zh-cn_image_0000001237616085](figures/zh-cn_image_0000001237616085.gif) - -```ts -// xxx.ets -@Entry -@Component -struct ToolbarBuilderExample { @State currentIndex: number = 0 @State Build: Array = [ { - icon: $r('app.media.ic_public_add'), - icon_after: $r('app.media.ic_public_addcolor'), text: 'add', num: 0 }, { - icon: $r('app.media.ic_public_app'), - icon_after: $r('app.media.ic_public_appcolor'), text: 'app', num: 1 }, { - icon: $r('app.media.ic_public_collect'), - icon_after: $r('app.media.ic_public_collectcolor'), text: 'collect', num: 2 } ] + @Builder NavigationTitle() { + Column() { + Text('Title') + .fontColor('#182431') + .fontSize(30) + .lineHeight(41) + .fontWeight(700) + Text('subtitle') + .fontColor('#182431') + .fontSize(14) + .lineHeight(19) + .opacity(0.4) + .margin({ top: 2 }) + }.alignItems(HorizontalAlign.Start) + } + + @Builder NavigationMenus() { + Row() { + Image('common/navigation_icon1.svg') + .width(24) + .height(24) + Image('common/navigation_icon1.svg') + .width(24) + .height(24) + .margin({ left: 24 }) + Image('common/navigation_icon2.svg') + .width(24) + .height(24) + .margin({ left: 24 }) + } + } + @Builder NavigationToolbar() { Row() { ForEach(this.Build, item => { Column() { - Image(this.currentIndex == item.num ? item.icon_after : item.icon) - .width(25) - .height(25) + Image(this.currentIndex == item.num ? 'common/public_icon_selected.svg' : 'common/public_icon.svg') + .width(24) + .height(24) Text(item.text) - .fontColor(this.currentIndex == item.num ? "#ff7500" : "#000000") - } + .fontColor(this.currentIndex == item.num ? '#007DFF' : '#182431') + .fontSize(10) + .lineHeight(14) + .fontWeight(500) + .margin({ top: 3 }) + }.width(104).height(56) .onClick(() => { this.currentIndex = item.num }) - .margin({ left: 70 }) }) - } + }.margin({ left: 24 }) } build() { Column() { Navigation() { - Flex() { + TextInput({ placeholder: 'search...' }) + .width(336) + .height(40) + .backgroundColor('#FFFFFF') + .margin({ top: 8, left: 12 }) + + List({ space: 12, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width(336) + .height(72) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .fontSize(16) + .fontWeight(500) + .textAlign(TextAlign.Center) + }.editable(true) + }, item => item) } + .height(324) + .width('100%') + .margin({ top: 12, left: 12 }) } + .title(this.NavigationTitle) + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Full) .toolBar(this.NavigationToolbar) - } + .hideTitleBar(false) + .hideToolBar(false) + .onTitleModeChange((titleModel: NavigationTitleMode) => { + console.info('titleMode' + titleModel) + }) + }.width('100%').height('100%').backgroundColor('#F1F3F5') } } ``` -![zh-cn_image_0000001192655288](figures/zh-cn_image_0000001192655288.gif) +![zh-cn_image_0000001192655288](figures/zh-cn_image_0000001192655288.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md index 124c299714c41b97f5239c3d3ad2087b24573ca0..92b69ccb79cf84d7033c67052aaf286020368d7f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md @@ -19,4 +19,4 @@ NavRouter() | 名称 | 功能描述 | | ---------------------------------------- | ---------------------------------------- | -| onStateChange(callback: (isActivated: boolean) => void) | 组件激活状态切换时触发该回调。返回值isActivated为true时表示激活,为false时表示未激活。
**说明:**用户点击NavRouter,激活NavRouter,加载对应的NavDestination子组件时,回调onStateChange(true);NavRouter对应的NavDestination子组件不再显示时,回调onStateChange(false)。 | +| onStateChange(callback: (isActivated: boolean) => void) | 组件激活状态切换时触发该回调。返回值isActivated为true时表示激活,为false时表示未激活。
**说明:** 用户点击NavRouter,激活NavRouter,加载对应的NavDestination子组件时,回调onStateChange(true);NavRouter对应的NavDestination子组件不再显示时,回调onStateChange(false)。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index d029ffdc31014f2046db268c33cc81917b2d783a..89ae82004a405e536ad3e7c686190a68528b43ba 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -3,6 +3,7 @@ 用于显示单个二维码的组件。 > **说明:** +> > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md index 605f333d3ad6dc85ee688321bc3f3f23dbaf321a..45552e9b3a8558c594c0445a78c47ec3ce5ddd4f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -47,21 +47,51 @@ Rating(options?: { rating: number, indicator?: boolean }) @Entry @Component struct RatingExample { - @State rating: number = 1 - @State indicator: boolean = false + @State rating: number = 3.5 build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('current score is ' + this.rating).fontSize(20) - Rating({ rating: this.rating, indicator: this.indicator }) - .stars(5) - .stepSize(0.5) - .onChange((value: number) => { - this.rating = value - }) - }.width(350).height(200).padding(35) + Column() { + Column() { + Rating({ rating: this.rating, indicator: false }) + .stars(5) + .stepSize(0.5) + .margin({ top: 24 }) + .onChange((value: number) => { + this.rating = value + }) + Text('current score is ' + this.rating) + .fontSize(16) + .fontColor('rgba(24,36,49,0.60)') + .margin({ top: 16 }) + }.width(360).height(113).backgroundColor('#FFFFFF').margin({ top: 68 }) + + Row() { + Image('common/testImage.jpg') + .width(40) + .height(40) + .borderRadius(20) + .margin({ left: 24 }) + Column() { + Text('Yue') + .fontSize(16) + .fontColor('#182431') + .fontWeight(500) + Row() { + Rating({ rating: 3.5, indicator: true }).margin({ top: 1, right: 8 }) + Text('2021/06/02') + .fontSize(10) + .fontColor('#182431') + } + }.margin({ left: 12 }).alignItems(HorizontalAlign.Start) + + Text('1st Floor') + .fontSize(10) + .fontColor('#182431') + .position({ x: 295, y: 8 }) + }.width(360).height(56).backgroundColor('#FFFFFF').margin({ top: 64 }) + }.width('100%').height('100%').backgroundColor('#F1F3F5') } } ``` -![zh-cn_image_0000001219662659](figures/zh-cn_image_0000001219662659.gif) +![rating](figures/rating.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index 055451e0feea7c6140d477b19e42ed09a352c661..825da4ef822e132555972061b29a983a3e8d58f4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -51,19 +51,20 @@ Select(options: Array\<[SelectOption](#selectoption对象说明)\>) struct SelectExample { build() { Column() { - Select([{ value: 'aaa', icon: "/common/1.png" }, - { value: 'bbb', icon: "/common/2.png" }, - { value: 'ccc', icon: "/common/3.png" }, - { value: 'ddd', icon: "/common/4.png" }]) + Select([{ value: 'aaa', icon: "/common/public_icon.svg" }, + { value: 'bbb', icon: "/common/public_icon.svg" }, + { value: 'ccc', icon: "/common/public_icon.svg" }, + { value: 'ddd', icon: "/common/public_icon.svg" }]) .selected(2) - .value('TTT') - .font({ size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) - .selectedOptionFont({ size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) - .optionFont({ size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) + .value('TTTTT') + .font({ size: 16, weight: 500 }) + .fontColor('#182431') + .selectedOptionFont({ size: 16, weight: 400 }) + .optionFont({ size: 16, weight: 400 }) .onSelect((index: number) => { - console.info("Select:" + index) + console.info('Select:' + index) }) - } + }.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 d289dd65cb227bd32f908925cd2947812e73411d..fd1a49a370bc272652fe1b5152f1730e7c5addb4 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 @@ -45,6 +45,22 @@ Stepper(value?: { index?: number }) ```ts // xxx.ets +@Styles function itemStyle () { + .width(336) + .height(621) + .margin({ top: 48, left: 12 }) + .borderRadius(24) + .backgroundColor('#FFFFFF') +} + +@Extend(Text) function itemTextStyle () { + .fontColor('#182431') + .fontSize(36) + .fontWeight(500) + .opacity(0.4) + .margin({ top: 82, bottom: 40 }) +} + @Entry @Component struct StepperExample { @@ -61,15 +77,13 @@ struct StepperExample { StepperItem() { Column() { Text('Page One') - .fontSize(35) - .fontColor(Color.Blue) - .lineHeight(50) - .margin({ top: 250, bottom: 50 }) + .itemTextStyle() Button('change status:' + this.firstState) + .backgroundColor('#007dFF') .onClick(() => { this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip }) - }.width('100%') + }.itemStyle() } .nextLabel('Next') .status(this.firstState) @@ -77,15 +91,13 @@ struct StepperExample { StepperItem() { Column() { Text('Page Two') - .fontSize(35) - .fontColor(Color.Blue) - .lineHeight(50) - .margin({ top: 250, bottom: 50 }) + .itemTextStyle() Button('change status:' + this.secondState) + .backgroundColor('#007dFF') .onClick(() => { this.secondState = this.secondState === ItemState.Disabled ? ItemState.Normal : ItemState.Disabled }) - }.width('100%') + }.itemStyle() } .nextLabel('Next') .prevLabel('Previous') @@ -94,29 +106,25 @@ struct StepperExample { StepperItem() { Column() { Text('Page Three') - .fontSize(35) - .fontColor(Color.Blue) - .lineHeight(50) - .margin({ top: 250, bottom: 50 }) + .itemTextStyle() Button('change status:' + this.thirdState) + .backgroundColor('#007dFF') .onClick(() => { this.thirdState = this.thirdState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting }) - }.width('100%') + }.itemStyle() } .status(this.thirdState) // 第四个步骤页 StepperItem() { - Text('Page four') - .fontSize(35) - .fontColor(Color.Blue) - .width('100%') - .textAlign(TextAlign.Center) - .lineHeight(50) - .margin({ top: 250 }) + Column() { + Text('Page Four') + .itemTextStyle() + }.itemStyle() } .nextLabel('Finish') } + .backgroundColor('#F1F3F5') .onFinish(() => { // 此处可处理点击最后一页的Finish时的逻辑,例如路由跳转等 console.info('onFinish') @@ -133,5 +141,5 @@ struct StepperExample { ``` -![zh-cn_image_0000001250678457](figures/zh-cn_image_0000001250678457.gif) +![stepper](figures/stepper.gif) 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 a36b7afae827d0421190ad5d788fcf06ce0a2080..223e021f125f2cf2a33ac53be2aa8d2eca238025 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 @@ -85,23 +85,29 @@ struct TextAreaExample { build() { Column() { - TextArea({ placeholder: 'The text area can hold an unlimited amount of text. input your word', controller: this.controller }) - .placeholderFont({ size: 14, weight: 400 }) - .width(400) - .height(50) + TextArea({ + placeholder: 'The text area can hold an unlimited amount of text. input your word...', + controller: this.controller + }) + .placeholderFont({ size: 16, weight: 400 }) + .width(336) + .height(56) .margin(20) - .fontSize(14) + .fontSize(16) + .fontColor('#182431') + .backgroundColor('#FFFFFF') .onChange((value: string) => { this.text = value }) Text(this.text) Button('Set caretPosition 1') + .backgroundColor('#007DFF') .margin(15) .onClick(() => { // 设置光标位置到第一个字符后 this.controller.caretPosition(1) }) - }.width('100%') + }.width('100%').height('100%').backgroundColor('#F1F3F5') } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md index bf56800c5b2345d524b0d321b9986e3a0dbb99d6..e00ea4bb7aeef7efb1f3b681563dcb37af8ef39a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -57,21 +57,20 @@ Toggle(options: { type: ToggleType, isOn?: boolean }) @Entry @Component struct ToggleExample { - build() { Column({ space: 10 }) { Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%') Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { Toggle({ type: ToggleType.Switch, isOn: false }) - .selectedColor(0xed6f21) - .switchPointColor(0xe5ffffff) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) Toggle({ type: ToggleType.Switch, isOn: true }) - .selectedColor(0x39a2db) - .switchPointColor(0xe5ffffff) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) @@ -80,15 +79,15 @@ struct ToggleExample { Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%') Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { Toggle({ type: ToggleType.Checkbox, isOn: false }) - .size({ width: 28, height: 28 }) - .selectedColor(0xed6f21) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) Toggle({ type: ToggleType.Checkbox, isOn: true }) - .size({ width: 28, height: 28 }) - .selectedColor(0x39a2db) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) @@ -97,17 +96,17 @@ struct ToggleExample { Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%') Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { Toggle({ type: ToggleType.Button, isOn: false }) { - Text('status button').padding({ left: 12, right: 12 }) - } - .selectedColor(0xed6f21) + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .selectedColor('rgba(0,125,255,0.20)') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) Toggle({ type: ToggleType.Button, isOn: true }) { - Text('status button').padding({ left: 12, right: 12 }) - } - .selectedColor(0x39a2db) + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .selectedColor('rgba(0,125,255,0.20)') .onChange((isOn: boolean) => { console.info('Component status:' + isOn) }) @@ -117,4 +116,4 @@ struct ToggleExample { } ``` -![zh-cn_image_0000001174104402](figures/zh-cn_image_0000001174104402.gif) +![toggle](figures/toggle.gif) 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 c53162cfdc10a7e7a6ff28649469cadbcb56e6f5..386efee96facc3021161228f1cbf436c21a181df 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 @@ -24,10 +24,10 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | -| ---------- | ------------------------------- | ---- | ------- | -| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 | -| controller | [WebController](#webcontroller) 或 [WebviewController](../apis/js-apis-webview.md#webviewcontroller) |是 | 控制器。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ---------- | ---------------------------------------- | ---- | ------- | +| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 | +| controller | [WebController](#webcontroller) 或 [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | 控制器。 | **示例:** @@ -98,8 +98,8 @@ domStorageAccess(domStorageAccess: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---------------- | ------- | ---- | ---- | ------------------------------------ | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---------------- | ------- | ---- | ----- | ------------------------------------ | | domStorageAccess | boolean | 是 | false | 设置是否开启文档对象模型存储接口(DOM Storage API)权限。 | **示例:** @@ -127,8 +127,8 @@ fileAccess(fileAccess: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---------- | ------- | ---- | ---- | ---------------------------------------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---------- | ------- | ---- | ---- | ---------------------- | | fileAccess | boolean | 是 | true | 设置是否开启应用中文件系统的访问,默认启用。 | **示例:** @@ -185,12 +185,12 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---------- | --------------- | ---- | ---- | ------------------------- | -| object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 | -| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 | -| methodList | Array\ | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | -| controller | [WebController](#webcontroller) 或 [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 控制器。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---------- | ---------------------------------------- | ---- | ---- | ------------------------- | +| object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 | +| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 | +| methodList | Array\ | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | +| controller | [WebController](#webcontroller) 或 [WebviewController](../apis/js-apis-webview.md#webviewcontroller) | 是 | - | 控制器。 | **示例:** @@ -296,8 +296,8 @@ mixedMode(mixedMode: MixedMode) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | --------------------------- | ---- | ---- | --------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| --------- | --------------------------- | ---- | -------------- | --------- | | mixedMode | [MixedMode](#mixedmode枚举说明) | 是 | MixedMode.None | 要设置的混合内容。 | **示例:** @@ -413,8 +413,8 @@ databaseAccess(databaseAccess: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------------- | ------- | ---- | ---- | ----------------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------------- | ------- | ---- | ----- | ----------------- | | databaseAccess | boolean | 是 | false | 设置是否开启数据库存储API权限。 | **示例:** @@ -442,9 +442,9 @@ geolocationAccess(geolocationAccess: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------------- | ------- | ---- | ---- | ----------------- | -| geolocationAccess | boolean | 是 | true | 设置是否开启获取地理位置权限。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ----------------- | ------- | ---- | ---- | --------------- | +| geolocationAccess | boolean | 是 | true | 设置是否开启获取地理位置权限。 | **示例:** @@ -471,9 +471,9 @@ mediaPlayGestureAccess(access: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | ------ | ---- | ---- | --------- | -| access | boolean | 是 | true | 设置视频播放是否需要用户手动点击。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------- | ---- | ---- | ----------------- | +| access | boolean | 是 | true | 设置视频播放是否需要用户手动点击。 | **示例:** @@ -501,8 +501,8 @@ multiWindowAccess(multiWindow: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------------- | ------- | ---- | ---- | ----------------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ----------- | ------- | ---- | ----- | ------------ | | multiWindow | boolean | 是 | false | 设置是否开启多窗口权限。 | **示例:** @@ -530,8 +530,8 @@ cacheMode(cacheMode: CacheMode) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | --------------------------- | ---- | ---- | --------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| --------- | --------------------------- | ---- | ----------------- | --------- | | cacheMode | [CacheMode](#cachemode枚举说明) | 是 | CacheMode.Default | 要设置的缓存模式。 | **示例:** @@ -560,9 +560,9 @@ textZoomRatio(textZoomRatio: number) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------------ | ------ | ---- | ---- | --------------- | -| textZoomRatio | number | 是 | 100 | 要设置的页面的文本缩放百分比。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------------- | ------ | ---- | ---- | --------------- | +| textZoomRatio | number | 是 | 100 | 要设置的页面的文本缩放百分比。 | **示例:** @@ -590,9 +590,9 @@ initialScale(percent: number) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------------ | ------ | ---- | ---- | --------------- | -| percent | number | 是 | 100 | 要设置的整体页面的缩放百分比。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------- | ------ | ---- | ---- | --------------- | +| percent | number | 是 | 100 | 要设置的整体页面的缩放百分比。 | **示例:** @@ -650,9 +650,9 @@ webDebuggingAccess(webDebuggingAccess: boolean) **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | ------ | ---- | ---- | --------- | -| webDebuggingAccess | boolean | 是 | false | 设置是否启用网页调试功能。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------------------ | ------- | ---- | ----- | ------------- | +| webDebuggingAccess | boolean | 是 | false | 设置是否启用网页调试功能。 | **示例:** @@ -1233,9 +1233,9 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------- | --------------------------------- | -| url | string | 访问的url。 | +| 参数名 | 参数类型 | 参数描述 | +| ----------- | ------- | ---------------------------------------- | +| url | string | 访问的url。 | | isRefreshed | boolean | true表示该页面是被重新加载的(调用[refresh](#refresh)接口),false表示该页面是新加载的。 | **示例:** @@ -1305,8 +1305,8 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector **返回值:** -| 类型 | 说明 | -| ------- | ----------------------------------- | +| 类型 | 说明 | +| ------- | ---------------------------------------- | | boolean | 当返回值为true时,用户可以调用系统提供的弹窗能力。当返回值为false时,触发Web默认弹窗。 | **示例:** @@ -1354,9 +1354,9 @@ onResourceLoad(callback: (event: {url: string}) => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ---- | ---------------------------------------- | --------- | -| url | string | 所加载的资源文件url信息。 | +| 参数名 | 参数类型 | 参数描述 | +| ---- | ------ | -------------- | +| url | string | 所加载的资源文件url信息。 | **示例:** @@ -1386,8 +1386,8 @@ onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ---- | ---------------------------------------- | --------- | +| 参数名 | 参数类型 | 参数描述 | +| -------- | ------ | ------------ | | oldScale | number | 变化前的显示比例百分比。 | | newScale | number | 变化后的显示比例百分比。 | @@ -1464,8 +1464,8 @@ onInterceptRequest(callback: (event?: { request: WebResourceRequest}) => WebReso **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | --------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | | [WebResourceResponse](#webresourceresponse) | 返回响应数据则按照响应数据加载,无响应数据则返回null表示按照原来的方式加载。 | **示例:** @@ -1592,10 +1592,10 @@ onSslErrorEventReceive(callback: (event: { handler: SslErrorHandler, error: SslE **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------- | ------------------------------------ | ---------------- | +| 参数名 | 参数类型 | 参数描述 | +| ------- | ------------------------------------ | -------------- | | handler | [SslErrorHandler](#sslerrorhandler9) | 通知Web组件用户操作行为。 | -| error | [SslError](#sslerror9枚举说明) | 错误码。 | +| error | [SslError](#sslerror9枚举说明) | 错误码。 | **示例:** @@ -1645,13 +1645,13 @@ onClientAuthenticationRequest(callback: (event: {handler : ClientAuthenticationH **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------- | ------------------------------------ | ---------------- | -| handler | [ClientAuthenticationHandler](#clientauthenticationhandler9) | 通知Web组件用户操作行为。| -| host | string | 请求证书服务器的主机名。 | -| port | number | 请求证书服务器的端口号。 | -| keyTypes| Array | 可接受的非对称秘钥类型。 | -| issuers | Array | 与私钥匹配的证书可接受颁发者。| +| 参数名 | 参数类型 | 参数描述 | +| -------- | ---------------------------------------- | --------------- | +| handler | [ClientAuthenticationHandler](#clientauthenticationhandler9) | 通知Web组件用户操作行为。 | +| host | string | 请求证书服务器的主机名。 | +| port | number | 请求证书服务器的端口号。 | +| keyTypes | Array | 可接受的非对称秘钥类型。 | +| issuers | Array | 与私钥匹配的证书可接受颁发者。 | **示例:** ```ts @@ -1700,9 +1700,9 @@ onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------- | ------------------------------------ | ---------------- | -| request | [PermissionRequest](#permissionrequest9) | 通知Web组件用户操作行为。 | +| 参数名 | 参数类型 | 参数描述 | +| ------- | ---------------------------------------- | -------------- | +| request | [PermissionRequest](#permissionrequest9) | 通知Web组件用户操作行为。 | **示例:** @@ -1749,15 +1749,15 @@ onContextMenuShow(callback: (event?: { param: WebContextMenuParam, result: WebCo **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------- | ------------------------------------ | ---------------- | -| param | [WebContextMenuParam](#webcontextmenuparam9) | 菜单相关参数。 | -| result | [WebContextMenuResult](#webcontextmenuresult9) | 菜单相应事件传入内核。 | +| 参数名 | 参数类型 | 参数描述 | +| ------ | ---------------------------------------- | ----------- | +| param | [WebContextMenuParam](#webcontextmenuparam9) | 菜单相关参数。 | +| result | [WebContextMenuResult](#webcontextmenuresult9) | 菜单相应事件传入内核。 | **返回值:** -| 类型 | 说明 | -| ------ | -------------------- | +| 类型 | 说明 | +| ------- | ------------------------ | | boolean | 自定义菜单返回true,默认菜单返回false。 | **示例:** @@ -1789,10 +1789,10 @@ onScroll(callback: (event: {xOffset: number, yOffset: number}) => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------- | ------------------------------------ | ---------------- | -| xOffset | number | 水平滚动条滚动所在位置。 | -| yOffset | number | 竖直滚动条滚动所在位置。 | +| 参数名 | 参数类型 | 参数描述 | +| ------- | ------ | ------------ | +| xOffset | number | 水平滚动条滚动所在位置。 | +| yOffset | number | 竖直滚动条滚动所在位置。 | **示例:** @@ -1822,10 +1822,10 @@ onGeolocationShow(callback: (event?: { origin: string, geolocation: JsGeolocatio **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | +| 参数名 | 参数类型 | 参数描述 | +| ----------- | ------------------------------- | -------------- | | origin | string | 指定源的字符串索引。 | -| geolocation | [JsGeolocation](#jsgeolocation) | 通知Web组件用户操作行为。| +| geolocation | [JsGeolocation](#jsgeolocation) | 通知Web组件用户操作行为。 | **示例:** @@ -1867,9 +1867,9 @@ onGeolocationHide(callback: () => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | -| callback | () => void | 地理位置信息获取请求已被取消的回调函数。 | +| 参数名 | 参数类型 | 参数描述 | +| -------- | ---------- | -------------------- | +| callback | () => void | 地理位置信息获取请求已被取消的回调函数。 | **示例:** @@ -1899,9 +1899,9 @@ onFullScreenEnter(callback: (event: { handler: FullScreenExitHandler }) => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | -| handler | [FullScreenExitHandler](#fullscreenexithandler9) | 用于退出全屏模式的函数句柄。 | +| 参数名 | 参数类型 | 参数描述 | +| ------- | ---------------------------------------- | -------------- | +| handler | [FullScreenExitHandler](#fullscreenexithandler9) | 用于退出全屏模式的函数句柄。 | **示例:** @@ -1932,9 +1932,9 @@ onFullScreenExit(callback: () => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | -| callback | () => void | 退出全屏模式时的回调函数。 | +| 参数名 | 参数类型 | 参数描述 | +| -------- | ---------- | ------------- | +| callback | () => void | 退出全屏模式时的回调函数。 | **示例:** @@ -1968,12 +1968,12 @@ onWindowNew(callback: (event: {isAlert: boolean, isUserTrigger: boolean, targetU **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | -| isAlert | boolean | true代表请求创建对话框,false代表新标签页。 | -| isUserTrigger | boolean | true代表用户触发,false代表非用户触发。 | -| targetUrl | string | 目标url。 | -| handler | [ControllerHandler](#controllerhandler9) | 用于设置新建窗口的WebController实例。 | +| 参数名 | 参数类型 | 参数描述 | +| ------------- | ---------------------------------------- | -------------------------- | +| isAlert | boolean | true代表请求创建对话框,false代表新标签页。 | +| isUserTrigger | boolean | true代表用户触发,false代表非用户触发。 | +| targetUrl | string | 目标url。 | +| handler | [ControllerHandler](#controllerhandler9) | 用于设置新建窗口的WebController实例。 | **示例:** @@ -2005,9 +2005,9 @@ onWindowExit(callback: () => void) **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ----------- | ------------------------------- | ---------------- | -| callback | () => void | 窗口请求关闭的回调函数。 | +| 参数名 | 参数类型 | 参数描述 | +| -------- | ---------- | ------------ | +| callback | () => void | 窗口请求关闭的回调函数。 | **示例:** @@ -2036,11 +2036,11 @@ onSearchResultReceive(callback: (event?: {activeMatchOrdinal: number, numberOfMa **参数:** -| 参数名 | 参数类型 | 参数描述 | -| ------------------ | ------------- | ----------------------------------- | -| activeMatchOrdinal | number | 当前匹配的查找项的序号(从0开始)。 | -| numberOfMatches | number | 所有匹配到的关键词的个数。 | -| isDoneCounting | boolean | 当次页内查找操作是否结束。该方法可能会回调多次,直到isDoneCounting为true为止。 | +| 参数名 | 参数类型 | 参数描述 | +| ------------------ | ------- | ---------------------------------------- | +| activeMatchOrdinal | number | 当前匹配的查找项的序号(从0开始)。 | +| numberOfMatches | number | 所有匹配到的关键词的个数。 | +| isDoneCounting | boolean | 当次页内查找操作是否结束。该方法可能会回调多次,直到isDoneCounting为true为止。 | **示例:** @@ -2165,8 +2165,8 @@ setWebController(controller: WebController): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | ------ | ---- | ---- | ----------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---------- | ------------- | ---- | ---- | ------------------------- | | controller | WebController | 是 | - | 新建web组件的的WebController对象。 | ## WebResourceError @@ -2556,10 +2556,10 @@ confirm(priKeyFile : string, certChainFile : string): void **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | ------ | ---- | ---------- | -| priKeyFile | string | 是 | 存放私钥的文件,包含路径和文件名。| -| certChainFile | string | 是 | 存放证书链的文件,包含路径和文件名。| +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------------- | ------ | ---- | ------------------ | +| priKeyFile | string | 是 | 存放私钥的文件,包含路径和文件名。 | +| certChainFile | string | 是 | 存放证书链的文件,包含路径和文件名。 | ### cancel9+ @@ -2591,9 +2591,9 @@ getOrigin(): string **返回值:** -| 类型 | 说明 | -| ------- | --------------------- | -| string | 当前请求权限网页的来源。 | +| 类型 | 说明 | +| ------ | ------------ | +| string | 当前请求权限网页的来源。 | ### getAccessibleResource9+ @@ -2603,8 +2603,8 @@ getAccessibleResource(): Array\ **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| --------------- | ------------- | | Array\ | 网页所请求的权限资源列表。 | ### grant9+ @@ -2615,9 +2615,9 @@ grant(resources: Array\): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | --------------- | ---- | ----- | ---------------------- | -| resources | Array\ | 是 | - | 网页所请求的权限资源列表。| +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| --------- | --------------- | ---- | ---- | ------------- | +| resources | Array\ | 是 | - | 网页所请求的权限资源列表。 | ## WebContextMenuParam9+ @@ -2631,8 +2631,8 @@ x(): number **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------ | ------------------ | | number | 显示正常返回非负整数,否则返回-1。 | ### y9+ @@ -2643,8 +2643,8 @@ y(): number **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------ | ------------------ | | number | 显示正常返回非负整数,否则返回-1。 | ### getLinkUrl9+ @@ -2655,8 +2655,8 @@ getLinkUrl(): string **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------ | ------------------------- | | string | 如果长按位置是链接,返回经过安全检查的url链接。 | ### getUnfilterendLinkUrl9+ @@ -2667,8 +2667,8 @@ getUnfilterendLinkUrl(): string **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------ | --------------------- | | string | 如果长按位置是链接,返回原始的url链接。 | ### getSourceUrl9+ @@ -2679,8 +2679,8 @@ getSourceUrl(): string **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------ | ------------------------ | | string | 如果选中的元素有src属性,返回src的url。 | ### existsImageContents9+ @@ -2691,8 +2691,8 @@ existsImageContents(): boolean **返回值:** -| 类型 | 说明 | -| --------------- | ----------------------- | +| 类型 | 说明 | +| ------- | ------------------------- | | boolean | 长按位置中有图片返回true,否则返回false。 | ## WebContextMenuResult9+ @@ -2723,11 +2723,11 @@ invoke(origin: string, allow: boolean, retain: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| --------- | ------- | ---- | ----- | ---------------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | -| allow | boolean | 是 | - | 设置的地理位置权限状态。 | -| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions](#geolocationpermissions9)接口管理保存到系统的地理位置权限。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------- | ---- | ---- | ---------------------------------------- | +| origin | string | 是 | - | 指定源的字符串索引。 | +| allow | boolean | 是 | - | 设置的地理位置权限状态。 | +| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions](#geolocationpermissions9)接口管理保存到系统的地理位置权限。 | ## WebController @@ -3735,8 +3735,8 @@ createWebMessagePorts(): Array\ **返回值:** -| 类型 | 说明 | -| ------------------------------- | ------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------- | | Array\<[WebMessagePort](#webmessageport9)\> | web消息端口列表。 | **示例:** @@ -3769,10 +3769,10 @@ postMessage(options: { message: WebMessageEvent, uri: string}): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---------- | --------------- | ---- | ---- | ------------------------- | -| message | [WebMessageEvent](#webmessageevent9) | 是 | - |要发送的消息,包含数据和消息端口。 | -| uri | string | 是 | - | 接收该消息的URI。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------- | ------------------------------------ | ---- | ---- | ----------------- | +| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的消息,包含数据和消息端口。 | +| uri | string | 是 | - | 接收该消息的URI。 | **示例:** @@ -3880,8 +3880,8 @@ getUrl(): string **返回值:** -| 类型 | 说明 | -| ------------------------------- | ------------- | +| 类型 | 说明 | +| ------ | ----------- | | string | 当前页面的url地址。 | **示例:** @@ -3912,8 +3912,8 @@ searchAllAsync(searchString: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---- | ------ | ---- | ---- | --------------------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------------ | ------ | ---- | ---- | ------- | | searchString | string | 是 | - | 查找的关键字。 | **示例:** @@ -3985,8 +3985,8 @@ searchNext(forward: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---- | ------ | ---- | ---- | --------------------- | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------- | ------- | ---- | ---- | ----------- | | forward | boolean | 是 | - | 从前向后或者逆向查找。 | @@ -4121,14 +4121,14 @@ getCookie(url: string): string **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| url | string | 是 | - | 要获取的cookie所属的url。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---- | ------ | ---- | ---- | ----------------- | +| url | string | 是 | - | 要获取的cookie所属的url。 | **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ------ | ----------------- | | string | 指定url对应的cookie的值。 | **示例:** @@ -4164,12 +4164,12 @@ setCookie(url: string, value: string): boolean | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | ----- | ------ | ---- | ---- | ----------------- | | url | string | 是 | - | 要设置的cookie所属的url。 | -| value | string | 是 | - | 要设置的cookie的值。 | +| value | string | 是 | - | 要设置的cookie的值。 | **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ------- | ------------- | | boolean | 设置cookie是否成功。 | **示例:** @@ -4236,8 +4236,8 @@ saveCookieAsync(): Promise\ **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ----------------- | --------------------------- | | Promise\ | Promise实例,用于获取cookie是否成功保存。 | **示例:** @@ -4275,9 +4275,9 @@ saveCookieAsync(callback: AsyncCallback\): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| callback | AsyncCallback\ | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | ----------------------- | ---- | ---- | ---------------------------- | +| callback | AsyncCallback\ | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | **示例:** @@ -4310,8 +4310,8 @@ isCookieAllowed(): boolean **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ------- | ------------------- | | boolean | 是否拥有发送和接收cookie的权限。 | **示例:** @@ -4344,9 +4344,9 @@ putAcceptCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------- | ---- | ---- | --------------------- | +| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 | **示例:** @@ -4377,8 +4377,8 @@ isThirdCookieAllowed(): boolean **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ------- | ---------------------- | | boolean | 是否拥有发送和接收第三方cookie的权限。 | **示例:** @@ -4411,9 +4411,9 @@ putAcceptThirdPartyCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------- | ---- | ---- | ------------------------ | +| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 | **示例:** @@ -4444,8 +4444,8 @@ existCookie(): boolean **返回值:** -| 类型 | 说明 | -| ------- | -------------------- | +| 类型 | 说明 | +| ------- | ----------- | | boolean | 是否存在cookie。 | **示例:** @@ -4688,9 +4688,9 @@ static allowGeolocation(origin: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | ---- | ----- | ------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------ | ---- | ---- | ---------- | +| origin | string | 是 | - | 指定源的字符串索引。 | **示例:** @@ -4722,9 +4722,9 @@ static deleteGeolocation(origin: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | ---- | ----- | ------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------ | ---- | ---- | ---------- | +| origin | string | 是 | - | 指定源的字符串索引。 | **示例:** @@ -4783,10 +4783,10 @@ static getAccessibleGeolocation(origin: string, callback: AsyncCallback\ | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | ------------------------ | ---- | ---- | ---------------------------------------- | +| origin | string | 是 | - | 指定源的字符串索引。 | +| callback | AsyncCallback\ | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | **示例:** @@ -4824,14 +4824,14 @@ static getAccessibleGeolocation(origin: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | ---- | ----- | ------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------ | ------ | ---- | ---- | ---------- | +| origin | string | 是 | - | 指定源的字符串索引。 | **返回值:** -| 类型 | 说明 | -| ------------------ | ------------------------------------ | +| 类型 | 说明 | +| ------------------ | ---------------------------------------- | | Promise\ | Promise实例,用于获取指定源的权限状态,获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | **示例:** @@ -4868,9 +4868,9 @@ static getStoredGeolocation(callback: AsyncCallback\\>): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | ---- | ----- | ------------- | -| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------------------------------- | ---- | ---- | -------------------- | +| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | **示例:** @@ -4908,14 +4908,14 @@ static getStoredGeolocation(): Promise\\> **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | ---- | ----- | ------------- | -| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------------------------------- | ---- | ---- | -------------------- | +| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | **返回值:** -| 类型 | 说明 | -| -------------------------- | ------------------------------------ | +| 类型 | 说明 | +| -------------------------- | -------------------------------- | | Promise\\> | Promise实例,用于获取已存储地理位置权限状态的所有源信息。 | **示例:** @@ -5337,25 +5337,25 @@ onRenderExited接口返回的渲染进程退出的具体原因。 | HttpAnchorImg | 带有超链接的图片,其中超链接的src为http。 | | Img | HTML::img标签。 | | Map | 地理地址。 | -| Phone | 手机电话号码。 | +| Phone | 电话号码。 | | Unknown | 未知内容。 | ## SslError9+枚举说明 onSslErrorEventReceive接口返回的SSL错误的具体原因。 -| 名称 | 描述 | -| -------------- | ----------------- | -| Invalid | 一般错误。 | -| HostMismatch | 主机名不匹配。 | -| DateInvalid | 证书日期无效。 | -| Untrusted | 证书颁发机构不受信任。 | +| 名称 | 描述 | +| ------------ | ----------- | +| Invalid | 一般错误。 | +| HostMismatch | 主机名不匹配。 | +| DateInvalid | 证书日期无效。 | +| Untrusted | 证书颁发机构不受信任。 | ## ProtectedResourceType9+枚举说明 -| 名称 | 描述 | 备注 | -| --------- | -------------- | -------------- | -| MidiSysex | MIDI SYSEX资源。| 目前仅支持权限事件上报,MIDI设备的使用还未支持。| +| 名称 | 描述 | 备注 | +| --------- | ------------- | -------------------------- | +| MidiSysex | MIDI SYSEX资源。 | 目前仅支持权限事件上报,MIDI设备的使用还未支持。 | ## WebAsyncController @@ -5423,8 +5423,8 @@ storeWebArchive(baseName: string, autoName: boolean): Promise **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------------------------------- | +| 类型 | 说明 | +| --------------- | -------------------------------- | | Promise | Promise实例,保存成功返回文件路径,保存失败返回null。 | **示例:** @@ -5470,9 +5470,9 @@ postMessageEvent(message: WebMessageEvent): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的消息。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ------- | ------------------------------------ | ---- | ---- | ------- | +| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的消息。 | **示例:** @@ -5505,9 +5505,9 @@ onMessageEvent(callback: (result: string) => void): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| callback | function | 是 | - | 接收消息的回调函数。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | ---- | ---- | ---------- | +| callback | function | 是 | - | 接收消息的回调函数。 | **示例:** @@ -5545,8 +5545,8 @@ getData(): string **返回值:** -| 类型 | 说明 | -| ------------------------------- | ------------- | +| 类型 | 说明 | +| ------ | -------------- | | string | 当前该类型对象中存放的消息。 | **示例:** @@ -5577,9 +5577,9 @@ setData(data: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| data | string | 是 | - | 要发送的消息。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ---- | ------ | ---- | ---- | ------- | +| data | string | 是 | - | 要发送的消息。 | **示例:** @@ -5611,8 +5611,8 @@ getPorts(): Array\ **返回值:** -| 类型 | 说明 | -| ------------------------------- | ------------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------- | | Array\<[WebMessagePort](#webmessageport9)\> | 当前该类型对象中存放的消息端口。 | **示例:** @@ -5645,9 +5645,9 @@ setPorts(ports: Array\): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| ports | Array\<[WebMessagePort](#webmessageport9)\> | 是 | - | 要发送的消息端口。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| ----- | ---------------------------------------- | ---- | ---- | --------- | +| ports | Array\<[WebMessagePort](#webmessageport9)\> | 是 | - | 要发送的消息端口。 | **示例:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md index e047ed2da951bb898627b9830bdb12737d6ad4c5..d1c026f7074546c14b41cff054ef2b99d7d43972 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md @@ -58,11 +58,10 @@ xcomponentController: XComponentController = new XComponentController() ### getXComponentSurfaceId -getXComponentSurfaceId() +getXComponentSurfaceId(): string 获取XComponent对应Surface的ID,供@ohos接口使用,比如camera相关接口。 -**系统接口:** 此接口为系统接口。 **返回值:** @@ -73,11 +72,10 @@ getXComponentSurfaceId() ### setXComponentSurfaceSize -setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}) +setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}): void 设置XComponent持有Surface的宽度和高度。 -**系统接口:** 此接口为系统接口。 **参数:** @@ -89,7 +87,7 @@ setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}) ### getXComponentContext -getXComponentContext() +getXComponentContext(): Object 获取XComponent实例对象的context。 @@ -102,12 +100,10 @@ getXComponentContext() ## 示例 -提供surface类型XComponent,支持相机预览等能力。 示例效果请以真机运行为准,当前IDE预览器不支持。 ```ts // xxx.ets -import camera from '@ohos.multimedia.camera' @Entry @Component struct PreviewArea { @@ -123,9 +119,6 @@ struct PreviewArea { .onLoad(() => { this.xcomponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}); this.surfaceId = this.xcomponentController.getXComponentSurfaceId() - camera.createPreviewOutput(this.surfaceId).then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance') - }) }) .width('640px') .height('480px') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 66adc3e73e3083a309db834bd5b0db9795e8df4b..07953a5d7f6e1bc9e7ee8dbefec000be6c398b45 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -769,7 +769,7 @@ clearRect(x: number, y: number, w: number, h: number): void Canvas(this.context) .width('100%') .height('100%') - .backgroundColor('#ffffff') + .backgroundColor('#ffff00') .onReady(() =>{ this.context.fillStyle = 'rgb(0,0,255)' this.context.fillRect(20,20,200,200) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md index d8d8bf52419bc243d81b7e3f47598560bc3851e0..03ef8e6c7a980e9383e7ed21cb98ad97832ca51d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md @@ -6,12 +6,6 @@ > > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 权限列表 - -无 - ## 子组件 不支持。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md index f3dd34c03f3578b435ded7faa34f7d3e01ea65a7..bd1b16a3981851566cb2970203935f439a3c74af 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md @@ -12,10 +12,14 @@ ImageData对象可以存储canvas渲染的像素数据。 | 属性 | 类型 | 描述 | | -------- | -------- | -------- | -| width | number | 矩形区域实际像素宽度。 | -| height | number | 矩形区域实际像素高度。 | +| width | number | 矩形区域实际像素宽度,单位为px。 | +| height | number | 矩形区域实际像素高度,单位为px。 | | data | Uint8ClampedArray | 一维数组,保存了相应的颜色数据,数据值范围为0到255。 | +> **说明:** +> +> 可使用[px2vp](ts-pixel-units.md)接口进行单位转换。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md index 086230f8b37b74650ed96120f8daf35916d14f7e..196529bc4e5b8507fdb5df7f8c926e770204dca4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md @@ -6,7 +6,7 @@ > > 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > -> 本组件均为系统接口,三方应用不支持调用。 +> 本组件为系统接口。 ## 使用约束 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 f22276a4149d4b76c62151cd5ca19dd0579ca9f3..e359c9adfa14fd1309eb46f4b7fa8a17f950490b 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 @@ -3,6 +3,7 @@ 可以附加在单个组件上用于信息标记的容器组件。 > **说明:** +> > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 @@ -61,90 +62,140 @@ @Entry @Component struct BadgeExample { - @State counts: number = 1 - @State message: string = 'new' - - build() { + @Builder TabBuilder(index: number) { 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) - - // 数字上标 + if (index === 2) { Badge({ - count: this.counts, - maxCount: 99, - position: BadgePosition.Left, - style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + value: '', + style: { badgeSize: 6, badgeColor: '#FA2A2D' } }) { - Button('message') - .onClick(() => { - this.counts++ - }) - .width(100).height(50).backgroundColor(0x317aff) - }.width(100).height(50) + Image('/common/public_icon_off.svg') + .width(24) + .height(24) + } + .width(24) + .height(24) + .margin({ bottom: 4 }) + } else { + Image('/common/public_icon_off.svg') + .width(24) + .height(24) + .margin({ bottom: 4 }) + } + Text('Tab') + .fontColor('#182431') + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').height('100%').justifyContent(FlexAlign.Center) + } + @Builder itemBuilder(value: string) { + Row() { + Image('common/public_icon.svg').width(32).height(32).opacity(0.6) + Text(value) + .width(177) + .height(21) + .margin({ left: 15, right: 76 }) + .textAlign(TextAlign.Start) + .fontColor('#182431') + .fontWeight(500) + .fontSize(16) + .opacity(0.9) + Image('common/public_icon_arrow_right.svg').width(12).height(24).opacity(0.6) + }.width('100%').padding({ left: 12, right: 12 }).height(56) + } - // 数字上标 - 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) - } + build() { + Column() { + Text('dotsBadge').fontSize(18).fontColor('#182431').fontWeight(500).margin(24) + Tabs() { + TabContent() + .tabBar(this.TabBuilder(0)) + TabContent() + .tabBar(this.TabBuilder(1)) + TabContent() + .tabBar(this.TabBuilder(2)) + TabContent() + .tabBar(this.TabBuilder(3)) + } + .width(360) + .height(56) + .backgroundColor('#F1F3F5') + + Column() { + Text('stringBadge').fontSize(18).fontColor('#182431').fontWeight(500).margin(24) + List({ space: 12 }) { + ListItem() { + Text('list1').fontSize(14).fontColor('#182431').margin({ left: 12 }) + } + .width('100%') + .height(56) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .align(Alignment.Start) + + ListItem() { + Badge({ + value: 'New', + position: BadgePosition.Right, + style: { badgeSize: 16, badgeColor: '#FA2A2D' } + }) { + Text('list2').width(27).height(19).fontSize(14).fontColor('#182431') + }.width(49.5).height(19) + .margin({ left: 12 }) + } + .width('100%') + .height(56) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .align(Alignment.Start) + }.width(336) + + Text('numberBadge').fontSize(18).fontColor('#182431').fontWeight(500).margin(24) + List() { + ListItem() { + this.itemBuilder('list1') + } + + ListItem() { + Row() { + Image('common/public_icon.svg').width(32).height(32).opacity(0.6) + Badge({ + count: 1, + position: BadgePosition.Right, + style: { badgeSize: 16, badgeColor: '#FA2A2D' } + }) { + Text('list2') + .width(177) + .height(21) + .textAlign(TextAlign.Start) + .fontColor('#182431') + .fontWeight(500) + .fontSize(16) + .opacity(0.9) + }.width(240).height(21).margin({ left: 15, right: 11 }) + + Image('common/public_icon_arrow_right.svg').width(12).height(24).opacity(0.6) + }.width('100%').padding({ left: 12, right: 12 }).height(56) + } + + ListItem() { + this.itemBuilder('list3') + } + + ListItem() { + this.itemBuilder('list4') + } + } + .width(336) + .height(232) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .padding({ top: 4, bottom: 4 }) + .divider({ strokeWidth: 0.5, color: 'rgba(0,0,0,0.1)', startMargin: 60, endMargin: 12 }) + }.width('100%').backgroundColor('#F1F3F5').padding({ bottom: 12 }) + }.width('100%') } } ``` 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 dd96432e8b7f5368ad47c9fc9b1823a362a2b75c..0ba38047bab43cbe3a266697f64ad1aa783d35cc 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 @@ -3,6 +3,7 @@ 将子组件纵向布局,并在每个子组件之间插入一根横向的分割线。 > **说明:** +> > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 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 0628db7cfcfb691e410c71a17e98d5bcb432e0ec..bd52cece165bb2ab581da8ae3260032baeb48232 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 @@ -3,6 +3,7 @@ 计数器组件,提供相应的增加或者减少的计数操作。 > **说明:** +> > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md index 09544a366d55618f9b6b11f1cf57148ec0983d5a..2dbd94b4cb78393b3a3d12faf28d34963fbad773 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md @@ -34,7 +34,7 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。
默认值:Axis.Vertical | | divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off | -| cachedCount | number | 设置预加载的ListItem数量。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | +| cachedCount | number | 设置列表中ListItem/ListItemGroup的预加载数量,其中ListItemGroup将作为一个整体进行计算,ListItemGroup中的所有ListItem会一次性全部加载出来。具体使用可参考[减少应用白块说明](../../ui/ui-ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | | editMode | boolean | 声明当前List组件是否处于可编辑模式。
默认值:false | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果。
默认值:EdgeEffect.Spring | | chainAnimation | boolean | 设置当前List是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。
默认值:false
- false:不启用链式联动。
- true:启用链式联动。 | @@ -70,8 +70,8 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | onScrollIndex(event: (start: number, end: number) => void) | 列表滑动时触发。
计算索引值时,ListItemGroup作为一个整体占一个索引值,不计算ListItemGroup内部ListItem的索引值。
- start: 滑动起始位置索引值。
- end: 滑动结束位置索引值。 | | onReachStart(event: () => void) | 列表到达起始位置时触发。 | | onReachEnd(event: () => void) | 列表到底末尾位置时触发。 | -| onScrollBegin9+(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }) | 列表开始滑动时触发。
\- dx:即将发生的水平方向滚动量。
\- dy:即将发生的竖直方向滚动量。
- dxRemain:水平方向滚动剩余量。
\- dyRemain:竖直方向滚动剩余量。 | -| onScrollStop(event: () => void) | 列表滑动停止时触发。 | +| onScrollBegin9+(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }) | 列表开始滑动时触发,事件参数传入即将发生的滑动量,事件处理函数中可根据应用场景计算实际需要的滑动量并作为事件处理函数的返回值返回,列表将按照返回值的实际滑动量进行滑动。
\- dx:即将发生的水平方向滑动量。
\- dy:即将发生的竖直方向滑动量。
- dxRemain:水平方向实际滑动量。
\- dyRemain:竖直方向实际滑动量。 | +| onScrollStop(event: () => void) | 列表滑动停止时触发。手拖动列表或列表的滚动条触发的滑动,手离开屏幕并且滑动停止时会触发该事件;使用[Scroller](ts-container-scroll.md#scroller)滑动控制器触发的滑动,不会触发该事件。 | | onItemMove(event: (from: number, to: number) => boolean) | 列表元素发生移动时触发。
- from: 移动前索引值。
- to: 移动后索引值。 | | onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => ((() => any) \| void) | 开始拖拽列表元素时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。
- itemIndex: 被拖拽列表元素索引值。 | | onItemDragEnter(event: (event: ItemDragInfo) => void) | 拖拽进入列表元素范围内时触发。
- event: 见[ItemDragInfo对象说明](ts-container-grid.md#itemdraginfo对象说明)。 | @@ -84,8 +84,8 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 描述 | | ------ | ------------------------- | | Idle | 未滑动状态。 | -| Scroll | 惯性滑动状态。 | -| Fling | 手指拖动状态。 | +| Scroll | 手指拖动状态。 | +| Fling | 惯性滑动状态。 | > **说明:** > diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md index 30f776153f65ebc24fae112be97eaffe0b276109..305be0e0a9378a6376c7f20da4f2b49f40e624e3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md @@ -4,7 +4,7 @@ > **说明:** > -> - 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 使用说明 当ListItemGroup的父组件List的listDirection属性为Axis.Vertical时,不允许设置ListItemGroup组件的height属性。ListItemGroup的高度为header高度、footer高度和所有ListItem布局后总高度之和。当父组件List的listDirection属性为Axis.Horizontal时,不允许设置ListItemGroup组件的width属性。ListItemGroup的宽度为header宽度、footer宽度和所有ListItem布局后总宽度之和。 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 4dabd93c50e006ac006d07fce5d6eae8cee7f8bc..385ed0175ca61adc84833dfaec314b4429d29fdc 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 @@ -3,6 +3,7 @@ 相对布局组件,用于复杂场景中元素对齐的布局。 > **说明:** +> > 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 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 ae460606c107c01221789228b458b7160e66d93a..7dd5e6a524d1c5bb4b224647e8d08be1a2481424 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 @@ -1,18 +1,15 @@ # RowSplit -> **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - 将子组件横向布局,并在每个子组件之间插入一根纵向的分割线。 - +> **说明:** +> +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 子组件 可以包含子组件 - ## 接口 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 4afb957f54b269836a33bbebba12473ce1811ba0..e45219eff3297eb33ebc4b1e0f0485338b7266e9 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 @@ -236,20 +236,21 @@ struct ScrollExample { 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() + private scrollerForScroll: Scroller = new Scroller() + private scrollerForList: Scroller = new Scroller() build() { Flex() { - Scroll(this.scroller) { + Scroll(this.scrollerForScroll) { Column() { Text("Scroll Area") .width("100%").height("40%").backgroundColor(0X330000FF) .fontSize(16).textAlign(TextAlign.Center) .onClick(() => { - this.scroller.scrollToIndex(5) + this.scrollerForList.scrollToIndex(5) }) - List({ space: 20, scroller: this.scroller }) { + List({ space: 20, scroller: this.scrollerForList }) { ForEach(this.arr, (item) => { ListItem() { Text("ListItem" + item) @@ -269,7 +270,7 @@ struct NestedScroll { }) .onScrollBegin((dx: number, dy: number) => { if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) { - this.scroller.scrollBy(0, -dy) + this.scrollerForScroll.scrollBy(0, -dy) return { dxRemain: dx, dyRemain: 0 } } this.listPosition = 1 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md index ac63672ce50807e39794c19b9aef87d9be25728c..1c61f55bd76dd289c0ee6cef06bde7ac990fd8e3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -33,84 +33,164 @@ TabContent() ## 示例 +示例1: + ```ts // xxx.ets @Entry @Component struct TabContentExample { - @State fontColor: string = 'rgba(0, 0, 0, 0.4)' - @State selectedFontColor: string = 'rgba(10, 30, 255, 1)' + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' @State currentIndex: number = 0 private controller: TabsController = new TabsController() @Builder TabBuilder(index: number) { Column() { - Image(this.currentIndex === index ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + Image(this.currentIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg') .width(24) .height(24) - .margin(6) - .opacity(this.currentIndex === index ? 1 : 0.4) + .margin({ bottom: 4 }) .objectFit(ImageFit.Contain) - Text(`Tab${(index > 2 ? (index - 1) : index) + 1}`) + Text(`Tab${index + 1}`) .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) .fontSize(10) + .fontWeight(500) + .lineHeight(14) }.width('100%') } - @Builder AddBuilder() { - Column() { - Image(this.currentIndex === 2 ? '/resources/ic_public_add_norm_filled_selected.png' : '/resources/ic_public_add_norm_filled.png') - .width(this.currentIndex === 2 ? 26 : 24) - .height(this.currentIndex === 2 ? 26 : 24) - .opacity(this.currentIndex === 2 ? 1 : 0.4) - .objectFit(ImageFit.Contain) - }.width('100%').height('100%').justifyContent(FlexAlign.Center) - } - build() { Column() { Tabs({ barPosition: BarPosition.End, controller: this.controller }) { TabContent() { Column() { - Text('Tab1').fontSize(32) + Text('Tab1') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }) + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) }.width('100%') }.tabBar(this.TabBuilder(0)) TabContent() { Column() { - Text('Tab2').fontSize(32) + Text('Tab2') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }) + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) }.width('100%') }.tabBar(this.TabBuilder(1)) TabContent() { Column() { - Text('Add').fontSize(32) + Text('Tab3') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }) + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) }.width('100%') - }.tabBar(this.AddBuilder()) + }.tabBar(this.TabBuilder(2)) TabContent() { Column() { - Text('Tab3').fontSize(32) + Text('Tab4') + .fontSize(36) + .fontColor('#182431') + .fontWeight(500) + .opacity(0.4) + .margin({ top: 30, bottom: 56.5 }) + Divider() + .strokeWidth(0.5) + .color('#182431') + .opacity(0.05) }.width('100%') }.tabBar(this.TabBuilder(3)) - - TabContent() { - Column() { - Text('Tab4').fontSize(32) - }.width('100%') - }.tabBar(this.TabBuilder(4)) } .vertical(false) - .barWidth(300) .barHeight(56) .onChange((index: number) => { this.currentIndex = index }) - .width('90%') - .backgroundColor('rgba(241, 243, 245, 0.95)') - }.width('100%').height(200).margin({ top: 15 }) + .width(360) + .height(190) + .backgroundColor('#F1F3F5') + .margin({ top: 38 }) + }.width('100%') + } +} +``` + +![tabContent](figures/tabContent1.gif) + +示例2: + +```ts +// xxx.ets +@Entry +@Component +struct TabContentExample { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 + private controller: TabsController = new TabsController() + + @Builder TabBuilder(index: number) { + Column() { + Image(this.currentIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg') + .width(24) + .height(24) + .margin({ bottom: 4 }) + .objectFit(ImageFit.Contain) + Text('Tab') + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .fontWeight(500) + .lineHeight(14) + }.width('100%').height('100%').justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { + TabContent() + .tabBar(this.TabBuilder(0)) + TabContent() + .tabBar(this.TabBuilder(1)) + TabContent() + .tabBar(this.TabBuilder(2)) + TabContent() + .tabBar(this.TabBuilder(3)) + } + .vertical(true) + .barWidth(96) + .barHeight(414) + .onChange((index: number) => { + this.currentIndex = index + }) + .width(96) + .height(414) + .backgroundColor('#F1F3F5') + .margin({ top: 52 }) + }.width('100%') } } ``` -![tabContent](figures/tabContent.gif) \ No newline at end of file +![tabContent](figures/tabContent2.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md index 05eef1bf720c7958a18597247743bb21ed1fc352..d0a1f7bb9f34a5750dd57c00a06c6c461c2b95e4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -91,41 +91,60 @@ changeIndex(value: number): void @Entry @Component struct TabsExample { + @State fontColor: string = '#182431' + @State selectedFontColor: string = '#007DFF' + @State currentIndex: number = 0 private controller: TabsController = new TabsController() + @Builder TabBuilder(index: number, name: string) { + Column() { + Text(name) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) + .fontSize(16) + .fontWeight(this.currentIndex === index ? 500 : 400) + .lineHeight(22) + .margin({ top: 17, bottom: 7 }) + Divider() + .strokeWidth(2) + .color('#007DFF') + .opacity(this.currentIndex === index ? 1 : 0) + }.width('100%') + } + build() { Column() { Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { TabContent() { - Column().width('100%').height('100%').backgroundColor(Color.Pink) - }.tabBar('pink') + Column().width('100%').height('100%').backgroundColor('#00CB87') + }.tabBar(this.TabBuilder(0, 'green')) TabContent() { - Column().width('100%').height('100%').backgroundColor(Color.Yellow) - }.tabBar('yellow') + Column().width('100%').height('100%').backgroundColor('#007DFF') + }.tabBar(this.TabBuilder(1, 'blue')) TabContent() { - Column().width('100%').height('100%').backgroundColor(Color.Blue) - }.tabBar('blue') + Column().width('100%').height('100%').backgroundColor('#FFBF00') + }.tabBar(this.TabBuilder(2, 'yellow')) TabContent() { - Column().width('100%').height('100%').backgroundColor(Color.Green) - }.tabBar('green') + Column().width('100%').height('100%').backgroundColor('#E67C92') + }.tabBar(this.TabBuilder(3, 'pink')) } - .vertical(true) - .scrollable(true) + .vertical(false) .barMode(BarMode.Fixed) - .barWidth(70) - .barHeight(150) + .barWidth(360) + .barHeight(56) .animationDuration(400) .onChange((index: number) => { - console.info(index.toString()) + this.currentIndex = index }) - .width('90%') - .backgroundColor(0xF5F5F5) - }.width('100%').height(150).margin({ top: 5 }) + .width(360) + .height(296) + .margin({ top: 52 }) + .backgroundColor('#F1F3F5') + }.width('100%') } } ``` -![zh-cn_image_0000001174264360](figures/zh-cn_image_0000001174264360.gif) +![tabs2](figures/tabs2.gif) \ No newline at end of file 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 e22cce09553a92a516fc3ffc7fd2c182000fbf1f..db6b7734889a55af7884e2be2de46c619861dbc3 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 @@ -36,8 +36,8 @@ Circle(options?: {width?: string | number, height?: string | number}) | 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
**说明:**
Circle组件无法设置锐角图形,该属性设置无效。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 设置边框透明度。
默认值:1 | +| strokeMiterLimit | number \| string | 设置斜接长度与边框宽度比值的极限值。
默认值:4
**说明:**
Circle组件无法设置尖角图形,该属性设置无效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 设置边框透明度。
默认值:1
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | 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 090fb561e60a7cdcf8dd5b79bdcbea8bb7c8a1d9..559a8791ece5b03ef04af063717555a58427429f 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 @@ -36,8 +36,8 @@ Ellipse(options?: {width?: string | number, height?: string | number}) | 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 | 设置边框透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。
**说明:**
Ellipse组件无法设置尖角图形,该属性设置无效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | 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 6487fe0fa436e686a9f093c158f49d46933e68a7..6c1be1faad4f8e10eab54066920563875b8cb531 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 @@ -1,18 +1,11 @@ # Line +直线绘制组件。 + > **说明:** > > 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - -直线绘制组件。 - - -## 权限列表 - -无 - - ## 子组件 无 @@ -46,7 +39,7 @@ Line(value?: {width?: string | number, height?: string | number}) | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。
**说明:**
Line组件无法设置锐角图形,该属性设置无效。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | strokeWidth | Length | 1 | 设置线条宽度。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。 | 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 097259b858a7a7c3be9fab7c87c6450cd128e63f..b55a9ffd0de75708aedc6af8994dceb6ff85430d 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 @@ -37,8 +37,8 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str | 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 | 设置线条透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | strokeWidth | Length | 1 | 设置线条宽度。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。 | 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 d573d7a8b0a22e6dffdc0c6b785455ca6f3ebf00..5ec83e3c362a6b4b9038e353633f9018c256af46 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 @@ -38,8 +38,8 @@ Polygon(value?: {width?: string | number, height?: string | number}) | 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 | 设置边框透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | strokeWidth | Length | 1 | 设置边框宽度。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。 | 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 a592609717b8bbd07c2eff7524b369a308dc0a0d..5074c350a2e3d096bd9ae32688b6ed9c24ffe4aa 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 @@ -38,8 +38,8 @@ Polyline(value?: {width?: string | number, height?: string | number}) | 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 | 设置线条透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | strokeWidth | Length | 1 | 设置线条宽度。 | | antiAlias | boolean | true | 是否开启抗锯齿效果。 | 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 7ef5471abf93317154a1b385e5ce36b83744a1d9..d455b7d6be8fb885fb29d23d369a25274cd44481 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 @@ -44,8 +44,8 @@ Rect(value?: {width?: string | number,height?: string | number,radius?: string | | 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 | 设置边框透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | 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 b3f695718de89fe04b96d7074ed21839b0eccd44..15d655ff27b9b2e468f2509b93b058f3279ad64c 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 @@ -42,8 +42,8 @@ Shape(value?: PixelMap) | 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 | 设置边框透明度。 | +| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。
**说明:**
该属性取值需大于等于1,且在strokeLineJoin属性取值LineJoinStyle.Miter时生效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。
**说明:**
该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | | 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-explicit-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md index eef21726017bab7f983eaa66d92615778127de09..17328cec7f6387f6526810d6ffb50fe33ee49553 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -69,7 +69,7 @@ struct AnimateToExample { }) Button('change rotate angle') .margin(50) - .rotate({ angle: this.rotateAngle }) + .rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }) .onClick(() => { animateTo({ duration: 1200, diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md index 25616026704a2146cdc171cd6ceb250a3aee3e79..2ab47f602bcda04b3f577036774cfa86fb7ebaf1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md @@ -3,15 +3,12 @@ 在页面范围内关闭通过[bindContextMenu](./ts-universal-attributes-menu.md#属性)属性绑定的菜单。 > **说明:** +> > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 - -无 - - ## ContextMenu.close + |方法|描述| |----|---| | close(): void | 可以通过该方法在页面范围内关闭通过[bindContextMenu](./ts-universal-attributes-menu.md#属性)给组件绑定的菜单。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index a6e2d28cb802e7bfe22f90fb8fc3bcaa368f0007..98b0c8b8401cce5c27349dd8baedc249f007cc70 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -181,7 +181,7 @@ struct LineCapExample { } ``` -![zh-cn_image_0000001194192454](figures/zh-cn_image_0000001194192454.png) +![zh-cn_image_0000001194192454](figures/zh-cn_image_0000001194192454.PNG) ### lineJoin diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md b/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md index 5df2adf1743dc74464863df7ecc0f3c5aa29c747..e745d745027f7d12a9276a49376e273eaf05e963 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md @@ -3,11 +3,11 @@ 为开发者提供4种像素单位,框架采用vp为基准数据单位。 -| 名称 | 描述 | -| ---- | ------------------------------------------------------------ | -| px | 屏幕物理像素单位。 | +| 名称 | 描述 | +| ---- | ---------------------------------------- | +| px | 屏幕物理像素单位。 | | vp | 屏幕密度相关像素,根据屏幕像素密度转换为屏幕物理像素,当数值不带单位时,默认单位vp。 | -| fp | 字体像素,与vp类似适用屏幕密度变化,随系统字体大小设置变化。 | +| fp | 字体像素,与vp类似适用屏幕密度变化,随系统字体大小设置变化。 | | lpx | 视窗逻辑像素单位,lpx单位为实际屏幕宽度与逻辑宽度(通过[designWidth](../../quick-start/package-structure.md)配置)的比值,designWidth默认值为720。当designWidth为720时,在实际宽度为1440物理像素的屏幕上,1lpx为2px大小。 | @@ -72,10 +72,3 @@ struct Example { ``` ![zh-cn_image_0000001169582302](figures/zh-cn_image_0000001169582302.png) - - -## 相关实例 - -基于像素转换,有以下相关实例可供参考: - -- [像素转换(ArkTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/PixelUnitsDemo) 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 index 25b640efc283b43e386883a4263e172f1ba98a6c..be16f57753ecab53f6f211b70b75dd9380d990e9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md @@ -701,7 +701,7 @@ EnvProp\(key: string, value: S): boolean | key | 类型 | 说明 | | ------------ | ------------- | ------------------- | -| accessibilityEnabled | boolean | 无障碍屏幕朗读是否启用。 | +| accessibilityEnabled | string | 无障碍屏幕朗读是否启用。 | | colorMode | ColorMode | 深浅色模式,可选值为:
- ColorMode.LIGHT:浅色模式;
- ColorMode.DARK:深色模式。 | | fontScale | number | 字体大小比例。 | | fontWeightScale | number | 字重比例。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-types.md b/zh-cn/application-dev/reference/arkui-ts/ts-types.md index a55b163537c12541dd54949a685f317c02ea83a8..34609e7f766baa8d8cb88f8e9b201261199135f0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-types.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-types.md @@ -156,7 +156,6 @@ | position | [Position](#position8) | 目标元素左上角相对父元素左上角的位置。 | | globalPosition | [Position](#position8) | 目标元素左上角相对页面左上角的位置。 | - ## Position8+ 位置类型,用于表示一个坐标点。 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 fbdaabe2a84141eb2de4b1f3a6f7387cea5dc96f..aeea88ebbd87f094527a258cf2c3a9ec7910fabb 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 @@ -3,6 +3,7 @@ 设置组件的模糊,阴影效果以及设置图片的图像效果。 > **说明:** +> > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 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 e46f3861c8fd4a4c294a5de7ee3ceb972d701df8..a4e65b50d26c7e4188f3ffc9409c6abf3a1265c5 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 @@ -17,7 +17,7 @@ | size | {
width?: [Length](ts-types.md#length),
height?: [Length](ts-types.md#length)
} | 设置高宽尺寸。 | | 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
} | +| 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大于maxWidth,则minWidth生效,minHeight与maxHeight同理。
默认值:
{
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
} | | layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
**说明:**
仅在Row/Column/Flex布局中生效。| diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index 505d064a9d292f502a440dbda39b4ff3c0da5382..fdd40a40fabab1ba523af3337ecd1593e3265788 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -47,15 +47,27 @@ ```ts // xxx.ets +@Extend(Text) function textStyle () { + .width('25%') + .height(35) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) +} + @Entry @Component struct DragExample { @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six'] @State text: string = '' - @State bool: boolean = false + @State bool: boolean = true + @State eventType: string = '' @State appleVisible: Visibility = Visibility.Visible @State orangeVisible: Visibility = Visibility.Visible @State bananaVisible: Visibility = Visibility.Visible + private dragList: string[] = ['apple', 'orange', 'banana'] + @State fruitVisible: Visibility[] = [Visibility.Visible, Visibility.Visible, Visibility.Visible] + @State index: number = 0 // 自定义拖拽过程中显示的内容 @Builder pixelMapBuilder() { @@ -79,46 +91,29 @@ struct DragExample { .textAlign(TextAlign.Start) .margin(5) Row({ space: 15 }) { - Text('apple') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.appleVisible) - .onDragStart(() => { - this.bool = true - this.text = 'apple' - this.appleVisible = Visibility.None - return this.pixelMapBuilder - }) - Text('orange') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.orangeVisible) - .onDragStart(() => { - this.bool = true - this.text = 'orange' - this.orangeVisible = Visibility.None - return this.pixelMapBuilder - }) - Text('banana') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.bananaVisible) - .onDragStart((event: DragEvent, extraParams: string) => { - console.log('Text onDragStart, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()) - this.bool = true - this.text = 'banana' - this.bananaVisible = Visibility.None - return this.pixelMapBuilder - }) + ForEach(this.dragList, (item, index) => { + Text(item) + .textStyle() + .visibility(this.fruitVisible[index]) + .onDragStart(() => { + this.bool = true + this.text = item + this.fruitVisible[index] = Visibility.None + return this.pixelMapBuilder + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down' + this.index = index + } + if (event.type === TouchType.Up) { + this.eventType = 'Up' + if (this.bool) { + this.fruitVisible[index] = Visibility.Visible + } + } + }) + }) }.padding({ top: 10, bottom: 10 }).margin(10) Text('This is a List element') @@ -156,12 +151,13 @@ struct DragExample { console.log('List onDragLeave, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()) }) .onDrop((event: DragEvent, extraParams: string) => { - var jsonString = JSON.parse(extraParams); + let jsonString = JSON.parse(extraParams); if (this.bool) { // 通过splice方法插入元素 this.numbers.splice(jsonString.insertIndex, 0, this.text) this.bool = false } + this.fruitVisible[this.index] = Visibility.None }) }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) } diff --git a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md index 2167160bcd9e984da617fa5a929a4700fb6e7eff..27c9f793bff0c3de4aac7b8dbfc98ad41e493a73 100644 --- a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md +++ b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md @@ -32,12 +32,15 @@ - 安全 - [AccessToken错误码](errorcode-access-token.md) - [HUKS错误码](errorcode-huks.md) + - [用户认证错误码](errorcode-useriam.md) - 数据管理 - [关系型数据库错误码](errorcode-data-rdb.md) - [数据共享错误码](errorcode-datashare.md) - [分布式数据对象错误码](errorcode-distributed-dataObject.md) - [分布式键值数据库错误码](errorcode-distributedKVStore.md) - [首选项错误码](errorcode-preferences.md) +- 文件管理 + - [文件管理子系统错误码](errorcode-filemanagement.md) - 网络管理 - [上传下载错误码](errorcode-request.md) - 通信与连接 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md b/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md index 7d64c906398d8f89e9abb047769fc8e52aae929c..c00ba1030f018be4cb1db455e9258860ef4ec80f 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md @@ -34,7 +34,7 @@ Parcel operation failed. **错误信息** -Inner transact failed. +IPC failed. **可能原因** @@ -63,7 +63,7 @@ System service operation failed. **错误信息** -Background task verification failed. +Continuous task verification failed. **可能原因** @@ -117,7 +117,7 @@ Task storage failed. **错误信息** -Caller information verification failed. +Caller information verification failed for a transient task. **可能原因** @@ -135,7 +135,7 @@ Caller information verification failed. **错误信息** -Background task verification failed. +Transient task verification failed. **可能原因** @@ -154,7 +154,7 @@ Background task verification failed. **错误信息** -Caller information verification failed. +Caller information verification failed when applying for efficiency resources. **可能原因** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-containers.md b/zh-cn/application-dev/reference/errorcodes/errorcode-containers.md index 1b938eb39dfea037ca25a03df56bd06485a49993..836759dc56e1c436f15ff1b2b945c864e4ac1e7e 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-containers.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-containers.md @@ -41,7 +41,7 @@ The {methodName} method cannot be bound. **错误信息** -The value of parameters are out of range. +The parameter value is out of range. **错误描述** @@ -59,7 +59,7 @@ The value of parameters are out of range. **错误信息** -Container is empty. +The container is empty. **错误描述** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md index e47bdda1481e9cae8480968f9379a0ebcc9e513f..381d687e85d54dec77c865096f180217a1f80419 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @@ -81,26 +81,7 @@ Not found. 2. 在数据库数据查询操作前,请检查查询关键字是否正确。 3. 在数据库数据删除操作前,请检查删除关键字是否正确或是否重复删除。 - -## 15100005 不支持当前操作 - -**错误信息** - -Not support the operation. - -**错误描述** - -该错误码表示在调用数据库backup、restore等接口时,当前数据库不支持该操作。 - -**可能原因** - -在调用数据库备份、恢复等接口时,当前数据库不支持该操作。 - -**处理步骤** - -检查当前数据库是否支持备份、恢复操作。 - -## 15100006 数据库或查询结果集已关闭 +## 15100005 数据库或查询结果集已关闭 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md b/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md new file mode 100644 index 0000000000000000000000000000000000000000..7aa2737352a8f203cf7c169df3aab22b7225a1a2 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md @@ -0,0 +1,716 @@ +# 文件管理子系统错误码 +文件管理子系统错误码由四部分组成,分别是基础文件IO错误码、用户数据管理错误码、公共文件访问错误码和空间统计错误码组成。 + +## 基础文件IO错误码 + +### 13900001 操作不允许 + +**错误信息** +Operation not permitted + +**可能原因** +当前用户文件操作不被允许 + +**处理步骤** +确认文件权限 + +### 13900002 没有这个文件或目录 + +**错误信息** +No such file or directory + +**可能原因** +文件或目录不存在 + +**处理步骤** +确认文件路径是否存在 + +### 13900003 没有这样的进程 + +**错误信息** +No such process + +**可能原因** +进程不存在 + +**处理步骤** +1.确认进程是否被意外杀死 +2.确认相关服务是否已启动 + +### 13900004 系统调用被中断 + +**错误信息** +Interrupted system call + +**可能原因** +系统调用被其他线程中断 + +**处理步骤** +1.检查多线程代码逻辑 +2.重新进行系统调用 + +### 13900005 I/0错误 + +**错误信息** +I/O error + +**可能原因** +I0请求非法 + +**处理步骤** +重新进行I0请求 + +### 13900006 没有这个设备或地址 + +**错误信息** +No such device or address + +**可能原因** +设备或地址信息错误 + +**处理步骤** +确认设备或地址信息 + +### 13900007 参数列表太长 + +**错误信息** +Arg list too long + +**可能原因** +参数列表过长 + +**处理步骤** +减少参数个数 + +### 13900008 坏的文件描述符 + +**错误信息** +Bad file descriptor + +**可能原因** +此文件描述符已关闭 + +**处理步骤** +确认此文件描述符是否已关闭 + +### 13900009 没有子进程 + +**错误信息** +No child processes + +**可能原因** +无法创建子进程 + +**处理步骤** +确认系统中最大进程数 + +### 13900010 资源暂时不可用 + +**错误信息** +Try again + +**可能原因** +资源被阻塞 + +**处理步骤** +重新请求资源 + +### 13900011 内存溢出 + +**错误信息** +Out of memory + +**可能原因** +内存溢出 + +**处理步骤** +1.确认内存开销 +2.管理系统内存开销 + +### 13900012 拒绝许可 + +**错误信息** +Permission denied + +**可能原因** +1.文件操作无权限 +2.文件沙箱路径地址错误 + +**处理步骤** +1.确认权限 +2.确认文件沙箱路径地址 + +### 13900013 错误的地址 + +**错误信息** +Bad address + +**可能原因** +地址错误 + +**处理步骤** +确认地址是否正确 + +### 13900014 设备或资源忙 + +**错误信息** +Device or resource busy + +**可能原因** +请求的资源不可用 + +**处理步骤** +重新请求资源 + +### 13900015 文件存在 + +**错误信息** +File exists + +**可能原因** +需创建的文件已存在 + +**处理步骤** +确认文件路径是否正确 + +### 13900016 无效的交叉链接 + +**错误信息** +Cross-device link + +**可能原因** +跨设备链接失败 + +**处理步骤** +确认跨设备是否正常 + +### 13900017 设备不存在 + +**错误信息** +No such device + +**可能原因** +设备未被识别 + +**处理步骤** +确认设备间连接是否正常 + +### 13900018 不是一个目录 + +**错误信息** +Not a directory + +**可能原因** +此路径不是文件夹目录 + +**处理步骤** +确认路径是否正确 + +### 13900019 是一个目录 + +**错误信息** +Is a directory + +**可能原因** +此路径是文件夹目录 + +**处理步骤** +确认路径是否正确 + +### 13900020 无效的参数 + +**错误信息** +Invalid argument + +**可能原因** +输入参数非法 + +**处理步骤** +确认参数合法性 + +### 13900021 打开太多的文件系统 + +**错误信息** +File table overflow + +**可能原因** +进程打开过多的文件描述符 + +**处理步骤** +关闭不相关的文件描述符 + +### 13900022 打开的文件过多 + +**错误信息** +Too many open files + +**可能原因** +系统打开过多的文件 + +**处理步骤** +关闭不需要的文件 + +### 13900023 文本文件忙 + +**错误信息** +Text file busy + +**可能原因** +程序的可执行文件正在被使用 + +**处理步骤** +关闭正在调试的程序 + +### 13900024 文件太大 + +**错误信息** +File too large + +**可能原因** +文件大小超出最大文件大小 + +**处理步骤** +确认文件大小是否满足最大文件大小 + +### 13900025 设备上没有空间 + +**错误信息** +No space left on device + +**可能原因** +设备存储空间不足 + +**处理步骤** +清理设备存储空间 + +### 13900026 非法移位 + +**错误信息** +Illegal seek + +**可能原因** +在管道或FIFO中使用seek + +**处理步骤** +确认seek使用 + +### 13900027 只读文件系统 + +**错误信息** +Read-only file system + +**可能原因** +文件系统只支持读 + +**处理步骤** +确认文件是否只读 + +### 13900028 太多的链接 + +**错误信息** +Too many links + +**可能原因** +文件已达最大链接数 + +**处理步骤** +清理无用链接 + +### 13900029 资源死锁错误 + +**错误信息** +Resource deadlock would occur + +**可能原因** +资源死锁 + +**处理步骤** +终止死锁进程 + +### 13900030 文件名太长 + +**错误信息** +Filename too Long + +**可能原因** +路径或文件名超过最大长度 + +**处理步骤** +确认路径或文件名长度 + +### 13900031 功能没有实现 + +**错误信息** +Function not implemented + +**可能原因** +系统不支持此功能 + +**处理步骤** +确认系统版本 + +### 13900032 目录非空 + +**错误信息** +Directory not empty + +**可能原因** +指定目录不为空 + +**处理步骤** +1.确认目录路径 +2.确认路径为空 + +### 13900033 符号链接层次太多 + +**错误信息** +Too many symbolic liks encountered + +**可能原因** +符号链接层次过多 + +**处理步骤** +清理无关符号链接 + +### 13900034 操作被阻塞 + +**错误信息** +Operation would block + +**可能原因** +操作被阻塞 + +**处理步骤** +重新进行操作 + +### 13900035 请求描述符无效 + +**错误信息** +Invalid request desecriptor + +**可能原因** +文件描述符非法 + +**处理步骤** +确认文件描述符是否合法 + +### 13900036 设备不是字符流 + +**错误信息** +Device not a stream + +**可能原因** +文件描述符指向非流设备 + +**处理步骤** +确认文件描述符是否指向流设备 + +### 13900037 无可用数据 + +**错误信息** +No data available + +**可能原因** +数据不可用 + +**处理步骤** +重新请求数据 + +### 13900038 对于定义的数据类型,值太大 + +**错误信息** +Value too large for defined data type + +**可能原因** +值超出所定义的数据类型范围 + +**处理步骤** +修改数据类型 + +### 13900039 文件描述符在坏状态 + +**错误信息** +File descriptor in bad state + +**可能原因** +文件描述符损坏 + +**处理步骤** +确认文件描述符合法性 + +### 13900040 应该重新启动被中断的系统调用 + +**错误信息** +Interrupted systen call should be restarted + +**可能原因** +系统调用被中断 + +**处理步骤** +重新进行系统调用 + +### 13900041 超出磁盘配额 + +**错误信息** +Quota exceeded + +**可能原因** +磁盘空间不足 + +**处理步骤** +清理磁盘存储空间 + +### 13900042 未知错误 + +**错误信息** +Unknown error + +**可能原因** +内部错误 + +**处理步骤** +1.重试接口 +2.重启服务 + +## 用户数据管理错误码 + +### 14000001 文件名非法 + +**错误信息** +Invalid display name + +**可能原因** +文件名存在非法字符 + +**处理步骤** +删除非法字符 + +### 14000002 非法URI + +**错误信息** +Invalid uri + +**可能原因** +URI不合法 + +**处理步骤** +直接使用查询获取的uri + +### 14000003 文件后缀非法 + +**错误信息** +Invalid file extension + +**可能原因** +按照文件类型命名 + +**处理步骤** +检查文件名后缀 + +### 14000004 文件已进入回收站 + +**错误信息** +File has been put into trash bin + +**可能原因** +文件已经被删除进入回收站 + +**处理步骤** +检查文件是否已经进入回收站 + +## 空间统计错误码 + +### 13600001 IPC通信失败 + +**错误信息** +IPC error + +**可能原因** +调用服务不存在 + +**处理步骤** +检查服务是否启动 + +### 13600002 文件系统类型不支持 + +**错误信息** +Not supported filesystem + +**可能原因** +操作的文件系统类型不支持 + +**处理步骤** +修改为正确的文件系统类型 + +### 13600003 挂载失败 + +**错误信息** +Failed to mount + +**可能原因** +调用挂载命令失败 + +**处理步骤** +拔卡尝试重新挂载 + +### 13600004 卸载失败 + +**错误信息** +Failed to unmount + +**可能原因** +设备繁忙 + +**处理步骤** +检查外卡文件是否被线程占用, 杀掉占用线程 + +### 13600005 卷状态错误 + +**错误信息** +Incorrect volume state + +**可能原因** +操作的卷状态错误 + +**处理步骤** +检查当前卷状态是否正确 + +### 13600006 创建目录或者节点失败 + +**错误信息** +Prepare directory or node error + +**可能原因** +目录或节点已存在 + +**处理步骤** +检查待创建目录或节点是否存在 + +### 13600007 删除目录或者节点失败 + +**错误信息** +Delete directory or node error + +**可能原因** +目录或节点已删除 + +**处理步骤** +检查待删除目录或节点是否存在 + +### 13600008 操作对象不存在 + +**错误信息** +No such object + +**可能原因** +1.输入错误的卷id +2.输入错误的包名 + +**处理步骤** +1.检查输入的卷是否存在 +2.检查输入的应用包名是否存在 + +### 13600009 用户id超出范围 + +**错误信息** +User id out of range + +**可能原因** +输入错误的用户id + +**处理步骤** +检查输入的用户id是否处于正常范围 + +## 公共文件访问错误码 + +### 14300001 IPC通信失败 + +**错误信息** +IPC error + +**可能原因** +1.server端服务不在 +2.extension机制异常 + +**处理步骤** +检查server端服务是否存在 + +### 14300002 URI格式错误 + +**错误信息** +Invalid uri + +**可能原因** +使用非法uri + +**处理步骤** +检查URI格式 + +### 14300003 查询server端ability信息失败 + +**错误信息** +Fail to get fileextension info + +**可能原因** +BMS接口异常 + +**处理步骤** +系统基础能力问题 + +### 14300004 js-server实际返回的结果异常 + +**错误信息** +Get wrong result + +**可能原因** +server端返回实际数据不当 + +**处理步骤** +server端返回值检查 + +### 14300005 notify注册失败 + +**错误信息** +Fail to register notification + +**可能原因** +1.server端服务不在 +2.extension机制异常 + +**处理步骤** +检查server端服务是否存在 + +### 14300006 notify移除失败 + +**错误信息** +Fail to remove notification + +**可能原因** +1.server端服务不在 +2.extension机制异常 + +**处理步骤** +检查server端服务是否存在 + +### 14300007 notify代理初始化失败 + +**错误信息** +Fail to init notification agent + +**可能原因** +未注册就去取消notify + +**处理步骤** +是否注册过 + +### 14300008 js-server端通知代理失败 + +**错误信息** +Fail to notify agent + +**可能原因** +1.服务不在 +2.extension机制异常 + +**处理步骤** +检查client是否异常 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-media.md b/zh-cn/application-dev/reference/errorcodes/errorcode-media.md new file mode 100644 index 0000000000000000000000000000000000000000..92e19c242cc544f4f63a0187c0643eb2accb4528 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-media.md @@ -0,0 +1,115 @@ +# Media错误码 + +## 5400101 内存分配失败 + +**错误信息** + +No memory. + +**错误描述** + +分配内存失败。 + +**可能原因** + +1. 实例数量超过16个。 +2. new或者malloc流程失败导致空指针。 + +**处理步骤** + +销毁当前实例,并重新创建,如果重新创建失败,则停止相关操作。 + +## 5400102 当前状态机不支持此操作 + +**错误信息** + +Operate not permit. + +**错误描述** + +当前操作不允许。 + +**可能原因** + +当前状态机不支持此操作。 + +**处理步骤** + +确认当前状态是否支持当前操作,把实例切换到正确的状态进行正确的操作。 + +## 5400103 出现IO错误 + +**错误信息** + +IO error. + +**错误描述** + +出现IO错误。 + +**可能原因** + +媒体与其他模块的数据交互发生问题(图形、音频、网络、HDI、相机)。 + +**处理步骤** + +确认网络是否通畅,并销毁当前实例,并重新创建,如果重新创建失败,则停止相关操作。 + +## 5400104 操作超时 + +**错误信息** + +Time out. + +**错误描述** + +操作超时。 + +**可能原因** + +1. 网络超时。 +2. 访问其他模块超时。 + +**处理步骤** + +1. 确认网络是否通畅。 +2. 销毁当前实例,并重新创建,如果重新创建失败,则停止相关操作。 + +## 5400105 播放服务死亡 + +**错误信息** + +Service died. + +**错误描述** + +播放服务死亡。 + +**可能原因** + +播放服务死亡。 + +**处理步骤** + +销毁当前实例,并重新创建,如果重新创建失败,则停止相关操作。 + +## 5400106 不支持的规格 + +**错误信息** + +Unsupport format. + +**错误描述** + +不支持的规格。 + +**可能原因** + +不支持的文件或者格式。 + +**处理步骤** + +当前使用的格式规格不支持,用户需要切换为支持的规格。 + + + diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md b/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md index 9ce15b0692b5bea93f3b82932dd3a5290a0ef8a9..a063b9df2ae5245aeb712e9a4b927d093c9d9f59 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md @@ -1,4 +1,4 @@ -# 通用误码 +# 通用错误码 ## 201 权限校验失败 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md new file mode 100644 index 0000000000000000000000000000000000000000..8c8159524635a0d0369b9b9e76cf99316af09ed3 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md @@ -0,0 +1,93 @@ +# 用户认证错误码 + +## 201 权限验证失败 + +具体参见[通用错误码](./errorcode-universal.md) + +## 202 调用方不是一个系统应用 + +具体参见[通用错误码](./errorcode-universal.md) + +## 401 参数不正确 + +具体参见[通用错误码](./errorcode-universal.md) + +## 12500002 一般的操作错误 + +**错误信息** + +General operation error. + +**可能原因** + +1. NAPI层解析参数出错。 +2. 用户认证服务的进程没有启动。 +3. IPC通信的proxy客户端写数据出错。 +4. IPC通信的stub服务端解析数据出错。 +5. 获取driver服务出错。 + +**处理步骤** + +重启设备,重新调用接口。 + +## 12500005 认证类型不支持 + +**错误信息** + +The authentication type is not supported. + +**可能原因** + +1. 传入的认证类型参数不支持,例如调用userAuth模块的getAvailableStatus接口时传入的参数不是FACE或FINGERPRINT类型,则会返回12500005错误码。 +2. 传入的认证类型参数在本设备上不支持,例如在没有部署指纹传感器的设备上发起指纹认证,则会返回12500005错误码。 + +**处理步骤** + +请检查传入的认证类型参数,重新调用接口。 + +## 12500006 认证信任等级不支持 + +**错误信息** + +The authentication trust level is not supported. + +**可能原因** + +1. 调用userAuth模块的getAvailableStatus或getAuthInstance接口时,传入的authTrustLevel参数不在[ATL1, ATL2, ATL3, ATL4]范围内。 +2. 当前的设备不支持该认证信任等级,例如在只部署了2D摄像头的设备上发起支付级别的人脸认证,则会返回12500006错误码。 + +**处理步骤** + +检查传入的authTrustLevel是否在合理范围,如果在合理范围,则是当前的设备不支持该认证信任等级。 + +## 12500010 该类型的凭据没有录入 + +**错误信息** + +The type of credential has not been enrolled. + +**可能原因** + +例如调用userAuth模块的getAvailableStatus接口,传入的authType参数为FACE,但是当前的设备没有录入人脸凭据,则会返回12500010错误码。 +调用start接口发起人脸认证,但是目前的设备没有录入人脸凭据,则会返回12500010错误码。 + +**处理步骤** + +检查是否录入该类型的凭据,如果没有录入,则需要成功录入该类型凭据后再调用相关接口。 + +## 12700001 人脸录入过程中的操作失败 + +**错误信息** + +The operation is failed. + +**可能原因** + +1. 例如调用faceAuth模块的setSurfaceId接口时,人脸认证服务未启动,则会返回12700001错误码。 +2. IPC通信的proxy客户端写数据出错。 +3. IPC通信的stub服务端解析数据出错。 +4. 人脸driver层调用出错。 + +**处理步骤** + +主要检查人脸认证服务的进程是否启动。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md b/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md index 7620f035a5d9888d59c462be650340ef37ad5bba..4177243c2312a4bcef18cd5f74526085e7283d43 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md @@ -49,7 +49,7 @@ System service operation failed. **错误信息** -Check workInfo failed. +Checking workInfo failed. **可能原因** diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md b/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md index 6810c9398d6dd287ef1351e934b41a7198acb492..1d010b8668696de709dea708bf03adc870c5b1f6 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/Readme-CN.md @@ -1,40 +1,40 @@ # JS服务卡片UI组件 - JS服务卡片UI框架说明 - - [文件组织](js-service-widget-file.md) - - 语法 - - [HML语法参考](js-service-widget-syntax-hml.md) - - [CSS语法参考](js-service-widget-syntax-css.md) - - [多语言支持](js-service-widget-multiple-languages.md) - - [版本兼容适配](js-service-widget-version-compatibility.md) - - [设置主题样式](js-service-widget-theme.md) + - [文件组织](js-service-widget-file.md) + - 语法 + - [HML语法参考](js-service-widget-syntax-hml.md) + - [CSS语法参考](js-service-widget-syntax-css.md) + - [多语言支持](js-service-widget-multiple-languages.md) + - [版本兼容适配](js-service-widget-version-compatibility.md) + - [设置主题样式](js-service-widget-theme.md) - 组件 - - 通用 - - [通用属性](js-service-widget-common-attributes.md) - - [通用样式](js-service-widget-common-styles.md) - - [通用事件](js-service-widget-common-events.md) - - [渐变样式](js-service-widget-common-gradient.md) - - [媒体查询](js-service-widget-common-mediaquery.md) - - [自定义字体样式](js-service-widget-common-customizing-font.md) - - [无障碍](js-service-widget-common-accessibility.md) - - [原子布局](js-service-widget-common-atomic-layout.md) - - 容器组件 - - [badge](js-service-widget-container-badge.md) - - [div](js-service-widget-container-div.md) - - [list](js-service-widget-container-list.md) - - [list-item](js-service-widget-container-list-item.md) - - [stack](js-service-widget-container-stack.md) - - [swiper](js-service-widget-container-swiper.md) - - 基础组件 - - [button](js-service-widget-basic-button.md) - - [calendar](js-service-widget-basic-calendar.md) - - [chart](js-service-widget-basic-chart.md) - - [clock](js-service-widget-basic-clock.md) - - [divider](js-service-widget-basic-divider.md) - - [image](js-service-widget-basic-image.md) - - [input](js-service-widget-basic-input.md) - - [progress](js-service-widget-basic-progress.md) - - [span](js-service-widget-basic-span.md) - - [text](js-service-widget-basic-text.md) + - 通用 + - [通用属性](js-service-widget-common-attributes.md) + - [通用样式](js-service-widget-common-styles.md) + - [通用事件](js-service-widget-common-events.md) + - [渐变样式](js-service-widget-common-gradient.md) + - [媒体查询](js-service-widget-common-mediaquery.md) + - [自定义字体样式](js-service-widget-common-customizing-font.md) + - [无障碍](js-service-widget-common-accessibility.md) + - [原子布局](js-service-widget-common-atomic-layout.md) + - 容器组件 + - [badge](js-service-widget-container-badge.md) + - [div](js-service-widget-container-div.md) + - [list](js-service-widget-container-list.md) + - [list-item](js-service-widget-container-list-item.md) + - [stack](js-service-widget-container-stack.md) + - [swiper](js-service-widget-container-swiper.md) + - 基础组件 + - [button](js-service-widget-basic-button.md) + - [calendar](js-service-widget-basic-calendar.md) + - [chart](js-service-widget-basic-chart.md) + - [clock](js-service-widget-basic-clock.md) + - [divider](js-service-widget-basic-divider.md) + - [image](js-service-widget-basic-image.md) + - [input](js-service-widget-basic-input.md) + - [progress](js-service-widget-basic-progress.md) + - [span](js-service-widget-basic-span.md) + - [text](js-service-widget-basic-text.md) - [自定义组件使用说明](js-service-widget-custom-basic-usage.md) - [数据类型说明](js-service-widget-appendix-types.md) diff --git a/zh-cn/application-dev/reference/native-apis/Readme-CN.md b/zh-cn/application-dev/reference/native-apis/Readme-CN.md index d6ce06376bc515eacba70c8d9d336e792ff4f704..54138c3cb2fb3c394ba3693d4498a98e4e15876d 100644 --- a/zh-cn/application-dev/reference/native-apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/native-apis/Readme-CN.md @@ -11,6 +11,7 @@ - [Image](image.md) - [Rawfile](rawfile.md) - [MindSpore](_mind_spore.md) + - [NeuralNeworkRuntime](_neural_nework_runtime.md) - 头文件 - [drawing_bitmap.h](drawing__bitmap_8h.md) - [drawing_brush.h](drawing__brush_8h.md) @@ -39,6 +40,8 @@ - [status.h](status_8h.md) - [tensor.h](tensor_8h.md) - [types.h](types_8h.md) + - [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) + - [neural_network_runtime.h](neural__network__runtime_8h.md) - 结构体 - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) - [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) @@ -56,3 +59,7 @@ - [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) - [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) - [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) + - [OH_NN_Memory](_o_h___n_n___memory.md) + - [OH_NN_QuantParam](_o_h___n_n___quant_param.md) + - [OH_NN_Tensor](_o_h___n_n___tensor.md) + - [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md b/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md new file mode 100644 index 0000000000000000000000000000000000000000..e265384899356daddc00292c13c345bd28152d49 --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/_neural_nework_runtime.md @@ -0,0 +1,1377 @@ +# NeuralNeworkRuntime + + +提供Neural Network Runtime加速模型推理的相关接口。 + + +@Syscap SystemCapability.Ai.NeuralNetworkRuntime + + +**起始版本:** + + +9 + + +## 汇总 + + +### 文件 + +| 文件名称 | 描述 | +| -------- | -------- | +| [neural_network_runtime.h](neural__network__runtime_8h.md) | Neural Network Runtime部件接口定义,AI推理框架通过Neural Network Runtime提供的Native接口,完成模型构造与编译,并在加速硬件上执行推理计算。 | +| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Neural Network Runtime定义的结构体和枚举值。 | + + +### 结构体 + +| 结构体名称 | 描述 | +| -------- | -------- | +| [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) | 自定义的32位无符号整型数组。 | +| [OH_NN_QuantParam](_o_h___n_n___quant_param.md) | 量化信息。 | +| [OH_NN_Tensor](_o_h___n_n___tensor.md) | 张量结构体。 | +| [OH_NN_Memory](_o_h___n_n___memory.md) | 内存结构体。 | + + +### 类型定义 + +| 类型定义名称 | 描述 | +| -------- | -------- | +| [OH_NNModel](#oh_nnmodel) | Neural Network Runtime的模型句柄。 | +| [OH_NNCompilation](#oh_nncompilation) | Neural Network Runtime的编译器句柄。 | +| [OH_NNExecutor](#oh_nnexecutor) | Neural Network Runtime的执行器句柄。 | +| [OH_NN_UInt32Array](#oh_nn_uint32array) | 自定义的32位无符号整型数组类型。 | +| [OH_NN_QuantParam](#oh_nn_quantparam) | 量化信息。 | +| [OH_NN_Tensor](#oh_nn_tensor) | 张量结构体。 | +| [OH_NN_Memory](#oh_nn_memory) | 内存结构体。 | + + +### 枚举 + +| 枚举名称 | 描述 | +| -------- | -------- | +| [OH_NN_PerformanceMode](#oh_nn_performancemode) { OH_NN_PERFORMANCE_NONE = 0, OH_NN_PERFORMANCE_LOW = 1, OH_NN_PERFORMANCE_MEDIUM = 2, OH_NN_PERFORMANCE_HIGH = 3, OH_NN_PERFORMANCE_EXTREME = 4 } | 硬件的性能模式。 | +| [OH_NN_Priority](#oh_nn_priority) { OH_NN_PRIORITY_NONE = 0, OH_NN_PRIORITY_LOW = 1, OH_NN_PRIORITY_MEDIUM = 2, OH_NN_PRIORITY_HIGH = 3 } | 模型推理任务优先级。 | +| [OH_NN_ReturnCode](#oh_nn_returncode) { OH_NN_SUCCESS = 0, OH_NN_FAILED = 1, OH_NN_INVALID_PARAMETER = 2, OH_NN_MEMORY_ERROR = 3, OH_NN_OPERATION_FORBIDDEN = 4, OH_NN_NULL_PTR = 5, OH_NN_INVALID_FILE = 6, OH_NN_UNAVALIDABLE_DEVICE = 7, OH_NN_INVALID_PATH = 8 } | Neural Network Runtime 定义的错误码类型。 | +| [OH_NN_FuseType](#oh_nn_fusetype) : int8_t { OH_NN_FUSED_NONE = 0, OH_NN_FUSED_RELU = 1, OH_NN_FUSED_RELU6 = 2 } | Neural Network Runtime 融合算子中激活函数的类型。 | +| [OH_NN_Format](#oh_nn_format) { OH_NN_FORMAT_NONE = 0, OH_NN_FORMAT_NCHW = 1, OH_NN_FORMAT_NHWC = 2 } | 张量数据的排布类型。 | +| [OH_NN_DeviceType](#oh_nn_devicetype) { OH_NN_OTHERS = 0, OH_NN_CPU = 1, OH_NN_GPU = 2, OH_NN_ACCELERATOR = 3 } | Neural Network Runtime 支持的设备类型。 | +| [OH_NN_DataType](#oh_nn_datatype) { OH_NN_UNKNOWN = 0, OH_NN_BOOL = 1, OH_NN_INT8 = 2, OH_NN_INT16 = 3, OH_NN_INT32 = 4, OH_NN_INT64 = 5, OH_NN_UINT8 = 6, OH_NN_UINT16 = 7, OH_NN_UINT32 = 8, OH_NN_UINT64 = 9, OH_NN_FLOAT16 = 10, OH_NN_FLOAT32 = 11, OH_NN_FLOAT64 = 12 } | Neural Network Runtime 支持的数据类型。 | +| [OH_NN_OperationType](#oh_nn_operationtype) { OH_NN_OPS_ADD = 1, OH_NN_OPS_AVG_POOL = 2, OH_NN_OPS_BATCH_NORM = 3, OH_NN_OPS_BATCH_TO_SPACE_ND = 4, OH_NN_OPS_BIAS_ADD = 5, OH_NN_OPS_CAST = 6, OH_NN_OPS_CONCAT = 7, OH_NN_OPS_CONV2D = 8, OH_NN_OPS_CONV2D_TRANSPOSE = 9, OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, OH_NN_OPS_DIV = 11, OH_NN_OPS_ELTWISE = 12, OH_NN_OPS_EXPAND_DIMS = 13, OH_NN_OPS_FILL = 14, OH_NN_OPS_FULL_CONNECTION = 15, OH_NN_OPS_GATHER = 16, OH_NN_OPS_HSWISH = 17, OH_NN_OPS_LESS_EQUAL = 18, OH_NN_OPS_MATMUL = 19, OH_NN_OPS_MAXIMUM = 20, OH_NN_OPS_MAX_POOL = 21, OH_NN_OPS_MUL = 22, OH_NN_OPS_ONE_HOT = 23, OH_NN_OPS_PAD = 24, OH_NN_OPS_POW = 25, OH_NN_OPS_SCALE = 26, OH_NN_OPS_SHAPE = 27, OH_NN_OPS_SIGMOID = 28, OH_NN_OPS_SLICE = 29, OH_NN_OPS_SOFTMAX = 30, OH_NN_OPS_SPACE_TO_BATCH_ND = 31, OH_NN_OPS_SPLIT = 32, OH_NN_OPS_SQRT = 33, OH_NN_OPS_SQUARED_DIFFERENCE = 34, OH_NN_OPS_SQUEEZE = 35, OH_NN_OPS_STACK = 36, OH_NN_OPS_STRIDED_SLICE = 37, OH_NN_OPS_SUB = 38, OH_NN_OPS_TANH = 39, OH_NN_OPS_TILE = 40, OH_NN_OPS_TRANSPOSE = 41, OH_NN_OPS_REDUCE_MEAN = 42, OH_NN_OPS_RESIZE_BILINEAR = 43, OH_NN_OPS_RSQRT = 44, OH_NN_OPS_RESHAPE = 45, OH_NN_OPS_PRELU = 46, OH_NN_OPS_RELU = 47, OH_NN_OPS_RELU6 = 48, OH_NN_OPS_LAYER_NORM = 49, OH_NN_OPS_REDUCE_PROD = 50, OH_NN_OPS_REDUCE_ALL = 51, OH_NN_OPS_QUANT_DTYPE_CAST = 52, OH_NN_OPS_TOP_K = 53, OH_NN_OPS_ARG_MAX = 54, OH_NN_OPS_UNSQUEEZE = 55, OH_NN_OPS_GELU = 56 } | Neural Network Runtime 支持算子的类型。 | +| [OH_NN_TensorType](#oh_nn_tensortype) { OH_NN_TENSOR = 0, OH_NN_ADD_ACTIVATIONTYPE = 1, OH_NN_AVG_POOL_KERNEL_SIZE = 2, OH_NN_AVG_POOL_STRIDE = 3, OH_NN_AVG_POOL_PAD_MODE = 4, OH_NN_AVG_POOL_PAD = 5, OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, OH_NN_BATCH_NORM_EPSILON = 7, OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, OH_NN_CONCAT_AXIS = 10, OH_NN_CONV2D_STRIDES = 11, OH_NN_CONV2D_PAD = 12,OH_NN_CONV2D_DILATION = 13, OH_NN_CONV2D_PAD_MODE = 14, OH_NN_CONV2D_ACTIVATION_TYPE = 15, OH_NN_CONV2D_GROUP = 16, OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, OH_NN_CONV2D_TRANSPOSE_PAD = 18, OH_NN_CONV2D_TRANSPOSE_DILATION = 19, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, OH_NN_CONV2D_TRANSPOSE_GROUP = 23, OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27, OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, OH_NN_DIV_ACTIVATIONTYPE = 29, OH_NN_ELTWISE_MODE = 30, OH_NN_FULL_CONNECTION_AXIS = 31, OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, OH_NN_MATMUL_TRANSPOSE_A = 33, OH_NN_MATMUL_TRANSPOSE_B = 34, OH_NN_MATMUL_ACTIVATION_TYPE = 35, OH_NN_MAX_POOL_KERNEL_SIZE = 36, OH_NN_MAX_POOL_STRIDE = 37, OH_NN_MAX_POOL_PAD_MODE = 38, OH_NN_MAX_POOL_PAD = 39, OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, OH_NN_MUL_ACTIVATION_TYPE = 41, OH_NN_ONE_HOT_AXIS = 42, OH_NN_PAD_CONSTANT_VALUE = 43, OH_NN_SCALE_ACTIVATIONTYPE = 44, OH_NN_SCALE_AXIS = 45, OH_NN_SOFTMAX_AXIS = 46, OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47, OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, OH_NN_SPLIT_AXIS = 49, OH_NN_SPLIT_OUTPUT_NUM = 50, OH_NN_SPLIT_SIZE_SPLITS = 51, OH_NN_SQUEEZE_AXIS = 52, OH_NN_STACK_AXIS = 53, OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, OH_NN_STRIDED_SLICE_END_MASK = 55, OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, OH_NN_SUB_ACTIVATIONTYPE = 59, OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63, OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, OH_NN_LAYER_NORM_EPSILON = 67, OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, OH_NN_REDUCE_PROD_KEEP_DIMS = 70, OH_NN_REDUCE_ALL_KEEP_DIMS = 71, OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, OH_NN_QUANT_DTYPE_CAST_DST_T = 73, OH_NN_TOP_K_SORTED = 74, OH_NN_ARG_MAX_AXIS = 75, OH_NN_ARG_MAX_KEEPDIMS = 76, OH_NN_UNSQUEEZE_AXIS = 77 } | 张量的类型。 | + + +### 函数 + +| 函数 名称 | 描述 | +| -------- | -------- | +| [OH_NNModel_Construct](#oh_nnmodel_construct) (void) | 创建[OH_NNModel](#oh_nnmodel)类型的模型实例,搭配OH_NNModel模块提供的其他接口,完成模型实例的构造。 | +| [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) (OH_NNModel \*model, const OH_NN_Tensor \*tensor) | 向模型实例中添加张量。 | +| [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata) (OH_NNModel \*model, uint32_t index, const void \*dataBuffer, size_t length) | 设置张量的数值。 | +| [OH_NNModel_AddOperation](#oh_nnmodel_addoperation) (OH_NNModel \*model, OH_NN_OperationType op, const OH_NN_UInt32Array \*paramIndices, const OH_NN_UInt32Array \*inputIndices, const OH_NN_UInt32Array \*outputIndices) | 向模型实例中添加算子。 | +| [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) (OH_NNModel \*model, const OH_NN_UInt32Array \*inputIndices, const OH_NN_UInt32Array \*outputIndices) | 指定模型的输入输出。 | +| [OH_NNModel_Finish](#oh_nnmodel_finish) (OH_NNModel \*model) | 完成模型构图。 | +| [OH_NNModel_Destroy](#oh_nnmodel_destroy) (OH_NNModel \*\*model) | 释放模型实例。 | +| [OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations) (OH_NNModel \*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | 查询硬件对模型内所有算子的支持情况,通过布尔值序列指示支持情况。 | +| [OH_NNCompilation_Construct](#oh_nncompilation_construct) (const OH_NNModel \*model) | 创建[OH_NNCompilation](#oh_nncompilation)类型的编译实例。 | +| [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice) (OH_NNCompilation \*compilation, size_t deviceID) | 指定模型编译和计算的硬件。 | +| [OH_NNCompilation_SetCache](#oh_nncompilation_setcache) (OH_NNCompilation \*compilation, const char \*cachePath, uint32_t version) | 设置编译后的模型缓存路径和缓存版本。 | +| [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode) (OH_NNCompilation \*compilation, OH_NN_PerformanceMode performanceMode) | 设置硬件的性能模式。 | +| [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority) (OH_NNCompilation \*compilation, OH_NN_Priority priority) | 设置模型计算的优先级。 | +| [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) (OH_NNCompilation \*compilation, bool enableFloat16) | 是否以float16的浮点数精度计算。 | +| [OH_NNCompilation_Build](#oh_nncompilation_build) (OH_NNCompilation \*compilation) | 进行模型编译。 | +| [OH_NNCompilation_Destroy](#oh_nncompilation_destroy) (OH_NNCompilation \*\*compilation) | 释放Compilation对象。 | +| [OH_NNExecutor_Construct](#oh_nnexecutor_construct) (OH_NNCompilation \*compilation) | 创建[OH_NNExecutor](#oh_nnexecutor)类型的执行器实例。 | +| [OH_NNExecutor_SetInput](#oh_nnexecutor_setinput) (OH_NNExecutor \*executor, uint32_t inputIndex, const OH_NN_Tensor \*tensor, const void \*dataBuffer, size_t length) | 设置模型单个输入的数据。 | +| [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput) (OH_NNExecutor \*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | 设置模型单个输出的缓冲区。 | +| [OH_NNExecutor_GetOutputShape](#oh_nnexecutor_getoutputshape) (OH_NNExecutor \*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | 获取输出张量的维度信息。 | +| [OH_NNExecutor_Run](#oh_nnexecutor_run) (OH_NNExecutor \*executor) | 执行推理。 | +| [OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, size_t length) | 在硬件上为单个输入申请共享内存。 | +| [OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, size_t length) | 在硬件上为单个输出申请共享内存。 | +| [OH_NNExecutor_DestroyInputMemory](#oh_nnexecutor_destroyinputmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, OH_NN_Memory \*\*memory) | 释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输入内存。 | +| [OH_NNExecutor_DestroyOutputMemory](#oh_nnexecutor_destroyoutputmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, OH_NN_Memory \*\*memory) | 释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输出内存。 | +| [OH_NNExecutor_SetInputWithMemory](#oh_nnexecutor_setinputwithmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, const OH_NN_Tensor \*tensor, const OH_NN_Memory \*memory) | 将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输入使用的共享内存。 | +| [OH_NNExecutor_SetOutputWithMemory](#oh_nnexecutor_setoutputwithmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, const OH_NN_Memory \*memory) | 将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输出使用的共享内存。 | +| [OH_NNExecutor_Destroy](#oh_nnexecutor_destroy) (OH_NNExecutor \*\*executor) | 销毁执行器实例,释放执行器占用的内存。 | +| [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid) (const size_t \*\*allDevicesID, uint32_t \*deviceCount) | 获取对接到 Neural Network Runtime 的硬件ID。 | +| [OH_NNDevice_GetName](#oh_nndevice_getname) (size_t deviceID, const char \*\*name) | 获取指定硬件的类型信息。 | +| [OH_NNDevice_GetType](#oh_nndevice_gettype) (size_t deviceID, OH_NN_DeviceType \*deviceType) | 获取指定硬件的类别信息。 | + + +## **类型定义说明** + + +### OH_NN_Memory + + +``` +typedef struct OH_NN_Memory OH_NN_Memory +``` + +**描述:** + +内存结构体。 + + +### OH_NN_QuantParam + + +``` +typedef struct OH_NN_QuantParam OH_NN_QuantParam +``` + +**描述:** + +量化信息。 + +在量化的场景中,32位浮点型数据根据以下公式量化为定点数据: + +![zh-cn_formulaimage_0000001460519245](figures/zh-cn_formulaimage_0000001460519245.png) + +其中s和z是量化参数,在OH_NN_QuanParam中通过scale和zeroPoint保存,r是浮点数,q是量化后的结果,q_min是量化后下界,q_max是量化后的上界,计算方式如下: + +![zh-cn_formulaimage_0000001460759081](figures/zh-cn_formulaimage_0000001460759081.png) + +![zh-cn_formulaimage_0000001460639441](figures/zh-cn_formulaimage_0000001460639441.png) + +clamp函数定义如下: + +![zh-cn_formulaimage_0000001410679330](figures/zh-cn_formulaimage_0000001410679330.png) + + +### OH_NN_Tensor + + +``` +typedef struct OH_NN_Tensor OH_NN_Tensor +``` + +**描述:** + +张量结构体。 + +通常用于构造模型图中的数据节点和算子参数,在构造张量时需要明确数据类型、维数、维度信息和量化信息。 + + +### OH_NN_UInt32Array + + +``` +typedef struct OH_NN_UInt32Array OH_NN_UInt32Array +``` + +**描述:** + +自定义的32位无符号整型数组类型。 + + +### OH_NNCompilation + + +``` +typedef struct OH_NNCompilation OH_NNCompilation +``` + +**描述:** + +Neural Network Runtime的编译器句柄。 + + +### OH_NNExecutor + + +``` +typedef struct OH_NNExecutor OH_NNExecutor +``` + +**描述:** + +Neural Network Runtime的执行器句柄。 + + +### OH_NNModel + + +``` +typedef struct OH_NNModel OH_NNModel +``` + +**描述:** + +Neural Network Runtime的模型句柄。 + + +## **枚举类型说明** + + +### OH_NN_DataType + + +``` +enum OH_NN_DataType +``` + +**描述:** + +Neural Network Runtime支持的数据类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_UNKNOWN | 张量数据类型未知。 | +| OH_NN_BOOL | 张量数据类型为bool。 | +| OH_NN_INT8 | 张量数据类型为int8。 | +| OH_NN_INT16 | 张量数据类型为int16。 | +| OH_NN_INT32 | 张量数据类型为int32。 | +| OH_NN_INT64 | 张量数据类型为int64。 | +| OH_NN_UINT8 | 张量数据类型为uint8。 | +| OH_NN_UINT16 | 张量数据类型为uint16。 | +| OH_NN_UINT32 | 张量数据类型为uint32。 | +| OH_NN_UINT64 | 张量数据类型为uint64。 | +| OH_NN_FLOAT16 | 张量数据类型为float16。 | +| OH_NN_FLOAT32 | 张量数据类型为float32。 | +| OH_NN_FLOAT64 | 张量数据类型为float64。 | + + +### OH_NN_DeviceType + + +``` +enum OH_NN_DeviceType +``` + +**描述:** + +Neural Network Runtime支持的设备类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_OTHERS | 不属于CPU、GPU、专用加速器的设备。 | +| OH_NN_CPU | CPU设备。 | +| OH_NN_GPU | GPU设备。 | +| OH_NN_ACCELERATOR | 专用硬件加速器。 | + + +### OH_NN_Format + + +``` +enum OH_NN_Format +``` + +**描述:** + +张量数据的排布类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_FORMAT_NONE | 当张量没有特定的排布类型(如标量或矢量)时,使用本枚举值。 | +| OH_NN_FORMAT_NCHW | 当张量按照NCHW的格式排布数据时,使用本枚举值。 | +| OH_NN_FORMAT_NHWC | 当张量按照NHWC的格式排布数据时,使用本枚举值。 | + + +### OH_NN_FuseType + + +``` +enum OH_NN_FuseType : int8_t +``` + +**描述:** + +Neural Network Runtime融合算子中激活函数的类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_FUSED_NONE | 未指定融合激活函数。 | +| OH_NN_FUSED_RELU | 融合relu激活函数。 | +| OH_NN_FUSED_RELU6 | 融合relu6激活函数。 | + + +### OH_NN_OperationType + + +``` +enum OH_NN_OperationType +``` + +**描述:** + +Neural Network Runtime支持算子的类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_OPS_ADD | 返回两个输入张量对应元素相加的和的张量。
输入:
- input1,第一个输入的张量,数据类型要求为布尔值或者数字。
- input2,第二个输入的张量,数据类型和形状需要和第一个输入保持一致。
参数:
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,input1和input2的和,数据形状与输入broadcast之后一样,数据类型与较高精度的输入精度一致 | +| OH_NN_OPS_AVG_POOL | 在输入张量上应用2D平均池化,仅支持NHWC格式的张量。支持int8量化输入。
如果输入中含有padMode参数:
输入:
- input,一个张量。
参数:
- kernelSize,用来取平均值的kernel大小,是一个长度为2的int数组[kernel_height,kernel_weight], 第一个数表示kernel高度,第二个数表示kernel宽度。
- strides,kernel移动的距离,是一个长度为2的int数组[stride_height,stride_weight], 第一个数表示高度上的移动步幅,第二个数表示宽度上的移动步幅。
- padMode,填充模式,int类型的可选值,0表示same,1表示valid,并且以最近邻的值填充。 same,输出的高度和宽度与input相同,填充总数将在水平和垂直方向计算,并在可能的情况下均匀分布到顶部 和底部、左侧和右侧。否则,最后一个额外的填充将从底部和右侧完成。 valid,输出的可能最大高度和宽度将在不填充的情况下返回。额外的像素将被丢弃。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
如果输入中含有padList参数:
输入:
- input,一个张量。
参数:
- kernelSize,用来取平均值的kernel大小,是一个长度为2的int数组[kernel_height,kernel_weight], 第一个数表示kernel高度,第二个数表示kernel宽度。
- strides,kernel移动的距离,是一个长度为2的int数组[stride_height,stride_weight], 第一个数表示高度上的移动步幅,第二个数表示宽度上的移动步幅。
- padList,input周围的填充,是一个长度为4的int数组[top,bottom,left,right],并且以最近邻的值填充。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,对input进行平均池化后的结果。 | +| OH_NN_OPS_BATCH_NORM | 对一个张量进行batch normalization,对张量元素进行缩放和位移,缓解一批数据中潜在的covariate shift。
输入:
- input,一个n维的张量,要求形状为[N,...,C],即第n维是通道数(channel)。
- scale,缩放因子的1D张量,用于缩放归一化的第一个张量。
- offset,用于偏移的1D张量,以移动到归一化的第一个张量。
- mean,总体均值的一维张量,仅用于推理;对于训练,必须为空。
- variance,用于总体方差的一维张量。仅用于推理;对于训练,必须为空。
参数:
- epsilon,数值稳定性的小附加值。
输出:
- output,n维输出张量,形状和数据类型与input一致。 | +| OH_NN_OPS_BATCH_TO_SPACE_ND | 将一个四维张量的batch维度按block_shape切分成小块,并将这些小块拼接到空间维度。
参数:
- input,输入张量,维将被切分,拼接回空间维度。
输出:
- blockSize,一个长度为2的数组[height_block,weight_block],指定切分到空间维度上的block大小。
- crops,一个shape为(2,2)的二维数组[[crop0_start,crop0_end],[crop1_start,crop1_end]], 表示在output的空间维度上截掉部分元素。
输出:
- output,假设input的形状为(n,h,w,c),output的形状为(n',h',w',c'): n' = n / (block_shape[0] \* block_shape[1]) h' = h \* block_shape[0] - crops[0][0] - crops[0][1] w' = w \* block_shape[1] - crops[1][0] - crops[1][1] c'= c | +| OH_NN_OPS_BIAS_ADD | 对给出的输入张量上的各个维度方向上的数据进行偏置。
输入:
- input,输入张量,可为2-5维度。
- bias,参数对应输入维度数量的偏移值。
输出:
- output,根据input中每个维度方向偏移后的结果。 | +| OH_NN_OPS_CAST | 对输入张量中的数据类型进行转换。
输入:
- input,输入张量。
- type,转换后的数据类型。
输出:
- output,转换后的张量。 | +| OH_NN_OPS_CONCAT | 在指定维度上连接张量。
输入:
- input:N个输入张量。
参数:
- axis,指定张量连接的维度。
输出:
- output,输出N个张量沿axis连接的结果。 | +| OH_NN_OPS_CONV2D | 二维卷积层。
如果输入中含有padMode参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,inChannel/group], inChannel必须要能整除group。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias 参数不需要量化参数,其量化 版本要求输入 OH_NN_INT32 类型数据,实际量化参数由 input 和 weight 共同决定。
参数:
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth], 值必须大于或等于1,并且不能超过input的height和width。
- padMode,input的填充模式,支持same和valid,int类型,0表示same,1表示valid。 same,输出的高度和宽度与input相同,填充总数将在水平和垂直方向计算,并在可能的情况下均匀分布到顶部和底部、左侧 和右侧。否则,最后一个额外的填充将从底部和右侧完成。 Valid,输出的可能最大高度和宽度将在不填充的情况下返回。额外的像素将被丢弃。
- group,将input按in_channel分组,int类型。group等于1,这是常规卷积;group大于1且小于或等于in_channel,这是分组卷积。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
如果输入中含有padList参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,inChannel/group], inChannel必须要能整除group。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias 参数不需要量化参数,其量化 版本要求输入 OH_NN_INT32 类型数据,实际量化参数由 input 和 weight 共同决定。
参数:
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth]。 值必须大于或等于1,并且不能超过input的height和width。
- padList,input周围的填充,是一个长度为4的int数组[top,bottom,left,right]。
- group,将input按in_channel分组,int类型。 group等于1,这是常规卷积。 group等于in_channel,这是depthwiseConv2d,此时group==in_channel==out_channel。 group大于1且小于in_channel,这是分组卷积,out_channel==group。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,卷积计算结果。 | +| OH_NN_OPS_CONV2D_TRANSPOSE | 二维卷积转置。
如果输入中含有padMode参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,inChannel/group], inChannel必须要能整除group。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias参数不需要量化参数,其量化 版本要求输入OH_NN_INT32类型数据,实际量化参数由input和weight共同决定。
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
参数:
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth]。 值必须大于或等于1,并且不能超过input的height和width。
- padMode,input的填充模式,支持same和valid,int类型,0表示same,1表示valid。 same,输出的高度和宽度与input相同,填充总数将在水平和垂直方向计算,并在可能的情况下均匀分布到顶部和底部、左侧 和右侧。否则,最后一个额外的填充将从底部和右侧完成。 Valid,输出的可能最大高度和宽度将在不填充的情况下返回。额外的像素将被丢弃。
- group,将input按in_channel分组,int类型。group等于1,这是常规卷积;group大于1且小于或等于in_channel,这是分组卷积。
- outputPads,一个整数或元组/2 个整数的列表,指定沿输出张量的高度和宽度的填充量。可以是单个整数,用于为所 有空间维度指定相同的值。沿给定维度的输出填充量必须小于沿同一维度的步幅。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
如果输入中含有padList参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,inChannel/group], inChannel必须要能整除group。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias 参数不需要量化参数,其量化 版本要求输入 OH_NN_INT32 类型数据,实际量化参数由 input 和 weight 共同决定。
参数:
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth]。 值必须大于或等于1,并且不能超过input的height和width。
- padList,input周围的填充,是一个长度为4的int数组[top,bottom,left,right]。
- group,将input按in_channel分组,int类型。group等于1,这是常规卷积;group大于1且小于或等于in_channel,这是分组卷积。
- outputPads,一个整数或元组/2 个整数的列表,指定沿输出张量的高度和宽度的填充量。可以是单个整数,用于为所 有空间维度指定相同的值。沿给定维度的输出填充量必须小于沿同一维度的步幅。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,卷积转置后的计算结果。 | +| OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE | 二维深度可分离卷积。
如果输入中含有padMode参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,1],outChannel = channelMultiplier \* inChannel。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias 参数不需要量化参数,其量化 版本要求输入 OH_NN_INT32 类型数据,实际量化参数由 input 和 weight 共同决定。
参数:
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth]。 值必须大于或等于1,并且不能超过input的height和width。
- padMode,input的填充模式,支持same和valid,int类型,0表示same,1表示valid same,输出的高度和宽度与input相同,填充总数将在水平和垂直方向计算,并在可能的情况下均匀分布到顶部和底部、左侧 和右侧。否则,最后一个额外的填充将从底部和右侧完成 Valid,输出的可能最大高度和宽度将在不填充的情况下返回。额外的像素将被丢弃
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
如果输入中含有padList 参数:
输入:
- input,输入张量。
- weight,卷积的权重,要求weight排布为[outChannel,kernelHeight,kernelWidth,1],outChannel = channelMultiplier \* inChannel。
- bias,卷积的偏置,是长度为[outChannel]的数组。在量化场景下,bias参数不需要量化参数,其量化 版本要求输入 OH_NN_INT32 类型数据,实际量化参数由 input和weight共同决定。
参数:
- stride,卷积核在height和weight上的步幅,是一个长度为2的int数组[strideHeight,strideWidth]。
- dilation,表示扩张卷积在height和weight上的扩张率,是一个长度为2的int数组[dilationHeight,dilationWidth]。 值必须大于或等于1,并且不能超过input的height和width。
- padList,input周围的填充,是一个长度为4的int数组[top,bottom,left,right]。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,卷积计算的结果。 | +| OH_NN_OPS_DIV | 对输入的两个标量或张量做除法。
输入:
- input1,第一个输入是标量或布尔值或数据类型为数字或布尔值的张量。
- input2,数据类型根据input1的类型,要求有所不同: 当第一个输入是张量时,第二个输入可以是实数或布尔值或数据类型为实数/布尔值的张量。 当第一个输入是实数或布尔值时,第二个输入必须是数据类型为实数/布尔值的张量。
参数:
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,input1和input2相除的结果。 | +| OH_NN_OPS_ELTWISE | 设置参数对输入进行product(点乘)、sum(相加减)或max(取大值)。
输入:
- input1,第一个输入张量。
- input2,第二个输入张量。
参数:
- mode,枚举,选择操作方式。
输出:
- output,计算后的结果,output和input1拥有相同的数据类型和形状。 | +| OH_NN_OPS_EXPAND_DIMS | 在给定维度上为张量添加一个额外的维度。
输入:
- input,输入张量。
- axis,需要添加的维度的index,int32_t类型,值必须在[-dim-1,dim],且只允许常量值。
输出:
- output,维度拓展后的张量。 | +| OH_NN_OPS_FILL | 根据指定的形状,创建由一个标量填充的张量。
输入:
- value,填充的标量。
- shape,指定创建张量的形状。
输出:
- output,生成的张量,和value具有相同的数据类型,张量形状由shape参数指定。 | +| OH_NN_OPS_FULL_CONNECTION | 全连接,整个输入作为feature map,进行特征提取。
输入:
- input,全连接的输入张量。
- weight,全连接的权重张量。
- bias,全连接的偏置,在量化场景下,bias参数不需要量化参数,其量化版本要求输入OH_NN_INT32 类型数据,实际量化参数由input和weight共同决定。
参数:
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,输出运算后的张量。
如果输入中含有axis参数:
输入:
- input,全连接的输入张量。
- weight,全连接的权重张量。
- bias,全连接的偏置,在量化场景下,bias参数不需要量化参数,其量化版本要求输入 OH_NN_INT32 类型数据,实际量化参数由input和weight共同决定。
参数:
- axis,input做全连接的轴,从指定轴axis开始,将axis和axis后面的轴展开成一维去做全连接
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,输出运算后的张量。 | +| OH_NN_OPS_GATHER | 根据指定的索引和轴返回输入张量的切片。
输入:
- input,输入待切片的张量。
- inputIndices,指定input在axis上的索引,是一个int类型的数组,值必须在[0,input.shape[axis])范围内
- axis,input被切片的轴,int32_t类型的数组,数组长度为1。
输出:
- output,输出切片后的张量。 | +| OH_NN_OPS_HSWISH | 计算输入的Hswish激活值。
输入:
- input,一个n维输入张量。
输出:
- output,n维Hswish激活值,数据类型和shape和input一致。 | +| OH_NN_OPS_LESS_EQUAL | 对input1和input2,计算每对元素的input1[i]<=input2[i]的结果,i是输入张量中每个元素的索引。
输入:
- input1,可以是实数、布尔值或数据类型是实数/NN_BOOL的张量。
- input2,如果input1是张量,input2可以是实数、布尔值,否则只能是张量,其数据类型是实数或NN_BOOL。
输出:
- 张量,数据类型为NN_BOOL的张量,使用量化模型时,output的量化参数不可省略,但量化参数的数值不会对输入结果产生影响。 | +| OH_NN_OPS_MATMUL | 计算input1和input2的内积。
输入:
- input1,n维输入张量。
- input2,n维输入张量。
参数:
- TransposeX,布尔值,是否对input1进行转置。
- TransposeY,布尔值,是否对input2进行转置。
输出:
- output,计算得到内积,当type!=NN_UNKNOWN时,output数据类型由type决定;当type==NN_UNKNOWN时, output的数据类型取决于input1和input2进行计算时转化的数据类型。 | +| OH_NN_OPS_MAXIMUM | 计算input1和input2对应元素最大值,input1和input2的输入遵守隐式类型转换规则,使数据类型一致。输入必须是两个张量或一个张量和一个标量。当输入是两个张量时,它们的数据类型不能同时为NN_BOOL。它们的形状支持broadcast成相同的大小。当输入是一个张量和一个标量时,标量只能是一个常数。
输入:
- input1,n维输入张量,实数或NN_BOOL类型。
- input2,n维输入张量,实数或NN_BOOL类型。
输出:
- output,n维输出张量,output的shape和数据类型和两个输入张量中精度或者位数高的相同。 | +| OH_NN_OPS_MAX_POOL | 在输入张量上应用2D最大值池化。
如果输入中含有padMode参数:
输入:
- input,一个张量。
参数:
- kernelSize,用来取最大值的kernel大小,是一个长度为2的int数组[kernel_height,kernel_weight], 第一个数表示kernel高度,第二个数表示kernel宽度。
- strides,kernel移动的距离,是一个长度为2的int数组[stride_height,stride_weight], 第一个数表示高度上的移动步幅,第二个数表示宽度上的移动步幅。
- padMode,填充模式,int类型的可选值,0表示same,1表示valid,并且以最近邻的值填充。 same,输出的高度和宽度与input相同,填充总数将在水平和垂直方向计算,并在可能的情况下均匀分布到顶部 和底部、左侧和右侧。否则,最后一个额外的填充将从底部和右侧完成。 valid,输出的可能最大高度和宽度将在不填充的情况下返回。额外的像素将被丢弃。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
如果输入中含有padList参数:
输入:
- input,一个张量。
参数:
- kernelSize,用来取最大值的kernel大小,是一个长度为2的int数组[kernel_height,kernel_weight], 第一个数表示kernel高度,第二个数表示kernel宽度。
- strides,kernel移动的距离,是一个长度为2的int数组[stride_height,stride_weight], 第一个数表示高度上的移动步幅,第二个数表示宽度上的移动步幅。
- padList,input周围的填充,是一个长度为4的int数组[top,bottom,left,right],并且以最近邻的值填充。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,对input最大值池化后的张量。 | +| OH_NN_OPS_MUL | 将input1和input2相同的位置的元素相乘得到output。如果input1和input2类型shape不同,要求input1和input2可以通过broadcast扩充成相同的shape进行相乘。
输入:
- input1,一个n维张量。
- input2,一个n维张量。
参数:
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,input1和input2每个元素的乘积。 | +| OH_NN_OPS_ONE_HOT | 根据indices指定的位置,生成一个由one-hot向量构成的张量。每个onehot向量中的有效值由on_value决定,其他位置由off_value决定。
输入:
- indices,n维张量。indices中每个元素决定每个one-hot向量,on_value的位置
- depth,一个整型标量,决定one-hot向量的深度。要求depth>0。
- on_value,一个标量,指定one-hot向量中的有效值。
- off_value,一个标量,指定one-hot向量中除有效位以外,其他位置的值。
参数:
- axis,一个整型标量,指定插入one-hot的维度。 indices的形状是[N,C],depth的值是D,当axis=0时,output形状为[D,N,C], indices的形状是[N,C],depth的值是D,当axis=-1时,output形状为[N,C,D], indices的形状是[N,C],depth的值是D,当axis=1时,output形状为[N,D,C]。
输出:
- output,如果indices时n维张量,则output是(n+1)维张量。output的形状由indices和axis共同决定。 | +| OH_NN_OPS_PAD | 在input1指定维度的数据前后,添加指定数值进行增广。
输入:
- input,一个n维张量,要求input1的排布为[BatchSize,…]。
- paddings,一个二维张量,指定每一维度增补的长度,shape为[n,2]。paddings[i][0]表示第i维上,需要在input前增补的数量; paddings[i][1]表示第i维上,需要在inputX后增补的数量。
参数:
- padValues,一个常数,数据类型和input一致,指定Pad操作补全的数值。
输出:
- output,一个n维张量,维数和数据类型和input保持一致。shape由input和paddings共同决定 output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1]。 | +| OH_NN_OPS_POW | 求input的y次幂,输入必须是两个张量或一个张量和一个标量。当输入是两个张量时,它们的数据类型不能同时为NN_BOOL, 且要求两个张量的shape相同。当输入是一个张量和一个标量时,标量只能是一个常数。
输入:
- input,实数、bool值或张量,张量的数据类型为实数/NN_BOOL。
- y,实数、bool值或张量,张量的数据类型为实数/NN_BOOL。
输出:
- output,形状由input和y通过broadcast后的形状决定。 | +| OH_NN_OPS_SCALE | 给定一个张量,计算其缩放后的值。
输入:
- input,一个n维张量。
- scale,缩放张量。
- bias,偏置张量。
参数:
- axis,指定缩放的维度。
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,scale的计算结果,一个n维张量,类型和input一致,shape由axis决定。 | +| OH_NN_OPS_SHAPE | 输入一个张量,计算其shape。
输入:
- input,一个n维张量。
输出:
- output,输出张量的维度,一个整型数组。 | +| OH_NN_OPS_SIGMOID | 给定一个张量,计算其sigmoid结果。
输入:
- input,一个n维张量。
输出:
- output,sigmoid的计算结果,一个n维张量,类型和shape和input一致。 | +| OH_NN_OPS_SLICE | 在输入张量的各个维度,以begin为起点,截取size长度的切片。
输入:
- input,n维输入张量。
- begin,一组不小于0的整数,指定每个维度上的起始切分点。
- size,一组不小于1的整数,指定每个维度上切片的长度。假设某一维度i,1<=size[i]<=input.shape[i]-begin[i]。
输出:
- output,切片得到的n维张量,其TensorType和input一致,shape和size相同。 | +| OH_NN_OPS_SOFTMAX | 给定一个张量,计算其softmax结果。
输入:
- input,n维输入张量。
参数:
- axis,int64类型,指定计算softmax的维度。整数取值范围为[-n,n)。
输出:
- output,softmax的计算结果,一个n维张量,类型和shape和input一致。 | +| OH_NN_OPS_SPACE_TO_BATCH_ND | 将四维张量在空间维度上进行切分成blockShape[0] \* blockShape[1]个小块,然后在batch维度上拼接这些小块。
输入:
- input,一个四维张量
参数:
- blockShape,一对整数,每个整数不小于1。
- paddings,一对数组,每个数组由两个整数组成。组成paddings的4个整数都不小于0。paddings[0][0]和paddings[0][1]指 定了第三个维度上padding的数量,paddings[1][0]和paddings[1][1]指定了第四个维度上padding的数量。
输出:
- output,一个四维张量,数据类型和input一致。shape由input,blockShape和paddings共同决定,假设input shape为[n,c,h,w],则有 output.shape[0] = n \* blockShape[0] \* blockShape[1] output.shape[1] = c output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] 要求(h + paddings[0][0] + paddings[0][1])和(w + paddings[1][0] + paddings[1][1])能被 blockShape[0]和blockShape[1]整除。 | +| OH_NN_OPS_SPLIT | Split算子沿axis维度将input拆分成多个张量,张量数量由outputNum指定。
输入:
- input,n维张量。
参数:
- outputNum,long,输出张量的数量,output_num类型为int。
- size_splits,一维张量,指定张量沿axis轴拆分后,每个张量的大小,size_splits 类型为 int。 如果size_splits的数据为空,则张量被拆分成大小均等的张量,此时要求input.shape[axis]可以被outputNum整除; 如果size_splits不为空,则要求 size_splits所有元素之和等于input.shape[axis]。
- axis,指定拆分的维度,axis类型为int。
输出:
- outputs,一组n维张量,每一个张量类型和shape相同,每个张量的类型和input一致。 | +| OH_NN_OPS_SQRT | 给定一个张量,计算其平方根。
输入:
- input,一个n维张量。
输出:
- output,输入的平方根,一个n维张量,类型和shape和input一致。 | +| OH_NN_OPS_SQUARED_DIFFERENCE | 计算两个输入的差值并返回差值的平方。SquaredDifference算子支持张量和张量相减。 如果两个张量的TensorType不相同,Sub算子会将低精度的张量转成更高精度的类型。 如果两个张量的shape不同,要求两个张量可以通过broadcast拓展成相同shape的张量。
输入:
- input1,被减数,input1是一个张量,张量的类型可以是NN_FLOAT16、NN_FLOAT32、NN_INT32或NN_BOOL。
- input2,减数,input2是一个张量,张量的类型可以是NN_FLOAT16、NN_FLOAT32、NN_INT32或NN_BOOL。
输出:
- output,两个输入差值的平方。output的shape由input1和input2共同决定,input1和input2的shape相同时, output的shape和input1、input2相同;shape不同时,需要将input1或input2做broadcast操作后,相减得到output。 output的TensorType由两个输入中更高精度的TensorType决定。 | +| OH_NN_OPS_SQUEEZE | 去除axis中,长度为1的维度。支持int8量化输入假设input的shape为[2,1,1,2,2],axis为[0,1], 则output的shape为[2,1,2,2]。第0维到第一维之间,长度为0的维度被去除。
输入:
- input,n维张量。
参数:
- axis,指定删除的维度。axis可以是一个int64_t的整数或数组,整数的取值范围为[-n,n)。
输出:
- output,输出张量。 | +| OH_NN_OPS_STACK | 将一组张量沿axis维度进行堆叠,堆叠前每个张量的维数为n,则堆叠后output维数为n+1。
输入:
- input,Stack支持传入多个输入n维张量,每个张量要求shape相同且类型相同。
参数:
- axis,一个整数,指定张量堆叠的维度。axis可以是负数,axis取值范围为[-(n+1),(n+1))。
输出:
- output,将input沿axis维度堆叠的输出,n+一维张量,TensorType和input相同。 | +| OH_NN_OPS_STRIDED_SLICE | 跨步截取张量。
输入:
- input,n维输入张量。
- begin,一维张量,begin的长度等于n,begin[i]指定第i维上截取的起点。
- end,一维张量,end的长度等于n,end[i]指定第i维上截取的终点。
- strides,一维张量,strides的长度等于n,strides[i]指定第i维上截取的步长。
参数:
- beginMask,一个整数,用于解除begin的限制。将beginMask转成二进制表示,如果binary(beginMask)[i]==1, 则对于第i维,从第一个元素开始,以strides[i]为步长截取元素直到第end[i]-1个元素。
- endMask,个整数,用于解除end的限制。将endMask转成二进制表示,如果binary(endMask)[i]==1,则对于第i维, 从第begin[i]个元素起,以strides[i]为步长截取元素直到张量边界。
- ellipsisMask,一个整数,用于解除begin和end的限制。将ellipsisMask转成二进制表示,如果binary(ellipsisMask)[i]==1, 则对于第i维,从第一个元素开始,以strides[i]为补偿,截取元素直到张量边界。binary(ellipsisMask)仅允许有一位不为0。
- newAxisMask,一个整数,用于新增维度。将newAxisMask转成二进制表示,如果binary(newAxisMask)[i]==1,则在第i维插入长度为1的新维度。
- shrinkAxisMask,一个整数,用于压缩指定维度。将shrinkAxisMask转成二进制表示,如果binary(shrinkAxisMask)[i]==1, 则舍去第i维所有元素,第i维长度压缩至1。
输出:
- 堆叠运算后的张量,数据类型与input相同。输出维度rank(input[0])+1 维。 | +| OH_NN_OPS_SUB | 计算两个输入的差值。
输入:
- input1,一个张量,作为减法中的被减数。
- input2,一个张量,作为减法中的减数。
参数:
- activationType,是一个整型常量,且必须是FuseType中含有的值。 在输出之前调用指定的激活。
输出:
- output,两个输入相减的差。output的shape由input1和input2共同决定,当input1和input2的shape相同时,output的shape和input1、input2相同; shape不同时,需要将input1或input2做broadcast操作后,相减得到output。output的TensorType由两个输入中更高精度的TensorType决定。 | +| OH_NN_OPS_TANH | 计算输入张量的双曲正切值。
输入:
- input,n维张量。
输出:
- output,input的双曲正切,TensorType和张量shape和input相同。 | +| OH_NN_OPS_TILE | 以multiples指定的次数拷贝输入。
输入:
- input,n维张量。
- multiples,一维张量,指定各个维度拷贝的次数。其长度m不小于input的维数n。
输出:
- 张量,m维张量,TensorType与input相同。如果input和multiples长度相同, 则output和input维数一致,都是n维张量;如果multiples长度大于n,则用1填充input的维度, 再在各个维度上拷贝相应的次数,得到m维张量。 | +| OH_NN_OPS_TRANSPOSE | 根据permutation对input进行数据重排。
输入:
- input,n维张量,待重排的张量。
- perm,一维张量,其长度和input的维数一致。
输出:
- output,n维张量,output的TensorType与input相同,shape由input的shape和permutation共同决定。 | +| OH_NN_OPS_REDUCE_MEAN | keepDims为false时,计算指定维度上的平均值,减少input的维数;当keepDims为true时,计算指定维度上的平均值,保留相应的维度。
输入:
- input,n维输入张量,n<8。
- axis,一维张量,指定计算均值的维度,axis中每个元素的取值范围为[-n,n)。
参数:
- keepDims,布尔值,是否保留维度的标志位。
输出:
- output,m维输出张量,数据类型和input相同。当keepDims为false时,m==n;当keepDims为true时,m<n。 | +| OH_NN_OPS_RESIZE_BILINEAR | 采用Bilinear方法,按给定的参数对input进行变形。
输入:
- input,四维输入张量,input中的每个元素不能小于0。input排布必须是[batchSize,height,width,channels]。
参数:
- newHeight,resize之后四维张量的height值。
- newWidth,resize之后四维张量的width值。
- preserveAspectRatio,一个布尔值,指示resize操作是否保持input的height/width比例。
- coordinateTransformMode,一个int32整数,指示Resize操作所使用的坐标变换方法,目前支持以下方法:
- excludeOutside,一个int64浮点数。当excludeOutside=1时,超出input边界的采样权重被置为0,其余权重重新归一化处理。
输出:
- output,n维输出张量,output的shape和数据类型和input相同。 | +| OH_NN_OPS_RSQRT | 求input平方根的倒数。
输入:
- input,n维输入张量,input中的每个元素不能小于0,n<8。
输出:
- output,n维输出张量,output的shape和数据类型和input相同。 | +| OH_NN_OPS_RESHAPE | 根据inputShape调整input的形状。
输入:
- input,一个n维输入张量。
- InputShape,一个一维张量,表示输出张量的shape,需要是一个常量张量。
输出:
- output,输出张量,数据类型和input一致,shape由inputShape决定。 | +| OH_NN_OPS_PRELU | 计算input和weight的PReLU激活值。
输入:
- input,一个n维张量,如果n>=2,则要求input的排布为[BatchSize,…,Channels],第二个维度为通道数。
- output,input的PReLU激活值。形状和数据类型和input保持一致。 | +| OH_NN_OPS_RELU | 计算input的Relu激活值。
输入:
- input,一个n维输入张量。
输出:
- output,n维Relu输出张量,数据类型和shape和input一致。 | +| OH_NN_OPS_RELU6 | 计算input的Relu6激活值,即对input中每个元素x,计算min(max(x,0),6)。
输入:
- input,一个n维输入张量。
输出:
- output,n维Relu6输出张量,数据类型和shape和input一致。 | +| OH_NN_OPS_LAYER_NORM | 对一个张量从某一axis开始做层归一化。
输入:
- input,一个n维输入张量。
- gamma,一个m维张量,gamma维度应该与input做归一化部分的shape一致。
- beta,一个m维张量,shape与gamma一样。
参数:
- beginAxis,是一个NN_INT32的标量,指定开始做归一化的轴,取值范围是[1,rank(input))。
- epsilon,是一个NN_FLOAT32的标量,是归一化公式中的微小量,常用值是1e-7。
输出:
- output,n维输出张量,数据类型和shape和input一致。 | +| OH_NN_OPS_REDUCE_PROD | 沿着axis指定的维度,计算input的累积。
输入:
- input,n维输入张量,n<8。
- axis,一维张量,指定计算乘的维度,axis中每个元素的取值范围为[-n,n)。
参数:
- keepDims,布尔值,是否保留维度的标志位。当keepDims为true时,output的维数和input保持一致;当keepDims为false时,output的维数缩减。
输出:
- output,m维输出张量,数据类型和input相同。当keepDims为false时,m==n;当keepDims为true时,m<n。 | +| OH_NN_OPS_REDUCE_ALL | 当keepDims为false时,计算指定维度上的逻辑与,减少input的维数;当keepDims为true时,计算指定维度上的逻辑与,保留相应的维度。
输入:
- input,n维输入张量,n<8。
- axis,一维张量,指定计算逻辑与的维度,axis中每个元素的取值范围为[-n,n)。
参数:
- keepDims,布尔值,是否保留维度的标志位。
输出:
- output,m维输出张量,数据类型和input相同。当keepDims为false时,m==n;当keepDims为true时,m<n。 | +| OH_NN_OPS_QUANT_DTYPE_CAST | 数据类型转换。
输入:
- input,n维张量。
参数:
- src_t,定义输入的数据类型。
- dst_t,定义输出的数据类型。
输出:
- output,n维张量,数据类型由input决定,输出的形状和输入相同。 | +| OH_NN_OPS_TOP_K | 查找沿最后一个维度的k个最大条目的值和索引。
输入:
- input,n维张量。
- k,指明是得到前k个数据以及其index。
参数:
- sorted,如果为True,按照大到小排序,如果为False,按照小到大排序。
输出:
- output0,最后一维的每个切片中的k个最大元素。
- output1,输入的最后一个维度内的值的索引。 | +| OH_NN_OPS_ARG_MAX | 返回跨轴的张量最大值的索引。
输入:
- input,n维张量,输入张量(N,∗),其中∗意味着任意数量的附加维度。
参数:
- axis,指定求最大值索引的维度。
- keep_dims,bool值,是否维持输入张量维度。
输出:
- output,张量,轴上输入张量最大值的索引。 | +| OH_NN_OPS_UNSQUEEZE | 根据输入axis的值,增加一个维度。
输入:
- input,n维张量。
参数:
- axis,指定增加的维度。axis可以是一个整数或一组整数,整数的取值范围为[-n,n)。
输出:
- output,输出张量。 | +| OH_NN_OPS_GELU | 高斯误差线性单元激活函数。output=0.5∗input∗(1+tanh(input/2)),不支持int量化输入。
输入:
- input,一个n维输入张量。
输出:
- output,n维Relu输出张量,数据类型和shape和input一致。 | + + +### OH_NN_PerformanceMode + + +``` +enum OH_NN_PerformanceMode +``` + +**描述:** + +硬件的性能模式。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_PERFORMANCE_NONE | 无性能模式偏好。 | +| OH_NN_PERFORMANCE_LOW | 低能耗模式。 | +| OH_NN_PERFORMANCE_MEDIUM | 中性能模式。 | +| OH_NN_PERFORMANCE_HIGH | 高性能模式。 | +| OH_NN_PERFORMANCE_EXTREME | 极致性能模式。 | + + +### OH_NN_Priority + + +``` +enum OH_NN_Priority +``` + +**描述:** + +模型推理任务优先级。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_PRIORITY_NONE | 无优先级偏好。 | +| OH_NN_PRIORITY_LOW | 低优先级。 | +| OH_NN_PRIORITY_MEDIUM | 中优先级。 | +| OH_NN_PRIORITY_HIGH | 高优先级。 | + + +### OH_NN_ReturnCode + + +``` +enum OH_NN_ReturnCode +``` + +**描述:** + +Neural Network Runtime定义的错误码类型。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_SUCCESS | 操作成功。 | +| OH_NN_FAILED | 操作失败。 | +| OH_NN_INVALID_PARAMETER | 非法参数。 | +| OH_NN_MEMORY_ERROR | 内存相关的错误,包括:内存不足、内存数据拷贝失败、内存申请失败等。 | +| OH_NN_OPERATION_FORBIDDEN | 非法操作。 | +| OH_NN_NULL_PTR | 空指针异常。 | +| OH_NN_INVALID_FILE | 无效文件。 | +| OH_NN_UNAVALIDABLE_DEVICE | 硬件发生错误,错误可能包含:HDL服务崩溃。 | +| OH_NN_INVALID_PATH | 非法路径。 | + + +### OH_NN_TensorType + + +``` +enum OH_NN_TensorType +``` + +**描述:** + +张量的类型。 + +张量通常用于设置模型的输入、输出和算子参数。 + +作为模型(或算子)的输入和输出时,需要将张量类型设置为OH_NN_TENSOR;当张量作为算子参数时,需要选择除OH_NN_TENSOR以外合适的枚举值,作为张量的类型。 + +假设正在设置OH_NN_OPS_CONV2D算子的pad参数,则需要将 [OH_NN_Tensor](_o_h___n_n___tensor.md)实例的type属性设置为OH_NN_CONV2D_PAD。 + +其他算子参数的设置以此类推,枚举值的命名遵守OH\_NN\_{算子名称}\_{属性名}的格式。 + +| 枚举值 | 描述 | +| -------- | -------- | +| OH_NN_TENSOR | 当张量作为模型(或算子)的输入或输出时,使用本枚举值。 | +| OH_NN_ADD_ACTIVATIONTYPE | 当张量作为Add算子的activationType参数时,使用本枚举值。 | +| OH_NN_AVG_POOL_KERNEL_SIZE | 当张量作为AvgPool算子的kernel_size参数时,使用本枚举值。 | +| OH_NN_AVG_POOL_STRIDE | 当张量作为AvgPool算子的stride参数时,使用本枚举值。 | +| OH_NN_AVG_POOL_PAD_MODE | 当张量作为AvgPool算子的pad_mode参数时,使用本枚举值。 | +| OH_NN_AVG_POOL_PAD | 当张量作为AvgPool算子的pad参数时,使用本枚举值。 | +| OH_NN_AVG_POOL_ACTIVATION_TYPE | 当张量作为AvgPool算子的activation_type参数时,使用本枚举值。 | +| OH_NN_BATCH_NORM_EPSILON | 当张量作为BatchNorm算子的eosilon参数时,使用本枚举值。 | +| OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE | 当张量作为BatchToSpaceND算子的blockSize参数时,使用本枚举值。 | +| OH_NN_BATCH_TO_SPACE_ND_CROPS | 当张量作为BatchToSpaceND算子的crops参数时,使用本枚举值。 | +| OH_NN_CONCAT_AXIS | 当张量作为Concat算子的axis参数时,使用本枚举值。 | +| OH_NN_CONV2D_STRIDES | 当张量作为Conv2D算子的strides参数时,使用本枚举值。 | +| OH_NN_CONV2D_PAD | 当张量作为Conv2D算子的pad参数,使用本枚举值。 | +| OH_NN_CONV2D_DILATION | 当张量作为Conv2D算子的dilation参数时,使用本枚举值。 | +| OH_NN_CONV2D_PAD_MODE | 当张量作为Conv2D算子的padMode参数时,使用本枚举值。 | +| OH_NN_CONV2D_ACTIVATION_TYPE | 当张量作为Conv2D算子的activationType参数时,使用本枚举值。 | +| OH_NN_CONV2D_GROUP | 当张量作为Conv2D算子的group参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_STRIDES | 当张量作为Conv2DTranspose算子的strides参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_PAD | 当张量作为Conv2DTranspose算子的pad参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_DILATION | 当张量作为Conv2DTranspose算子的dilation参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS | 当张量作为Conv2DTranspose算子的outputPaddings参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_PAD_MODE | 当张量作为Conv2DTranspose算子的padMode参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE | 当张量作为Conv2DTranspose算子的activationType参数时,使用本枚举值。 | +| OH_NN_CONV2D_TRANSPOSE_GROUP | 当张量作为Conv2DTranspose算子的group参数时,使用本枚举值。 | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES | 当张量作为DepthwiseConv2dNative算子的strides参数时,使用本枚举值。 | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD | 当张量作为DepthwiseConv2dNative算子的pad参数时,使用本枚举值。 | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION | 当张量作为DepthwiseConv2dNative算子的dilation参数时,使用本枚举值。 | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE | 当张量作为DepthwiseConv2dNative算子的padMode参数时,使用本枚举值。 | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE | 当张量作为DepthwiseConv2dNative算子的activationType参数时,使用本枚举值。 | +| OH_NN_DIV_ACTIVATIONTYPE | 当张量作为Div算子的activationType参数时,使用本枚举值。 | +| OH_NN_ELTWISE_MODE | 当张量作为Eltwise算子的mode参数时,使用本枚举值。 | +| OH_NN_FULL_CONNECTION_AXIS | 当张量作为FullConnection算子的axis参数时,使用本枚举值。 | +| OH_NN_FULL_CONNECTION_ACTIVATIONTYPE | 当张量作为FullConnection算子的activationType参数时,使用本枚举值。 | +| OH_NN_MATMUL_TRANSPOSE_A | 当张量作为Matmul算子的transposeA参数时,使用本枚举值。 | +| OH_NN_MATMUL_TRANSPOSE_B | 当张量作为Matmul算子的transposeB参数时,使用本枚举值。 | +| OH_NN_MATMUL_ACTIVATION_TYPE | 当张量作为Matmul算子的activationType参数时,使用本枚举值。 | +| OH_NN_MAX_POOL_KERNEL_SIZE | 当张量作为MaxPool算子的kernel_size参数时,使用本枚举值。 | +| OH_NN_MAX_POOL_STRIDE | 当张量作为MaxPool算子的stride参数时,使用本枚举值。 | +| OH_NN_MAX_POOL_PAD_MODE | 当张量作为MaxPool算子的pad_mode参数时,使用本枚举值。 | +| OH_NN_MAX_POOL_PAD | 当张量作为MaxPool算子的pad参数时,使用本枚举值。 | +| OH_NN_MAX_POOL_ACTIVATION_TYPE | 当张量作为MaxPool算子的activation_type参数时,使用本枚举值。 | +| OH_NN_MUL_ACTIVATION_TYPE | 当张量作为Mul算子的activationType参数时,使用本枚举值。 | +| OH_NN_ONE_HOT_AXIS | 当张量作为OneHot算子的axis参数时,使用本枚举值。 | +| OH_NN_PAD_CONSTANT_VALUE | 当张量作为Pad算子的constant_value参数时,使用本枚举值。 | +| OH_NN_SCALE_ACTIVATIONTYPE | 当张量作为Scale算子的activationType参数时,使用本枚举值。 | +| OH_NN_SCALE_AXIS | 当张量作为Scale算子的axis参数时,使用本枚举值。 | +| OH_NN_SOFTMAX_AXIS | 当张量作为Softmax算子的axis参数时,使用本枚举值。 | +| OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE | 当张量作为SpaceToBatchND算子的BlockShape参数时,使用本枚举值。 | +| OH_NN_SPACE_TO_BATCH_ND_PADDINGS | 当张量作为SpaceToBatchND算子的Paddings参数时,使用本枚举值。 | +| OH_NN_SPLIT_AXIS | 当张量作为Split算子的Axis参数时,使用本枚举值。 | +| OH_NN_SPLIT_OUTPUT_NUM | 当张量作为Split算子的OutputNum参数时,使用本枚举值。 | +| OH_NN_SPLIT_SIZE_SPLITS | 当张量作为Split算子的SizeSplits参数时,使用本枚举值。 | +| OH_NN_SQUEEZE_AXIS | 当张量作为Squeeze算子的Axis参数时,使用本枚举值。 | +| OH_NN_STACK_AXIS | 当张量作为Stack算子的Axis参数时,使用本枚举值。 | +| OH_NN_STRIDED_SLICE_BEGIN_MASK | 当张量作为StridedSlice算子的BeginMask参数时,使用本枚举值。 | +| OH_NN_STRIDED_SLICE_END_MASK | 当张量作为StridedSlice算子的EndMask参数时,使用本枚举值。 | +| OH_NN_STRIDED_SLICE_ELLIPSIS_MASK | 当张量作为StridedSlice算子的EllipsisMask参数时,使用本枚举值。 | +| OH_NN_STRIDED_SLICE_NEW_AXIS_MASK | 当张量作为StridedSlice算子的NewAxisMask参数时,使用本枚举值。 | +| OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK | 当张量作为StridedSlice算子的ShrinkAxisMask参数时,使用本枚举值。 | +| OH_NN_SUB_ACTIVATIONTYPE | 当张量作为Sub算子的ActivationType参数时,使用本枚举值。 | +| OH_NN_REDUCE_MEAN_KEEP_DIMS | 当张量作为ReduceMean算子的keep_dims参数时,使用本枚举值。 | +| OH_NN_RESIZE_BILINEAR_NEW_HEIGHT | 当张量作为ResizeBilinear算子的new_height参数时,使用本枚举值。 | +| OH_NN_RESIZE_BILINEAR_NEW_WIDTH | 当张量作为ResizeBilinear算子的new_width参数时,使用本枚举值。 | +| OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO | 当张量作为ResizeBilinear算子的preserve_aspect_ratio参数时,使用本枚举值。 | +| OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE | 当张量作为ResizeBilinear算子的coordinate_transform_mode参数时,使用本枚举值。 | +| OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE | 当张量作为ResizeBilinear算子的exclude_outside参数时,使用本枚举值。 | +| OH_NN_LAYER_NORM_BEGIN_NORM_AXIS | 当张量作为LayerNorm算子的beginNormAxis参数时,使用本枚举值。 | +| OH_NN_LAYER_NORM_EPSILON | 当张量作为LayerNorm算子的epsilon参数时,使用本枚举值。 | +| OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS | 当张量作为LayerNorm算子的beginParamsAxis参数时,使用本枚举值。 | +| OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE | 当张量作为LayerNorm算子的elementwiseAffine参数时,使用本枚举值。 | +| OH_NN_REDUCE_PROD_KEEP_DIMS | 当张量作为ReduceProd算子的keep_dims参数时,使用本枚举值。 | +| OH_NN_REDUCE_ALL_KEEP_DIMS | 当张量作为ReduceAll算子的keep_dims参数时,使用本枚举值。 | +| OH_NN_QUANT_DTYPE_CAST_SRC_T | 当张量作为QuantDTypeCast算子的src_t参数时,使用本枚举值。 | +| OH_NN_QUANT_DTYPE_CAST_DST_T | 当张量作为QuantDTypeCast算子的dst_t参数时,使用本枚举值。 | +| OH_NN_TOP_K_SORTED | 当张量作为Topk算子的Sorted参数时,使用本枚举值。 | +| OH_NN_ARG_MAX_AXIS | 当张量作为ArgMax算子的axis参数时,使用本枚举值。 | +| OH_NN_ARG_MAX_KEEPDIMS | 当张量作为ArgMax算子的keepDims参数时,使用本枚举值。 | +| OH_NN_UNSQUEEZE_AXIS | 当张量作为Unsqueeze算子的Axis参数时,使用本枚举值。 | + + +## **函数说明** + + +### OH_NNCompilation_Build() + + +``` +OH_NN_ReturnCode OH_NNCompilation_Build (OH_NNCompilation * compilation) +``` + +**描述:** + +进行模型编译。 + +完成编译配置后,调用本方法指示模型编译已完成。编译实例将模型和编译选项推送至硬件设备进行编译。 + +在调用本方法后,无法进行额外的编译操作,调用 [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice)、[OH_NNCompilation_SetCache](#oh_nncompilation_setcache)、 [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode)、 [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority)和[OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) 方法将返回OH_NN_OPERATION_FORBIDDEN。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNCompilation_Construct() + + +``` +OH_NNCompilation* OH_NNCompilation_Construct (const OH_NNModel * model) +``` + +**描述:** + +创建[OH_NNCompilation](#oh_nncompilation)类型的编译实例。 + +使用OH_NNModel模块完成模型的构造后,借助OH_NNCompilation模块提供的接口,将模型传递到底层硬件完成编译。本方法接受一个 [OH_NNModel](#oh_nnmodel)实例,创建出[OH_NNCompilation](#oh_nncompilation)实例;通过 [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice)方法,设置编译的设备,最后调用 [OH_NNCompilation_Build](#oh_nncompilation_build)完成编译。 + +除了计算硬件的选择,OH_NNCompilation模块支持模型缓存、性能偏好、优先级设置、float16计算等特性,参考以下方法: + +- [OH_NNCompilation_SetCache](#oh_nncompilation_setcache) + +- [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode) + +- [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority) + +- [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) + +调用本方法创建[OH_NNCompilation](#oh_nncompilation)后,[OH_NNModel](#oh_nnmodel)实例可以释放。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | + +**返回:** + +返回一个指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 + + +### OH_NNCompilation_Destroy() + + +``` +void OH_NNCompilation_Destroy (OH_NNCompilation ** compilation) +``` + +**描述:** + +释放Compilation对象。 + +调用[OH_NNCompilation_Construct](#oh_nncompilation_construct)创建的编译实例需要调用本方法主动释放,否则将造成内存泄漏。 + +如果compilation为空指针或者\*compilation为空指针,本方法只打印warning日志,不执行释放逻辑。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的二级指针。编译实例销毁后,本方法将\*compilation主动设置为空指针。 | + + +### OH_NNCompilation_EnableFloat16() + + +``` +OH_NN_ReturnCode OH_NNCompilation_EnableFloat16 (OH_NNCompilation * compilation, bool enableFloat16 ) +``` + +**描述:** + +是否以float16的浮点数精度计算。 + +Neural Network Runtime目前仅支持构造float32浮点模型和int8量化模型。在支持float16精度的硬件上调用本方法, float32浮点数精度的模型将以float16的精度执行计算,以减少内存占用和执行时间。 + +在不支持float16精度计算的硬件上调用本方法,将返回OH_NN_UNAVALIDABLE_DEVICE错误码。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | +| enableFloat16 | Float16低精度计算标志位。设置为true时,执行Float16推理;设置为false时,执行float32推理。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNCompilation_SetCache() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetCache (OH_NNCompilation * compilation, const char * cachePath, uint32_t version ) +``` + +**描述:** + +设置编译后的模型缓存路径和缓存版本。 + +在支持缓存的硬件上,模型在硬件驱动层编译后可以保存为缓存文件,下次编译时直接从缓存文件读取模型,减少重新编译的耗时。本方法接受缓存路径和版本,根据缓存 路径中和版本的不同情况,本方法采取不同的行为: + +- 缓存路径指定的目录下没有文件: 将编译后的模型缓存到目录下,设置缓存版本等于version。 + +- 缓存路径指定的目录下存在完整的缓存文件,且版本号 == version: 读取路径下的缓存文件,传递到底层硬件中转换为可以执行的模型实例。 + +- 缓存路径指定的目录下存在完整的缓存文件,但版本号 < version: 路径下的缓存文件需要更新,模型在底层硬件完成编译后,覆写路径下的缓存文件,将版本号更新为version。 + +- 缓存路径指定的目录下存在完整的缓存文件,但版本号 > version: 路径下的缓存文件版本高于version,不读取缓存文件,同时返回OH_NN_INVALID_PARAMETER错误码。 + +- 缓存路径指定的目录下的缓存文件不完整或没有缓存文件的访问权限: 返回OH_NN_INVALID_FILE错误码。 + +- 缓存目录不存在,或者没有访问权限: 返回OH_NN_INVALID_PATH错误码。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | +| cachePath | 模型缓存文件目录,本方法在cachePath目录下为不同的硬件创建缓存目录。建议每个模型使用单独的缓存目录。 | +| version | 缓存版本。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNCompilation_SetDevice() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetDevice (OH_NNCompilation * compilation, size_t deviceID ) +``` + +**描述:** + +指定模型编译和计算的硬件。 + +编译阶段,需要指定模型编译和执行计算的硬件设备。先调用[OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid)获取可用的设备ID,通过[OH_NNDevice_GetType](#oh_nndevice_gettype)和[OH_NNDevice_GetType](#oh_nndevice_gettype)获取设备信息后,将期望编译执行的设备ID传入本方法进行设置。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | +| deviceID | 指定的硬件ID。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNCompilation_SetPerformanceMode() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetPerformanceMode (OH_NNCompilation * compilation, OH_NN_PerformanceMode performanceMode ) +``` + +**描述:** + +设置模型计算的性能模式。 + +Neural Network Runtime支持为模型计算设置性能模式,满足低功耗到极致性能的需求。 + +如果编译阶段没有调用本方法设置性能模式, 编译实例为模型默认分配OH_NN_PERFORMANCE_NONE模式。 + +在OH_NN_PERFORMANCE_NONE 模式下,硬件按默认的性能模式执行计算。 + +在不支持性能模式设置的硬件上调用本方法,将返回OH_NN_UNAVALIDABLE_DEVICE错误码。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | +| performanceMode | 指定性能模式,可选的性能模式参考[OH_NN_PerformanceMode](#oh_nn_performancemode)。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNCompilation_SetPriority() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetPriority (OH_NNCompilation * compilation, OH_NN_Priority priority ) +``` + +**描述:** + +设置模型计算的优先级。 + +Neural Network Runtime 支持为模型设置计算优先级,优先级仅作用于相同uid进程创建的模型,不同uid进程、不同设备的优先级不会 相互影响。 + +在不支持优先级设置的硬件上调用本方法,将返回OH_NN_UNAVALIDABLE_DEVICE错误码。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | +| priority | 指定优先级,可选的优先级参考[OH_NN_Priority](#oh_nn_priority)。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNDevice_GetAllDevicesID() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetAllDevicesID (const size_t ** allDevicesID, uint32_t * deviceCount ) +``` + +**描述:** + +获取对接到 Neural Network Runtime 的硬件ID。 + +每个硬件在 Neural Network Runtime 中存在唯一且固定ID,本方法通过uin32_t数组返回当前设备上已经对接的硬件ID。 + +硬件ID通过size_t数组返回,数组的每个元素是单个硬件的ID值。数组内存由Neural Network Runtime管理。在下次调用本方法前, 数据指针有效。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| allDevicesID | 指向size_t数组的指针。要求传入的(\*allDevicesID)为空指针,否则返回OH_NN_INVALID_PARAMETER。 | +| deviceCount | uint32_t类型的指针,用于返回(\*allDevicesID)的长度。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNDevice_GetName() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetName (size_t deviceID, const char ** name ) +``` + +**描述:** + +获取指定硬件的类型信息。 + +通过deviceID指定计算硬件,获取硬件的名称。硬件ID需要调用[OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid)获取。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| deviceID | 指定硬件ID。 | +| name | 指向char数组的指针,要求传入的(\*char)为空指针,否则返回OH_NN_INVALID_PARAMETER。
(\*name)以C风格字符串保存硬件名称,数组以'\0'结尾。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNDevice_GetType() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetType (size_t deviceID, OH_NN_DeviceType * deviceType ) +``` + +**描述:** + +获取指定硬件的类别信息。 + +通过deviceID指定计算硬件,获取硬件的类别。目前 Neural Network Runtime 支持的设备类型有: + +- CPU设备:OH_NN_CPU + +- GPU设备:OH_NN_GPU + +- 机器学习专用加速器:OH_NN_ACCELERATOR + +- 不属于以上类型的其他硬件类型:OH_NN_OTHERS + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| deviceID | 指定硬件ID。 | +| deviceType | 指向[OH_NN_DeviceType](#oh_nn_devicetype)实例的指针,返回硬件的类别信息。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_AllocateInputMemory() + + +``` +OH_NN_Memory* OH_NNExecutor_AllocateInputMemory (OH_NNExecutor * executor, uint32_t inputIndex, size_t length ) +``` + +**描述:** + +在硬件上为单个输入申请共享内存。 + +Neural Network Runtime 提供主动申请硬件共享内存的方法。通过指定执行器和输入索引值,本方法在单个输入关联的硬件 上,申请大小为length的共享内存,通过[OH_NN_Memory](_o_h___n_n___memory.md)实例返回。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| inputIndex | 输入的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输入数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,inputIndices为{1,5,9}, 则在申请输入内存时,三个输入的索引值分别为{0,1,2}。 | +| length | 申请的内存字节。 | + +**返回:** + +指向[OH_NN_Memory](_o_h___n_n___memory.md)实例的指针。 + + +### OH_NNExecutor_AllocateOutputMemory() + + +``` +OH_NN_Memory* OH_NNExecutor_AllocateOutputMemory (OH_NNExecutor * executor, uint32_t outputIndex, size_t length ) +``` + +**描述:** + +在硬件上为单个输出申请共享内存。 + +Neural Network Runtime提供主动申请硬件共享内存的方法。通过指定执行器和输出索引值,本方法在单个输出关联的硬件上,申请大小为length的共享内存,通过[OH_NN_Memory](_o_h___n_n___memory.md)实例返回。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| outputIndex | 输出的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输出数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,outputIndices为{4,6,8}, 则在申请输出内存时,三个输出的索引值分别为{0,1,2}。 | +| length | 申请的内存字节。 | + +**返回:** + +指向[OH_NN_Memory](_o_h___n_n___memory.md)实例的指针。 + + +### OH_NNExecutor_Construct() + + +``` +OH_NNExecutor* OH_NNExecutor_Construct (OH_NNCompilation * compilation) +``` + +**描述:** + +创建[OH_NNExecutor](#oh_nnexecutor)类型的执行器实例 + +本方法接受一个编译器,构造一个与硬件关联的模型推理执行器。通过[OH_NNExecutor_SetInput](#oh_nnexecutor_setinput)设置模型输入数据, 设置输入数据后,调用[OH_NNExecutor_Run](#oh_nnexecutor_run)方法执行推理,最后通过 [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput)获取计算结果。 + +调用本方法创建[OH_NNExecutor](#oh_nnexecutor)实例后,如果不需要创建其他执行器,可以安全释放[OH_NNCompilation](#oh_nncompilation)实例。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| compilation | 指向[OH_NNCompilation](#oh_nncompilation)实例的指针。 | + +**返回:** + +返回指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 + + +### OH_NNExecutor_Destroy() + + +``` +void OH_NNExecutor_Destroy (OH_NNExecutor ** executor) +``` + +**描述:** + +销毁执行器实例,释放执行器占用的内存。 + +调用[OH_NNExecutor_Construct](#oh_nnexecutor_construct)创建的执行器实例需要调用本方法主动释放,否则将造成内存泄漏。 + +如果executor为空指针或者\*executor为空指针,本方法只打印warning日志,不执行释放逻辑。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的二级指针。 | + + +### OH_NNExecutor_DestroyInputMemory() + + +``` +void OH_NNExecutor_DestroyInputMemory (OH_NNExecutor * executor, uint32_t inputIndex, OH_NN_Memory ** memory ) +``` + +**描述:** + +释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输入内存。 + +调用[OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory)创建的内存实例,需要主动调用本方法进行释放,否则将造成内存泄漏。 inputIndex和memory的对应关系需要和创建内存实例时保持一致。 + +如果memory或\*memory为空指针,本方法只打印warning日志,不执行释放逻辑。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| inputIndex | 输入的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输入数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,inputIndices为{1,5,9}, 则在执行释放输入内存时,三个输入的索引值分别为{0,1,2}。 | +| memory | 指向[OH_NN_Memory](_o_h___n_n___memory.md)实例的二级指针。共享内存销毁后,本方法将\*memory主动设置为空指针。 | + + +### OH_NNExecutor_DestroyOutputMemory() + + +``` +void OH_NNExecutor_DestroyOutputMemory (OH_NNExecutor * executor, uint32_t outputIndex, OH_NN_Memory ** memory ) +``` + +**描述:** + +释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输出内存。 + +调用[OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory)创建的内存实例,需要主动调用本方法进行释放,否则将造成内存泄漏。 outputIndex和memory的对应关系需要和创建内存实例时保持一致。 + +如果memory或\*memory为空指针,本方法只打印warning日志,不执行释放逻辑。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| outputIndex | 输出的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输出数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,outputIndices为{4,6,8}, 则在执行释放输出内存时,三个输出的索引值分别为{0,1,2}。 | +| memory | 指向[OH_NN_Memory](_o_h___n_n___memory.md)实例的二级指针。共享内存销毁后,本方法将\*memory主动设置为空指针。 | + + +### OH_NNExecutor_GetOutputShape() + + +``` +OH_NN_ReturnCode OH_NNExecutor_GetOutputShape (OH_NNExecutor * executor, uint32_t outputIndex, int32_t ** shape, uint32_t * shapeLength ) +``` + +**描述:** + +获取输出张量的维度信息。 + +调用[OH_NNExecutor_Run](#oh_nnexecutor_run)完成单次推理后,本方法获取指定输出的维度信息和维数。在动态形状输入、输出的场景中常用。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| outputIndex | 输出的索引值。与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输出数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,outputIndices为{4,6,8}, 则在获取输出张量维度信息的阶段,三个输出的索引值分别为{0,1,2}。 | +| shape | 指向int32_t数组的指针,数组中的每个元素值,是输出张量在每个维度上的长度。 | +| shapeLength | uint32_t类型的指针,返回输出的维数。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_Run() + + +``` +OH_NN_ReturnCode OH_NNExecutor_Run (OH_NNExecutor * executor) +``` + +**描述:** + +执行推理。 + +在执行器关联的硬件上,执行模型的端到端推理计算。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_SetInput() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetInput (OH_NNExecutor * executor, uint32_t inputIndex, const OH_NN_Tensor * tensor, const void * dataBuffer, size_t length ) +``` + +**描述:** + +设置模型单个输入的数据。 + +本方法将dataBuffer中,长度为length个字节的数据,拷贝到底层硬件的共享内存。inputIndex指定设置的输入,tensor用于设置输入的 形状、类型、量化参数等信息。 + +由于Neural Network Runtime支持动态输入形状的模型,在固定形状输入和动态形状输入的场景下,本方法采取不同的处理策略: + +- 固定形状输入的场景:tensor各属性必须和构图阶段调用[OH_NNModel_AddTensor](#oh_nnmodel_addtensor)添加的张量保持一致; + +- 动态形状输入的场景:在构图阶段,由于动态输入的形状不确定,调用本方法时,要求tensor.dimensions中的每个值必须大于0, 以确定执行计算阶段输入的形状。设置形状时,只允许调整数值为-1的维度。假设在构图阶段,输入A的维度为 [-1, 224, 224, 3],调用本方法时,只能调整第一个维度的尺寸,如:[3, 224, 224, 3]。调整其他维度将返回OH_NN_INVALID_PARAMETER。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| inputIndex | 输入的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输入数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,inputIndices为{1,5,9}, 则在设置输入的阶段,三个输入的索引值分别为{0,1,2}。 | +| tensor | 设置输入数据对应的张量。 | +| dataBuffer | 指向输入数据的指针。 | +| length | 数据缓冲区的字节长度。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_SetInputWithMemory() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetInputWithMemory (OH_NNExecutor * executor, uint32_t inputIndex, const OH_NN_Tensor * tensor, const OH_NN_Memory * memory ) +``` + +**描述:** + +将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输入使用的共享内存。 + +在需要自行管理内存的场景下,本方法将执行输入和[OH_NN_Memory](_o_h___n_n___memory.md)内存实例绑定。执行计算时,底层硬件从内存实例指向的共享内存中读取 输入数据。通过本方法,可以实现设置输入、执行计算、读取输出的并发执行,提升数据流的推理效率。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| inputIndex | 输入的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输入数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,inputIndices为{1,5,9}, 则在指定输入的共享内存时,三个输入的索引值分别为{0,1,2}。 | +| tensor | 指向[OH_NN_Tensor](_o_h___n_n___tensor.md)的指针,设置单个输入所对应的张量。 | +| memory | 指向[OH_NN_Memory](_o_h___n_n___memory.md)的指针。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_SetOutput() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetOutput (OH_NNExecutor * executor, uint32_t outputIndex, void * dataBuffer, size_t length ) +``` + +**描述:** + +设置模型单个输出的缓冲区。 + +本方法将dataBuffer指向的缓冲区与outputIndex指定的输出绑定,缓冲区的长度由length指定。 + +调用[OH_NNExecutor_Run](#oh_nnexecutor_run)完成单次模型推理后,Neural Network Runtime将比对dataBuffer指向的缓冲区与 输出数据的长度,根据不同情况,返回不同结果: + +- 如果缓冲区大于或等于数据长度:则推理后的结果将拷贝至缓冲区,并返回OH_NN_SUCCESS,可以通过访问dataBuffer读取推理结果。 + +- 如果缓冲区小于数据长度:则[OH_NNExecutor_Run](#oh_nnexecutor_run)将返回OH_NN_INVALID_PARAMETER, 并输出日志告知缓冲区太小的信息。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 指向[OH_NNExecutor](#oh_nnexecutor)实例的指针。 | +| outputIndex | 输出的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输出数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,outputIndices为{4,6,8}, 则设置输出缓冲区时,三个输出的索引值分别为{0,1,2}。 | +| dataBuffer | 指向输出数据的指针。 | +| length | 数据缓冲区的字节长度。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNExecutor_SetOutputWithMemory() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetOutputWithMemory (OH_NNExecutor * executor, uint32_t outputIndex, const OH_NN_Memory * memory ) +``` + +**描述:** + +将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输出使用的共享内存。 + +在需要自行管理内存的场景下,本方法将执行输出和[OH_NN_Memory](_o_h___n_n___memory.md)内存实例绑定。执行计算时,底层硬件将计算结果直接写入内存实例指向 的共享内存。通过本方法,可以实现设置输入、执行计算、读取输出的并发执行,提升数据流的推理效率。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| executor | 执行器。 | +| outputIndex | 输出的索引值,与调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时输出数据的顺序一致。假设调用[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)时,outputIndices为{4,6,8}, 则在指定输出的共享内存时,三个输出的索引值分别为{0,1,2}。 | +| memory | 指向[OH_NN_Memory](_o_h___n_n___memory.md)的指针。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_AddOperation() + + +``` +OH_NN_ReturnCode OH_NNModel_AddOperation (OH_NNModel * model, OH_NN_OperationType op, const OH_NN_UInt32Array * paramIndices, const OH_NN_UInt32Array * inputIndices, const OH_NN_UInt32Array * outputIndices ) +``` + +**描述:** + +向模型实例中添加算子。 + +本方法向模型实例中添加算子,算子类型由op指定,算子的参数、输入和输出由paramIndices、inputIndices和 outputIndices指定。本方法将对算子参数的属性和输入输出的数量进行校验,这些属性需要在调用 [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)添加张量的时候正确设置。每个算子期望的参数、输入和输出属性请参考 [OH_NN_OperationType](#oh_nn_operationtype)。 + +paramIndices、inputIndices和outputIndices中存储的是张量的索引值,每个索引值根据张量添加进模型的顺序决定,正确 设置并添加算子要求准确设置每个张量的索引值。张量的添加参考[OH_NNModel_AddTensor](#oh_nnmodel_addtensor)。 + +如果添加算子时,添加了额外的参数(非算子需要的参数),本方法返回OH_NN_INVALID_PARAMETER;如果没有设置算子参数, 则算子按默认值设置缺省的参数,默认值请参考[OH_NN_OperationType](#oh_nn_operationtype)。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | +| op | 指定添加的算子类型,取值请参考[OH_NN_OperationType](#oh_nn_operationtype)的枚举值。 | +| paramIndices | OH_NN_UInt32Array实例的指针,设置算子的参数。 | +| inputIndices | OH_NN_UInt32Array实例的指针,指定算子的输入。 | +| outputIndices | OH_NN_UInt32Array实例的指针,设置算子的输出。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_AddTensor() + + +``` +OH_NN_ReturnCode OH_NNModel_AddTensor (OH_NNModel * model, const OH_NN_Tensor * tensor ) +``` + +**描述:** + +向模型实例中添加张量。 + +Neural Network Runtime模型中的数据节点和算子参数均由模型的张量构成。本方法根据tensor,向model实 例中添加张量。张量添加的顺序是模型中记录张量的索引值,[OH_NNModel_SetTensorData](#oh_nnmodel_settensordata)、 [OH_NNModel_AddOperation](#oh_nnmodel_addoperation)和[OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) 方法根据该索引值,指定不同的张量。 + +Neural Network Runtime支持动态形状输入和输出。在添加动态形状的数据节点时,需要将tensor.dimensions中支持动态 变化的维度设置为-1。例如:一个四维tensor,将tensor.dimensions设置为[1, -1, 2, 2],表示其第二个维度支持 动态变化。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | +| tensor | [OH_NN_Tensor](_o_h___n_n___tensor.md)张量的指针,tensor指定了添加到模型实例中张量的属性。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_Construct() + + +``` +OH_NNModel* OH_NNModel_Construct (void ) +``` + +**描述:** + +创建[OH_NNModel](#oh_nnmodel)类型的模型实例,搭配OH_NNModel模块提供的其他接口,完成模型实例的构造。 + +在开始构图前,先调用[OH_NNModel_Construct](#oh_nnmodel_construct)创建模型实例,根据模型的拓扑结构,调用 [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)、[OH_NNModel_AddOperation](#oh_nnmodel_addoperation)和 [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata)方法,填充模型的数据节点和算子节点;然后调用 [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)指定模型的输入和输出;当构造完模型的拓扑结构,调用 [OH_NNModel_Finish](#oh_nnmodel_finish)完成模型的构建。 + +模型实例使用完毕后,需要调用[OH_NNModel_Destroy](#oh_nnmodel_destroy)销毁模型实例,避免内存泄漏。 + +**返回:** + +返回一个指向[OH_NNModel](#oh_nnmodel)实例的指针。 + + +### OH_NNModel_Destroy() + + +``` +void OH_NNModel_Destroy (OH_NNModel ** model) +``` + +**描述:** + +释放模型实例。 + +调用[OH_NNModel_Construct](#oh_nnmodel_construct)创建的模型实例需要调用本方法主动释放,否则将造成内存泄漏。 + +如果model为空指针或者\*model为空指针,本方法只打印warning日志,不执行释放逻辑。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的二级指针。模型实例销毁后,本方法将\*model主动设置为空指针。 | + + +### OH_NNModel_Finish() + + +``` +OH_NN_ReturnCode OH_NNModel_Finish (OH_NNModel * model) +``` + +**描述:** + +完成模型构图。 + +完成模型拓扑结构的搭建后,调用本方法指示构图已完成。 + +在调用本方法后,无法进行额外的构图操作,调用 [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)、[OH_NNModel_AddOperation](#oh_nnmodel_addoperation)、 [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata)和 [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs)将返回OH_NN_OPERATION_FORBIDDEN。 + +在调用[OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations)和[OH_NNCompilation_Construct](#oh_nncompilation_construct) 之前,必须先调用本方法完成构图。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_GetAvailableOperations() + + +``` +OH_NN_ReturnCode OH_NNModel_GetAvailableOperations (OH_NNModel * model, size_t deviceID, const bool ** isSupported, uint32_t * opCount ) +``` + +**描述:** + +查询硬件对模型内所有算子的支持情况,通过布尔值序列指示支持情况。 + +查询底层硬件对模型实例内每个算子的支持情况,硬件由deviceID指定,结果将通过isSupported指向的数组表示。如果支持第i个算子,则 (\*isSupported)[i] == true,否则为 false。 + +本方法成功执行后,(\*isSupported)将指向记录算子支持情况的bool数组,数组长度和模型实例的算子数量相等。该数组对应的内存由 Neural Network Runtime管理,在模型实例销毁或再次调用本方法后自动销毁。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | +| deviceID | 指定查询的硬件ID,通过[OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid)获取。 | +| isSupported | 指向bool数组的指针。调用本方法时,要求(\*isSupported)为空指针,否则返回OH_NN_INVALID_PARAMETER。 | +| opCount | 模型实例中算子的数量,对应(\*isSupported)数组的长度。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_SetTensorData() + + +``` +OH_NN_ReturnCode OH_NNModel_SetTensorData (OH_NNModel * model, uint32_t index, const void * dataBuffer, size_t length ) +``` + +**描述:** + +设置张量的数值。 + +对于具有常量值的张量(如模型的权重),需要在构图阶段使用本方法设置数值。张量的索引值根据张量添加进模型的顺序决定,张量的添加参考 [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | +| index | 张量的索引值。 | +| dataBuffer | 指向真实数据的指针。 | +| length | 数据缓冲区的长度。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 + + +### OH_NNModel_SpecifyInputsAndOutputs() + + +``` +OH_NN_ReturnCode OH_NNModel_SpecifyInputsAndOutputs (OH_NNModel * model, const OH_NN_UInt32Array * inputIndices, const OH_NN_UInt32Array * outputIndices ) +``` + +**描述:** + +指定模型的输入输出。 + +模型实例需要指定张量作为端到端的输入和输出,设置为输入和输出的张量不能使用[OH_NNModel_SetTensorData](#oh_nnmodel_settensordata)设置 数值,需要在执行阶段调用OH_NNExecutor的方法设置输入、输出数据。 + +张量的索引值根据张量添加进模型的顺序决定,张量的添加参考 [OH_NNModel_AddTensor](#oh_nnmodel_addtensor)。 + +暂时不支持异步设置模型输入输出。 + +**参数:** + +| 名称 | 描述 | +| -------- | -------- | +| model | 指向[OH_NNModel](#oh_nnmodel)实例的指针。 | +| inputIndices | OH_NN_UInt32Array实例的指针,指定算子的输入。 | +| outputIndices | OH_NN_UInt32Array实例的指针,指定算子的输出。 | + +**返回:** + +函数执行的结果状态。执行成功返回OH_NN_SUCCESS;失败返回具体错误码,具体失败错误码可参考[OH_NN_ReturnCode](#oh_nn_returncode)。 diff --git a/zh-cn/application-dev/reference/native-apis/_o_h___n_n___memory.md b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___memory.md new file mode 100644 index 0000000000000000000000000000000000000000..9e662630edbdf808026ecd5563b7216fff20eec7 --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___memory.md @@ -0,0 +1,52 @@ +# OH_NN_Memory + + +## 概述 + +内存结构体。 + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 成员变量 + +| 成员变量名称 | 描述 | +| -------- | -------- | +| [data](#data) | 指向共享内存的指针,该共享内存通常由底层硬件驱动申请。 | +| [length](#length) | 记录共享内存的字节长度。 | + + +## 结构体成员变量说明 + + +### data + + +``` +void* const OH_NN_Memory::data +``` + +**描述:** + +指向共享内存的指针,该共享内存通常由底层硬件驱动申请。 + + +### length + + +``` +const size_t OH_NN_Memory::length +``` + +**描述:** + +记录共享内存的字节长度。 diff --git a/zh-cn/application-dev/reference/native-apis/_o_h___n_n___quant_param.md b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___quant_param.md new file mode 100644 index 0000000000000000000000000000000000000000..ec04d118dee19a267067a85be49a328aacd77a61 --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___quant_param.md @@ -0,0 +1,94 @@ +# OH_NN_QuantParam + + +## 概述 + +量化信息。 + +在量化的场景中,32位浮点型数据根据以下公式量化为定点数据: + +![zh-cn_formulaimage_0000001405137102](figures/zh-cn_formulaimage_0000001405137102.png) + +其中s和z是量化参数,在OH_NN_QuanParam中通过scale和zeroPoint保存,r是浮点数,q是量化后的结果,q_min是量化后下界,q_max是量化后的上界,计算方式如下: + +![zh-cn_formulaimage_0000001459019845](figures/zh-cn_formulaimage_0000001459019845.png) + +![zh-cn_formulaimage_0000001408820090](figures/zh-cn_formulaimage_0000001408820090.png) + +clamp函数定义如下: + +![zh-cn_formulaimage_0000001455538697](figures/zh-cn_formulaimage_0000001455538697.png) + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 成员变量 + +| 成员变量名称 | 描述 | +| -------- | -------- | +| [quantCount](#quantcount) | 指定numBits、scale和zeroPoint数组的长度。
在per-layer量化的场景下,quantCount通常指定为1,即一个张量所有通道共享一套量化参数;在per-channel量化场景下,quantCount通常和张量通道数一致,每个通道使用自己的量化参数。 | +| [numBits](#numbits) | 量化位数。 | +| [scale](#scale) | 指向量化公式中量化参数s的指针。 | +| [zeroPoint](#zeropoint) | 指向量化公式中量化参数z的指针。 | + + +## 结构体成员变量说明 + + +### numBits + + +``` +const uint32_t* OH_NN_QuantParam::numBits +``` + +**描述:** + +量化位数。 + + +### quantCount + + +``` +uint32_t OH_NN_QuantParam::quantCount +``` + +**描述:** + +指定numBits、scale和zeroPoint数组的长度。 + +在per-layer量化的场景下,quantCount通常指定为1,即一个张量所有通道 共享一套量化参数;在per-channel量化场景下,quantCount通常和张量通道数一致,每个通道使用自己的量化参数。 + + +### scale + + +``` +const double* OH_NN_QuantParam::scale +``` + +**描述:** + +指向量化公式中scale数据的指针。 + + +### zeroPoint + + +``` +const int32_t* OH_NN_QuantParam::zeroPoint +``` + +**描述:** + +指向量化公式中zero point数据的指针。 diff --git a/zh-cn/application-dev/reference/native-apis/_o_h___n_n___tensor.md b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___tensor.md new file mode 100644 index 0000000000000000000000000000000000000000..43580162dd374006014edea77b9f2ded88a2af20 --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___tensor.md @@ -0,0 +1,97 @@ +# OH_NN_Tensor + + +## 概述 + +张量结构体。 + +通常用于构造模型图中的数据节点和算子参数,在构造张量时需要明确数据类型、维数、维度信息和量化信息。 + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 成员变量 + +| 成员变量名称 | 描述 | +| -------- | -------- | +| [dataType](#datatype) | 指定张量的数据类型,要求从[OH_NN_DataType](_neural_nework_runtime.md#ohnndatatype)枚举类型中取值。 | +| [dimensionCount](#dimensioncount) | 指定张量的维数。 | +| [dimensions](#dimensions) | 指定张量的维度信息(形状)。 | +| [quantParam](#quantparam) | 指定张量的量化信息,数据类型要求为[OH_NN_QuantParam](_o_h___n_n___quant_param.md)。 | +| [type](#type) | 指定张量的类型,type的取值和张量的用途相关。
当张量作为模型的输入或输出,则要求type设置为OH_NN_TENSOR;
当张量作为算子参数,则要求从[OH_NN_TensorType](_neural_nework_runtime.md#ohnntensortype)枚举类型中选择除OH_NN_TENSOR之外的合适的枚举值。 | + + +## 结构体成员变量说明 + + +### dataType + + +``` +OH_NN_DataType OH_NN_Tensor::dataType +``` + +**描述:** + +指定张量的数据类型,要求从[OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype)枚举类型中取值。 + + +### dimensionCount + + +``` +uint32_t OH_NN_Tensor::dimensionCount +``` + +**描述:** + +指定张量的维数。 + + +### dimensions + + +``` +const int32_t* OH_NN_Tensor::dimensions +``` + +**描述:** + +指定张量的维度信息(形状)。 + + +### quantParam + + +``` +const OH_NN_QuantParam* OH_NN_Tensor::quantParam +``` + +**描述:** + +指定张量的量化信息,数据类型要求为[OH_NN_QuantParam](_o_h___n_n___quant_param.md)。 + + +### type + + +``` +OH_NN_TensorType OH_NN_Tensor::type +``` + +**描述:** + +指定张量的类型,type的取值和张量的用途相关。 + +当张量作为模型的输入或输出,则要求type设置为OH_NN_TENSOR; + +当张量作为算子参数,则要求从[OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype)枚举类型中选择除OH_NN_TENSOR之外的合适的枚举值。 diff --git a/zh-cn/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md new file mode 100644 index 0000000000000000000000000000000000000000..7b8ffb3d241c4fd1e0da3c5790240bbce97e12f7 --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md @@ -0,0 +1,52 @@ +# OH_NN_UInt32Array + + +## 概述 + +该结构体用于存储32位无符号整型数组。 + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 成员变量 + +| 成员变量名称 | 描述 | +| -------- | -------- | +| [data](#data) | 无符号整型数组的指针。 | +| [size](#size) | 数组长度。 | + + +## 结构体成员变量说明 + + +### data + + +``` +uint32_t* OH_NN_UInt32Array::data +``` + +**描述:** + +无符号整型数组的指针。 + + +### size + + +``` +uint32_t OH_NN_UInt32Array::size +``` + +**描述:** + +数组长度。 diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001405137102.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001405137102.png new file mode 100644 index 0000000000000000000000000000000000000000..46347066443a2459f195afcf71871493593c621a Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001405137102.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001408820090.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001408820090.png new file mode 100644 index 0000000000000000000000000000000000000000..0a2eaf5929a455793d034e3cca4ce48f74e9615c Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001408820090.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001410679330.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001410679330.png new file mode 100644 index 0000000000000000000000000000000000000000..954fd83c82f9af44663db79f28f72b3bc1c6531a Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001410679330.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001455538697.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001455538697.png new file mode 100644 index 0000000000000000000000000000000000000000..954fd83c82f9af44663db79f28f72b3bc1c6531a Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001455538697.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001459019845.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001459019845.png new file mode 100644 index 0000000000000000000000000000000000000000..168f0c40140b31dae728b2be37152eaaaf28b2a6 Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001459019845.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460519245.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460519245.png new file mode 100644 index 0000000000000000000000000000000000000000..46347066443a2459f195afcf71871493593c621a Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460519245.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460639441.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460639441.png new file mode 100644 index 0000000000000000000000000000000000000000..0a2eaf5929a455793d034e3cca4ce48f74e9615c Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460639441.png differ diff --git a/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460759081.png b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460759081.png new file mode 100644 index 0000000000000000000000000000000000000000..168f0c40140b31dae728b2be37152eaaaf28b2a6 Binary files /dev/null and b/zh-cn/application-dev/reference/native-apis/figures/zh-cn_formulaimage_0000001460759081.png differ diff --git a/zh-cn/application-dev/reference/native-apis/neural__network__runtime_8h.md b/zh-cn/application-dev/reference/native-apis/neural__network__runtime_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7a0de6290cca74829d0b26972e4016b55847db4b --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/neural__network__runtime_8h.md @@ -0,0 +1,54 @@ +# neural_network_runtime.h + + +## 概述 + +Neural Network Runtime部件接口定义,AI推理框架通过Neural Network Runtime提供的Native接口,完成模型构造与编译,并在加速硬件上执行推理计算。 + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 函数 + +| 函数名称 | 描述 | +| -------- | -------- | +| [OH_NNModel_Construct](_neural_nework_runtime.md#oh_nnmodel_construct) (void) | 创建[OH_NNModel](_neural_nework_runtime.md#oh_nnmodel)类型的模型实例,搭配OH_NNModel模块提供的其他接口,完成模型实例的构造。 | +| [OH_NNModel_AddTensor](_neural_nework_runtime.md#oh_nnmodel_addtensor) (OH_NNModel \*model, const OH_NN_Tensor \*tensor) | 向模型实例中添加张量。 | +| [OH_NNModel_SetTensorData](_neural_nework_runtime.md#oh_nnmodel_settensordata) (OH_NNModel \*model, uint32_t index, const void \*dataBuffer, size_t length) | 设置张量的数值。 | +| [OH_NNModel_AddOperation](_neural_nework_runtime.md#oh_nnmodel_addoperation) (OH_NNModel \*model, OH_NN_OperationType op, const OH_NN_UInt32Array \*paramIndices, const OH_NN_UInt32Array \*inputIndices, const OH_NN_UInt32Array \*outputIndices) | 向模型实例中添加算子。 | +| [OH_NNModel_SpecifyInputsAndOutputs](_neural_nework_runtime.md#oh_nnmodel_specifyinputsandoutputs) (OH_NNModel \*model, const OH_NN_UInt32Array \*inputIndices, const OH_NN_UInt32Array \*outputIndices) | 指定模型的输入输出。 | +| [OH_NNModel_Finish](_neural_nework_runtime.md#oh_nnmodel_finish) (OH_NNModel \*model) | 完成模型构图。 | +| [OH_NNModel_Destroy](_neural_nework_runtime.md#oh_nnmodel_destroy) (OH_NNModel \*\*model) | 释放模型实例。 | +| [OH_NNModel_GetAvailableOperations](_neural_nework_runtime.md#oh_nnmodel_getavailableoperations) (OH_NNModel \*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | 查询硬件对模型内所有算子的支持情况,通过布尔值序列指示支持情况。 | +| [OH_NNCompilation_Construct](_neural_nework_runtime.md#oh_nncompilation_construct) (const OH_NNModel \*model) | 创建[OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation)类型的编译实例。 | +| [OH_NNCompilation_SetDevice](_neural_nework_runtime.md#oh_nncompilation_setdevice) (OH_NNCompilation \*compilation, size_t deviceID) | 指定模型编译和计算的硬件。 | +| [OH_NNCompilation_SetCache](_neural_nework_runtime.md#oh_nncompilation_setcache) (OH_NNCompilation \*compilation, const char \*cachePath, uint32_t version) | 设置编译后的模型缓存路径和缓存版本。 | +| [OH_NNCompilation_SetPerformanceMode](_neural_nework_runtime.md#oh_nncompilation_setperformancemode) (OH_NNCompilation \*compilation, OH_NN_PerformanceMode performanceMode) | 设置模型计算的性能模式。 | +| [OH_NNCompilation_SetPriority](_neural_nework_runtime.md#oh_nncompilation_setpriority) (OH_NNCompilation \*compilation, OH_NN_Priority priority) | 设置模型计算的优先级。 | +| [OH_NNCompilation_EnableFloat16](_neural_nework_runtime.md#oh_nncompilation_enablefloat16) (OH_NNCompilation \*compilation, bool enableFloat16) | 是否以float16的浮点数精度计算。 | +| [OH_NNCompilation_Build](_neural_nework_runtime.md#oh_nncompilation_build) (OH_NNCompilation \*compilation) | 进行模型编译。 | +| [OH_NNCompilation_Destroy](_neural_nework_runtime.md#oh_nncompilation_destroy) (OH_NNCompilation \*\*compilation) | 释放Compilation对象。 | +| [OH_NNExecutor_Construct](_neural_nework_runtime.md#oh_nnexecutor_construct) (OH_NNCompilation \*compilation) | 创建[OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor)类型的执行器实例。 | +| [OH_NNExecutor_SetInput](_neural_nework_runtime.md#oh_nnexecutor_setinput) (OH_NNExecutor \*executor, uint32_t inputIndex, const OH_NN_Tensor \*tensor, const void \*dataBuffer, size_t length) | 设置模型单个输入的数据。 | +| [OH_NNExecutor_SetOutput](_neural_nework_runtime.md#oh_nnexecutor_setoutput) (OH_NNExecutor \*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | 设置模型单个输出的缓冲区。 | +| [OH_NNExecutor_GetOutputShape](_neural_nework_runtime.md#oh_nnexecutor_getoutputshape) (OH_NNExecutor \*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | 获取输出张量的维度信息。 | +| [OH_NNExecutor_Run](_neural_nework_runtime.md#oh_nnexecutor_run) (OH_NNExecutor \*executor) | 执行推理。 | +| [OH_NNExecutor_AllocateInputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateinputmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, size_t length) | 在硬件上为单个输入申请共享内存。 | +| [OH_NNExecutor_AllocateOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateoutputmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, size_t length) | 在硬件上为单个输出申请共享内存。 | +| [OH_NNExecutor_DestroyInputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyinputmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, OH_NN_Memory \*\*memory) | 释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输入内存。 | +| [OH_NNExecutor_DestroyOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyoutputmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, OH_NN_Memory \*\*memory) | 释放[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的输出内存。 | +| [OH_NNExecutor_SetInputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setinputwithmemory) (OH_NNExecutor \*executor, uint32_t inputIndex, const OH_NN_Tensor \*tensor, const OH_NN_Memory \*memory) | 将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输入使用的共享内存。 | +| [OH_NNExecutor_SetOutputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setoutputwithmemory) (OH_NNExecutor \*executor, uint32_t outputIndex, const OH_NN_Memory \*memory) | 将[OH_NN_Memory](_o_h___n_n___memory.md)实例指向的硬件共享内存,指定为单个输出使用的共享内存。 | +| [OH_NNExecutor_Destroy](_neural_nework_runtime.md#oh_nnexecutor_destroy) (OH_NNExecutor \*\*executor) | 销毁执行器实例,释放执行器占用的内存。 | +| [OH_NNDevice_GetAllDevicesID](_neural_nework_runtime.md#oh_nndevice_getalldevicesid) (const size_t \*\*allDevicesID, uint32_t \*deviceCount) | 获取对接到 Neural Network Runtime 的硬件ID。 | +| [OH_NNDevice_GetName](_neural_nework_runtime.md#oh_nndevice_getname) (size_t deviceID, const char \*\*name) | 获取指定硬件的类型信息。 | +| [OH_NNDevice_GetType](_neural_nework_runtime.md#oh_nndevice_gettype) (size_t deviceID, [OH_NN_DeviceType](_neural_nework_runtime.md#oh_nn_devicetype) \*deviceType) | 获取指定硬件的类别信息。 | diff --git a/zh-cn/application-dev/reference/native-apis/neural__network__runtime__type_8h.md b/zh-cn/application-dev/reference/native-apis/neural__network__runtime__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..542c8fc8c0361244f772edfc7f54818473ece6af --- /dev/null +++ b/zh-cn/application-dev/reference/native-apis/neural__network__runtime__type_8h.md @@ -0,0 +1,55 @@ +# neural_network_runtime_type.h + + +## 概述 + +Neural Network Runtime定义的结构体和枚举值。 + +**起始版本:** + +9 + +**相关模块:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## 汇总 + + +### 结构体 + +| 结构体名称 | 描述 | +| -------- | -------- | +| [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) | 自定义的32位无符号整型数组类型。 | +| [OH_NN_QuantParam](_o_h___n_n___quant_param.md) | 量化信息。 | +| [OH_NN_Tensor](_o_h___n_n___tensor.md) | 张量结构体。 | +| [OH_NN_Memory](_o_h___n_n___memory.md) | 内存结构体。 | + + +### 类型定义 + +| 类型定义名称 | 描述 | +| -------- | -------- | +| [OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) | Neural Network Runtime的模型句柄。 | +| [OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) | Neural Network Runtime的编译器句柄。 | +| [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) | Neural Network Runtime的执行器句柄。 | +| [OH_NN_UInt32Array](_neural_nework_runtime.md#oh_nn_uint32array) | 自定义的32位无符号整型数组类型。 | +| [OH_NN_QuantParam](_neural_nework_runtime.md#oh_nn_quantparam) | 量化信息。 | +| [OH_NN_Tensor](_neural_nework_runtime.md#oh_nn_tensor) | 张量结构体。 | +| [OH_NN_Memory](_neural_nework_runtime.md#oh_nn_memory) | 内存结构体。 | + + +### 枚举 + +| 枚举名称 | 描述 | +| -------- | -------- | +| [OH_NN_PerformanceMode](_neural_nework_runtime.md#oh_nn_performancemode) { OH_NN_PERFORMANCE_NONE = 0, OH_NN_PERFORMANCE_LOW = 1, OH_NN_PERFORMANCE_MEDIUM = 2, OH_NN_PERFORMANCE_HIGH = 3, OH_NN_PERFORMANCE_EXTREME = 4 } | 硬件的性能模式。 | +| [OH_NN_Priority](_neural_nework_runtime.md#oh_nn_priority) { OH_NN_PRIORITY_NONE = 0, OH_NN_PRIORITY_LOW = 1, OH_NN_PRIORITY_MEDIUM = 2, OH_NN_PRIORITY_HIGH = 3 } | 模型推理任务优先级。 | +| [OH_NN_ReturnCode](_neural_nework_runtime.md#oh_nn_returncode) { OH_NN_SUCCESS = 0, OH_NN_FAILED = 1, OH_NN_INVALID_PARAMETER = 2, OH_NN_MEMORY_ERROR = 3, OH_NN_OPERATION_FORBIDDEN = 4, OH_NN_NULL_PTR = 5, OH_NN_INVALID_FILE = 6, OH_NN_UNAVALIDABLE_DEVICE = 7, OH_NN_INVALID_PATH = 8 } | Neural Network Runtime定义的错误码类型。 | +| [OH_NN_FuseType](_neural_nework_runtime.md#oh_nn_fusetype) : int8_t { OH_NN_FUSED_NONE = 0, OH_NN_FUSED_RELU = 1, OH_NN_FUSED_RELU6 = 2 } | Neural Network Runtime融合算子中激活函数的类型。 | +| [OH_NN_Format](_neural_nework_runtime.md#oh_nn_format) { OH_NN_FORMAT_NONE = 0, OH_NN_FORMAT_NCHW = 1, OH_NN_FORMAT_NHWC = 2 } | 张量数据的排布类型。 | +| [OH_NN_DeviceType](_neural_nework_runtime.md#oh_nn_devicetype) { OH_NN_OTHERS = 0, OH_NN_CPU = 1, OH_NN_GPU = 2, OH_NN_ACCELERATOR = 3 } | Neural Network Runtime支持的设备类型。 | +| [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype) { OH_NN_UNKNOWN = 0, OH_NN_BOOL = 1, OH_NN_INT8 = 2, OH_NN_INT16 = 3, OH_NN_INT32 = 4, OH_NN_INT64 = 5, OH_NN_UINT8 = 6, OH_NN_UINT16 = 7, OH_NN_UINT32 = 8, OH_NN_UINT64 = 9, OH_NN_FLOAT16 = 10, OH_NN_FLOAT32 = 11, OH_NN_FLOAT64 = 12 } | Neural Network Runtime支持的数据类型。 | +| [OH_NN_OperationType](_neural_nework_runtime.md#oh_nn_operationtype) { OH_NN_OPS_ADD = 1, OH_NN_OPS_AVG_POOL = 2, OH_NN_OPS_BATCH_NORM = 3, OH_NN_OPS_BATCH_TO_SPACE_ND = 4, OH_NN_OPS_BIAS_ADD = 5, OH_NN_OPS_CAST = 6, OH_NN_OPS_CONCAT = 7, OH_NN_OPS_CONV2D = 8, OH_NN_OPS_CONV2D_TRANSPOSE = 9, OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, OH_NN_OPS_DIV = 11, OH_NN_OPS_ELTWISE = 12, OH_NN_OPS_EXPAND_DIMS = 13, OH_NN_OPS_FILL = 14, OH_NN_OPS_FULL_CONNECTION = 15, OH_NN_OPS_GATHER = 16, OH_NN_OPS_HSWISH = 17, OH_NN_OPS_LESS_EQUAL = 18, OH_NN_OPS_MATMUL = 19, OH_NN_OPS_MAXIMUM = 20, OH_NN_OPS_MAX_POOL = 21, OH_NN_OPS_MUL = 22, OH_NN_OPS_ONE_HOT = 23, OH_NN_OPS_PAD = 24, OH_NN_OPS_POW = 25, OH_NN_OPS_SCALE = 26, OH_NN_OPS_SHAPE = 27, OH_NN_OPS_SIGMOID = 28, OH_NN_OPS_SLICE = 29, OH_NN_OPS_SOFTMAX = 30, OH_NN_OPS_SPACE_TO_BATCH_ND = 31, OH_NN_OPS_SPLIT = 32, OH_NN_OPS_SQRT = 33, OH_NN_OPS_SQUARED_DIFFERENCE = 34, OH_NN_OPS_SQUEEZE = 35, OH_NN_OPS_STACK = 36, OH_NN_OPS_STRIDED_SLICE = 37, OH_NN_OPS_SUB = 38, OH_NN_OPS_TANH = 39, OH_NN_OPS_TILE = 40, OH_NN_OPS_TRANSPOSE = 41, OH_NN_OPS_REDUCE_MEAN = 42, OH_NN_OPS_RESIZE_BILINEAR = 43, OH_NN_OPS_RSQRT = 44, OH_NN_OPS_RESHAPE = 45, OH_NN_OPS_PRELU = 46, OH_NN_OPS_RELU = 47, OH_NN_OPS_RELU6 = 48, OH_NN_OPS_LAYER_NORM = 49, OH_NN_OPS_REDUCE_PROD = 50, OH_NN_OPS_REDUCE_ALL = 51, OH_NN_OPS_QUANT_DTYPE_CAST = 52, OH_NN_OPS_TOP_K = 53, OH_NN_OPS_ARG_MAX = 54, OH_NN_OPS_UNSQUEEZE = 55, OH_NN_OPS_GELU = 56 } | Neural Network Runtime支持算子的类型。 | +| [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype) { OH_NN_TENSOR = 0, OH_NN_ADD_ACTIVATIONTYPE = 1, OH_NN_AVG_POOL_KERNEL_SIZE = 2, OH_NN_AVG_POOL_STRIDE = 3, OH_NN_AVG_POOL_PAD_MODE = 4, OH_NN_AVG_POOL_PAD = 5, OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, OH_NN_BATCH_NORM_EPSILON = 7, OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, OH_NN_CONCAT_AXIS = 10, OH_NN_CONV2D_STRIDES = 11, OH_NN_CONV2D_PAD = 12, OH_NN_CONV2D_DILATION = 13, OH_NN_CONV2D_PAD_MODE = 14, OH_NN_CONV2D_ACTIVATION_TYPE = 15, OH_NN_CONV2D_GROUP = 16, OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, OH_NN_CONV2D_TRANSPOSE_PAD = 18, OH_NN_CONV2D_TRANSPOSE_DILATION = 19, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, OH_NN_CONV2D_TRANSPOSE_GROUP = 23, OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27, OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, OH_NN_DIV_ACTIVATIONTYPE = 29, OH_NN_ELTWISE_MODE = 30, OH_NN_FULL_CONNECTION_AXIS = 31, OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, OH_NN_MATMUL_TRANSPOSE_A = 33, OH_NN_MATMUL_TRANSPOSE_B = 34, OH_NN_MATMUL_ACTIVATION_TYPE = 35, OH_NN_MAX_POOL_KERNEL_SIZE = 36, OH_NN_MAX_POOL_STRIDE = 37, OH_NN_MAX_POOL_PAD_MODE = 38, OH_NN_MAX_POOL_PAD = 39, OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, OH_NN_MUL_ACTIVATION_TYPE = 41, OH_NN_ONE_HOT_AXIS = 42, OH_NN_PAD_CONSTANT_VALUE = 43, OH_NN_SCALE_ACTIVATIONTYPE = 44, OH_NN_SCALE_AXIS = 45, OH_NN_SOFTMAX_AXIS = 46, OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47, OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, OH_NN_SPLIT_AXIS = 49, OH_NN_SPLIT_OUTPUT_NUM = 50, OH_NN_SPLIT_SIZE_SPLITS = 51, OH_NN_SQUEEZE_AXIS = 52, OH_NN_STACK_AXIS = 53, OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, OH_NN_STRIDED_SLICE_END_MASK = 55, OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, OH_NN_SUB_ACTIVATIONTYPE = 59, OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63, OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, OH_NN_LAYER_NORM_EPSILON = 67, OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, OH_NN_REDUCE_PROD_KEEP_DIMS = 70, OH_NN_REDUCE_ALL_KEEP_DIMS = 71, OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, OH_NN_QUANT_DTYPE_CAST_DST_T = 73, OH_NN_TOP_K_SORTED = 74, OH_NN_ARG_MAX_AXIS = 75, OH_NN_ARG_MAX_KEEPDIMS = 76, OH_NN_UNSQUEEZE_AXIS = 77 } | 张量的类型。 | diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md index 342754163710cdcd1481f51b796fffd56400bce0..70de82b8a93e26d99d7c5e540d2beeeb9eb8383d 100644 --- a/zh-cn/application-dev/security/accesstoken-guidelines.md +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -14,6 +14,8 @@ > > 当权限校验结果显示当前应用尚未被授权该权限时,再通过动态弹框授权方式给用户提供手动授权入口。 +应用可申请的权限,可查询[应用权限列表](permission-list.md) + ## 接口说明 以下仅列举本指导使用的接口,更多说明可以查阅[API参考](../reference/apis/js-apis-ability-context.md)。 diff --git a/zh-cn/application-dev/security/app-provision-structure.md b/zh-cn/application-dev/security/app-provision-structure.md index a0bc15058289791d98d02b48bb1ff499d79e5faf..da778e038302f22d35be5c23f986eae6931602cc 100644 --- a/zh-cn/application-dev/security/app-provision-structure.md +++ b/zh-cn/application-dev/security/app-provision-structure.md @@ -66,12 +66,12 @@ HarmonyAppProvision文件示例: | development-certificate | 表示[调试证书](hapsigntool-guidelines.md)的信息。 | 数值 | 当type属性为debug时,该属性必选;否则,该属性可选。 | 不可缺省 | | distribution-certificate | 表示[发布证书](hapsigntool-guidelines.md)的信息。 | 数值 | 当type属性为release时,该标签必选;否则,该标签可选。 | 不可缺省 | | bundle-name | 表示应用程序的包名。 | 字符串 | 必选 | 不可缺省 | -| apl | 表示应用程序的[apl级别](accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core。 | 字符串 | 必选 | 不可缺省 | +| apl | 表示应用程序的[APL级别](accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core。 | 字符串 | 必选 | 不可缺省 | | app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用)。只有系统应用才允许调用系统API,普通应用调用系统API可能会调用失败或运行异常。 | 字符串 | 必选 | 不可缺省 | ### acls对象内部结构 -acls对象包含已授权的[acl权限](accesstoken-overview.md)。需要指出的是,开发者仍然需要在应用包配置文件([config.json](../quick-start/package-structure.md))将acls权限信息填写到reqPermissions属性中。 +acls对象包含已授权的[ACL权限](accesstoken-overview.md)。需要指出的是,开发者仍然需要在应用包配置文件([config.json](../quick-start/package-structure.md))将acls权限信息填写到reqPermissions属性中。 表4 acls对象的内部结构 | 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | @@ -93,4 +93,19 @@ debug-info对象包含应用调试场景下的信息,主要是设备管控的 | 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | | ------------------------ | ------------------------------- | ------- | ------- | --------- | | device-id-type | 表示设备ID的类型,当前系统仅提供udid的设备ID类型。 | 字符串 | 可选 | 不可缺省 | -| device-ids | 表示应用调试场景下允许调试的设备ID列表。 | 字符串数组 | 可选 | 不可缺省 | \ No newline at end of file +| device-ids | 表示应用调试场景下允许调试的设备ID列表。 | 字符串数组 | 可选 | 不可缺省 | + +## 修改HarmonyAppProvision配置文件 + +当开发者新建一个工程时,应用的类型默认为hos_normal_app(普通应用),APL级别默认为normal。 + +当需要使用系统API时,开发者需要手动修改app-feature字段为hos_system_app(系统应用);当需要申请高级别权限时,开发者可能需要修改apl、acl等字段,请根据实际需要,参考[访问控制开发概述](accesstoken-overview.md)进行修改。 + + +开发者可以参考以下步骤,修改HarmonyAppProvision配置文件。 + +1. 打开OpenHarmony SDK所在目录(可通过DevEco Studio菜单栏中单击File > Settings > OpenHarmony SDK界面查看 )。 +2. 在SDK目录下,进入Toolchains > {Version} > lib文件夹,打开“UnsgnedReleasedProfileTemplate.json”文件。 +3. 根据实际需求,修改对应的字段。 + +完成配置文件修改后,开发者可以参考[Hap包签名工具使用指导](hapsigntool-overview.md)进行应用签名。 \ No newline at end of file diff --git a/zh-cn/application-dev/security/cryptoFramework-guidelines.md b/zh-cn/application-dev/security/cryptoFramework-guidelines.md index a282c7b7c6113719ca57af818846887e20ce5f19..d4f34d7421fd77a54ba7a17408c252f6696cb4ec 100644 --- a/zh-cn/application-dev/security/cryptoFramework-guidelines.md +++ b/zh-cn/application-dev/security/cryptoFramework-guidelines.md @@ -13,7 +13,7 @@ 1. 随机生成算法库密钥对象。该对象可用于后续的加解密等操作。 2. 根据指定数据生成算法库密钥对象(也就是将外部或存储的二进制数据转换为算法库的密钥对象)。该对象可用于后续的加解密等操作。 3. 获取算法库密钥对象的二进制数据,用于存储或传输。 -> **说明**:密钥对象Key包括对称密钥SymKey和非对称密钥(公钥PubKey和私钥PriKey),其中公钥和私钥组成密钥对KeyPair。密钥之间的具体关系可参考[接口声明](../reference/apis/js-apis-cryptoFramework.md)。 +> **说明**:密钥对象Key包括对称密钥SymKey和非对称密钥(公钥PubKey和私钥PriKey),其中公钥和私钥组成密钥对KeyPair。密钥之间的具体关系可参考[API参考](../reference/apis/js-apis-cryptoFramework.md)。 **接口及参数说明** @@ -107,7 +107,7 @@ function testGenerateAesKey() { import cryptoFramework from '@ohos.security.cryptoFramework'; function convertAsyKey() { - let rsaGenerator = cfm.createAsyKeyGenerator("RSA1024"); + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024"); let pkval = new Uint8Array([48,129,159,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,129,141,0,48,129,137,2,129,129,0,174,203,113,83,113,3,143,213,194,79,91,9,51,142,87,45,97,65,136,24,166,35,5,179,42,47,212,79,111,74,134,120,73,67,21,19,235,80,46,152,209,133,232,87,192,140,18,206,27,106,106,169,106,46,135,111,118,32,129,27,89,255,183,116,247,38,12,7,238,77,151,167,6,102,153,126,66,28,253,253,216,64,20,138,117,72,15,216,178,37,208,179,63,204,39,94,244,170,48,190,21,11,73,169,156,104,193,3,17,100,28,60,50,92,235,218,57,73,119,19,101,164,192,161,197,106,105,73,2,3,1,0,1]); let pkBlob = {data : pkval}; rsaGenerator.convertKey(pkBlob, null, function(err, keyPair) { @@ -262,14 +262,14 @@ function stringToUint8Array(str) { return new Uint8Array(arr); } -// 字节流转成可理解的字符串 +// 字节流以16进制输出 function uint8ArrayToShowStr(uint8Array) { return Array.prototype.map .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) .join(''); } -// 字节流以16进制输出 +// 字节流转成可理解的字符串 function uint8ArrayToString(array) { let arrayString = ''; for (let i = 0; i < array.length; i++) { @@ -381,14 +381,14 @@ function stringToUint8Array(str) { return new Uint8Array(arr); } -// 字节流转成可理解的字符串 +// 字节流以16进制输出 function uint8ArrayToShowStr(uint8Array) { return Array.prototype.map .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) .join(''); } -// 字节流以16进制输出 +// 字节流转成可理解的字符串 function uint8ArrayToString(array) { let arrayString = ''; for (let i = 0; i < array.length; i++) { @@ -563,15 +563,15 @@ function encryptMessageCallback() { |Sign|init(priKey : PriKey) : Promise\|使用Promise方式设置密钥并初始化Sign对象| |Sign|update(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式添加签名数据| |Sign|update(data : DataBlob) : Promise\|用Promise方式添加签名数据| -|Sign|sign(data : DataBlob, callback : AsyncCallback) : void|使用callback方式签名所有数据| -|Sign|sign(data : DataBlob) : Promise|使用Promise方式签名所有数据| +|Sign|sign(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式签名所有数据| +|Sign|sign(data : DataBlob) : Promise\|使用Promise方式签名所有数据| |cryptoFramework|function createVerify(algName : string) : Verify|根据String设置的参数创建Verify对象| |Verify|init(priKey : PriKey, callback : AsyncCallback\) : void|使用callback方式设置密钥并初始化Verify对象| |Verify|init(priKey : PriKey) : Promise\|使用Promise方式设置密钥并初始化Verify对象| |Verify|update(data : DataBlob, callback : AsyncCallback\) : void|使用callback方式添加验签数据| |Verify|update(data : DataBlob) : Promise\|用Promise方式添加验签数据| -|Verify|verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback) : void|使用callback方式验签所有数据| -|Verify|verify(data : DataBlob, signatureData : DataBlob) : Promise|使用Promise方式验签所有数据| +|Verify|verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\) : void|使用callback方式验签所有数据| +|Verify|verify(data : DataBlob, signatureData : DataBlob) : Promise\|使用Promise方式验签所有数据| **开发步骤** @@ -761,10 +761,10 @@ function verifyMessageCallback() { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | -------------------------------------------------- | | cryptoFramework | function createMd(algName : string) : Md; | 指定摘要算法,生成摘要操作实例Md | -| Md | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受用户输入数据,通过Callback的方式,异步更新摘要 | -| Md | update(input : DataBlob) : Promise\; | 接受用户输入数据,通过Promise的方式,异步更新摘要 | -| Md | digest(callback : AsyncCallback\) : void; | 通过Callback的方式,返回结果 | -| Md | digest() : Promise\; | 通过Promise的方式,返回结果 | +| Md | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受用户输入数据,通过Callback的方式,异步更新摘要 | +| Md | update(input : DataBlob) : Promise\; | 接受用户输入数据,通过Promise的方式,异步更新摘要 | +| Md | digest(callback : AsyncCallback\) : void; | 通过Callback的方式,返回结果 | +| Md | digest() : Promise\; | 通过Promise的方式,返回结果 | | Md | getMdLength() : number; | 获取摘要的长度(由指定的摘要算法决定) | | Md | readonly algName : string; | 获取当前设置的摘要算法名 | @@ -922,13 +922,13 @@ Mac(message authentication code)可以对消息进行完整性校验,通过使 | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | --------------------------------------------------- | -| cryptoFramework | function createMd(algName : string) : Md; | 指定摘要算法,生成消息认证码实例Mac | -| Mac | init(key : SymKey, callback : AsyncCallback\) : void; | 接收输入对称密钥,通过Callback的方式,异步初始化MAC | -| Mac | init(key : SymKey) : Promise\; | 接收输入对称密钥,通过Promise的方式,异步初始化MAC | -| Mac | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受输入数据,通过Callback的方式,异步更新MAC | -| Mac | update(input : DataBlob) : Promise\; | 接受输入数据,通过Promise的方式,异步更新MAC | -| Mac | doFinal(callback : AsyncCallback\) : void; | 通过Callback的方式,返回MAC计算结果 | -| Mac | doFinal() : Promise\; | 通过Promise的方式,返回MAC计算结果 | +| cryptoFramework | function createMac(algName : string) : Mac; | 指定摘要算法,生成消息认证码实例Mac | +| Mac | init(key : SymKey, callback : AsyncCallback\) : void; | 接收输入对称密钥,通过Callback的方式,异步初始化MAC | +| Mac | init(key : SymKey) : Promise\; | 接收输入对称密钥,通过Promise的方式,异步初始化MAC | +| Mac | update(input : DataBlob, callback : AsyncCallback\) : void; | 接受输入数据,通过Callback的方式,异步更新MAC | +| Mac | update(input : DataBlob) : Promise\; | 接受输入数据,通过Promise的方式,异步更新MAC | +| Mac | doFinal(callback : AsyncCallback\) : void; | 通过Callback的方式,返回MAC计算结果 | +| Mac | doFinal() : Promise\; | 通过Promise的方式,返回MAC计算结果 | | Mac | getMacLength() : number; | 获取MAC的长度(由指定的摘要算法决定) | | Mac | readonly algName : string; | 获取当前设置的摘要算法名 | @@ -1055,10 +1055,10 @@ function doHmacByCallback(algName) { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | ---------------------------------------------- | | cryptoFramework | function createRandom() : Random; | 生成随机数Random实例 | -| Random | generateRandom(len : number, callback: AsyncCallback\) : void; | 接受输入长度,通过Callback,异步生成随机数 | -| Random | generateRandom(len : number) : Promise\; | 接受输入长度,通过Promise,异步生成随机数 | -| Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void; | 接受输入Blob,通过Callback的方式,异步设置种子 | -| Random | setSeed(seed : DataBlob) : Promise\; | 接受输入Blob,通过Promise的方式,异步设置种子 | +| Random | generateRandom(len : number, callback: AsyncCallback\) : void; | 接受输入长度,通过Callback,异步生成随机数 | +| Random | generateRandom(len : number) : Promise\; | 接受输入长度,通过Promise,异步生成随机数 | +| Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void; | 接受输入Blob,通过Callback的方式,异步设置种子 | +| Random | setSeed(seed : DataBlob) : Promise\; | 接受输入Blob,通过Promise的方式,异步设置种子 | **开发步骤** @@ -1135,16 +1135,16 @@ function doRandByCallback(len) { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | -------------------------------------------- | -| 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方式校验证书有效期 | +| 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 | 获取证书颁发者名称 | @@ -1287,27 +1287,27 @@ function certSample() { | 实例名 | 接口名 | 描述 | | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| 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方式检查证书是否被吊销 | +| 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 | 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 | 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 | @@ -1437,8 +1437,8 @@ function crlSample() { | 实例名 | 接口名 | 描述 | | ------------------ | ------------------------------------------------------------ | -------------------------------- | | cryptoFramework | createCertChainValidator(algorithm :string) : CertChainValidator | 使用指定算法生成证书链校验器对象 | -| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback) : void | 使用callback方式校验证书链 | -| CertChainValidator | validate(certChain : CertChainData) : Promise | 使用promise方式校验证书链 | +| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback\) : void | 使用callback方式校验证书链 | +| CertChainValidator | validate(certChain : CertChainData) : Promise\ | 使用promise方式校验证书链 | | CertChainValidator | algorithm : string | 证书链校验器算法名称 | **开发步骤** @@ -1548,13 +1548,13 @@ function certChainValidatorSample() { | 实例名 | 接口名 | 描述 | | ------------ | ----------------------------------------------------------- | ------------------------------------------ | -| X509CrlEntry | getEncoded(callback : AsyncCallback) : void; | 使用callback方式获取被吊销证书的序列化数据 | -| X509CrlEntry | getEncoded() : Promise; | 使用promise方式获取被吊销证书的序列化数据 | +| 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方式获取被吊销证书的吊销日期 | +| X509CrlEntry | getCertIssuer(callback : AsyncCallback\) : void; | 使用callback方式获取被吊销证书颁发者 | +| X509CrlEntry | getCertIssuer() : Promise\; | 使用promise方式获取被吊销证书颁发者 | +| X509CrlEntry | getRevocationDate(callback : AsyncCallback\) : void; | 使用callback方式获取被吊销证书的吊销日期 | +| X509CrlEntry | getRevocationDate() : Promise\; | 使用promise方式获取被吊销证书的吊销日期 | **开发步骤** @@ -1606,4 +1606,3 @@ function crlEntrySample() { }); } ``` - diff --git a/zh-cn/application-dev/security/cryptoFramework-overview.md b/zh-cn/application-dev/security/cryptoFramework-overview.md index 8334ea9255f3c38a07382f9496d6fa808fa4441e..b1cae2e44127e3d42721e3963c1198c07f161de5 100644 --- a/zh-cn/application-dev/security/cryptoFramework-overview.md +++ b/zh-cn/application-dev/security/cryptoFramework-overview.md @@ -36,7 +36,7 @@ - PKCS5:填充字符由一个字节序列组成,每个字节填充该填充字节序列的长度,规定是8字节填充; - PKCS7:填充字符和PKCS5填充方法一致,但是可以在1-255字节之间任意填充; - > **说明:** ECB、CBC加密模式,明文长度不是128位整数倍,必须使用填充方法补足; + > **说明:** ECB、CBC加密模式,明文长度不是128位整数倍,必须使用填充方法补足。
由于需要填充至分组大小,所以实际算法库中的PKCS5和PKCS7都是以分组大小作为填充长度的,即AES加密填充至16字节。 - **对称3DES加解密** 该算法的加解密过程分别是对明文/密文数据进行三次DES加密或解密,得到相应的密文或明文。 @@ -46,7 +46,7 @@ - PKCS5:填充字符由一个字节序列组成,每个字节填充该填充字节序列的长度,规定是8字节填充; - PKCS7:填充字符和PKCS5填充方法一致,但是可以在1-255字节之间任意填充; - > **说明:** ECB、CBC加密模式,明文长度不是64位整数倍,必须使用填充方法补足 + > **说明:** ECB、CBC加密模式,明文长度不是64位整数倍,必须使用填充方法补足。
由于需要填充至分组大小,所以实际算法库中的PKCS5和PKCS7都是以分组大小作为填充长度的,即3DES加密填充至8字节。 - **非对称RSA加解密** @@ -116,19 +116,21 @@ HMAC(Hash-based Message Authentication Code)是一种基于密钥的消息 支持的对称密钥生成参数: -|对称密钥算法|密钥长度|生成密钥的字符串参数| +|对称密钥算法|密钥长度(bit)|字符串参数| |---|---|---| |3DES|192|3DES192| |AES|128|AES128| |AES|192|AES192| |AES|256|AES256| + > **说明**:“字符串参数”是“对称密钥算法”和“密钥长度”拼接而成,用于在创建对称密钥生成器时,指定密钥规格。 + **非对称密钥生成规格** - **RSA密钥生成** 支持的非对称密钥生成参数: - |非对称密钥算法|密钥长度|素数个数|生成密钥的字符串参数| + |非对称密钥算法|密钥长度(bit)|素数个数|字符串参数| |---|---|---|---| |RSA|512|2|RSA512\|PRIMES_2| |RSA|768|2|RSA768\|PRIMES_2| @@ -165,7 +167,7 @@ HMAC(Hash-based Message Authentication Code)是一种基于密钥的消息 支持的对称加密算法: -|对称加解密算法|分组模式|指定算法名称字符串| +|对称加解密算法|分组模式| 字符串参数 | |---|---|---| |3DES|ECB|3DES192\|ECB\|[NoPadding\|PKCS5\|PKCS7]| |3DES|CBC|3DES192\|CBC\|[NoPadding\|PKCS5\|PKCS7]| @@ -179,7 +181,9 @@ HMAC(Hash-based Message Authentication Code)是一种基于密钥的消息 |AES|GCM|AES[128\|192\|256]\|GCM\|[NoPadding\|PKCS5\|PKCS7]| |AES|CCM|AES[128\|192\|256]\|CCM\|[NoPadding\|PKCS5\|PKCS7]| -> **说明:** []中只能任选一项 +> **说明:** +> 1. []中只能任选一项。 +> 2. “字符串参数”是“对称加解密算法(含密钥长度)”、“分组模式”、“填充模式”拼接而成,用于在创建对称加解密实例时,指定对称加解密算法规格。 **非对称RSA加解密** diff --git a/zh-cn/application-dev/security/userauth-guidelines.md b/zh-cn/application-dev/security/userauth-guidelines.md index d30a71e607a2f8492b134e7ecc843347597ceac8..fa18eefba7491f6ec43b6a92c04c7426cdd59931 100644 --- a/zh-cn/application-dev/security/userauth-guidelines.md +++ b/zh-cn/application-dev/security/userauth-guidelines.md @@ -1,113 +1,239 @@ # 用户认证开发指导 > **说明:** -> 该开发指导需匹配API Version 8或以上版本的SDK使用。 +> 该开发指导需配合API version 9版本的SDK使用。 ## 场景介绍 -当前用户认证支持2D人脸识别、3D人脸识别,可应用于设备解锁、应用登录、支付等身份认证场景。 +当前用户认证支持人脸识别和指纹识别,可应用于设备解锁、应用登录、支付等身份认证场景。 ## 接口说明 -userIAM_userAuth模块提供了用户认证的相关方法,包括检测认证能力、认证和取消认证等,用户可以使用人脸等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md)。 +userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证能力、发起认证和取消认证等,用户可以使用人脸、指纹等生物特征信息进行认证操作。具体接口说明可以查阅[API参考文档](../reference/apis/js-apis-useriam-userauth.md)。 -在执行认证前,需要检查设备是否支持该认证能力,具体指认证类型、认证等级。如果不支持,需要考虑使用其他认证能力。 +在执行认证前,需要指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),查询设备是否支持该认证能力。 **表1** 用户认证开放能力列表 -| 接口名 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| getVersion() : number | 获取认证对象的版本信息。 | -| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | -| auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法。 | -| cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 | - -## 开发步骤 - -开发前请完成以下准备工作: - -1. 在应用配置权限文件中,增加ohos.permission.ACCESS_BIOMETRIC的权限声明。 -2. 在使用用户认证能力的代码文件中增加import userIAM_userAuth from '@ohos.userIAM.userAuth'。 - -开发过程: - -1. 获取Authenticator的单例对象,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - ``` - -2. (可选)获取认证对象的版本信息,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - let version = auth.getVersion(); - console.info("auth version = " + version); - ``` - -3. 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); - if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("check auth support success"); - // 此处添加支持指定类型认证的逻辑 - } else { - console.error("check auth support fail, code = " + checkCode); - // 此处添加不支持指定类型认证的逻辑 - } - ``` - -4. 执行认证操作,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - try { - console.info("auth onResult result = " + result); - console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == userIAM_userAuth.ResultCode.SUCCESS) { - // 此处添加认证成功逻辑 - } else { - // 此处添加认证失败逻辑 - } - } catch (e) { - console.info("auth onResult error = " + e); - } - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - try { - console.info("auth onAcquireInfo module = " + module); - console.info("auth onAcquireInfo acquire = " + acquire); - console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); - } catch (e) { - console.info("auth onAcquireInfo error = " + e); - } - } - }); - ``` - -5. 认证过程中取消认证,代码示例如下: - - ```js - let auth = new userIAM_userAuth.UserAuth(); - // contextId通过auth接口获取 - let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - console.info("auth onResult result = " + result); - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - console.info("auth onAcquireInfo module = " + module); - } - }); - let cancelCode = auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } - ``` +| 接口名称 | 功能描述 | +| ---------- | ----------------------- | +| getVersion() : number | 获取认证对象的版本信息。 | +| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | +| getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel): AuthInstance | 获取AuthInstance对象,用于执行用户身份认证。 | +| on(name : AuthEventKey, callback : AuthEvent) : void | 订阅指定类型的用户认证事件。 | +| off(name : AuthEventKey) : void | 取消订阅特定类型的认证事件。 | +| start: void | 执行用户认证。 | +| cancel: void | 取消本次认证操作。 | + +## 获取认证对象的版本信息 + +### 开发步骤 + +1. 申请权限。调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 调用[getVersion](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetversion9)接口获取版本信息。 + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + // 获取版本信息 + try { + let version = userIAM_userAuth.getVersion(); + console.info("auth version = " + version); + } catch (error) { + console.info("get version failed, error = " + error); + } + ``` + +## 查询当前设备是否支持相应的认证能力 + +### 开发步骤 + +1. 申请权限。调用[getAvailableStatus](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetavailablestatus9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),调用[getAvailableStatus](../reference/apis/js-apis-useriam-userauth.md#useriam_userauthgetavailablestatus9)接口查询当前的设备是否支持相应的认证能力。 + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + // 查询认证能力是否支持 + try { + userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); + console.info("current auth trust level is supported"); + } catch (error) { + console.info("current auth trust level is not supported, error = " + error); + } + ``` + +## 执行认证操作并请阅认证结果 + +### 开发步骤 + +1. 申请权限。调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 + +3. 调用[on](../reference/apis/js-apis-useriam-userauth.md#on9)接口订阅认证结果。 + +4. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证,通过[callback](../reference/apis/js-apis-useriam-userauth.md#callback9)回调返回认证结果。 + +5. 调用[off](../reference/apis/js-apis-useriam-userauth.md#off9)接口取消订阅认证结果。 + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 订阅认证结果 + try { + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + console.log("subscribe authentication event success"); + } catch (error) { + console.log("subscribe authentication event failed " + error); + } + + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消订阅认证结果 + try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); + } catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); + } + ``` + +## 执行认证操作并订阅认证过程中的提示信息 + +### 开发步骤 + +1. 申请权限。调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 + +3. 调用[on](../reference/apis/js-apis-useriam-userauth.md#on9)接口订阅认证过程中的提示信息。 + +4. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证,通过[callback](../reference/apis/js-apis-useriam-userauth.md#callback9)回调返回认证过程中的提示信息。 + +5. 调用[off](../reference/apis/js-apis-useriam-userauth.md#off9)接口取消订阅认证过程中的提示信息。 + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 订阅认证过程中的提示信息 + try { + 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 + } + } + }); + console.log("subscribe authentication event success"); + } catch (error) { + console.log("subscribe authentication event failed " + error); + } + + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消订阅认证过程中的提示信息 + try { + auth.off("tip"); + console.info("cancel subscribe tip information success"); + } catch (error) { + console.info("cancel subscribe tip information failed, error = " + error); + } + ``` + +## 认证过程中取消认证 + +### 开发步骤 + +1. 申请权限。调用[cancel](../reference/apis/js-apis-useriam-userauth.md#cancel9)接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](../quick-start/stage-structure.md)。 + +2. 指定challenge、[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 + +3. 调用[start](../reference/apis/js-apis-useriam-userauth.md#start9)接口发起认证。 + +4. 通过调用[cancel](../reference/apis/js-apis-useriam-userauth.md#cancel9)接口取消本次认证。 + + ```js + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消认证 + try { + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); + } + ``` diff --git a/zh-cn/application-dev/security/userauth-overview.md b/zh-cn/application-dev/security/userauth-overview.md index 9c9ccf82781e6f17f0486af824bd55e3eb09c650..b566680f07552e94fe084eb3d552e82827499b39 100644 --- a/zh-cn/application-dev/security/userauth-overview.md +++ b/zh-cn/application-dev/security/userauth-overview.md @@ -1,24 +1,26 @@ # 用户认证开发概述 -提供用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。 +## 用户认证模块的定义 -当前用户认证能力提供2D人脸识别、3D人脸识别两种人脸识别能力,设备具备哪种识别能力,取决于设备的硬件能力和技术实现。 +用户认证模块提供用户认证能力,对应用开发者而言,可使用该模块进行用户身份认证,用于设备解锁、支付、应用登录等身份认证场景。 -3D人脸识别技术识别率、防伪能力都优于2D人脸识别技术,但具有3D人脸能力(比如3D结构光、3D TOF等)的设备才可以使用3D人脸识别技术。 +当前用户认证提供人脸识别和指纹识别能力,设备具备哪种识别能力,取决于当前设备的硬件能力和技术实现。 ## 基本概念 -人脸识别:基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。 +- 人脸识别:基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。 + +- 指纹识别:基于人的指尖皮肤纹路进行身份识别的一种生物特征识别技术。当用户触摸指纹采集器件时,器件感知并获取到用户的指纹图像,然后传输到指纹识别模块进行一定的处理后与用户预先注册的指纹信息进行比对,从而识别出用户身份。 ## 运作机制 -人脸识别会在摄像头和TEE(Trusted Execution Environment)之间建立安全通道,人脸图像信息通过安全通道传递到TEE中,由于人脸图像信息从REE(Rich Execution Environment)侧无法获取,从而避免了恶意软件从REE侧进行攻击。对人脸图像采集、特征提取、活体检测、特征比对等处理完全在TEE中,基于TrustZone进行安全隔离,外部的人脸框架只负责人脸的认证发起和处理认证结果等数据,不涉及人脸数据本身。 +人脸或指纹识别过程中,特征采集器件和TEE(Trusted Execution Environment)之间会建立安全通道,将采集的生物特征信息直接通过安全通道传递到TEE中,从而避免了恶意软件从REE(Rich Execution Environment)侧进行攻击。传输到TEE中的生物特征数据从活体检测、特征提取、特征存储、特征比对到特征销毁等处理都完全在TEE中完成,基于TrustZone进行安全隔离,提供API的服务框架只负责管理认证请求和处理认证结果等数据,不涉及生物特征数据本身。 -人脸特征数据通过TEE的安全存储区进行存储,采用高强度的密码算法对人脸特征数据进行加密和完整性保护,外部无法获取到加密人脸特征数据的密钥,保证用户的人脸特征数据不会泄露。本能力采集和存储的人脸特征数据不会在用户未授权的情况下被传出TEE,这意味着,用户未授权时,无论是系统应用还是三方应用都无法获得人脸特征数据,也无法将人脸特征数据传送或备份到任何外部存储介质。 +用户注册的生物特征数据在TEE的安全存储区进行存储,采用高强度的密码算法进行加密和完整性保护,外部无法获取到加密生物特征数据的密钥,保证了用户生物特征数据的安全性。本能力采集和存储的生物特征数据不会在用户未授权的情况下被传出TEE。这意味着,用户未授权时,无论是系统应用还是三方应用都无法获得人脸和指纹等特征数据,也无法将这些特征数据传送或备份到任何外部存储介质。 ## 约束与限制 -- 当前版本提供的用户认证能力只包含人脸识别,且只支持本地认证,不提供认证界面。 -- 要求设备上具备摄像器件,且人脸图像像素大于100*100。 -- 要求设备上具有TEE安全环境,人脸特征信息高强度加密保存在TEE中。 +- 当前版本提供的用户认证能力包含人脸识别和指纹识别,且只支持本地认证,不提供认证界面。 +- 要求设备上具备相应的生物特征采集器,且对于人脸识别要求人脸图像分辨率大于100*100。 +- 要求设备上具有TEE安全环境,人脸和指纹等生物特征信息高强度加密保存在TEE中。 - 对于面部特征相似的人、面部特征不断发育的儿童,人脸特征匹配率有所不同。如果对此担忧,可考虑其他认证方式。 \ No newline at end of file diff --git a/zh-cn/application-dev/task-management/background-task-overview.md b/zh-cn/application-dev/task-management/background-task-overview.md index c24d818516a8d473bca665304c4d8851f2b531f2..28aeecd05341e1af55e638d2fece6954fca614c2 100644 --- a/zh-cn/application-dev/task-management/background-task-overview.md +++ b/zh-cn/application-dev/task-management/background-task-overview.md @@ -50,17 +50,17 @@ OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业 **表1** 长时任务种类 -| 后台模式 | 说明 | 通知栏显示提示 | 备注 | -| -------- | -------- | -------- | -------- | -| dataTransfer | 通过网络/对端设备进行数据下载、备份、分享、传输等 | 正在运行数据传输任务 | - | -| audioPlayback | 音频输出 | 正在运行音频播放任务 | - | -| audioRecording | 音频输入 | 正在运行录音任务 | - | -| location | 定位、导航 | 正在运行定位任务 | - | -| bluetoothInteraction | 蓝牙传输 | 正在运行蓝牙相关任务 | - | -| multiDeviceConnection | 分布式互联任务 | 正在运行分布式任务 | - | -| wifiInteraction | WLAN传输 | 正在运行WLAN相关任务 | System API,仅对System权限应用开放 | -| voip | 音视频电话、VOIP | 正在运行通话相关任务 | System API,仅对System权限应用开放 | -| taskKeeping | 计算任务 | 正在运行计算任务 | 仅在特定设备生效 | +| 后台模式 | 说明 | 通知栏显示提示 | 备注 | +| --------------------- | ------------------------- | ------------ | ------------------------- | +| dataTransfer | 通过网络/对端设备进行数据下载、备份、分享、传输等 | 正在运行数据传输任务 | - | +| audioPlayback | 音频输出 | 正在运行音频播放任务 | - | +| audioRecording | 音频输入 | 正在运行录音任务 | - | +| location | 定位、导航 | 正在运行定位任务 | - | +| bluetoothInteraction | 蓝牙传输 | 正在运行蓝牙相关任务 | - | +| multiDeviceConnection | 分布式互联任务 | 正在运行分布式任务 | - | +| wifiInteraction | WLAN传输 | 正在运行WLAN相关任务 | System API,仅对System权限应用开放 | +| voip | 音视频电话、VOIP | 正在运行通话相关任务 | System API,仅对System权限应用开放 | +| taskKeeping | 计算任务 | 正在运行计算任务 | 仅在特定设备生效 | ### 长时任务使用约束 - 如果用户选择可感知业务(如播音、导航等),触发对应后台模式,在任务启动时,系统会强制弹出通知提醒用户。 @@ -79,15 +79,15 @@ OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业 - **超时**:系统会设置超时机制,延迟任务回调只允许运行一段时间,超时之后,系统会主动停止。默认的超时限制为2分钟,对于系统应用,可以通过[申请能效资源](efficiency-resources-apply-dev-guide.md)获取更长的执行时间(充电状态20分钟,非充电状态10分钟)。 - **执行频率**:系统会根据应用的活跃度对延迟任务做分级管控,限制延迟任务调度的执行频率。对于通过能效资源接口申请了WORK_SCHEDULER资源的应用,在资源的有效期内,它的延迟任务执行频率不受限制。 - | 应用分组 | 延迟任务执行频率约束 | - | --------------------|------------------------- | - | 活跃 | 最小间隔2小时 | - | 每日使用 | 最小间隔4小时 | - | 经常使用 | 最小间隔24小时 | - | 不经常使用 | 最小间隔48小时 | - | 受限分组 | 禁止 | - | 未使用分组 | 禁止 | - | [能效资源豁免分组](../reference/apis/js-apis-backgroundTaskManager.md#resourcetype9) | 执行频率不受限制 | + | 应用分组 | 延迟任务执行频率约束 | + | ---------------------------------------- | ---------- | + | 活跃 | 最小间隔2小时 | + | 每日使用 | 最小间隔4小时 | + | 经常使用 | 最小间隔24小时 | + | 不经常使用 | 最小间隔48小时 | + | 受限分组 | 禁止 | + | 未使用分组 | 禁止 | + | [能效资源豁免分组](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#resourcetype) | 执行频率不受限制 | - **WorkInfo设置参数约束** @@ -111,15 +111,15 @@ OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业 **表1** 能效资源种类 -| 参数名 | 参数值 | 描述 | -| ----------------------- | ---- | --------------------- | -| CPU | 1 | CPU资源,申请后不被挂起 | -| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉 | -| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉 | -| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间 | -| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉 | -| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉 | -| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉 | +| 参数名 | 参数值 | 描述 | +| -------------- | ---- | ------------------- | +| CPU | 1 | CPU资源,申请后不被挂起 | +| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉 | +| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉 | +| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间 | +| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉 | +| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉 | +| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉 | ### 能效资源使用约束 - 能效资源申请或者释放可以由进程或者应用发起,由应用发起的资源释放会释放属于它的同类型的所有资源,包括进程申请的资源。例如应用申请了CPU资源,进程申请了CPU和WORK_SCHEDULER资源,当应用释放CPU资源的时候,会将进程的CPU资源一同释放,同时不同类型的WORK_SCHEDULER资源不受影响。由进程发起的资源释放对应用申请的资源没有影响,例如当应用和进程同时申请了CPU,进程发起了CPU资源释放,应用的CPU资源不会被释放。 diff --git a/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md b/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md index ebdd94a0c1a20876b854d16a19725ad854c773f2..885dacbcd1e2ccef1e082f398f270385b22c9cd3 100644 --- a/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md +++ b/zh-cn/application-dev/task-management/efficiency-resources-apply-dev-guide.md @@ -1,22 +1,22 @@ -## 申请能效资源 +# 申请能效资源 -### 场景说明 +## 场景说明 在实际的系统中,存在一些重要性高的系统应用,虽然此类应用相比普通应用具有一定的特权,但为了进一步平衡系统的功耗开销,这些应用同样需要支持在后台可被挂起。但对于系统特权应用,为了避免挂起后重要功能受到影响,提供了独立的能效资源申请接口,使这些特权应用可以在后台执行一些特殊的任务和使用特定的系统资源,例如在被挂起期间如果仍然希望能够收到系统公共事件,可以使用能效资源接口向系统申请使用公共事件资源。 对于需要升级为特权应用的,开发者需要合理评估自己的业务诉求,向应用中心提出申请。 -### 接口说明 +## 接口说明 **表1** 申请能效资源主要接口 -| 接口名 | 描述 | -| ---------------------------------------- | ---------------------------------------- | -| applyEfficiencyResources(request: [EfficiencyResourcesRequest](../reference/apis/js-apis-backgroundTaskManager.md#efficiencyresourcesrequest9)): boolean | 申请能效资源。 | -| resetAllEfficiencyResources():void | 释放申请的能效资源。 | +| 接口名 | 描述 | +| ---------------------------------------- | ---------- | +| applyEfficiencyResources(request: [EfficiencyResourcesRequest](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#efficiencyresourcesrequest)): boolean | 申请能效资源。 | +| resetAllEfficiencyResources():void | 释放申请的能效资源。 | -### 开发步骤 +## 开发步骤 1、当特权应用需要在后台使用特殊资源时。向系统申请目标资源。 diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index 78f5e05588a6d86a06b3b6f9c7bdfcce9fed1d36..45fe37d4d80aaf4de83651583b059e049a85a31e 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -2,100 +2,100 @@ - [方舟开发框架(ArkUI)概述](arkui-overview.md) - UI开发(基于ArkTS的声明式开发范式) - - [概述](ui-ts-overview.md) - - [声明式UI开发指导](ui-ts-developing-intro.md) - - 声明式UI开发实例 - - [创建简单视图](ui-ts-creating-simple-page.md) - - 构建完整实例 - - [构建食物数据模型](ui-ts-building-data-model.md) - - [构建食物列表List布局](ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) - - [页面跳转与数据传递](ui-ts-page-redirection-data-transmission.md) - - 添加闪屏动画 - - [绘制图像](ui-ts-drawing-feature.md) - - [添加动画效果](ui-ts-animation-feature.md) - - [常用组件说明](ui-ts-components-intro.md) - - 常见布局开发指导 - - 自适应布局 - - [线性布局](ui-ts-layout-linear.md) - - [层叠布局](ui-ts-layout-stack.md) - - [弹性布局](ui-ts-layout-flex.md) - - [网格布局](ui-ts-layout-grid.md) - - 响应式布局 - - [栅格布局](ui-ts-layout-grid-container-new.md) - - [媒体查询](ui-ts-layout-mediaquery.md) - - [自定义组件的生命周期](ui-ts-custom-component-lifecycle-callbacks.md) - - [Web组件开发指导](ui-ts-components-web.md) - - [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) + - [概述](ui-ts-overview.md) + - [声明式UI开发指导](ui-ts-developing-intro.md) + - 声明式UI开发实例 + - [创建简单视图](ui-ts-creating-simple-page.md) + - 构建完整实例 + - [构建食物数据模型](ui-ts-building-data-model.md) + - [构建食物列表List布局](ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui-ts-page-redirection-data-transmission.md) + - 添加闪屏动画 + - [绘制图像](ui-ts-drawing-feature.md) + - [添加动画效果](ui-ts-animation-feature.md) + - [常用组件说明](ui-ts-components-intro.md) + - 常见布局开发指导 + - 自适应布局 + - [线性布局](ui-ts-layout-linear.md) + - [层叠布局](ui-ts-layout-stack.md) + - [弹性布局](ui-ts-layout-flex.md) + - [网格布局](ui-ts-layout-grid.md) + - 响应式布局 + - [栅格布局](ui-ts-layout-grid-container-new.md) + - [媒体查询](ui-ts-layout-mediaquery.md) + - [自定义组件的生命周期](ui-ts-custom-component-lifecycle-callbacks.md) + - [Web组件开发指导](ui-ts-components-web.md) + - [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) - UI开发(兼容JS的类Web开发范式) - - [概述](ui-js-overview.md) - - 框架说明 - - [文件组织](js-framework-file.md) - - [js标签配置](js-framework-js-tag.md) - - [app.js](js-framework-js-file.md) - - 语法 - - [HML语法参考](js-framework-syntax-hml.md) - - [CSS语法参考](js-framework-syntax-css.md) - - [JS语法参考](js-framework-syntax-js.md) - - [生命周期](js-framework-lifecycle.md) - - [资源限定与访问](js-framework-resource-restriction.md) - - [多语言支持](js-framework-multiple-languages.md) - - 构建用户界面 - - [组件介绍](ui-js-building-ui-component.md) - - 构建布局 - - [布局说明](ui-js-building-ui-layout-intro.md) - - [添加标题行和文本区域](ui-js-building-ui-layout-text.md) - - [添加图片区域](ui-js-building-ui-layout-image.md) - - [添加留言区域](ui-js-building-ui-layout-comment.md) - - [添加容器](ui-js-building-ui-layout-external-container.md) - - [添加交互](ui-js-building-ui-interactions.md) - - [动画](ui-js-building-ui-animation.md) - - [手势事件](ui-js-building-ui-event.md) - - [页面路由](ui-js-building-ui-routes.md) - - 常见组件开发指导 - - 容器组件 - - [List开发指导](ui-js-components-list.md) - - [Dialog开发指导](ui-js-components-dialog.md) - - [Form开发指导](ui-js-components-form.md) - - [Stepper开发指导](ui-js-components-stepper.md) - - [Tabs开发指导](ui-js-component-tabs.md) - - [Swiper开发指导](ui-js-components-swiper.md) - - 基础组件 - - [Text开发指导](ui-js-components-text.md) - - [Input开发指导](ui-js-components-input.md) - - [Button开发指导](ui-js-components-button.md) - - [Picker开发指导](ui-js-components-picker.md) - - [Image开发指导](ui-js-components-images.md) - - [Image-animator开发指导](ui-js-components-image-animator.md) - - [Rating开发指导](ui-js-components-rating.md) - - [Slider开发指导](ui-js-components-slider.md) - - [Chart开发指导](ui-js-components-chart.md) - - [Switch开发指导](ui-js-components-switch.md) - - [Toolbar开发指导](ui-js-components-toolbar.md) - - [Menu开发指导](ui-js-components-menu.md) - - [Marquee开发指导](ui-js-components-marquee.md) - - [Qrcode开发指导](ui-js-components-qrcode.md) - - [Search开发指导](ui-js-components-search.md) - - Canvas开发指导 - - [Canvas对象](ui-js-components-canvas.md) - - [CanvasRenderingContext2D对象](ui-js-components-canvasrenderingcontext2d.md) - - [Path2D对象](ui-js-components-path2d.md) - - [OffscreenCanvas对象](ui-js-components-offscreencanvas.md) - - [栅格布局](ui-js-components-grid.md) - - Svg开发指导 - - [基础知识](ui-js-components-svg-overview.md) - - [绘制图形](ui-js-components-svg-graphics.md) - - [绘制路径](ui-js-components-svg-path.md) - - [绘制文本](ui-js-components-svg-text.md) - - 动效开发指导 - - CSS动画 - - [属性样式动画](ui-js-animate-attribute-style.md) - - [transform样式动画](ui-js-animate-transform.md) - - [background-position样式动画](ui-js-animate-background-position-style.md) - - [svg动画](ui-js-animate-svg.md) - - JS动画 - - [组件动画](ui-js-animate-component.md) - - 插值器动画 - - [动画动效](ui-js-animate-dynamic-effects.md) - - [动画帧](ui-js-animate-frame.md) - - [自定义组件](ui-js-custom-components.md) \ No newline at end of file + - [概述](ui-js-overview.md) + - 框架说明 + - [文件组织](js-framework-file.md) + - [js标签配置](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - 语法 + - [HML语法参考](js-framework-syntax-hml.md) + - [CSS语法参考](js-framework-syntax-css.md) + - [JS语法参考](js-framework-syntax-js.md) + - [生命周期](js-framework-lifecycle.md) + - [资源限定与访问](js-framework-resource-restriction.md) + - [多语言支持](js-framework-multiple-languages.md) + - 构建用户界面 + - [组件介绍](ui-js-building-ui-component.md) + - 构建布局 + - [布局说明](ui-js-building-ui-layout-intro.md) + - [添加标题行和文本区域](ui-js-building-ui-layout-text.md) + - [添加图片区域](ui-js-building-ui-layout-image.md) + - [添加留言区域](ui-js-building-ui-layout-comment.md) + - [添加容器](ui-js-building-ui-layout-external-container.md) + - [添加交互](ui-js-building-ui-interactions.md) + - [动画](ui-js-building-ui-animation.md) + - [手势事件](ui-js-building-ui-event.md) + - [页面路由](ui-js-building-ui-routes.md) + - 常见组件开发指导 + - 容器组件 + - [List开发指导](ui-js-components-list.md) + - [Dialog开发指导](ui-js-components-dialog.md) + - [Form开发指导](ui-js-components-form.md) + - [Stepper开发指导](ui-js-components-stepper.md) + - [Tabs开发指导](ui-js-component-tabs.md) + - [Swiper开发指导](ui-js-components-swiper.md) + - 基础组件 + - [Text开发指导](ui-js-components-text.md) + - [Input开发指导](ui-js-components-input.md) + - [Button开发指导](ui-js-components-button.md) + - [Picker开发指导](ui-js-components-picker.md) + - [Image开发指导](ui-js-components-images.md) + - [Image-animator开发指导](ui-js-components-image-animator.md) + - [Rating开发指导](ui-js-components-rating.md) + - [Slider开发指导](ui-js-components-slider.md) + - [Chart开发指导](ui-js-components-chart.md) + - [Switch开发指导](ui-js-components-switch.md) + - [Toolbar开发指导](ui-js-components-toolbar.md) + - [Menu开发指导](ui-js-components-menu.md) + - [Marquee开发指导](ui-js-components-marquee.md) + - [Qrcode开发指导](ui-js-components-qrcode.md) + - [Search开发指导](ui-js-components-search.md) + - Canvas开发指导 + - [Canvas对象](ui-js-components-canvas.md) + - [CanvasRenderingContext2D对象](ui-js-components-canvasrenderingcontext2d.md) + - [Path2D对象](ui-js-components-path2d.md) + - [OffscreenCanvas对象](ui-js-components-offscreencanvas.md) + - [栅格布局](ui-js-components-grid.md) + - Svg开发指导 + - [基础知识](ui-js-components-svg-overview.md) + - [绘制图形](ui-js-components-svg-graphics.md) + - [绘制路径](ui-js-components-svg-path.md) + - [绘制文本](ui-js-components-svg-text.md) + - 动效开发指导 + - CSS动画 + - [属性样式动画](ui-js-animate-attribute-style.md) + - [transform样式动画](ui-js-animate-transform.md) + - [background-position样式动画](ui-js-animate-background-position-style.md) + - [svg动画](ui-js-animate-svg.md) + - JS动画 + - [组件动画](ui-js-animate-component.md) + - 插值器动画 + - [动画动效](ui-js-animate-dynamic-effects.md) + - [动画帧](ui-js-animate-frame.md) + - [自定义组件](ui-js-custom-components.md) diff --git a/zh-cn/application-dev/ui/figures/component.gif b/zh-cn/application-dev/ui/figures/component.gif index e50a590ed7049a3c52149d10886e5b38ffdae2a5..12ae330c55f90588551d16bb8cbaeca63eadd96e 100644 Binary files a/zh-cn/application-dev/ui/figures/component.gif and b/zh-cn/application-dev/ui/figures/component.gif differ diff --git a/zh-cn/application-dev/ui/figures/itemalignstretch.png b/zh-cn/application-dev/ui/figures/itemalignstretch.png new file mode 100644 index 0000000000000000000000000000000000000000..0fadb0e9099cc754a281bd1bedfdea4a59f64894 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/itemalignstretch.png differ diff --git a/zh-cn/application-dev/ui/figures/stack1.png b/zh-cn/application-dev/ui/figures/stack1.png index 87574a9c72652fdda57f54405b675b622f804479..2a5ce8f30c87da69422731a07758760c9344227f 100644 Binary files a/zh-cn/application-dev/ui/figures/stack1.png and b/zh-cn/application-dev/ui/figures/stack1.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739570.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739570.png deleted file mode 100644 index 006efca8f390adea7edb0b4f54609c04fd0bd098..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739570.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/ts-component-based-builder.md b/zh-cn/application-dev/ui/ts-component-based-builder.md deleted file mode 100644 index 7f21c9e5e18d080b28bd9ac6d4d0b65c57daa633..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-component-based-builder.md +++ /dev/null @@ -1,182 +0,0 @@ -# @Builder - - -@Builder装饰的方法用于定义组件的声明式UI描述,在一个自定义组件内快速生成多个布局内容。如果\@Builder装饰的方法中使用了自定义组件,那么该方法每次被调用时,对应的自定义组件均会重新创建。\@Builder装饰方法的功能和语法规范与[build函数](ts-function-build.md)相同。 - - -```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](../ui/ts-function-build.md)一致。此场景下自定义组件内有且仅有一个使用@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" - }) - } - } - } -} -``` 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 deleted file mode 100644 index 97f9bd7e718c8e682d788137be2497aaca1c8860..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-framework-file-access-rules.md +++ /dev/null @@ -1,67 +0,0 @@ -# 文件访问规则 -应用代码中文件访问方法主要有下面两种: - -- **相对路径**:使用相对路径引用代码文件,以"../"访问上一级目录,以"./"访问当前目录,也可以省略不写。 - -- **绝对路径**:使用当前模块根路径引用代码文件,比如:common/utils/utils。 - - - -## 示例 -示例页面位于pages目录中,在pages同级目录common中存放utils,从示例xxx.ets访问utils.ets文件方法如下: -```ts -// xxx.ets -import { FoodData, FoodList } from "../common/utils/utils"; - -@Entry -@Component -struct FoodCategoryList { - private foodItems: FoodData[] = [ - new FoodData("Tomato"), - new FoodData("Strawberry"), - new FoodData("Cucumber") - ] - build() { - Column() { - FoodList({ foodItems: this.foodItems }) - } - } -} -``` - -被导入文件utils.ets: - -```ts -//common/utils/utils.ets -export class FoodData { - name: string; - constructor(name: string) { - this.name = name; - } -} - -@Component -export struct FoodList { - private foodItems: FoodData[] - - build() { - Column() { - Flex({justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center}) { - Text('Food List') - .fontSize(20) - } - .width(200) - .height(56) - .backgroundColor('#FFf1f3f5') - List() { - ForEach(this.foodItems, item => { - ListItem() { - Text(item.name) - .fontSize(14) - } - }, item => item.toString()) - } - } - } -} -``` \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-switch.md b/zh-cn/application-dev/ui/ui-js-components-switch.md index a8554912f7467a7ff1e667833fbd4965a9490027..f9642207ddd97d6f0b40eceb7dcade8a62d96ccd 100644 --- a/zh-cn/application-dev/ui/ui-js-components-switch.md +++ b/zh-cn/application-dev/ui/ui-js-components-switch.md @@ -12,7 +12,7 @@ switch为开关选择器,切换开启或关闭状态。具体用法请参考[s ```html
- +
``` @@ -30,7 +30,7 @@ switch为开关选择器,切换开启或关闭状态。具体用法请参考[s ## 添加属性和方法 - witch组件通过textoff和showtext属性设置文本选中和未选中时的状态。设置checked属性值为true(组件为打开状态)。添加change事件,当组件状态改变时触发,触发后执行switchChange函数获取组件当前状态(关闭/打开)。 + switch组件通过textoff和showtext属性设置文本选中和未选中时的状态。设置checked属性值为true(组件为打开状态)。添加change事件,当组件状态改变时触发,触发后执行switchChange函数获取组件当前状态(关闭/打开)。 ```html diff --git a/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md b/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md index 5201e0e720b83083b0ceaeaac73ca95d15ed9290..24516e9220bbf5015abff68f1306507ec5e6ded6 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md +++ b/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md @@ -26,6 +26,12 @@ ``` 3. 引入FoodData类和initializeOnStartup方法。 + +应用代码中文件访问方法主要有下面两种: +- **相对路径**:使用相对路径引用代码文件,以"../"访问上一级目录,以"./"访问当前目录,也可以省略不写。 +- **绝对路径**:使用当前模块根路径引用代码文件,比如:common/utils/utils。 +这里使用相对路径访问: + ``` import { FoodData } from '../model/FoodData' import { initializeOnStartup } from '../model/FoodDataModels' diff --git a/zh-cn/application-dev/ui/ui-ts-components-web.md b/zh-cn/application-dev/ui/ui-ts-components-web.md index 6f4acc31caca52b4bab2e97e9913922dd86904fa..884066df04728957cacc39ab5c1263d003519ced 100644 --- a/zh-cn/application-dev/ui/ui-ts-components-web.md +++ b/zh-cn/application-dev/ui/ui-ts-components-web.md @@ -151,6 +151,38 @@ struct WebComponent { ``` + +## 开启网页调试 +在PC上启用端口转发,以及设置Web组件属性webDebuggingAccess为true后,便可以在PC上调试通过USB连接的开发设备上的Web组件里的网页。 + +设置步骤如下: + +1、首先设置Web组件属性webDebuggingAccess为true。 + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController() + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .webDebuggingAccess(true) // true表示启用调试功能 + } + } + } + ``` + +2、PC上启用端口转发功能,添加TCP端口9222映射。 + ```ts + hdc fport tcp:9222 tcp:9222 + ``` + 添加是否成功可以通过如下命令来查看已存在的映射关系表。 + ```ts + hdc fport ls + ``` +如上设置完成后,首先打开应用Web组件、访问要调试的网页,然后在PC上使用chrome浏览器访问:http://localhost:9222, 就可以在PC上调试开发设备刚才访问的网页。 + ## 场景示例 该场景实现了Web组件中视频的动态播放。首先在HTML页面内嵌入视频资源,再使用Web组件的控制器调用onActive和onInactive方法激活和暂停页面渲染。点击onInactive按钮,Web页面停止渲染,视频暂停播放;点击onActive按钮,激活Web组件,视频继续播放。 diff --git a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md index ca4fe0bd1e5f2f04a8e2aba9d881f0a37f3ac969..c8163cb4497b444bc0ab5ee0f99f7adbc6177474 100644 --- a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md +++ b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md @@ -2,7 +2,7 @@ 在这一小节中,我们将开始食物详情页的开发,学习如何通过容器组件Stack、Flex和基础组件Image、Text,构建用户自定义组件,完成图文并茂的食物介绍。 -在创建页面前,请先创建eTS工程,FA模型请参考[创建FA模型的eTS工程](../quick-start/start-with-ets-stage.md#创建ets工程),Stage模型请参考[创建Stage模型的eTS工程](..//quick-start/start-with-ets-fa.md#创建ets工程)。 +在创建页面前,请先创建ArkTS工程,FA模型请参考[创建FA模型的ArkTS工程](../quick-start/start-with-ets-stage.md#创建arkts工程),Stage模型请参考[创建Stage模型的ArkTS工程](../quick-start/start-with-ets-fa.md#创建arkts工程)。 ## 构建Stack布局 diff --git a/zh-cn/application-dev/ui/ui-ts-developing-intro.md b/zh-cn/application-dev/ui/ui-ts-developing-intro.md index 62f4538cbe834025650e252f413ec7934b171cd4..db7e9da5930a56d406c7b376cd31563d863a5bdc 100644 --- a/zh-cn/application-dev/ui/ui-ts-developing-intro.md +++ b/zh-cn/application-dev/ui/ui-ts-developing-intro.md @@ -2,14 +2,14 @@ ## 开发说明 -| 任务 | 简介 | 相关资源 | -| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| 准备开发环境 | 了解声明式UI的工程结构。
了解资源分类与访问。 | [OpenHarmony工程介绍](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650)
[资源分类与访问](../quick-start/resource-categories-and-access.md) | -| 学习ArkTS语言 | ArkTS是HarmonyOS优选的主力应用开发语言,当前,ArkTS在TS基础上主要扩展了声明式UI能力。 | [学习ArkTS语言](../quick-start/arkts-get-started.md) | -| 开发页面 | 根据页面的使用场景,选择合适的布局。
根据页面需要实现的内容,添加系统内置组件,并修改组件样式。
更新页面内容,丰富页面展现形式。 | [创建页面](#创建页面)
[常见布局开发指导](ui-ts-layout-linear.md)
[常见组件说明](ui-ts-components-intro.md)
[修改组件样式](#修改组件样式)
[更新页面内容](#更新页面内容) | -| (可选)页面多样化 | 绘图和动画。 | [绘图组件](../reference/arkui-ts/ts-drawing-components-circle.md)
[画布组件](../reference/arkui-ts/ts-components-canvas-canvas.md)
[动画](../reference/arkui-ts/ts-animatorproperty.md) | -| (可选)页面之间的跳转 | 使用页面路由实现多个页面之前的跳转。 | [页面路由](../reference/apis/js-apis-router.md) | -| (可选)性能提升 | 避免低性能代码对应用的性能造成负面影响。 | [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) | +| 任务 | 简介 | 相关资源 | +| ----------- | ---------------------------------------- | ---------------------------------------- | +| 准备开发环境 | 了解声明式UI的工程结构。
了解资源分类与访问。 | [OpenHarmony工程介绍](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650)
[资源分类与访问](../quick-start/resource-categories-and-access.md) | +| 学习ArkTS语言 | ArkTS是OpenHarmony优选的主力应用开发语言,当前,ArkTS在TS基础上主要扩展了声明式UI能力。 | [学习ArkTS语言](../quick-start/arkts-get-started.md) | +| 开发页面 | 根据页面的使用场景,选择合适的布局。
根据页面需要实现的内容,添加系统内置组件,并修改组件样式。
更新页面内容,丰富页面展现形式。 | [创建页面](#创建页面)
  [常见布局开发指导](ui-ts-layout-linear.md)
  [常见组件说明](ui-ts-components-intro.md)
[修改组件样式](#修改组件样式)
[更新页面内容](#更新页面内容) | +| (可选)页面多样化 | 绘图和动画。 | [绘图组件](../reference/arkui-ts/ts-drawing-components-circle.md)
[画布组件](../reference/arkui-ts/ts-components-canvas-canvas.md)
[动画](../reference/arkui-ts/ts-animatorproperty.md) | +| (可选)页面之间的跳转 | 使用页面路由实现多个页面之前的跳转。 | [页面路由](../reference/apis/js-apis-router.md) | +| (可选)性能提升 | 避免低性能代码对应用的性能造成负面影响。 | [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) | ## 创建页面 diff --git a/zh-cn/application-dev/ui/ui-ts-layout-flex.md b/zh-cn/application-dev/ui/ui-ts-layout-flex.md index 3d33681082d1dc1014a17a4a9dae262a7a9e359f..ceac355dcd2597840c09d256a39670e3bafb87f5 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-flex.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-flex.md @@ -5,10 +5,12 @@ - 容器: [Flex组件](../reference/arkui-ts/ts-container-flex.md)作为Flex布局的容器,用于设置布局相关属性。 - 子组件: Flex组件内的子组件自动成为布局的子组件。 -- 主轴: 水平方向的轴线,子组件默认沿着主轴排列。主轴开始的位置称为主轴起始端,结束位置称为主轴终点端。 -- 交叉轴: 垂直方向的轴线。交叉始的位置称为主轴首部,结束位置称为交叉轴尾部。 +- 主轴: Flex组件布局方向的轴线,子组件默认沿着主轴排列。主轴开始的位置称为主轴起始端,结束位置称为主轴终点端。 +- 交叉轴: 垂直于主轴方向的轴线。交叉轴起始的位置称为主轴首部,结束位置称为交叉轴尾部。 - ![](figures/flex.png) +以FlexDirection.Row的Flex为例: + +![](figures/flex.png) ## 容器组件属性 @@ -312,8 +314,8 @@ .padding(10) .backgroundColor(0xAFEEEE) ``` - - ![zh-cn_image_0000001218739570](figures/zh-cn_image_0000001218739570.png) + + ![zh-cn_image_0000001218739570](figures/itemalignstretch.png) - ItemAlign. Baseline:交叉轴方向文本基线对齐。 diff --git a/zh-cn/application-dev/ui/ui-ts-layout-stack.md b/zh-cn/application-dev/ui/ui-ts-layout-stack.md index 63904bd277cea803b4c9147ebf618be26e561d02..19f7026c6f9868826fb716afeaaf0bf37e715b57 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-stack.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-stack.md @@ -47,7 +47,7 @@ Stack容器中兄弟组件显示层级关系可以通过[zIndex](../reference/ar ```ts Stack({ alignContent: Alignment.BottomStart }) { Column() { - Text('Stack子元素1').textAlign(TextAlign.End).fontSize(20) + Text('Stack子元素1').fontSize(20) }.width(100).height(100).backgroundColor(0xffd306).zIndex(2) Column() { Text('Stack子元素2').fontSize(20) diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 96e02fdd8648a52265c6357090a4159af16f4ff9..b43c02c8ddd4c18f29b4abe9a5a8fc5976c80a1b 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -8,10 +8,10 @@ - [使用ArkTS语言开发(FA模型)](quick-start/start-with-ets-fa.md) - [使用JS语言开发(FA模型)](quick-start/start-with-js-fa.md) - 开发基础知识 - - [应用包结构说明(FA模型)](quick-start/package-structure.md) - - [应用包结构说明(Stage模型)](quick-start/stage-structure.md) + - [应用包结构配置文件的说明(FA模型)](quick-start/package-structure.md) + - [应用包结构配置文件的说明(Stage模型)](quick-start/stage-structure.md) - [SysCap说明](quick-start/syscap.md) - - [HarmonyAppProvision配置文件](quick-start/app-provision-structure.md) + - [资源分类与访问](quick-start/resource-categories-and-access.md) - 学习ArkTS语言 - [初识ArkTS语言](quick-start/arkts-get-started.md) - ArkTS语法(声明式UI) @@ -49,35 +49,30 @@ - [方舟开发框架(ArkUI)概述](ui/arkui-overview.md) - 基于ArkTS的声明式开发范式 - [概述](ui/ui-ts-overview.md) - - 框架说明 - - 文件组织 - - [目录结构](ui/ts-framework-directory.md) - - [应用代码文件访问规则](ui/ts-framework-file-access-rules.md) - - 资源管理 - - [资源文件的分类](ui/ui-ts-basic-resource-file-categories.md) - - [资源访问](ui/ts-resource-access.md) - - [像素单位](ui/ts-pixel-units.md) - - 深入理解组件化 - - [自定义组件初始化](ui/ts-custom-component-initialization.md) - - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - - [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md) - - 常见组件开发指导 - - [Button开发指导](ui/ui-ts-basic-components-button.md) - - [Web开发指导](ui/ui-ts-components-web.md) - - 常见布局开发指导 - - [弹性布局](ui/ui-ts-layout-flex.md) - - [栅格布局](ui/ui-ts-layout-grid-container.md) - - [媒体查询](ui/ui-ts-layout-mediaquery.md) - - 体验声明式UI - - [创建声明式UI工程](ui/ui-ts-creating-project.md) - - [初识Component](ui/ui-ts-components.md) + - [声明式UI开发指导](ui/ui-ts-developing-intro.md) + - 声明式UI开发实例 - [创建简单视图](ui/ui-ts-creating-simple-page.md) - - 页面布局与连接 - - [构建食物数据模型](ui/ui-ts-building-data-model.md) - - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) - - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) - - [性能提升的推荐方法](ui/ts-performance-improvement-recommendation.md) + - 构建完整实例 + - [构建食物数据模型](ui/ui-ts-building-data-model.md) + - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) + - [页面跳转与数据传递](ui/ui-ts-page-redirection-data-transmission.md) + - 添加闪屏动画 + - [绘制图像](ui/ui-ts-drawing-feature.md) + - [添加动画效果](ui/ui-ts-animation-feature.md) + - [常用组件说明](ui/ui-ts-components-intro.md) + - 常见布局开发指导 + - 自适应布局 + - [线性布局](ui/ui-ts-layout-linear.md) + - [层叠布局](ui/ui-ts-layout-stack.md) + - [弹性布局](ui/ui-ts-layout-flex.md) + - [网格布局](ui/ui-ts-layout-grid.md) + - 响应式布局 + - [栅格布局](ui/ui-ts-layout-grid-container-new.md) + - [媒体查询](ui/ui-ts-layout-mediaquery.md) + - [自定义组件的生命周期](ui/ui-ts-custom-component-lifecycle-callbacks.md) + - [Web组件开发指导](ui/ui-ts-components-web.md) + - [性能提升的推荐方法](ui/ui-ts-performance-improvement-recommendation.md) - 兼容JS的类Web开发范式 - [概述](ui/ui-js-overview.md) - 框架说明 @@ -174,9 +169,14 @@ - [OpenSL ES播放开发指导](media/opensles-playback.md) - [OpenSL ES录音开发指导](media/opensles-capture.md) - [音频焦点模式开发指导](media/audio-interruptmode.md) + - [音量管理开发指导](media/audio-volume-manager.md) + - [路由、设备管理开发指导](media/audio-routing-manager.md) - 视频 - [视频播放开发指导](media/video-playback.md) - [视频录制开发指导](media/video-recorder.md) + - 媒体会话 + - [AVSession开发概述](media/avsession-overview.md) + - [AVSession开发指导](media/avsession-guidelines.md) - 图片 - [图片开发指导](media/image.md) - 相机 @@ -200,6 +200,7 @@ - Hap包签名工具 - [Hap包签名工具概述](security/hapsigntool-overview.md) - [Hap包签名工具指导](security/hapsigntool-guidelines.md) + - [HarmonyAppProvision配置文件](security/app-provision-structure.md) - 网络与连接 - 网络管理 - [网络管理开发概述](connectivity/net-mgmt-overview.md) @@ -230,6 +231,12 @@ - 数据共享 - [数据共享概述](database/database-datashare-overview.md) - [数据共享开发指导](database/database-datashare-guidelines.md) + - 文件管理 + - 媒体库管理 + - [媒体库开发概述](file-management/medialibrary-overview.md) + - [媒体资源使用指导](file-management/medialibrary-resource-guidelines.md) + - [文件路径使用指导](file-management/medialibrary-filepath-guidelines.md) + - [相册资源使用指导](file-management/medialibrary-album-guidelines.md) - 任务管理 - 后台任务 - [后台任务概述](task-management/background-task-overview.md) @@ -254,12 +261,15 @@ - 振动 - [振动开发概述](device/vibrator-overview.md) - [振动开发指导](device/vibrator-guidelines.md) + - 多模输入 + - [输入设备开发指导](device/inputdevice-guidelines.md) + - [鼠标光标开发指导](device/pointerstyle-guidelines.md) - 升级服务 - [示例服务器开发概述](device/sample-server-overview.md) - [示例服务器开发指导](device/sample-server-guidelines.md) - 设备使用信息统计 - [设备使用信息统计概述](device-usage-statistics/device-usage-statistics-overview.md) - - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-dev-guide.md) + - [设备使用信息统计开发指导](device-usage-statistics/device-usage-statistics-use-guide.md) - DFX - 应用事件打点 - [应用事件打点概述](dfx/hiappevent-overview.md) @@ -272,10 +282,15 @@ - [分布式跟踪开发指导](dfx/hitracechain-guidelines.md) - 错误管理 - [错误管理开发指导](dfx/errormanager-guidelines.md) + - [应用恢复开发指导](dfx/apprecovery-guidelines.md) - 国际化 - [国际化开发概述](internationalization/international-overview.md) - [Intl开发指导](internationalization/intl-guidelines.md) - [I18n开发指导](internationalization/i18n-guidelines.md) + - 应用测试 + - [自动化测试框架使用指导](application-test/arkxtest-guidelines.md) + - [SmartPerf性能工具使用指导](application-test/smartperf-guidelines.md) + - [wukong稳定性工具使用指导](application-test/wukong-guidelines.md) - 一次开发,多端部署 - [前言](key-features/multi-device-app-dev/foreword.md) - [简介](key-features/multi-device-app-dev/introduction.md) @@ -329,6 +344,7 @@ - [Rawfile开发指导](napi/rawfile-guidelines.md) - [Window开发指导](napi/native-window-guidelines.md) - [使用MindSpore Lite引擎进行模型推理](napi/mindspore-lite-guidelines.md) + - [Neural Network Runtime对接AI推理框架开发指导](napi/neural-network-runtime-guidelines.md) - 工具 - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 @@ -337,6 +353,7 @@ - API参考 - [Syscap列表](reference/syscap-list.md) - 组件参考(基于ArkTS的声明式开发范式) + - [组件导读](reference/arkui-ts/ts-components-summary.md) - 组件通用信息 - 通用事件 - [点击事件](reference/arkui-ts/ts-universal-events-click.md) @@ -402,6 +419,8 @@ - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [NavRouter](reference/arkui-ts/ts-basic-components-navrouter.md) + - [NavDestination](reference/arkui-ts/ts-basic-components-navdestination.md) - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - [Progress](reference/arkui-ts/ts-basic-components-progress.md) @@ -435,6 +454,7 @@ - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) - [Counter](reference/arkui-ts/ts-container-counter.md) - [Flex](reference/arkui-ts/ts-container-flex.md) + - [FlowItem](reference/arkui-ts/ts-container-flowitem.md) - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - [GridCol](reference/arkui-ts/ts-container-gridcol.md) - [GridRow](reference/arkui-ts/ts-container-gridrow.md) @@ -455,6 +475,7 @@ - [Swiper](reference/arkui-ts/ts-container-swiper.md) - [Tabs](reference/arkui-ts/ts-container-tabs.md) - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - [WaterFlow](reference/arkui-ts/ts-container-waterflow.md) - 媒体组件 - [Video](reference/arkui-ts/ts-media-components-video.md) - 绘制组件 @@ -483,7 +504,6 @@ - [组件内转场](reference/arkui-ts/ts-transition-animation-component.md) - [共享元素转场](reference/arkui-ts/ts-transition-animation-shared-elements.md) - [路径动画](reference/arkui-ts/ts-motion-path-animation.md) - - 全局UI方法 - 弹窗 - [警告弹窗](reference/arkui-ts/ts-methods-alert-dialog-box.md) @@ -493,8 +513,12 @@ - [时间选择弹窗](reference/arkui-ts/ts-methods-timepicker-dialog.md) - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [菜单](reference/arkui-ts/ts-methods-menu.md) + - [应用级变量的状态管理](reference/arkui-ts/ts-state-management.md) + - [像素单位](reference/arkui-ts/ts-pixel-units.md) - [枚举说明](reference/arkui-ts/ts-appendix-enums.md) - [类型说明](reference/arkui-ts/ts-types.md) + - 已停止维护的组件 + - [GridContainer(栅格)](reference/arkui-ts/ts-container-gridcontainer.md) - 组件参考(兼容JS的类Web开发范式) - 组件通用信息 - [通用属性](reference/arkui-js/js-components-common-attributes.md) @@ -590,12 +614,11 @@ - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - 自定义组件 - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) + - [数据传递与处理](reference/arkui-js/js-components-custom-props.md) - [继承样式](reference/arkui-js/js-components-custom-style.md) - - [自定义事件](reference/arkui-js/js-components-custom-events.md) - - [Props](reference/arkui-js/js-components-custom-props.md) - - [事件参数](reference/arkui-js/js-components-custom-event-parameter.md) - [slot插槽](reference/arkui-js/js-components-custom-slot.md) - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) + - [动态创建组件](reference/arkui-js/js-components-create-elements.md) - [数据类型说明](reference/arkui-js/js-appendix-types.md) - JS服务卡片UI组件参考 - JS服务卡片UI框架说明 @@ -603,9 +626,9 @@ - 语法 - [HML语法参考](reference/js-service-widget-ui/js-service-widget-syntax-hml.md) - [CSS语法参考](reference/js-service-widget-ui/js-service-widget-syntax-css.md) - - [配置数据和事件](reference/js-service-widget-ui/js-service-widget-configuration.md) - [多语言支持](reference/js-service-widget-ui/js-service-widget-multiple-languages.md) - - [低版本兼容](reference/js-service-widget-ui/js-service-widget-version-compatibility.md) + - [版本兼容适配](reference/js-service-widget-ui/js-service-widget-version-compatibility.md) + - [设置主题样式](reference/js-service-widget-ui/js-service-widget-theme.md) - 组件 - 通用 - [通用属性](reference/js-service-widget-ui/js-service-widget-common-attributes.md) @@ -617,6 +640,7 @@ - [无障碍](reference/js-service-widget-ui/js-service-widget-common-accessibility.md) - [原子布局](reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md) - 容器组件 + - [badge](reference/js-service-widget-ui/js-service-widget-container-badge.md) - [div](reference/js-service-widget-ui/js-service-widget-container-div.md) - [list](reference/js-service-widget-ui/js-service-widget-container-list.md) - [list-item](reference/js-service-widget-ui/js-service-widget-container-list-item.md) @@ -633,15 +657,13 @@ - [progress](reference/js-service-widget-ui/js-service-widget-basic-progress.md) - [span](reference/js-service-widget-ui/js-service-widget-basic-span.md) - [text](reference/js-service-widget-ui/js-service-widget-basic-text.md) - - 自定义组件 - - [自定义组件基本用法](reference/js-service-widget-ui/js-service-widget-custom-basic-usage.md) - - [自定义事件](reference/js-service-widget-ui/js-service-widget-custom-events.md) - - [Props](reference/js-service-widget-ui/js-service-widget-custom-props.md) + - [自定义组件使用说明](reference/js-service-widget-ui/js-service-widget-custom-basic-usage.md) - [数据类型说明](reference/js-service-widget-ui/js-service-widget-appendix-types.md) - 接口参考(JS及TS API) - [开发说明](reference/apis/development-intro.md) - Ability框架 - FA模型 + - [@ohos.ability.ability (Ability)](reference/apis/js-apis-ability-ability.md) - [@ohos.ability.featureAbility (FeatureAbility模块)](reference/apis/js-apis-featureAbility.md) - [@ohos.ability.particleAbility (particleAbility模块)](reference/apis/js-apis-particleAbility.md) - [dataAbilityHelper (DataAbilityHelper模块)](reference/apis/js-apis-dataAbilityHelper.md) @@ -652,6 +674,7 @@ - [@ohos.application.AbilityStage (AbilityStage)](reference/apis/js-apis-application-abilitystage.md) - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](reference/apis/js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.DataShareExtensionAbility (数据共享扩展能力)](reference/apis/js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](reference/apis/js-apis-application-EnvironmentCallback.md) - [@ohos.application.FormExtension (FormExtension)](reference/apis/js-apis-formextension.md) - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](reference/apis/js-apis-service-extension-ability.md) - [@ohos.application.StartOptions (StartOptions)](reference/apis/js-apis-application-StartOptions.md) @@ -664,19 +687,17 @@ - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) - [PermissionRequestResult (PermissionRequestResult)](reference/apis/js-apis-permissionrequestresult.md) - - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) + - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) - 通用 - [@ohos.ability.dataUriUtils (DataUriUtils模块)](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.errorCode (ErrorCode)](reference/apis/js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant (wantConstant)](reference/apis/js-apis-ability-wantConstant.md) + - [@ohos.app.ability.appRecovery (appRecovery)](reference/apis/js-apis-app-ability-appRecovery.md) - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.md) - [@ohos.application.abilityManager (AbilityManager)](reference/apis/js-apis-application-abilityManager.md) - - [@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionContext)](reference/apis/js-apis-accessibility-extension-context.md) - - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.application.appManager (appManager)](reference/apis/js-apis-appmanager.md) - - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-configuration.md) - - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-configurationconstant.md) - - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](reference/apis/js-apis-application-EnvironmentCallback.md) + - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-application-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-application-configurationConstant.md) - [@ohos.application.errorManager (ErrorManager)](reference/apis/js-apis-errorManager.md) - [@ohos.application.formBindingData (卡片数据绑定类)](reference/apis/js-apis-formbindingdata.md) - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) @@ -686,55 +707,55 @@ - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) - [@ohos.application.quickFixManager (quickFixManager)](reference/apis/js-apis-application-quickFixManager.md) - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) - - [@ohos.continuation.continuationManager (ContinuationExtraParams)](reference/apis/js-apis-continuation-continuationExtraParams.md) - [@ohos.continuation.continuationManager (continuationManager)](reference/apis/js-apis-continuation-continuationManager.md) - [@ohos.wantAgent (WantAgent模块)](reference/apis/js-apis-wantAgent.md) + - [abilityResult (AbilityResult)](reference/apis/js-apis-ability-abilityResult.md) + - [Want (Want)](reference/apis/js-apis-ability-Want.md) - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) - [abilityMonitor (AbilityMonitor)](reference/apis/js-apis-application-abilityMonitor.md) - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) - - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) - [ProcessRunningInformation (ProcessRunningInformation)](reference/apis/js-apis-processrunninginformation.md) - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) - - continuation/[ContinuationResult (ContinuationResult)](reference/apis/js-apis-continuation-continuationResult.md) + - [continuationExtraParams (ContinuationExtraParams)](reference/apis/js-apis-continuation-continuationExtraParams.md) + - [continuationResult (ContinuationResult)](reference/apis/js-apis-continuation-continuationResult.md) - 公共事件与通知 - - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.md) + - [@ohos.commonEventManager (公共事件模块)](reference/apis/js-apis-commonEventManager.md) - [@ohos.events.emitter (Emitter)](reference/apis/js-apis-emitter.md) - [@ohos.notification (Notification模块)](reference/apis/js-apis-notification.md) - - [@ohos.reminderAgent (后台代理提醒)](reference/apis/js-apis-reminderAgent.md) - [EventHub (EventHub)](reference/apis/js-apis-eventhub.md) - - 应用程序包管理 - - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) - - [@ohos.bundle.defaultAppManager (Bundle模块)](reference/apis/js-apis-bundle-defaultAppManager.md) - - [@ohos.bundle.innerBundleManager (innerBundleManager模块(JS端SDK接口))](reference/apis/js-apis-Bundle-InnerBundleManager.md) - - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) - - [@ohos.distributedBundle (distributedBundle模块(JS端SDK接口))](reference/apis/js-apis-Bundle-distributedBundle.md) + - 包管理 + - [@ohos.bundle.appControl(appControl模块)](reference/apis/js-apis-appControl.md) + - [@ohos.bundle.bundleManager (bundleManager模块)](reference/apis/js-apis-bundleManager.md) + - [@ohos.bundle.bundleMonitor (bundleMonitor模块)](reference/apis/js-apis-bundleMonitor.md) + - [@ohos.bundle.defaultAppManager (默认应用管理)](reference/apis/js-apis-defaultAppManager.md) + - [@ohos.bundle.distributedBundle (distributedBundle模块)](reference/apis/js-apis-distributedBundle.md) + - [@ohos.bundle.freeInstall (freeInstall模块)](reference/apis/js-apis-freeInstall.md) + - [@ohos.bundle.installer (installer模块)](reference/apis/js-apis-installer.md) + - [@ohos.bundle.launcherBundleManager (launcherBundleManager模块)](reference/apis/js-apis-launcherBundleManager.md) - [@ohos.zlib (Zip模块)](reference/apis/js-apis-zlib.md) - - [AbilityInfo (AbilityInfo)](reference/apis/js-apis-bundle-AbilityInfo.md) - - [ApplicationInfo (ApplicationInfo)](reference/apis/js-apis-bundle-ApplicationInfo.md) - - [BundleInfo (BundleInfo)](reference/apis/js-apis-bundle-BundleInfo.md) - - [BundleInstaller (BundleInstaller)](reference/apis/js-apis-bundle-BundleInstaller.md) - - [BundleStatusCallback (BundleStatusCallback)](reference/apis/js-apis-Bundle-BundleStatusCallback.md) - - [CustomizeData (CustomizeData)](reference/apis/js-apis-bundle-CustomizeData.md) - - [DispatchInfo (DispatchInfo)](reference/apis/js-apis-dispatchInfo.md) - - [ElementName (ElementName)](reference/apis/js-apis-bundle-ElementName.md) - - [ExtensionAbilityInfo (ExtensionAbilityInfo)](reference/apis/js-apis-bundle-ExtensionAbilityInfo.md) - - [HapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundle-HapModuleInfo.md) - - [LauncherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) - - [Metadata (Metadata)](reference/apis/js-apis-bundle-Metadata.md) - - [ModuleInfo (ModuleInfo)](reference/apis/js-apis-bundle-ModuleInfo.md) - - [PackInfo (PackInfo)](reference/apis/js-apis-bundle-PackInfo.md) - - [PermissionDef (PermissionDef)](reference/apis/js-apis-bundle-PermissionDef.md) - - [RemoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundle-remoteAbilityInfo.md) - - [ShortcutInfo (ShortcutInfo)](reference/apis/js-apis-bundle-ShortcutInfo.md) + - [abilityInfo (AbilityInfo)](reference/apis/js-apis-bundleManager-abilityInfo.md) + - [applicationInfo (ApplicationInfo)](reference/apis/js-apis-bundleManager-applicationInfo.md) + - [bundleInfo (BundleInfo)](reference/apis/js-apis-bundleManager-bundleInfo.md) + - [dispatchInfo (DispatchInfo)](reference/apis/js-apis-bundleManager-dispatchInfo.md) + - [elementName (ElementName)](reference/apis/js-apis-bundleManager-elementName.md) + - [extensionAbilityInfo (ExtensionAbilityInfo)](reference/apis/js-apis-bundleManager-extensionAbilityInfo.md) + - [hapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundleManager-hapModuleInfo.md) + - [launcherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundleManager-launcherAbilityInfo.md) + - [metadata (Metadata)](reference/apis/js-apis-bundleManager-metadata.md) + - [packInfo (PackInfo)](reference/apis/js-apis-bundleManager-packInfo.md) + - [permissionDef (PermissionDef)](reference/apis/js-apis-bundleManager-permissionDef.md) + - [remoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundleManager-remoteAbilityInfo.md) + - [shortcutInfo (ShortcutInfo)](reference/apis/js-apis-bundleManager-shortcutInfo.md) - UI界面 - [@ohos.animator (动画)](reference/apis/js-apis-animator.md) + - [@ohos.curves (插值计算)](reference/apis/js-apis-curve.md) + - [@ohos.matrix4 (矩阵变换)](reference/apis/js-apis-matrix4.md) - [@ohos.mediaquery (媒体查询)](reference/apis/js-apis-mediaquery.md) - - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.promptAction (弹窗)](reference/apis/js-apis-promptAction.md) - [@ohos.router (页面路由)](reference/apis/js-apis-router.md) - - [@ohos.uiAppearance(用户界面外观)](reference/apis/js-apis-uiappearance.md) - 图形图像 - [@ohos.animation.windowAnimationManager (窗口动画管理)](reference/apis/js-apis-windowAnimationManager.md) - [@ohos.display (屏幕属性)](reference/apis/js-apis-display.md) @@ -747,6 +768,7 @@ - [webgl2 (WebGL2)](reference/apis/js-apis-webgl2.md) - 媒体 - [@ohos.multimedia.audio (音频管理)](reference/apis/js-apis-audio.md) + - [@ohos.multimedia.avsession (媒体会话管理)](reference/apis/js-apis-avsession.md) - [@ohos.multimedia.camera (相机管理)](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image (图片处理)](reference/apis/js-apis-image.md) - [@ohos.multimedia.media (媒体服务)](reference/apis/js-apis-media.md) @@ -755,19 +777,16 @@ - [@ohos.intl (国际化-Intl)](reference/apis/js-apis-intl.md) - [@ohos.resourceManager (资源管理)](reference/apis/js-apis-resource-manager.md) - 资源调度 - - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.distributedMissionManager (分布式任务管理)](reference/apis/js-apis-distributedMissionManager.md) - - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) + - [@ohos.reminderAgentManager (后台代理提醒)](reference/apis/js-apis-reminderAgentManager.md) + - [@ohos.resourceschedule.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-resourceschedule-backgroundTaskManager.md) + - [@ohos.resourceschedule.workScheduler (延迟任务调度)](reference/apis/js-apis-resourceschedule-workScheduler.md) + - [@ohos.resourceschedule.usageStatistics (设备使用信息统计)](reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - - 定制管理 - - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-config-policy.md) - - [@ohos.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - - [@ohos.enterpriseDeviceManager (企业设备管理)](reference/apis/js-apis-enterprise-device-manager.md) - - [DeviceSettingsManager(设备设置管理)](reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) - 安全 - - [@ohos.abilityAccessCtrl (访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.abilityAccessCtrl (程序访问控制管理)](reference/apis/js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager (隐私管理)](reference/apis/js-apis-privacyManager.md) - - [@ohos.security.cryptoFramework (加密算法库框架)](reference/apis/js-apis-cryptoFramework.md) + - [@ohos.security.cryptoFramework (加解密算法库框架)](reference/apis/js-apis-cryptoFramework.md) - [@ohos.security.huks (通用密钥库系统)](reference/apis/js-apis-huks.md) - [@ohos.userIAM.faceAuth (人脸认证)](reference/apis/js-apis-useriam-faceauth.md) - [@ohos.userIAM.userAuth (用户认证)](reference/apis/js-apis-useriam-userauth.md) @@ -777,19 +796,18 @@ - [@ohos.data.dataShare (数据共享)](reference/apis/js-apis-data-dataShare.md) - [@ohos.data.dataSharePredicates (数据共享谓词)](reference/apis/js-apis-data-dataSharePredicates.md) - [@ohos.data.dataShareResultSet (数据共享结果集)](reference/apis/js-apis-data-DataShareResultSet.md) - - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedDataObject (分布式数据对象)](reference/apis/js-apis-data-distributedobject.md) + - [@ohos.data.distributedKVStore (分布式键值数据库)](reference/apis/js-apis-distributedKVStore.md) - [@ohos.data.preferences (首选项)](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb (关系型数据库)](reference/apis/js-apis-data-rdb.md) - [@ohos.data.ValuesBucket (数据集)](reference/apis/js-apis-data-ValuesBucket.md) - [resultSet (结果集)](reference/apis/js-apis-data-resultset.md) - 文件管理 - - [@ohos.data.fileAccess (公共文件访问与管理)](reference/apis/js-apis-fileAccess.md) - - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) - [@ohos.environment (目录环境能力)](reference/apis/js-apis-environment.md) + - [@ohos.data.fileAccess (公共文件访问与管理)](reference/apis/js-apis-fileAccess.md) - [@ohos.fileExtensionInfo (公共文件访问与管理属性信息)](reference/apis/js-apis-fileExtensionInfo.md) - [@ohos.fileio (文件管理)](reference/apis/js-apis-fileio.md) - - [@ohos.filemanagement.userfile_manager (用户数据管理)](reference/apis/js-apis-userfilemanager.md) + - [@ohos.filemanagement.userFileManager (用户数据管理)](reference/apis/js-apis-userFileManager.md) - [@ohos.multimedia.medialibrary (媒体库管理)](reference/apis/js-apis-medialibrary.md) - [@ohos.securityLabel (数据标签)](reference/apis/js-apis-securityLabel.md) - [@ohos.statfs (statfs)](reference/apis/js-apis-statfs.md) @@ -807,11 +825,8 @@ - [@ohos.net.connection (网络连接管理)](reference/apis/js-apis-net-connection.md) - [@ohos.net.ethernet (以太网连接管理)](reference/apis/js-apis-net-ethernet.md) - [@ohos.net.http (数据请求)](reference/apis/js-apis-http.md) - - [@ohos.net.policy (网络策略管理)](reference/apis/js-apis-net-policy.md) - [@ohos.net.sharing (网络共享管理)](reference/apis/js-apis-net-sharing.md) - [@ohos.net.socket (Socket连接)](reference/apis/js-apis-socket.md) - - [@ohos.net.statistics (网络流量管理)](reference/apis/js-apis-net-statistics.md) - - [@ohos.net.tlsSocket (TLSSocket连接)](reference/apis/js-apis-tlsSocket.md) - [@ohos.net.webSocket (WebSocket连接)](reference/apis/js-apis-webSocket.md) - [@ohos.request (上传下载)](reference/apis/js-apis-request.md) - 通信与连接 @@ -822,40 +837,49 @@ - [@ohos.nfc.tag (标准NFC-Tag)](reference/apis/js-apis-nfcTag.md) - [@ohos.rpc (RPC通信)](reference/apis/js-apis-rpc.md) - [@ohos.wifi (WLAN)](reference/apis/js-apis-wifi.md) - - [@ohos.wifiext (WLAN)](reference/apis/js-apis-wifiext.md) + - [@ohos.wifiext (WLAN扩展接口)](reference/apis/js-apis-wifiext.md) - [nfctech (标准NFC-Tag Nfc 技术)](reference/apis/js-apis-nfctech.md) - [tagSession (标准NFC-Tag TagSession)](reference/apis/js-apis-tagSession.md) - 系统基础能力 - [@ohos.accessibility (辅助功能)](reference/apis/js-apis-accessibility.md) - [@ohos.accessibility.config (系统辅助功能配置)](reference/apis/js-apis-accessibility-config.md) + - [@ohos.accessibility.GesturePath (手势路径)](reference/apis/js-apis-accessibility-GesturePath.md) + - [@ohos.accessibility.GesturePoint (手势触摸点)](reference/apis/js-apis-accessibility-GesturePoint.md) + - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.faultLogger (故障日志获取)](reference/apis/js-apis-faultLogger.md) - - [@ohos.hiAppEvent (应用打点)](reference/apis/js-apis-hiappevent.md) - [@ohos.hichecker (检测模式)](reference/apis/js-apis-hichecker.md) - [@ohos.hidebug (Debug调试)](reference/apis/js-apis-hidebug.md) - - [@ohos.hilog (日志打印)](reference/apis/js-apis-hilog.md) + - [@ohos.hilog (HiLog日志打印)](reference/apis/js-apis-hilog.md) - [@ohos.hiSysEvent (系统事件打点)](reference/apis/js-apis-hisysevent.md) - [@ohos.hiTraceChain (分布式跟踪)](reference/apis/js-apis-hitracechain.md) - [@ohos.hiTraceMeter (性能打点)](reference/apis/js-apis-hitracemeter.md) + - [@ohos.hiviewdfx.hiAppEvent (应用事件打点)](reference/apis/js-apis-hiviewdfx-hiappevent.md) - [@ohos.inputmethod (输入法框架)](reference/apis/js-apis-inputmethod.md) - [@ohos.inputmethodengine (输入法服务)](reference/apis/js-apis-inputmethodengine.md) - [@ohos.inputmethodextensionability (InputMethodExtensionAbility)](reference/apis/js-apis-inputmethod-extension-ability.md) - [@ohos.inputmethodextensioncontext (InputMethodExtensionContext)](reference/apis/js-apis-inputmethod-extension-context.md) + - [@ohos.inputmethodsubtype(输入法子类型)](reference/apis/js-apis-inputmethod-subtype.md) - [@ohos.pasteboard (剪贴板)](reference/apis/js-apis-pasteboard.md) - [@ohos.screenLock (锁屏管理)](reference/apis/js-apis-screen-lock.md) - [@ohos.systemTime (系统时间、时区)](reference/apis/js-apis-system-time.md) - [@ohos.systemTimer(系统定时器)](reference/apis/js-apis-system-timer.md) - [@ohos.wallpaper (壁纸)](reference/apis/js-apis-wallpaper.md) + - [@ohos.web.webview(Web)](reference/apis/js-apis-webview.md) + - [console (日志打印)](reference/apis/js-apis-logs.md) - [Timer (定时器)](reference/apis/js-apis-timer.md) + - [AccessibilityExtensionContext (辅助功能扩展上下文)](reference/apis/js-apis-accessibility-extension-context.md) - 设备管理 - [@ohos.batteryInfo (电量信息)](reference/apis/js-apis-battery-info.md) + - [@ohos.batteryStatistics (耗电统计)](reference/apis/js-apis-batteryStatistics.md) - [@ohos.brightness (屏幕亮度)](reference/apis/js-apis-brightness.md) - [@ohos.deviceInfo (设备信息)](reference/apis/js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (设备管理)](reference/apis/js-apis-device-manager.md) - - [@ohos.geolocation (位置服务)](reference/apis/js-apis-geolocation.md) + - [@ohos.geoLocationManager (位置服务)](reference/apis/js-apis-geoLocationManager.md) - [@ohos.multimodalInput.inputConsumer (组合按键)](reference/apis/js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越)](reference/apis/js-apis-cooperate.md) - [@ohos.multimodalInput.inputEvent (输入事件)](reference/apis/js-apis-inputevent.md) - - [@ohos.multimodalInput.inputEventClient (注入按键)](reference/apis/js-apis-inputeventclient.md) + - [@ohos.multimodalInput.inputEventClient (按键注入)](reference/apis/js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (输入监听)](reference/apis/js-apis-inputmonitor.md) - [@ohos.multimodalInput.keyCode (键值)](reference/apis/js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (按键输入事件)](reference/apis/js-apis-keyevent.md) @@ -866,15 +890,21 @@ - [@ohos.runningLock (Runninglock锁)](reference/apis/js-apis-runninglock.md) - [@ohos.sensor (传感器)](reference/apis/js-apis-sensor.md) - [@ohos.settings (设置数据项名称)](reference/apis/js-apis-settings.md) - - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.md) + - [@ohos.systemCapability (系统能力)](reference/apis/js-apis-system-capability.md) + - [@ohos.systemParameterV9 (系统属性)](reference/apis/js-apis-system-parameterV9.md) - [@ohos.thermal (热管理)](reference/apis/js-apis-thermal.md) - [@ohos.update (升级)](reference/apis/js-apis-update.md) - - [@ohos.usb (USB管理)](reference/apis/js-apis-usb.md) + - [@ohos.usbV9 (USB管理)](reference/apis/js-apis-usb.md) - [@ohos.vibrator (振动)](reference/apis/js-apis-vibrator.md) - 帐号管理 - [@ohos.account.appAccount (应用帐号管理)](reference/apis/js-apis-appAccount.md) - [@ohos.account.distributedAccount (分布式帐号管理)](reference/apis/js-apis-distributed-account.md) - [@ohos.account.osAccount (系统帐号管理)](reference/apis/js-apis-osAccount.md) + - 定制管理 + - [@ohos.configPolicy (配置策略)](reference/apis/js-apis-configPolicy.md) + - [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) + - [@ohos.enterprise.adminManager (企业设备管理)](reference/apis/js-apis-enterprise-adminManager.md) + - [@ohos.enterprise.dateTimeManager(系统时间管理)](reference/apis/js-apis-enterprise-dateTimeManager.md) - 语言基础类库 - [@ohos.buffer (Buffer)](reference/apis/js-apis-buffer.md) - [@ohos.convertxml (xml转换JavaScript)](reference/apis/js-apis-convertxml.md) @@ -902,8 +932,22 @@ - [@ohos.application.testRunner (TestRunner)](reference/apis/js-apis-testRunner.md) - [@ohos.uitest (UiTest)](reference/apis/js-apis-uitest.md) - 已停止维护的接口 + - [@ohos.backgroundTaskManager (后台任务管理)](reference/apis/js-apis-backgroundTaskManager.md) + - [@ohos.bundle (Bundle模块)](reference/apis/js-apis-Bundle.md) + - [@ohos.bundle.innerBundleManager (innerBundleManager模块)](reference/apis/js-apis-Bundle-InnerBundleManager.md) + - [@ohos.bundleState (设备使用信息统计)](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.bytrace (性能打点)](reference/apis/js-apis-bytrace.md) + - [@ohos.commonEvent (公共事件模块)](reference/apis/js-apis-commonEvent.md) - [@ohos.data.storage (轻量级存储)](reference/apis/js-apis-data-storage.md) + - [@ohos.data.distributedData (分布式数据管理)](reference/apis/js-apis-distributed-data.md) + - [@ohos.distributedBundle (分布式包管理)](reference/apis/js-apis-Bundle-distributedBundle.md) + - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) + - [@ohos.geolocation (位置服务)](reference/apis/js-apis-geolocation.md) + - [@ohos.hiAppEvent (应用打点)](reference/apis/js-apis-hiappevent.md) + - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) + - [@ohos.reminderAgent (后台代理提醒)](reference/apis/js-apis-reminderAgent.md) + - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.md) + - [@ohos.usb (USB管理)](reference/apis/js-apis-usb-deprecated.md) - [@system.app (应用上下文)](reference/apis/js-apis-system-app.md) - [@system.battery (电量信息)](reference/apis/js-apis-system-battery.md) - [@system.bluetooth (蓝牙)](reference/apis/js-apis-system-bluetooth.md) @@ -923,8 +967,100 @@ - [@system.sensor (传感器)](reference/apis/js-apis-system-sensor.md) - [@system.storage (数据存储)](reference/apis/js-apis-system-storage.md) - [@system.vibrator (振动)](reference/apis/js-apis-system-vibrate.md) - - [console (日志打印)](reference/apis/js-apis-logs.md) - + - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) + - [abilityInfo (AbilityInfo)](reference/apis/js-apis-bundle-AbilityInfo.md) + - [applicationInfo (ApplicationInfo)](reference/apis/js-apis-bundle-ApplicationInfo.md) + - [bundleInfo (BundleInfo)](reference/apis/js-apis-bundle-BundleInfo.md) + - [bundleInstaller (BundleInstaller)](reference/apis/js-apis-bundle-BundleInstaller.md) + - [bundleStatusCallback (BundleStatusCallback)](reference/apis/js-apis-Bundle-BundleStatusCallback.md) + - [customizeData (CustomizeData)](reference/apis/js-apis-bundle-CustomizeData.md) + - [elementName (ElementName)](reference/apis/js-apis-bundle-ElementName.md) + - [hapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundle-HapModuleInfo.md) + - [launcherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) + - [moduleInfo (ModuleInfo)](reference/apis/js-apis-bundle-ModuleInfo.md) + - [PermissionDef (PermissionDef)](reference/apis/js-apis-bundle-PermissionDef.md) + - [remoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundle-remoteAbilityInfo.md) + - [shortcutInfo (shortcutInfo)](reference/apis/js-apis-bundle-ShortcutInfo.md) + - 错误码参考 + - [通用错误码](reference/errorcodes/errorcode-universal.md) + - Ability框架 + - [元能力子系统错误码](reference/errorcodes/errorcode-ability.md) + - [DistributedSchedule错误码](reference/errorcodes/errorcode-DistributedSchedule.md) + - 包管理 + - [包管理子系统通用错误码](reference/errorcodes/errorcode-bundle.md) + - [zlib子系统错误码](reference/errorcodes/errorcode-zlib.md) + - 公共事件与通知 + - [事件错误码](reference/errorcodes/errorcode-CommonEventService.md) + - [DistributedNotificationService错误码](reference/errorcodes/errorcode-DistributedNotificationService.md) + - UI界面 + - [动画错误码](reference/errorcodes/errorcode-animator.md) + - [弹窗错误码](reference/errorcodes/errorcode-promptAction.md) + - [页面路由错误码](reference/errorcodes/errorcode-router.md) + - 图形图像 + - [色彩管理错误码](reference/errorcodes/errorcode-colorspace-manager.md) + - [屏幕错误码](reference/errorcodes/errorcode-display.md) + - [窗口错误码](reference/errorcodes/errorcode-window.md) + - 媒体 + - [Audio错误码](reference/errorcodes/errorcode-audio.md) + - [媒体会话管理错误码](reference/errorcodes/errorcode-avsession.md) + - 资源管理 + - [I18n错误码](reference/errorcodes/errorcode-i18n.md) + - [资源管理错误码](reference/errorcodes/errorcode-resource-manager.md) + - 资源调度 + - [backgroundTaskManager错误码](reference/errorcodes/errorcode-backgroundTaskMgr.md) + - [DeviceUsageStatistics错误码](reference/errorcodes/errorcode-DeviceUsageStatistics.md) + - [reminderAgentManager错误码](reference/errorcodes/errorcode-reminderAgentManager.md) + - [workScheduler错误码](reference/errorcodes/errorcode-workScheduler.md) + - 安全 + - [AccessToken错误码](reference/errorcodes/errorcode-access-token.md) + - [HUKS错误码](reference/errorcodes/errorcode-huks.md) + - [用户认证错误码](reference/errorcodes/errorcode-useriam.md) + - 数据管理 + - [关系型数据库错误码](reference/errorcodes/errorcode-data-rdb.md) + - [数据共享错误码](reference/errorcodes/errorcode-datashare.md) + - [分布式数据对象错误码](reference/errorcodes/errorcode-distributed-dataObject.md) + - [分布式键值数据库错误码](reference/errorcodes/errorcode-distributedKVStore.md) + - [首选项错误码](reference/errorcodes/errorcode-preferences.md) + - 文件管理 + - [文件管理子系统错误码](reference/errorcodes/errorcode-filemanagement.md) + - 网络管理 + - [上传下载错误码](reference/errorcodes/errorcode-request.md) + - 通信与连接 + - [NFC错误码](reference/errorcodes/errorcode-nfc.md) + - [RPC错误码](reference/errorcodes/errorcode-rpc.md) + - 系统基础能力 + - [无障碍子系统错误码](reference/errorcodes/errorcode-accessibility.md) + - [Faultlogger错误码](reference/errorcodes/errorcode-faultlogger.md) + - [应用事件打点错误码](reference/errorcodes/errorcode-hiappevent.md) + - [系统事件错误码](reference/errorcodes/errorcode-hisysevent.md) + - [Hidebug错误码](reference/errorcodes/errorcode-hiviewdfx-hidebug.md) + - [输入法框架错误码](reference/errorcodes/errorcode-inputmethod-framework.md) + - [剪贴板错误码](reference/errorcodes/errorcode-pasteboard.md) + - [Webview错误码](reference/errorcodes/errorcode-webview.md) + - 帐号管理 + - [Account错误码](reference/errorcodes/errorcode-account.md) + - [应用帐号错误码](reference/errorcodes/errorcode-app-account.md) + - 设备管理 + - [耗电统计错误码](reference/errorcodes/errorcode-batteryStatistics.md) + - [屏幕亮度错误码](reference/errorcodes/errorcode-brightness.md) + - [系统电源管理错误码](reference/errorcodes/errorcode-power.md) + - [RunningLock锁错误码](reference/errorcodes/errorcode-runninglock.md) + - [热管理错误码](reference/errorcodes/errorcode-thermal.md) + - [设备管理错误码](reference/errorcodes/errorcode-device-manager.md) + - [位置服务子系统错误码](reference/errorcodes/errorcode-geoLocationManager.md) + - [键鼠穿越管理错误码](reference/errorcodes/errorcode-multimodalinput.md) + - [传感器错误码](reference/errorcodes/errorcode-sensor.md) + - [振动错误码](reference/errorcodes/errorcode-vibrator.md) + - [系统参数错误码](reference/errorcodes/errorcode-system-parameterV9.md) + - [USB服务错误码](reference/errorcodes/errorcode-usb.md) + - [升级错误码](reference/errorcodes/errorcode-update.md) + - 定制管理 + - [企业设备管理错误码](reference/errorcodes/errorcode-enterpriseDeviceManager.md) + - 语言基础类库 + - [buffer错误码](reference/errorcodes/errorcode-buffer.md) + - [containers错误码](reference/errorcodes/errorcode-containers.md) + - 测试 + - [uitest错误码](reference/errorcodes/errorcode-uitest.md) - 接口参考(Native API) - 模块 - [Native XComponent](reference/native-apis/_o_h___native_x_component.md) @@ -937,6 +1073,7 @@ - [Image](reference/native-apis/image.md) - [Rawfile](reference/native-apis/rawfile.md) - [MindSpore](reference/native-apis/_mind_spore.md) + - [NeuralNeworkRuntime](reference/native-apis/_neural_nework_runtime.md) - 头文件 - [drawing_bitmap.h](reference/native-apis/drawing__bitmap_8h.md) - [drawing_brush.h](reference/native-apis/drawing__brush_8h.md) @@ -965,6 +1102,8 @@ - [status.h](reference/native-apis/status_8h.md) - [tensor.h](reference/native-apis/tensor_8h.md) - [types.h](reference/native-apis/types_8h.md) + - [neural_network_runtime_type.h](reference/native-apis/neural__network__runtime__type_8h.md) + - [neural_network_runtime.h](reference/native-apis/neural__network__runtime_8h.md) - 结构体 - [OH_Drawing_BitmapFormat](reference/native-apis/_o_h___drawing___bitmap_format.md) - [OH_NativeBuffer_Config](reference/native-apis/_o_h___native_buffer___config.md) @@ -982,6 +1121,10 @@ - [OH_AI_CallBackParam](reference/native-apis/_o_h___a_i___call_back_param.md) - [OH_AI_ShapeInfo](reference/native-apis/_o_h___a_i___shape_info.md) - [OH_AI_TensorHandleArray](reference/native-apis/_o_h___a_i___tensor_handle_array.md) + - [OH_NN_Memory](reference/native-apis/_o_h___n_n___memory.md) + - [OH_NN_QuantParam](reference/native-apis/_o_h___n_n___quant_param.md) + - [OH_NN_Tensor](reference/native-apis/_o_h___n_n___tensor.md) + - [OH_NN_UInt32Array](reference/native-apis/_o_h___n_n___u_int32_array.md) - 标准库 - [Node_API](reference/native-lib/third_party_napi/napi.md) - [libuv](reference/native-lib/third_party_libuv/libuv.md) @@ -992,14 +1135,21 @@ - [Native api中导出的OpenGL ES 3.0符号列表](reference/native-lib/third_party_opengl/openglesv3-symbol.md) - 常见问题 - [full-SDK替换指南](quick-start/full-sdk-switch-guide.md) + - [开发语言常见问题](faqs/faqs-language.md) - [Ability框架开发常见问题](faqs/faqs-ability.md) + - [应用程序包管理开发常见问题](faqs/faqs-bundle.md) + - [ArkUI组件(ArkTS)开发常见问题](faqs/faqs-ui-ets.md) + - [ArkUI Web组件(ArkTS)开发常见问题](faqs/faqs-web-arkts.md) - [UI框架(JS)开发常见问题](faqs/faqs-ui-js.md) - - [UI框架(ArkTS)开发常见问题](faqs/faqs-ui-ets.md) + - [公共事件与通知开发常见问题](faqs/faqs-event-notification.md) - [图形图像开发常见问题](faqs/faqs-graphics.md) - [文件管理开发常见问题](faqs/faqs-file-management.md) + - [媒体开发常见问题](faqs/faqs-media.md) - [网络与连接开发常见问题](faqs/faqs-connectivity.md) - [数据管理开发常见问题](faqs/faqs-data-management.md) - [设备管理开发常见问题](faqs/faqs-device-management.md) + - [DFX开发常见问题](faqs/faqs-dfx.md) + - [国际化开发常见问题](faqs/faqs-international.md) - [Native API使用常见问题](faqs/faqs-native.md) - [三四方库使用常见问题](faqs/faqs-third-party-library.md) - [IDE使用常见问题](faqs/faqs-ide.md) diff --git a/zh-cn/contribute/OpenHarmony-security-test-guide.md b/zh-cn/contribute/OpenHarmony-security-test-guide.md index 2ef9bd4f8bbce5ab95a5100098077b68b16ef5c8..baea8ed9d108a6a673813a8260aa2d418f052a96 100644 --- a/zh-cn/contribute/OpenHarmony-security-test-guide.md +++ b/zh-cn/contribute/OpenHarmony-security-test-guide.md @@ -1,27 +1,41 @@ -# OpenHarmony安全测试规范 +# OpenHarmony安全测试规范 + 本文档主要参考业界安全测试标准和最佳实践,提供OpenHarmony安全测试规范,用于指导开发人员/测试人员进行安全测试。 +## 1 安全测试内容 + +1、各模块依据[OpenHarmony C&C++安全编程指南](OpenHarmony-c-cpp-secure-coding-guide.md),进行代码安全检视,检视问题均需要修复。 + +2、通过OpenHarmony代码门禁安全扫描工具测试,扫描告警结果清零。 + +3、依据[OpenHarmony编译规范](https://gitee.com/openharmony/community/blob/master/sig/sig-buildsystem/编译规范.md),使用编译选项扫描工具检查二进制文件编译选项开启情况,二进制文件编译选项均需要符合规范要求。 + +4、针对接收并处理用户态参数模块,开发人员需依据[Fuzz测试框架](https://gitee.com/openharmony/test_developertest/tree/master/libs/fuzzlib)开发灰白盒Fuzz测试套,并完成灰白盒Fuzz测试验证。 +5、针对开源组件使用业界漏洞扫描工具扫描,开源组件漏洞均已按照社区漏洞管理流程修复。 -## 安全编码测试 +6、针对发布版本进行一致性验证,在[版本发布网站](../release-notes/Readme.md)中检查版本镜像是否提供SAH256校验码。 -1、各模块依据[OpenHarmony安全编码规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md),进行代码安全检视。 +7、各模块依据[OpenHarmony安全设计规范](OpenHarmony-security-design-guide.md),结合业务完成安全设计自检验证,自检设计问题均需要修复。 -2、使用安全编码扫描工具扫描测试,扫描告警结果清零。OpenHarmony代码门禁已集成安全编码扫描工具。 +8、使用主流病毒扫描软件扫描软件包,病毒扫描结果均修复或确认为工具误报。 +9、在代码中搜索“.cer”、“.pem”等证书秘钥格式或者“PRIVATE KEY”等证书秘钥证书关键词找到证书秘钥,检查证书秘钥是否在有效期内,加密算法是否符合[加密算法要求](OpenHarmony-security-design-guide.md#3加密),证书秘钥问题均需要修复。 -## 安全设计验证 +10、针对暴露用户态接口进行黑盒Fuzz,包括但不限于系统服务接口、内核驱动接口、socket网络接口。 -1、各模块依据[OpenHarmony安全设计规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-security-design-guide.md),结合业务完成安全设计自检验证。 +>说明:上述要求不区分继承特性及新需求。 +## 2 安全测试完成要求 +版本发布前需进行安全测试,安全测试完成标准如下: -## 安全测试工具扫描 +1、上述章节中各项安全测试内容执行完成。 -1、针对高风险模块,开发人员需要依据[Fuzz测试框架](https://gitee.com/openharmony/test_developertest/tree/master/libs/fuzzlib)开发灰白盒Fuzz测试套,并完成灰白盒Fuzz测试。 +2、安全问题均已关闭。 -2、针对暴露用户态接口进行黑盒Fuzz,包括但不限于系统服务接口、内核驱动接口、socket网络接口。 +## 3 安全测试报告模板 -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),使用编译选项扫描工具检查文件编译选项开启情况。 +1、安全测试报告需包含第1章节安全测试各项结果,需包含未关闭安全问题情况。 -4、针对开源组件使用业界漏洞扫描工具扫描,开源组件漏洞均已按照社区漏洞管理流程修复。 \ No newline at end of file +2、版本安全测试报告无需单独发布和归档,随版本整体测试报告发布。 \ No newline at end of file diff --git a/zh-cn/contribute/style-guide/style-guide-document-structure.md b/zh-cn/contribute/style-guide/style-guide-document-structure.md index 07935ecd30a56bf6458d15b5d8852d5bd0092e87..6d67e8e64d2c63d970b0a134bda0f779393074f8 100644 --- a/zh-cn/contribute/style-guide/style-guide-document-structure.md +++ b/zh-cn/contribute/style-guide/style-guide-document-structure.md @@ -131,7 +131,7 @@ - 由字母、数字、中划线“-”组成。统一使用“.md”(小写)后缀。 -- 除Readme.md外,其他文件名原则上全小写。 +- 除Readme.md外,其他文件名原则上全小写。如果驼峰写法能够使文件名可读性更好,可以酌情使用驼峰写法。 - 语义化,文件名能对文档主题内容进行概括,建议取自该文档的英文标题,如:ability-assistant-guidelines.md。 diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" "b/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" index ae8a73e9c771c7a42ce662c325c43d4990f82182..7c88515d1be29f7211403c4ead878da940d6755f 100755 --- "a/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" +++ "b/zh-cn/contribute/\350\264\241\347\214\256\344\273\243\347\240\201.md" @@ -30,6 +30,10 @@ 若要引入新的第三方开源软件到OpenHarmony项目中,请参考[第三方开源软件引入指导](第三方开源软件引入指导.md) +### 测试规范 + +[OpenHarmony安全测试规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-security-test-guide.md) + ## 贡献工作流 有关详细信息,请参考[贡献流程](贡献流程.md)。 @@ -45,4 +49,3 @@ - [安全问题处理和发布流程](https://gitee.com/openharmony/security/blob/master/zh/security-process/README.md) - [安全和披露说明](https://gitee.com/openharmony/security/blob/master/zh/security-process/security-disclosure.md) - diff --git a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md index 15f4c4e15ee145b2df316976f781a00884ad0763..48ffbf0f5263bd9d898e07ec03a5f096778628ec 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-face_auth-des.md @@ -6,7 +6,7 @@ 人脸识别功能是端侧设备不可或缺的一部分,为设备提供一种用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。它是基于人的脸部特征信息进行身份识别的一种生物特征识别技术,用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别,通常也叫做人像识别、面部识别、人脸认证。人脸识别功能整体框架如图1。 -基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸的录入,删除,认证和识别等。 +基于HDF(Hardware Driver Foundation)驱动框架开发的Face_auth驱动,能够屏蔽硬件器件差异,为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力接口,包括人脸识别执行器列表查询、执行器信息查询、指定人脸模板ID查询模板信息、用户认证框架和执行器间的人脸模板信息对账、人脸录入、删除、认证和识别等。 **图1** 人脸识别功能整体框架 @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -51,6 +51,22 @@ 用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。 +- HAPs + + HAPs(OpenHarmony Ability Packages),广义上指可以安装在OpenHarmony上的应用包,本章节中仅代表Face_auth驱动的上层应用。 + +- IDL接口 + + 接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Face_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)。 + +- IPC通信 + + IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)。 + +- HDI + + HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)。 + ### 运作机制 Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务提供稳定的人脸识别基础能力,保证设备上人脸识别功能可以正常运行。 @@ -74,24 +90,28 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/face_auth/v1_0/)。 + +在本文中,人脸凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于人脸执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | -| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 | +| 接口名称 | 功能介绍 | +| ----------------------------------- | ---------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定人脸模板ID的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey, const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的人脸模板列表用于对账。 | -| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入人脸模板。 | -| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证人脸模板。 | +| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入人脸模板。 | +| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证人脸模板。 | | Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别人脸模板。 | -| Delete(const std::vector& templateIdList) | 删除人脸模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | +| Delete(const std::vector& templateIdList) | 删除人脸模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | | SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 人脸认证服务向Face_auth驱动传递参数的通用接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | ------------------------ | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnTip(int32_t code, const std::vector& extraInfo) | 返回操作的过程交互信息。 | @@ -102,15 +122,15 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 ```undefined // drivers/peripheral/face_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # Face_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── include # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── face_auth_interface_driver.cpp # Face_auth驱动入口 - └── face_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # Face_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── include # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── face_auth_interface_driver.cpp # Face_auth驱动入口 + └── face_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -423,66 +443,59 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - console.info("start auth"); - this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - try { - console.info("auth onResult result = " + result); - console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == userIAM_userAuth.ResultCode.SUCCESS) { - // 此处添加认证成功逻辑 - } else { - // 此处添加认证失败逻辑 - } - } catch (e) { - console.info("auth onResult error = " + e); - } - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - try { - console.info("auth onAcquireInfo module = " + module); - console.info("auth onAcquireInfo acquire = " + acquire); - console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); - } catch (e) { - console.info("auth onAcquireInfo error = " + e); - } - } - }); - }, - - cancelAuth() { - console.info("start cancel auth"); - // contextId通过auth接口获取 - let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - console.info("auth onResult result = " + result); - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - console.info("auth onAcquireInfo module = " + module); + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 订阅认证结果 + try { + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); } }); - let cancelCode = this.auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } + console.log("subscribe authentication event success"); + } catch (error) { + console.log("subscribe authentication event failed " + error); } -} -``` + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消认证 + try { + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); + } + + // 取消订阅认证结果 + try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); + } catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); + } + ``` diff --git a/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md index 17e0a1dccd809db2818c2da321c766d86e648d96..0f593ed75d8056df216db4837681c86934b2e7a9 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-fingerprint_auth-des.md @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -53,15 +53,19 @@ - HAPs - HAPs(OpenHarmony Ability Packages),本章节中仅代表Fingerprint_auth驱动的上层应用。 + HAPs(OpenHarmony Ability Packages),广义上指可以安装在OpenHarmony上的应用包,本章节中仅代表Fingerprint_auth驱动的上层应用。 - IDL接口 - 接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口实现Fingerprint_auth服务和驱动的通信。 + 接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Fingerprint_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)。 - IPC通信 - IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互。 + IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)。 + +- HDI + + HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)。 ### 运作机制 @@ -84,24 +88,27 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/fingerprint_auth/v1_0/)。 +在本文中,指纹凭据的录入、认证、识别和删除相关的HDI接口如表1所示,表2中的回调函数分别用于指纹执行器返回操作结果给框架和返回操作过程中的提示信息给上层应用。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| 接口名称 | 功能介绍 | +| -------------------------------- | ----------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | | GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息,包括执行器类型、执行器角色、认证类型、安全等级、执行器公钥等信息,用于向用户认证框架注册执行器。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定模板ID的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey, const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的模板列表用于对账。 | | Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入指纹模板。 | -| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证指纹模板。 | -| Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别指纹模板。 | -| Delete(const std::vector& templateIdList) | 删除指纹模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | +| Authenticate(uint64_t scheduleId, const std::vector& templateIdList,
const std::vector& extraInfo, const sptr& callbackObj) | 认证指纹模板。 | +| Identify(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 识别指纹模板。 | +| Delete(const std::vector& templateIdList) | 删除指纹模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定录入、认证、识别操作。 | | SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 指纹认证服务向Fingerprint_auth驱动传递参数的通用接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | ------------------------ | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnTip(int32_t code, const std::vector& extraInfo) | 返回操作的过程交互信息。 | @@ -112,15 +119,15 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin ```undefined // drivers/peripheral/fingerprint_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # Fingerprint_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── include # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口 - └── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # Fingerprint_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── include # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── fingerprint_auth_interface_driver.cpp # Fingerprint_auth驱动入口 + └── fingerprint_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -433,47 +440,59 @@ Fingerprint_auth驱动的主要工作是为上层用户认证框架和Fingerprin 驱动开发完成后,开发者可以通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,JS应用通过Fingerprint_auth服务调用Fingerprint_auth驱动,从而验证驱动开发是否符合预期。基于Hi3516DV300平台验证,认证功能验证的JS测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - console.info("start auth"); - // auth是开发者可以调用的API接口,开发者可以指定认证类型为FINGERPRINT,从而验证驱动是否向框架注册成功以及认证接口实现是否符合预期,result即为认证结果。 - this.auth.auth(null, userIAM_userAuth.UserAuthType.FINGERPRINT, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - try { - console.info("auth onResult result = " + result); - console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == userIAM_userAuth.ResultCode.SUCCESS) { - // 此处添加认证成功逻辑 - } else { - // 此处添加认证失败逻辑 - } - } catch (e) { - console.info("auth onResult error = " + e); - } - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - try { - console.info("auth onAcquireInfo module = " + module); - console.info("auth onAcquireInfo acquire = " + acquire); - console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); - } catch (e) { - console.info("auth onAcquireInfo error = " + e); - } + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FINGERPRINT; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 订阅认证结果 + try { + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); } }); + console.log("subscribe authentication event success"); + } catch (error) { + console.log("subscribe authentication event failed " + error); } -} -``` + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消认证 + try { + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); + } + + // 取消订阅认证结果 + try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); + } catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); + } + ``` diff --git a/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md b/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md index 3722339fa368d07543929fdb6f9f8da33f3b06d7..d7fb9533461155f43ad86d78425756746164cf94 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-pinauth-des.md @@ -21,7 +21,7 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别。 + 执行器提供能力时所在运行环境达到的安全级别。 - 执行器角色 @@ -52,6 +52,18 @@ 用户认证框架统一管理用户身份和凭据ID的映射关系,执行器对接到用户认证框架时,会读取用户身份认证框架内保存的该执行器的模板ID列表,执行器需要与自己维护的模板ID列表进行比对,并删除冗余信息。 +- IDL接口 + + 接口定义语言(Interface Definition Language)通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现Pin_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)。 + +- IPC通信 + + IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)。 + +- HDI + + HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)。 + ### 运作机制 Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提供稳定的口令认证的基础能力,保证口令认证的功能可以正常运行。开发者可基于HDF框架对不同芯片进行各自驱动的开发以及HDI层接口的调用。 @@ -61,7 +73,7 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ![image](figures/pin_auth服务与驱动交互.png "pin_auth服务与驱动交互") ### 约束与限制 -口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的保密信息需要在安全环境中存储。 +口令认证的实现需要在TEE安全环境中实现,口令凭据等数据的加密信息需要在安全环境中存储。 ## 开发指导 ### 场景介绍 @@ -69,24 +81,27 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/pin_auth/v1_0/)。 +在本文中,口令凭据的录入、认证和删除相关的HDI接口如表1所示,表2中的回调函数分别用于口令执行器返回操作结果给框架和获取用户输入的口令信息。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | -| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 | -| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 | +| 接口名称 | 功能介绍 | +| ------------------------------- | ------------------------------------------- | +| GetExecutorList(std::vector>& executorList) | 获取执行器列表。 | +| GetExecutorInfo(ExecutorInfo& info) | 获取执行器信息。 | +| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | 获取指定templateId的模板信息。 | | OnRegisterFinish(const std::vector& templateIdList,
const std::vector& frameworkPublicKey,
const std::vector& extraInfo) | 执行器注册成功后,获取用户认证框架的公钥信息;获取用户认证框架的template 列表用于对账。 | -| OnSetData(uint64_t scheduleId, uint64_t authSubType,
const std::vector &data) | 用于回调传pin码认证的子类型和脱敏数据。 | -| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入pin码。 | -| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector& extraInfo, const sptr& callbackObj) | pin码认证。 | -| Delete(uint64_t templateId) | 删除pin码模板。 | -| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定操作。 | -| SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 预留接口。 | +| OnSetData(uint64_t scheduleId, uint64_t authSubType,
const std::vector &data) | 回调函数,返回用户录入的口令子类型和录入的口令脱敏数据。 | +| Enroll(uint64_t scheduleId, const std::vector& extraInfo,
const sptr& callbackObj) | 录入pin码。 | +| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector& extraInfo, const sptr& callbackObj) | pin码认证。 | +| Delete(uint64_t templateId) | 删除pin码模板。 | +| Cancel(uint64_t scheduleId) | 通过scheduleId取消指定操作。 | +| SendCommand(int32_t commandId, const std::vector& extraInfo,
const sptr& callbackObj) | 预留接口。 | **表2** 回调函数介绍 -| 接口名 | 功能介绍 | +| 接口名称 | 功能介绍 | | ------------------------------------------------------------ | -------------------- | | IExecutorCallback::OnResult(int32_t code, const std::vector& extraInfo) | 返回操作的最终结果。 | | IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector& salt,
uint64_t authSubType)| 返回获取pin码数据信息。 | @@ -97,21 +112,21 @@ Pin_auth驱动的主要工作是为上层用户认证框架和Pin_auth服务提 ```text // drivers/peripheral/pin_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -├── test # 测试用例 -└── hdi_service # Pin_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── adaptor # 相关算法实现 - ├── common # 公共接口实现 - ├── database # 数据库实现 - ├── main # 口令相关功能实现入口 - └── service # Pin_auth驱动实现入口 - ├── inc # 头文件 - └── src - ├── executor_impl.cpp # 认证、录入等功能接口实现 - ├── pin_auth_interface_driver.cpp # Pin_auth驱动入口 - └── pin_auth_interface_service.cpp # 获取执行器列表接口实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +├── test # 测试用例 +└── hdi_service # Pin_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── adaptor # 相关算法实现 + ├── common # 公共接口实现 + ├── database # 数据库实现 + ├── main # 口令相关功能实现入口 + └── service # Pin_auth驱动实现入口 + ├── inc # 头文件 + └── src # 源文件 + ├── executor_impl.cpp # 认证、录入等功能接口实现 + ├── pin_auth_interface_driver.cpp # Pin_auth驱动入口 + └── pin_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 diff --git a/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md b/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md index e3da0d9c7387c838e710e79c58ca9562101a1ccc..57c11bc60473b958dd3421f13e04700c3655d0db 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-user-auth-des.md @@ -21,7 +21,7 @@ - 认证凭据模板 - 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并用和当次认证过程中产生的认证数据做对比,完成身份认证。 + 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并和当次认证过程中产生的认证数据做对比,完成身份认证。 - 执行器 @@ -41,11 +41,11 @@ - 执行器安全等级 - 执行器提供能力时运行环境所达到的安全级别,如操作运行在无访问控制安全等级低于操作运行硬件可信执行环境的安全等级。 + 执行器提供能力时所在运行环境达到的安全级别。 - 用户认证框架公钥 & 执行器公钥 - 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交互各自的公钥,其中: + 用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交换各自的公钥,其中: - 执行器通过用户认证框架公钥校验调度指令的准确性,如锁定一个人脸模板,这种情况导致无法使用人脸功能,属于敏感操作,需要确保指令准确,才可处理。 @@ -76,6 +76,18 @@ OpenHarmony系统向系统应用提供的应用编程接口。 +- IDL接口 + + 接口定义语言(Interface Definition Language),通过IDL编译器编译后,能够生成与编程语言相关的文件:客户端桩文件,服务器框架文件。本文主要是通过IDL接口生成的客户端和服务端来实现User_auth服务和驱动的通信,详细使用方法可参考[IDL简介](https://gitee.com/openharmony/ability_idl_tool/blob/master/README.md)。 + +- IPC通信 + + IPC(Inter Process Communication),进程间通信是指两个进程的数据之间产生交互,详细原理可参考[IPC通信简介](https://gitee.com/openharmony/communication_ipc/blob/master/README_zh.md)。 + +- HDI + + HDI(Hardware Device Interface),硬件设备接口,位于基础系统服务层和设备驱动层之间,是提供给硬件系统服务开发者使用的、统一的硬件设备功能抽象接口,其目的是为系统服务屏蔽底层硬件设备差异,具体可参考[HDI规范](../../design/hdi-design-specifications.md)。 + ### 运作机制 User_auth驱动主要工作是屏蔽不同安全器件和安全环境的差异,通过统一的认证能力注册、录入、认证接口,向User_auth服务提供认证执行器管理、认证凭据管理和认证方案生成管理等能力。 @@ -97,31 +109,34 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ### 接口说明 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/user_auth/v1_0/)。 +在本文中,执行器注册、凭据录入、凭据删除、用户认证和用户识别相关的HDI接口如表1所示。 + **表1** 接口功能介绍 -| 接口名 | 功能介绍 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| Init() | 初始化缓存信息。 | -| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector& publicKey,
std::vector& templateIds) | 添加认证执行器,获得此认证能力。 | -| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 | -| OpenSession(int32_t userId, std::vector& challenge) | 开启认证凭据管理Session。 | -| CloseSession(int32_t userId) | 关闭认证凭据管理Session。 | +| 接口名称 | 功能介绍 | +| --------------------------- | --------------------------- | +| Init() | 初始化缓存信息。 | +| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector& publicKey,
std::vector& templateIds) | 添加认证执行器,获得此认证能力。 | +| DeleteExecutor(uint64_t index) | 根据索引值index删除认证执行器。 | +| OpenSession(int32_t userId, std::vector& challenge) | 开启认证凭据管理Session。 | +| CloseSession(int32_t userId) | 关闭认证凭据管理Session。 | | BeginEnrollment(int32_t userId, const std::vector& authToken, const EnrollParam& param,
ScheduleInfo& info) | 发起用户的认证凭据的录入,当录入类型为PIN码且当前用户已录入PIN码的情况下会更新PIN码。 | -| UpdateEnrollmentResult(int32_t userId, const std::vector& scheduleResult, uint64_t& credentialId,
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 | -| CancelEnrollment(int32_t userId) | 取消此次录入。 | +| UpdateEnrollmentResult(int32_t userId, const std::vector& scheduleResult, uint64_t& credentialId,
CredentialInfo& oldInfo) | 更新录入结果,完成此次录入。 | +| CancelEnrollment(int32_t userId) | 取消此次录入。 | | DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector& authToken,
CredentialInfo& info) | 根据credentialId删除凭据信息。 | | DeleteUser(int32_t userId, const std::vector& authToken,
std::vector& deletedInfos) | 删除PIN码即在用户认证框架中删除用户。 | | EnforceDeleteUser(int32_t userId, std::vector& deletedInfos) | 强制删除用户,当系统内此用户被删除时强制调用。 | -| GetCredential(int32_t userId, AuthType authType, std::vector& infos) | 查询用户某种认证类型下的凭据信息。 | +| GetCredential(int32_t userId, AuthType authType, std::vector& infos) | 查询用户某种认证类型下的凭据信息。 | | GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector& infos) | 查询用户的安全用户Id和每种认证类型的录入标记Id。 | | BeginAuthentication(uint64_t contextId, const AuthSolution& param,
std::vector& scheduleInfos) | 发起认证,生成认证方案和调度信息。 | | UpdateAuthenticationResult(uint64_t contextId, const std::vector& scheduleResult,
AuthResultInfo& info) | 更新认证结果,进行此次认证方案结果的评估。 | -| CancelAuthentication(uint64_t contextId) | 取消此次认证。 | +| CancelAuthentication(uint64_t contextId) | 取消此次认证。 | | BeginIdentification(uint64_t contextId, AuthType authType, const std::vector& challenge,
uint32_t executorId, ScheduleInfo& scheduleInfo) | 发起识别,生成识别方案和调度信息。 | | UpdateIdentificationResult(uint64_t contextId, const std::vector& scheduleResult,
IdentifyResultInfo& info) | 更新识别结果,进行此次识别方案结果的评估。 | -| CancelIdentification(uint64_t contextId) | 取消此次识别。 | -| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 | -| GetValidSolution(int32_t userId, const std::vector& authTypes, uint32_t authTrustLevel,
std::vector& validTypes) | 筛选此用户当前认证可信等级下可用认证方式。 | +| CancelIdentification(uint64_t contextId) | 取消此次识别。 | +| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | 获取此用户当前认证类型的认证可信等级。 | +| GetValidSolution(int32_t userId, const std::vector& authTypes, uint32_t authTrustLevel,
std::vector& validTypes) | 筛选此用户当前认证可信等级下可用的认证方式。 | ### 开发步骤 @@ -129,14 +144,14 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ```undefined // drivers/peripheral/user_auth -├── BUILD.gn # 编译脚本 -├── bundle.json # 组件描述文件 -└── hdi_service # User_auth驱动实现 - ├── BUILD.gn # 编译脚本 - ├── module # 功能实现 +├── BUILD.gn # 编译脚本 +├── bundle.json # 组件描述文件 +└── hdi_service # User_auth驱动实现 + ├── BUILD.gn # 编译脚本 + ├── module # 功能实现 └── service - ├── user_auth_interface_driver.cpp # User_auth驱动入口 - └── user_auth_interface_service.cpp # 获取执行器列表接口实现 + ├── user_auth_interface_driver.cpp # User_auth驱动入口 + └── user_auth_interface_service.cpp # 获取执行器列表接口实现 ``` 下面结合DEMO实例介绍驱动开发的具体步骤。 @@ -494,66 +509,59 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 驱动开发完成后,通过[用户认证API接口](../../application-dev/reference/apis/js-apis-useriam-userauth.md)开发JS应用,基于Hi3516DV300平台验证。认证和取消功能验证的JS测试代码如下: -```js -// API version 8 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); - -export default { - getVersion() { - console.info("start get version"); - let version = this.auth.getVersion(); - console.info("auth version = " + version); - }, - - startAuth() { - console.info("start auth"); - this.auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - try { - console.info("auth onResult result = " + result); - console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == 'SUCCESS') { - // 此处添加认证成功逻辑 - } else { - // 此处添加认证失败逻辑 - } - } catch (e) { - console.info("auth onResult error = " + e); - } - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - try { - console.info("auth onAcquireInfo module = " + module); - console.info("auth onAcquireInfo acquire = " + acquire); - console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); - } catch (e) { - console.info("auth onAcquireInfo error = " + e); - } - } - }); - }, - - cancelAuth() { - console.info("start cancel auth"); - // contextId通过auth接口获取 - let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - console.info("auth onResult result = " + result); - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - console.info("auth onAcquireInfo module = " + module); + ```js + // API version 9 + import userIAM_userAuth from '@ohos.userIAM.userAuth'; + + let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); + let authType = userIAM_userAuth.UserAuthType.FACE; + let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; + + // 获取认证对象 + let auth; + try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); + } catch (error) { + console.log("get auth instance failed" + error); + } + + // 订阅认证结果 + try { + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); } }); - let cancelCode = this.auth.cancel(contextId); - if (cancelCode == userIAM_userAuth.Result.SUCCESS) { - console.info("cancel auth success"); - } else { - console.error("cancel auth fail"); - } + console.log("subscribe authentication event success"); + } catch (error) { + console.log("subscribe authentication event failed " + error); + } + + // 开始认证 + try { + auth.start(); + console.info("authV9 start auth success"); + } catch (error) { + console.info("authV9 start auth failed, error = " + error); + } + + // 取消认证 + try { + auth.cancel(); + console.info("cancel auth success"); + } catch (error) { + console.info("cancel auth failed, error = " + error); } -} -``` + // 取消订阅认证结果 + try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); + } catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); + } + ``` diff --git a/zh-cn/device-dev/faqs/faqs-environment-setup.md b/zh-cn/device-dev/faqs/faqs-environment-setup.md index a2072ca2c8698cac7a0618fb2d8a7630496f2b3f..2f815cda6914329286e372c80a60f1b6c3e0f05b 100644 --- a/zh-cn/device-dev/faqs/faqs-environment-setup.md +++ b/zh-cn/device-dev/faqs/faqs-environment-setup.md @@ -224,4 +224,44 @@ ``` sudo apt-get remove python3-apt sudo apt-get install python3-apt - ``` \ No newline at end of file + ``` + +### 如何将下载好的源码升级为其他分支源码 +- **场景描述** + + 当您的环境中已有下载好的OpenHarmony源码,需要将其升级为其他分支(例如Master)源码时,可按照如下步骤进行操作。 + +- **操作方法** + + 1. 进入现有OpenHarmony根目录。 + + 请注意该目录下包含一个隐藏目录.repo,如没有此隐藏目录,请重新解压获取的源码包,以获取完整的源码内容。 + + 2. 使用repo init命令重新初始化源码库信息。 + + 其中,branch表示分支名称,例如master、OpenHarmony-3.2-Beta3等。 + ```shell + repo init -u https://gitee.com/openharmony/manifest -b branch --no-repo-verify + ``` + + 3. 下载更新源码文件。 + + ```shell + repo sync -c + repo forall -c 'pwd;git lfs pull' + ``` + 如果想保持工作路径清洁,可以执行如下命令。 + + >![icon-note.gif](public_sys-resources/icon-caution.gif) **注意:** + >此操作会重置本地工作区,删除未被git管理的文件或目录,请谨慎操作。 + ```shell + repo forall -c 'git reset --hard;git clean -fdx' + ``` + + 4. 执行prebuilts脚本,安装编译器及二进制工具。 + + ```shell + bash build/prebuilts_download.sh + ``` + + \ No newline at end of file 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 0555592c3d2e17c7b2b9a25faca5a830a2ac026c..8e87d1fd2a3a399d90e93186557cf810825b5175 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-20220930141628922.png b/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png index f4c4e437a0089ac5ba3371f531694daac4b36703..fe945b422010efd214d82a0ccc4bfafd2cefd860 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image-20220930141628922.png 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_0000001160018656.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png index d5693bd916ea4f009687af8233054baedf06ddf3..6635920e71a8c2f978ebcdf03e17c13674222e89 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001160018656.png differ diff --git a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png index aab178cde608403d259af3cd10c11188e213de08..463d88f332966f2389daf5b7d83b6ec626ebfc73 100644 Binary files a/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png and b/zh-cn/device-dev/kernel/figures/zh-cn_image_0000001199351155.png differ diff --git a/zh-cn/device-dev/kernel/kernel-standard-newip.md b/zh-cn/device-dev/kernel/kernel-standard-newip.md index caf9c0bb4cd638c0dbf5346d7559a71814c530ec..895a1b2551e066e4f7ec0c954dd4c1cd0d3407af 100644 --- a/zh-cn/device-dev/kernel/kernel-standard-newip.md +++ b/zh-cn/device-dev/kernel/kernel-standard-newip.md @@ -1,9 +1,9 @@ -# NewIP内核协议栈介绍 +# New IP内核协议栈介绍 ## 基本概念 -NewIP在现有IP能力的基础上,以灵活轻量级报头和可变长多语义地址为基础,通过二三层协议融合,对协议去冗和压缩,减少冗余字节,实现高能效比,高净吞吐,提升通信效率。打造终端之间高效的横向通信,支撑超级终端的体验,实现异构网络的端到端互联。 +New IP在现有IP能力的基础上,以灵活轻量级报头和可变长多语义地址为基础,通过二三层协议融合,对协议去冗和压缩,减少冗余字节,实现高能效比,高净吞吐,提升通信效率。打造终端之间高效的横向通信,支撑超级终端的体验,实现异构网络的端到端互联。 目前WiFi协议报文,三层报头和地址开销使得报文开销大,传输效率较低。 @@ -14,21 +14,21 @@ IPv4地址长度固定4字节,IPv6地址长度固定16字节。 IPv4网络层报头长度20~60字节,IPv6网络层报头长度40字节。 ``` -NewIP支持**可变长多语义地址(最短1字节)**,**可变长定制化报头封装(最短5字节)**,通过精简报文头开销,提升数据传输效率。 +New IP支持**可变长多语义地址(最短1字节)**,**可变长定制化报头封装(最短5字节)**,通过精简报文头开销,提升数据传输效率。 -NewIP报头开销,相比IPv4节省25.9%,相比IPv6节省44.9%。 +New IP报头开销,相比IPv4节省25.9%,相比IPv6节省44.9%。 -NewIP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33%。 +New IP载荷传输效率,相比IPv4提高最少1%,相比IPv6提高最少2.33%。 -| 对比场景 | 报头开销 | 载荷传输效率(WiFi MTU=1500B,BT MTU=255B) | -| -------------- | ------------ | ------------------------------------------- | -| IPv4 for WiFi | 30+8+20=58 B | (1500-58)/1500=96.13% | -| IPv6 for WiFi | 30+8+40=78 B | (1500-78)/1500=94.8% | -| NewIP for WiFi | 30+8+5=43 B | (1500-43)/1500=97.13% | +| 对比场景 | 报头开销 | 载荷传输效率(WiFi MTU=1500B,BT MTU=255B) | +| --------------- | ------------ | ------------------------------------------- | +| IPv4 for WiFi | 30+8+20=58 B | (1500-58)/1500=96.13% | +| IPv6 for WiFi | 30+8+40=78 B | (1500-78)/1500=94.8% | +| New IP for WiFi | 30+8+5=43 B | (1500-43)/1500=97.13% | ## 可变长报头格式 -NewIP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识NewIP灵活极简报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示特定目标特性的存在性。 +New IP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType = 0xEADD标识New IP报文。Bitmap是一组由0和1组成的二进制序列,每个二进制位的数值用于表示New IP报头中是否携带某个字段,即New IP报文头可以由用户根据业务场景自行定制报头中携带哪些字段。 ![zh-cn_image-20220915140627223](figures/zh-cn_image-20220915140627223.png) @@ -39,34 +39,34 @@ NewIP WiFi灵活极简报文头如下图所示,通过LLC Header中的EtherType **Bitmap字段定义如下:** -| 极简Bitmap标识 | Bitops | 字段长度 | 置位策略 | 备注 | -| -------------------------- | ------ | ---------------- | -------------- | --------------------------------------- | -| Bitmap 1st Byte: | - | - | - | - | -| 标记位Dispatch | 0 | 不表示具体字段 | 置0 | 0:极简帧,1:普通帧。 | -| TTL | 1 | 1 Byte | 置1 | 剩余跳数。 | -| Total Length | 2 | 2 Byte | UDP置0,TCP置1 | NewIP报文总长度(包含报头长度)。 | -| Next Header | 3 | 1 Byte | 置1 | 协议类型。 | -| Reserve | 4 | 保留 | 置0 | 保留字段。 | -| Dest Address | 5 | 变长(1~8 Byte) | 置1 | 目的地址。 | -| Source Address | 6 | 变长(1~8 Byte) | 由协议自行确定 | 源地址。 | -| 标记位,标志是否有2nd Byte | 7 | 不表示具体字段 | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | -| Bitmap 2nd Byte: | - | - | - | - | -| Header Length | 0 | 1 Byte | - | NewIP报头长度。 | -| Reserve | 1 | 保留 | 置0 | - | -| Reserve | 2 | 保留 | 置0 | - | -| Reserve | 3 | 保留 | 置0 | - | -| Reserve | 4 | 保留 | 置0 | - | -| Reserve | 5 | 保留 | 置0 | - | -| Reserve | 6 | 保留 | 置0 | - | -| 标记位,标志是否有3rd Byte | 7 | 不表示具体字段 | 置0 | 0:bitmap结束,1:后跟另外8bit bitmap。 | - -NewIP数据报头(极简模式)解析遇到新bitmap字段时的处理方法: +| 极简Bitmap标识 | Bitops | 携带字段的长度 | 置位策略 | 备注 | +| ---------------------------- | ------ | ---------------- | -------------- | --------------------------------------- | +| Bitmap 1st Byte: | - | - | - | 下面8bit是从高位到低位排列。 | +| 标记位Dispatch | 0 | - | 置0 | 0:极简封装报头,1:非极简封装报头。 | +| 报文头是否携带TTL | 1 | 1 Byte | 置1 | 剩余跳数。 | +| 报文头是否携带Total Length | 2 | 2 Byte | UDP置0,TCP置1 | New IP报文总长度(包含报头长度)。 | +| 报文头是否携带Next Header | 3 | 1 Byte | 置1 | 协议类型。 | +| Reserve | 4 | 保留 | 置0 | 保留字段。 | +| 报文头是否携带Dest Address | 5 | 变长(1~8 Byte) | 置1 | 目的地址。 | +| 报文头是否携带Source Address | 6 | 变长(1~8 Byte) | 由协议自行确定 | 源地址。 | +| 标记位,标志是否有2nd Byte | 7 | - | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | +| Bitmap 2nd Byte: | - | - | - | 下面8bit是从高位到低位排列。 | +| 报文头是否携带Header Length | 0 | 1 Byte | - | New IP报头长度。 | +| Reserve | 1 | 保留 | 置0 | - | +| Reserve | 2 | 保留 | 置0 | - | +| Reserve | 3 | 保留 | 置0 | - | +| Reserve | 4 | 保留 | 置0 | - | +| Reserve | 5 | 保留 | 置0 | - | +| Reserve | 6 | 保留 | 置0 | - | +| 标记位,标志是否有3rd Byte | 7 | - | - | 0:bitmap结束,1:后跟另外8bit bitmap。 | + +New IP报头(极简封装)解析遇到新bitmap字段时的处理方法: 仅解析当前版本协议中已定义的bitmap字段,从第一个未知语义的bitmap字段开始,跳过后面的所有bitmap字段,直接通过header length定位到报文开始位置并解析报文。如果报头中携带了未知语义的bitmap字段,且未携带header length字段,则丢弃该数据包。 ## 可变长地址格式 -NewIP采用自解释编码,编码格式如下所示: +New IP支持可变长地址(IPv4/IPv6地址长度固定),支持自解析地址长度,报文头中可以不携带地址长度字段,New IP地址编码格式如下所示: | First Byte | Semantics | 地址段有效范围 | | ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ | @@ -87,32 +87,40 @@ NewIP采用自解释编码,编码格式如下所示: -## NewIP配置指导 +## New IP配置指导 -启用NewIP,需要通过编译内核时打开相应的配置项及依赖,NewIP相关CONFIG如下: +### New IP使能 + +目前只有rk3568开发板Linux 5.10内核上支持New IP内核协议栈,在rk3568开发板内核模块配置文件中搜索NEWIP,将其修改成“CONFIG_XXX=y”即可,New IP相关CONFIG如下。 -```c -CONFIG_NEWIP=y // 使能NewIP内核协议栈 -CONFIG_NEWIP_HOOKS=y // 使能NewIP内核侵入式修改插桩函数注册,使能NewIP的同时必须使用NewIP插桩功能 +``` +# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig +CONFIG_NEWIP=y // 使能New IP内核协议栈 +CONFIG_NEWIP_HOOKS=y // 使能New IP内核侵入式修改插桩函数注册,使能New IP的同时必须使用New IP HOOKS功能 +VENDOR_HOOKS=y // 使能内核插桩基础框架(New IP依赖此配置项,rk3568开发板已默认开启) ``` -另有部分CONFIG被依赖: +代码编译完成后,通过下面命令可以确认New IP协议栈代码是否使能成功。 -```c -VENDOR_HOOKS=y // 使能内核插桩基础框架 +``` +find out/ -name *nip*.o +... +out/kernel/OBJ/linux-5.10/net/newip/nip_addrconf_core.o +out/kernel/OBJ/linux-5.10/net/newip/nip_hdr_decap.o +out/kernel/OBJ/linux-5.10/net/newip/nip_addr.o +out/kernel/OBJ/linux-5.10/net/newip/nip_checksum.o +out/kernel/OBJ/linux-5.10/net/newip/tcp_nip_output.o +... ``` -备注: - -1. 只在Linux 5.10内核上支持NewIP内核协议栈。 -2. OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。 +备注:OpenHarmony linux内核要求所有原生内核代码侵入式修改,都要修改成插桩方式。例如下面IPv4,IPv6协议栈公共流程中增加New IP处理时,不能直接调用New IP函数,需要在公共流程中增加插桩点,New IP使能后在模块初始化时将xx功能函数注册到对应的函数指针上,下面公共流程就可以通过函数指针的形式调用到New IP的函数。 ```c -/* 将NewIP ehash函数注册到内核 */ +/* 将New IP ehash函数注册到内核 */ register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL); -/* 下面是IPv4,IPv6协议栈总入口函数,在总入口函数内新增NewIP协议栈相关处理 */ +/* 下面是IPv4,IPv6协议栈总入口函数,在总入口函数内新增New IP协议栈相关处理 */ static u32 sk_ehashfn(const struct sock *sk) { /* IPv6 */ @@ -128,7 +136,7 @@ static u32 sk_ehashfn(const struct sock *sk) if (sk->sk_family == AF_NINET) { u32 ret = 0; - /* NewIP注册的ehash函数 */ + /* New IP注册的ehash函数 */ trace_ninet_ehashfn_hook(sock_net(sk), &sk->sk_nip_rcv_saddr, sk->sk_num, &sk->sk_nip_daddr, sk->sk_dport, &ret); return ret; @@ -142,47 +150,35 @@ static u32 sk_ehashfn(const struct sock *sk) } ``` +### New IP禁用 +在rk3568开发板内核模块配置文件中搜索NEWIP,将其“CONFIG_NEWIP=y”和“CONFIG_NEWIP_HOOKS=y”删除或使用#注释掉即可。 -代码编译完成后,通过下面命令可以确认newip协议栈代码是否使能成功。 - -```c -find out/ -name *nip*.o -out/rk3568/obj/third_party/glib/glib/glib_source/guniprop.o -out/kernel/OBJ/linux-5.10/net/newip/nip_addrconf_core.o -out/kernel/OBJ/linux-5.10/net/newip/nip_hdr_decap.o -out/kernel/OBJ/linux-5.10/net/newip/nip_addr.o -out/kernel/OBJ/linux-5.10/net/newip/nip_checksum.o -out/kernel/OBJ/linux-5.10/net/newip/tcp_nip_output.o -... ``` - -禁用NewIP内核协议栈,删除CONFIG_NEWIP使能开关,删除out/kernel目录后重新编译。 - -```c +# kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig # CONFIG_NEWIP is not set # CONFIG_NEWIP_HOOKS is not set ``` -## NewIP相关接口 +## New IP相关接口 -用户态应用程序调用Socket API创建NewIP socket,采用NewIP极简帧头封装进行收发包,NewIP协议socket接口列表如下: +用户态应用程序调用Socket API创建New IP socket,采用New IP极简封装进行收发包,New IP协议socket接口列表如下: | 函数 | 输入 | 输出 | 返回值 | 接口具体描述 | | -------- | ------------------------------------------------------------ | ---------------------------------------------- | ---------------- | ------------------------------------------------------------ | -| socket | int **domain**, int type, int **protocol** | NA | Socket句柄sockfd | 创建NewIP 协议类型socket,并返回socket实例所对应的句柄。**domain参数填写 AF_NINET,表示创建NewIP协议类型socket。protocol参数填写IPPROTO_TCP或IPPROTO_UDP**。 | +| socket | int **domain**, int type, int **protocol** | NA | Socket句柄sockfd | 创建New IP 协议类型socket,并返回socket实例所对应的句柄。**domain参数填写 AF_NINET,表示创建New IP协议类型socket。protocol参数填写IPPROTO_TCP或IPPROTO_UDP**。 | | bind | int sockfd, const **struct sockaddr_nin** *myaddr, socklen_t addrlen | NA | int,返回错误码 | 将创建的socket绑定到指定的IP地址和端口上。**myaddr->sin_family填写AF_NINET**。 | -| listen | int socket, int backlog | NA | int,返回错误码 | 服务端监听NewIP地址和端口。 | +| listen | int socket, int backlog | NA | int,返回错误码 | 服务端监听New IP地址和端口。 | | connect | int sockfd, const **struct sockaddr_nin** *addr, aocklen_t addrlen | NA | int,返回错误码 | 客户端创建至服务端的连接。 | | accept | int sockfd, **struct sockaddr_nin** *address, socklen_t *address_len | NA | 返回socket的fd | 服务端返回已建链成功的socket。 | -| send | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr_nin** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket已连接的NewIP类型数据发送。 | -| recv | int sockfd, size_t len, int flags, **struct sockaddr_nin** *src_addr, | void **buf, int* *fromlen | int,返回错误码 | 用于socket已连接的NewIP类型数据接收。 | +| send | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr_nin** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket已连接的New IP类型数据发送。 | +| recv | int sockfd, size_t len, int flags, **struct sockaddr_nin** *src_addr, | void **buf, int* *fromlen | int,返回错误码 | 用于socket已连接的New IP类型数据接收。 | | close | int sockfd | NA | int,返回错误码 | 关闭socket,释放资源。 | -| ioctl | int sockfd, unsigned long cmd, ... | NA | int,返回错误码 | 对NewIP协议栈相关信息进行查询或更改。 | -| sendto | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket无连接的NewIP类型数据发送。 | -| recvfrom | int sockfd, size_t len, int flags, | void *buf, struct sockaddr *from, int *fromlen | int,返回错误码 | 用于socket无连接的NewIP类型数据接收。 | +| ioctl | int sockfd, unsigned long cmd, ... | NA | int,返回错误码 | 对New IP协议栈相关信息进行查询或更改。 | +| sendto | int sockfd, const void *msg, int len, unsigned int flags, const **struct sockaddr** *dst_addr, int addrlen | NA | int,返回错误码 | 用于socket无连接的New IP类型数据发送。 | +| recvfrom | int sockfd, size_t len, int flags, | void *buf, struct sockaddr *from, int *fromlen | int,返回错误码 | 用于socket无连接的New IP类型数据接收。 | -NewIP短地址结构如下: +New IP短地址结构如下: ```c enum nip_8bit_addr_index { @@ -244,21 +240,21 @@ struct sockaddr_nin { }; ``` -## NewIP开发说明 +## New IP开发说明 -目前只在OpenHarmony Linux-5.10内核支持NewIP内核协议栈,只能在用户态人工配置NewIP地址和路由到内核,两台设备通过路由器WiFi连接。如果想配置NewIP地址和路由后自动切换到NewIP内核协议栈通信,应用可以参考下面蓝框中描述。 +目前只在OpenHarmony Linux-5.10内核支持New IP内核协议栈,只能在用户态人工配置New IP地址和路由到内核,两台设备通过路由器WiFi连接。如果想配置New IP地址和路由后自动切换到New IP内核协议栈通信,应用可以参考下面蓝框中描述。 ![zh-cn_image-20221009112548444](figures/zh-cn_image-20221009112548444.png) -上图中NewIP地址,路由配置程序可以参考[代码仓examples代码](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples),根据CPU硬件差异更改Makefile中CC定义编译成二级制文件后推送到开发板,参考上图命令给设备配置NewIP地址和路由。 +上图中New IP地址,路由配置程序可以参考[代码仓examples代码](https://gitee.com/openharmony/kernel_common_modules_newip/tree/master/examples),根据CPU硬件差异更改Makefile中CC定义编译成二级制文件后推送到开发板,参考上图命令给设备配置New IP地址和路由。 -| 文件名 | 功能 | -| ------------------ | ------------------------------------------------------ | -| nip_addr.c | NewIP可变长地址配置demo代码(可配置任意有效NewIP地址) | -| nip_route.c | NewIP路由配置demo代码(可配置任意有效NewIP地址) | -| check_nip_enable.c | 获取本机NewIP能力 | +| 文件名 | 功能 | +| ------------------ | -------------------------------------------------------- | +| nip_addr.c | New IP可变长地址配置demo代码(可配置任意有效New IP地址) | +| nip_route.c | New IP路由配置demo代码(可配置任意有效New IP地址) | +| check_nip_enable.c | 获取本机New IP能力 | -设备1上查看NewIP地址和路由: +设备1上查看New IP地址和路由: ```sh # cat /proc/net/nip_addr @@ -268,7 +264,7 @@ struct sockaddr_nin { 01 01 2149580801 wlan0 # 本机自发自收路由 ``` -设备2上查看NewIP地址和路由: +设备2上查看New IP地址和路由: ```sh # cat /proc/net/nip_addr @@ -278,19 +274,19 @@ struct sockaddr_nin { 02 02 2149580801 wlan0 # 本机自发自收路由 ``` -## NewIP收发包代码示例 +## New IP收发包代码示例 -NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,NewIP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony/communication_sfc_newip/tree/master/examples)。demo代码内配置固定地址和路由,执行编译后二进制程序时不需要人工指定地址和路由。 +New IP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如下,New IP协议栈用户态接口使用方法可以参考[代码仓examples代码](https://gitee.com/openharmony/kernel_common_modules_newip/tree/master/examples)。demo代码内配置固定地址和路由,执行编译后二进制程序时不需要人工指定地址和路由。 -| 文件名 | 功能 | -| --------------------- | ----------------------------- | -| nip_addr_cfg_demo.c | NewIP可变长地址配置demo代码 | -| nip_route_cfg_demo.c | NewIP路由配置demo代码 | -| nip_udp_server_demo.c | NewIP UDP收发包服务端demo代码 | -| nip_udp_client_demo.c | NewIP UDP收发包客户端demo代码 | -| nip_tcp_server_demo.c | NewIP TCP收发包服务端demo代码 | -| nip_tcp_client_demo.c | NewIP TCP收发包客户端demo代码 | -| nip_lib.c | 接口索引获取等API接口demo代码 | +| 文件名 | 功能 | +| --------------------- | ------------------------------ | +| nip_addr_cfg_demo.c | New IP可变长地址配置demo代码 | +| nip_route_cfg_demo.c | New IP路由配置demo代码 | +| nip_udp_server_demo.c | New IP UDP收发包服务端demo代码 | +| nip_udp_client_demo.c | New IP UDP收发包客户端demo代码 | +| nip_tcp_server_demo.c | New IP TCP收发包服务端demo代码 | +| nip_tcp_client_demo.c | New IP TCP收发包客户端demo代码 | +| nip_lib.c | 接口索引获取等API接口demo代码 | **基础操作步骤:** @@ -302,9 +298,9 @@ NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如 3. 执行“ifconfig wlan0 up”开启网卡设备。 -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的shell下执行“./nip_addr_cfg_demo server”给服务端配置0xDE00(2字节)变长地址,在设备2的shell下执。行“./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的shell下执行“./nip_route_cfg_demo server”给服务端配置路由,在设备2的shell下执行“./nip_route_cfg_demo client”给客户端配置路由,通过“cat /proc/net/nip_route”查看内核路由配置结果。 以上步骤操作完成后,可以进行UDP/TCP收发包,收发包demo默认使用上面步骤中配置的地址和路由。 @@ -312,10 +308,10 @@ NewIP可变长地址配置,路由配置,UDP/TCP收发包demo代码链接如 **UDP收发包操作步骤:** -先在服务端执行“./nip_udp_server_demo”,然后再在客户端执行“./nip_udp_client_demo”,客户端会发送10个NewIP报文,客户端收到报文后再发送给服务端。 +先在服务端执行“./nip_udp_server_demo”,然后再在客户端执行“./nip_udp_client_demo”,客户端会发送10个New IP报文,服务端收到报文后再发送给客户端。 ``` -服务端sh窗口打印内容: +服务端shell窗口打印内容: Received -- 1661826989 498038 NIP_UDP # 0 -- from 0x50:57605 Sending -- 1661826989 498038 NIP_UDP # 0 -- to 0x50:57605 Received -- 1661826990 14641 NIP_UDP # 1 -- from 0x50:57605 @@ -338,10 +334,10 @@ Received --1661827011 590576 NIP_UDP # 9 sock 3 success: 10/ 10/no= **TCP收发包操作步骤:** -先在服务端执行“./nip_tcp_server_demo”,然后再在客户端执行“./nip_tcp_client_demo”,客户端会发送10个NewIP报文,客户端收到报文后再发送给服务端。 +先在服务端执行“./nip_tcp_server_demo”,然后再在客户端执行“./nip_tcp_client_demo”,客户端会发送10个New IP报文,服务端收到报文后再发送给客户端。 ``` -服务端sh窗口打印内容: +服务端shell窗口打印内容: Received -- 1661760202 560605 NIP_TCP # 0 --:1024 Sending -- 1661760202 560605 NIP_TCP # 0 --:1024 Received -- 1661760203 69254 NIP_TCP # 1 --:1024 @@ -352,7 +348,7 @@ Sending -- 1661760203 571604 NIP_TCP # 2 --:1024 Received -- 1661760207 86544 NIP_TCP # 9 --:1024 Sending -- 1661760207 86544 NIP_TCP # 9 --:1024 -客户端sh窗口打印内容: +客户端shell窗口打印内容: Received --1661760202 560605 NIP_TCP # 0 sock 3 success: 1/ 1/no= 0 Received --1661760203 69254 NIP_TCP # 1 sock 3 success: 2/ 2/no= 1 ... @@ -361,7 +357,7 @@ Received --1661760207 86544 NIP_TCP # 9 sock 3 success: 10/ 10/no= ## selinux规则说明 -用户态进程操作NewIP socket需要添加selinux policy,否则操作会被拦截。 +用户态进程操作New IP socket需要添加selinux policy,否则操作会被拦截。 ```sh # base\security\selinux\sepolicy\ohos_policy\xxx\xxx.te @@ -379,18 +375,18 @@ allowxperm thread_xxx thread_xxx:socket ioctl { 0x8933 0x8916 0x890B }; ## WireShark报文解析模板 -Wireshark默认报文解析规则无法解析NewIP报文,在WireShark配置中添加NewIP报文解析模板可以实现NewIP报文解析,[NewIP报文解析模板](https://gitee.com/openharmony/communication_sfc_newip/blob/master/tools/wireshark_cfg_for_newip.lua)详见代码仓。 +Wireshark默认报文解析规则无法解析New IP报文,在WireShark配置中添加New IP报文解析模板可以实现New IP报文解析,[New IP报文解析模板](https://gitee.com/openharmony/kernel_common_modules_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插件所在路径。 +依次单击 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报文解析模板添加样例: +New IP报文解析模板添加样例: ``` -NewIP报文解析模板存放路径: +New IP报文解析模板存放路径: D:\tools\WireShark\wireshark_cfg_for_newip.lua WireShark配置文件路径: @@ -404,7 +400,9 @@ dofile("D:\\tools\\WireShark\\wireshark_cfg_for_newip.lua") #### ND请求 -NewIP邻居发现请求报文格式如下,NewIP极简报文头包含1字节的bitmap(0x76),bitmap标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。NewIP ND请求报文包含报文类型,操作码,校验和和请求地址。 +New IP邻居发现(Neighbor Discovery)请求报文格式如下,New IP极简报文头包含1字节的bitmap(0x76),bitmap标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。New IP ND请求报文包含报文类型,操作码,校验和和请求地址。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![zh-cn_image-20221011144901470](figures/zh-cn_image-20221011144901470.png) @@ -412,7 +410,9 @@ NewIP邻居发现请求报文格式如下,NewIP极简报文头包含1字节的 #### ND应答 -NewIP邻居发现应答报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。NewIP ND应答报文包含报文类型,操作码,校验和和邻居MAC地址长度,邻居MAC地址。 +New IP邻居发现(Neighbor Discovery)应答报文格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。New IP ND应答报文包含报文类型,操作码,校验和和邻居MAC地址长度,邻居MAC地址。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![zh-cn_image-20221011145157288](figures/zh-cn_image-20221011145157288.png) @@ -420,7 +420,9 @@ NewIP邻居发现应答报文格式如下,NewIP极简报文头包含2字节的 #### TCP握手 -TCP三次握手SYN报文格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 +TCP三次握手SYN报文格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![image-20221011150018915](figures/zh-cn_image-20221011150018915.png) @@ -428,7 +430,9 @@ TCP三次握手SYN报文格式如下,NewIP极简报文头包含2字节的bitma #### TCP数据包 -TCP数据格式如下,NewIP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 +TCP数据格式如下,New IP极简报文头包含2字节的bitmap(0x77,0x00),bitmap1标识后面携带TTL,报文总长度,上层协议类型,目的地址,源地址。bitmap2是字节对齐不携带任何数据(rk3568开发板链路层数据发送要求数据长度是偶数字节)。 + +备注:New IP支持变长地址(1字节~8字节),下图中1字节地址仅表示当前报文头中携带的地址是1字节。 ![image-20221011150215316](figures/zh-cn_image-20221011150215316.png) diff --git a/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md b/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md index 9c278c1a7a860c4818d9ecc0f4f9ab06166636b3..327e5e5f64896afa2144fd06a150420503c7b711 100755 --- a/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md @@ -24,7 +24,7 @@ OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单 ### 配置方式 -1. 在[HarmonyAppProvision文件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/app-provision-structure.md)中添加字段”app-privilege-capabilities“,按需配置通用权限能力。 +1. 在[HarmonyAppProvision文件](../../application-dev/security/app-provision-structure.md)中添加字段”app-privilege-capabilities“,按需配置通用权限能力。 2. 使用签名工具对HarmonyAppProvision文件重新签名,生成p7b文件 3. 使用p7b文件签名hap diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md b/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md index 6e89b406d5facd5ce69c7e456136c8c4192b94b5..d3bf8b07e67ce76f23a2b66a6add3887cbe522cf 100644 --- a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md @@ -1,23 +1,51 @@ -# USB服务概述 - +# USB服务 ## 概述 +### 功能简介 + USB设备分为Host设备(主机设备)和Device设备(从设备)。用户可通过Port Service来根据实际业务把运行OpenHarmony的设备切换为Host设备或者Device设备。目前在Host模式下,支持获取USB设备列表,USB设备权限管理,控制传输、批量传输的同异步数据传输等,在Device模式下,支持HDC(调试)、ACM(串口)、ECM(网口)等功能的切换。 +### 基本概念 + +- USB服务 + + USB服务是应用访问底层的一种设备抽象概念。开发者根据提供的USB API,可以获取设备列表、控制设备访问权限、以及与连接的设备进行数据传输、控制命令传输等。 + +- USB API + + 基于USB Service服务,使用NAPI技术,向上提供JS接口。提供USB的基础API,主要包含查询USB设备的列表、设备插拔通知、USB HOST/DEVICE 功能切换、批量数据传输、控制命令传输、USB设备打开的权限控制及USB device模式下的function功能切换等。 + +- USB Service + + 使用C++代码实现,包含Host、Device、Port、Right四个模块。基于HDI接口,主要实现USB设备列表管理、Function 管理、Port管理、USB设备权限管理等功能。主要实现HAL层数据接收、解析、分发,前后台的策略管控,对该设备USB的管理,USB权限管控等。 + +- USB HAL + + 使用C代码实现,基于Host DDK(Driver Develop Kit)和Device DDK,封装了对USB设备的基本操作,向上提供C++接口,同时通过HDF框架接收内核上报的信息。 + +### 运作机制 + +USB服务系统包含USB API、USB Service、USB HAL。 + **图1** USB服务架构图 ![zh-cn_image_0000001267088285](figures/zh-cn_image_0000001267088285.png) -- USB API:基于USB Service服务,使用NAPI技术,向上提供JS接口。 +- USB API:提供USB的基础API,主要包含查询USB设备列表、批量数据传输、控制命令传输、权限控制等。 + +- USB Service:主要实现HAL层数据的接收、解析、分发,前后台的策略管控以及对设备的管理等。 -- USB Service:使用C++代码实现,包含Host、Device、Port三个模块。基于HDI接口,主要实现USB设备列表管理、Function 管理、Port管理、USB设备权限管理等功能。 +- USB HAL层:提供给用户态可直接调用的驱动能力接口。 -- USB HAL:使用C代码实现,基于Host DDK(Driver Develop Kit)和Device DDK,封装了对USB设备的基本操作,向上提供C++接口,同时通过HDF框架接收内核上报的信息。 +## 使用指导 +### 场景介绍 -## 接口说明 +Host模式下,可以获取到已经连接的设备列表,并根据需要打开和关闭设备、控制设备权限、进行数据传输等。 -- Host部分 +### 接口说明 + + **表1** Host部分 | 接口名称 | 功能描述 | | ------------------------------------------------------------ | ------------------------------------------------------------ | @@ -45,7 +73,7 @@ USB设备分为Host设备(主机设备)和Device设备(从设备)。用 | int32_t BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr &ashmem); | 批量传输异步写 | | int32_t BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint); | 批量传输异步取消接口,用于取消当前接口的异步批量读写操作 | -- Device部分 + **表2** Device部分 | 接口名称 | 功能描述 | | -------------------------------------------------- | ------------------------------------------------------ | @@ -54,10 +82,257 @@ USB设备分为Host设备(主机设备)和Device设备(从设备)。用 | int32_t UsbFunctionsFromString(std::string funcs); | 将给定的功能列表描述字符串转换为功能列表的数字组合掩码 | | std::string UsbFunctionsToString(int32_t funcs); | 将给定的功能列表的数字组合掩码转换为功能列表描述字符串 | -- Port部分 + **表3** Port部分 | 接口名称 | 功能描述 | | ------------------------------------------------------------ | -------------------------------------------------------- | | int32_t GetSupportedModes(int32_t portId, int32_t &supportedModes); | 获取指定的端口支持的模式列表的组合掩码 | | int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole); | 设置指定的端口支持的角色模式,包含充电角色、数据传输角色 | | int32_t GetPorts(std::vector &usbPorts); | 获取物理USB端口描述信息列表 | + +### USB服务子系统使用步骤 + +以bulktransfer为例。 + +1. 获取usb service实例。 + + ```cpp + static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance(); + ``` + +2. 获取usb设备列表。 + + ```cpp + std::vector deviceList; + int32_t ret = g_usbClient.GetDevices(deviceList); + ``` + +3. 申请设备权限。 + + ```cpp + int32_t ret = g_usbClient.RequestRight(device.GetName()); + ``` + +4. 打开设备。 + + ```cpp + USBDevicePipe pip; + int32_t et = g_usbClient.OpenDevice(device, pip); + ``` + +5. 配置设备接口。 + + ```cpp + //interface为deviceList中device的interface。 + ret = g_usbClient.ClaimInterface(pip, interface, true); + ``` + +6. 数据传输。 + + ```cpp + // pipe为打开设备后的数据传输通道,endpoint为device中数据传输的端点,vdata是需要传输或读取的二进制数据块,timeout为传输超时时长。 + srvClient.BulkTransfer(pipe, endpoint, vdata, timeout); + ``` + +7. 关闭设备。 + + ```cpp + ret = g_usbClient.Close(pip); + ``` + +### USB服务子系统使用实例 + +```cpp +#include +#include +#include +#include +#include +#include +#include "if_system_ability_manager.h" +#include "ipc_skeleton.h" +#include "iremote_object.h" +#include "iservice_registry.h" +#include "iusb_srv.h" +#include "string_ex.h" +#include "system_ability_definition.h" +#include "usb_common.h" +#include "usb_device.h" +#include "usb_errors.h" +#include "usb_request.h" +#include "usb_server_proxy.h" +#include "usb_srv_client.h" + +const int32_t REQUESTYPE = ((1 << 7) | (0 << 5) | (0 & 0x1f)); +const int32_t REQUESTCMD = 6; +const int32_t VALUE = (2 << 8) + 0; +const int32_t TIMEOUT = 5000; +const int32_t ITFCLASS = 10; +const int32_t PRAMATYPE = 2; +const int32_t BUFFERLENGTH = 21; + +void GetType(OHOS::USB::USBEndpoint &tep, OHOS::USB::USBEndpoint &outEp, bool &outEpFlg) +{ + if ((tep.GetType() == PRAMATYPE)) { + if (tep.GetDirection() == 0) { + outEp = tep; + outEpFlg = true; + } + } +} + +bool SelectEndpoint(OHOS::USB::USBConfig config, + std::vector interfaces, + OHOS::USB::UsbInterface &interface, + OHOS::USB::USBEndpoint &outEp, + bool &outEpFlg) +{ + for (int32_t i = 0; i < config.GetInterfaceCount(); ++i) { + OHOS::USB::UsbInterface tif = interfaces[i]; + std::vector mEndpoints = tif.GetEndpoints(); + for (int32_t j = 0; j < tif.GetEndpointCount(); ++j) { + OHOS::USB::USBEndpoint tep = mEndpoints[j]; + if ((tif.GetClass() == ITFCLASS) && (tif.GetSubClass() == 0) && (tif.GetProtocol() == PRAMATYPE)) { + GetType(tep, outEp, outEpFlg); + } + } + if (outEpFlg) { + interface = interfaces[i]; + return true; + } + std::cout << std::endl; + } + return false; +} + +int OpenDeviceTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::UsbDevice device, OHOS::USB::USBDevicePipe &pip) +{ + int ret = Instran.RequestRight(device.GetName()); + std::cout << "device RequestRight ret = " << ret << std::endl; + if (0 != ret) { + std::cout << "device RequestRight failed = " << ret << std::endl; + } + ret = Instran.OpenDevice(device, pip); + return ret; +} + +int CtrTransferTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::USBDevicePipe &pip) +{ + std::cout << "usb_device_test : << Control Transfer >> " << std::endl; + std::vector vData; + const OHOS::USB::UsbCtrlTransfer tctrl = {REQUESTYPE, REQUESTCMD, VALUE, 0, TIMEOUT}; + int ret = Instran.ControlTransfer(pip, tctrl, vData); + if (ret != 0) { + std::cout << "control message read failed width ret = " << ret << std::endl; + } else { + } + std::cout << "control message read success" << std::endl; + + return ret; +} + +int ClaimTest(OHOS::USB::UsbSrvClient &Instran, + OHOS::USB::USBDevicePipe &pip, + OHOS::USB::UsbInterface &interface, + bool interfaceFlg) +{ + if (interfaceFlg) { + std::cout << "ClaimInterface InterfaceInfo:" << interface.ToString() << std::endl; + int ret = Instran.ClaimInterface(pip, interface, true); + if (ret != 0) { + std::cout << "ClaimInterface failed width ret = " << ret << std::endl; + } else { + std::cout << "ClaimInterface success" << std::endl; + } + } + return 0; +} + +int BulkTransferTest(OHOS::USB::UsbSrvClient &Instran, + OHOS::USB::USBDevicePipe &pip, + OHOS::USB::USBEndpoint &outEp, + bool interfaceFlg, + bool outEpFlg) +{ + if (interfaceFlg) { + std::cout << "usb_device_test : << Bulk transfer start >> " << std::endl; + if (outEpFlg) { + uint8_t buffer[50] = "hello world 123456789"; + std::vector vData(buffer, buffer + BUFFERLENGTH); + int ret = Instran.BulkTransfer(pip, outEp, vData, TIMEOUT); + if (ret != 0) { + std::cout << "Bulk transfer write failed width ret = " << ret << std::endl; + } else { + std::cout << "Bulk transfer write success" << std::endl; + } + return ret; + } + } + return 0; +} + +int main(int argc, char **argv) +{ + std::cout << "usb_device_test " << std::endl; + static OHOS::USB::UsbSrvClient &Instran = OHOS::USB::UsbSrvClient::GetInstance(); + // GetDevices + std::vector deviceList; + int32_t ret = Instran.GetDevices(deviceList); + if (ret != 0) { + return OHOS::USB::UEC_SERVICE_INVALID_VALUE; + } + if (deviceList.empty()) { + return OHOS::USB::UEC_SERVICE_INVALID_VALUE; + } + + OHOS::USB::UsbDevice device = deviceList[0]; + std::vector configs = device.GetConfigs(); + OHOS::USB::USBConfig config = configs[0]; + std::vector interfaces = config.GetInterfaces(); + OHOS::USB::UsbInterface interface; + OHOS::USB::USBEndpoint outEp; + bool interfaceFlg = false; + bool outEpFlg = false; + interfaceFlg = SelectEndpoint(config, interfaces, interface, outEp, outEpFlg); + + // OpenDevice + std::cout << "usb_device_test : << OpenDevice >> test begin -> " << std::endl; + OHOS::USB::USBDevicePipe pip; + ret = OpenDeviceTest(Instran, device, pip); + if (ret != 0) { + return OHOS::USB::UEC_SERVICE_INVALID_VALUE; + } + + // ControlTransfer + CtrTransferTest(Instran, pip); + + // ClaimInterface + ClaimTest(Instran, pip, interface, interfaceFlg); + + // BulkTransferWrite + BulkTransferTest(Instran, pip, outEp, interfaceFlg, outEpFlg); + + // CloseDevice + std::cout << "usb_device_test : << Close Device >> " << std::endl; + ret = Instran.Close(pip); + if (ret == 0) { + std::cout << "Close device failed width ret = " << ret << std::endl; + return OHOS::USB::UEC_SERVICE_INVALID_VALUE; + } else { + std::cout << "Close Device success" << std::endl; + } + return 0; +} +``` + +### 参考手册 + +[驱动子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E9%A9%B1%E5%8A%A8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) + +[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral/blob/master/README_zh.md) + +[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README_zh.md) + +[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README_zh.md) + +[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README_zh.md) \ No newline at end of file diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 84d2960c20fa39e0820acd66d26d6afcb6090acf..c091321e1e2f367a24677779896299caa80af601 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -468,6 +468,7 @@ - [HiTraceChain开发指导](subsystems/subsys-dfx-hitracechain.md) - [HiCollie开发指导](subsystems/subsys-dfx-hicollie.md) - HiSysEvent开发指导 + - [HiSysEvent概述](subsystems/subsys-dfx-hisysevent-overview.md) - [HiSysEvent打点配置指导](subsystems/subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent打点指导](subsystems/subsys-dfx-hisysevent-logging.md) - [HiSysEvent订阅指导](subsystems/subsys-dfx-hisysevent-listening.md) @@ -524,6 +525,7 @@ - [hiperf 使用指南](subsystems/subsys-toolchain-hiperf.md) - [XTS认证](device-test/xts.md) - 工具 + - [工具概述](get-code/gettools-overview.md) - [Docker编译环境](get-code/gettools-acquire.md) - [IDE集成开发环境](get-code/gettools-ide.md) - 示例教程 diff --git "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" index 123e8b3acb357954dac6cb1c00e7db9ad3a90df6..0331ee8fc60602fc1424baf03c58bfccb9093056 100644 --- "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" @@ -2,7 +2,7 @@ ## 简介 -用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据信息管理和用户身份认证框架能力,支持多用户分别设置认证凭据信息,并根据用户设置的认证凭据信息提供用户身份认证功能,支撑锁屏等安全场景。同时,用户IAM子系统也提供API,支持三方开发者调用系统提供的身份认证能力来实现业务对用户的访问控制要求。 +用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据管理和身份认证的能力,支持多用户分别设置凭据信息,并根据用户设置的凭据信息提供用户身份认证功能,支撑锁屏和支付等安全场景。同时,用户IAM子系统也提供对外的接口供三方应用调用,实现业务对用户的访问控制要求。 **图1** 子系统架构图 @@ -14,16 +14,15 @@ - **用户身份凭据管理:** 向上提供系统内统一的用户身份凭据信息管理接口,向下通过认证执行器管理模块,调用系统内的认证资源,完成用户身份凭据的生命周期管理和安全存储。 - **认证执行器管理:** 提供认证资源管理和认证会话管理功能,支持系统内身份认证相关**执行器**统一管理和协同调度,支持不同类型的身份认证执行器灵活对接。 -基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令认证和人脸认证,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。 +基于统一用户认证框架,系统可以扩展支持多种认证能力。OpenHarmony框架当前已经支持的**认证执行器**包含口令执行器和人脸执行器,开发者如果想实现新的认证执行器,只需要在新的部件内实现认证相关功能,并且按照执行器管理模块定义的接口与统一用户认证框架对接即可。 -*注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,处理口令采集、口令处理和比对、口令安全存储的全过程,因此可以抽象为一个口令认证的全功能执行器。* +*注:在用户IAM子系统内,将一个用户身份认证操作的最小执行单元称为**执行器**,如一个口令认证模块,包含口令采集、处理、安全存储和口令比对的全过程,因此可以抽象为一个口令认证的全功能执行器。* ## 目录 - ```undefined -//base/user_iam -├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理 +//base/useriam +├── user_auth_framework # 用户认证框架,包括用户认证、凭据管理和执行器管理 ├── face_auth # 人脸认证部件,与认证执行器管理对接,支持人脸录入、删除和人脸认证功能 ├── pin_auth # 口令认证部件,与认证执行器管理对接,支持口令录入、删除和口令认证功能 @@ -31,7 +30,7 @@ ## 约束 -1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用调用。 +1. 用户身份凭据信息管理类操作,是系统内的关键操作,相关接口只支持系统基础应用的调用。 2. 执行器内部真正完成用户凭据信息的处理,因此只支持系统服务实现执行器的功能,与认证执行器管理模块对接。 ## 说明 @@ -39,7 +38,7 @@ ### 使用说明 1. 统一用户认证框架必须配合一个认证执行器才可以使用。 -2. 系统内默认存在的第一个认证执行器应该是口令执行器。 +2. 系统内默认存在的第一个认证执行器是口令执行器。 ## 相关仓 diff --git a/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md b/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md index c380b5694ad84bc4e60304fd97298696941fea97..f12df131aa6cec6c96bdc526ea47f89dffd65386 100644 --- a/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v1-1-4-LTS.md @@ -77,7 +77,7 @@ repo forall -c 'git lfs pull' | -------- | -------- | | [I4AJEN](https://gitee.com/openharmony/third_party_freetype/issues/I4AJEN) | 修复third_party_freetype组件的CVE-2020-15999安全漏洞 | | [I4AJ6T](https://gitee.com/openharmony/third_party_mbedtls/issues/I4AJ6T) | 修复third_party_mbedtls组件的CVE-2020-36475和CVE-2020-36478安全漏洞 | -| [I4AIYJ](https://gitee.com/openharmony/device_hisilicon_third_party_uboot/issues/I4AIYJ?from=project-issue) | 修复third_party_uboot组件的CVE-2021-27138和CVE-2021-27097安全漏洞 | +| I4AIYJ | 修复third_party_uboot组件的CVE-2021-27138和CVE-2021-27097安全漏洞 | | [I4HUM6](https://gitee.com/openharmony/third_party_lwip/issues/I4HUM6?from=project-issue) | 修复third_party_lwip组件的CVE-2020-22284安全漏洞 | | I4QTVZ | 修复third_party_mbedtls组件的CVE-2021-44732和CVE-2021-45450安全漏洞 | | [I46RRM](https://gitee.com/openharmony/third_party_wpa_supplicant/issues/I46RRM?from=project-issue) | 修复P2P客户端的辅助设备类型的复制存在的一个安全漏洞 | diff --git a/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md b/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md index 144e6e9552c8acf164912d7cdcd9268873f7f238..4a639a4346b77b3abe9f1a24d663c14e9db6bde1 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md @@ -162,7 +162,7 @@ API变更请参考:[JS API 差异报告](api-change/v3.0-LTS/js-apidiff-v3.0-l | ISSUE单号 | 问题描述 | | -------- | -------- | | I46A6H | XTS子系统压力测试过程中libace.z.so异常导致ohos.samples.flashlight出现cppcrash异常 | -| [I48HLN](https://gitee.com/openharmony/app_samples/issues/I48HLN) | Demo&应用子系统- [ JsCanvas] 清除的button功能未生效 | +| I48HLN | Demo&应用子系统- [ JsCanvas] 清除的button功能未生效 | | [I46HH7](https://gitee.com/openharmony/drivers_peripheral/issues/I46HH7) | 驱动子系统-标准系统单板WLAN测试用例失败 | | [I4312A](https://gitee.com/openharmony/communication_dsoftbus/issues/I4312A) | 【2.2 Beta2】【软总线】已组网,断1端网络后,自组网失败(GetAllNodeDeviceInfo返回null) | | [I43WIJ](https://gitee.com/openharmony/communication_dsoftbus/issues/I43WIJ) | 【2.2 Beta2】【软总线】已组网,一端切换网络再切回,过程中组网未下线(无上下线回调) | @@ -179,6 +179,6 @@ API变更请参考:[JS API 差异报告](api-change/v3.0-LTS/js-apidiff-v3.0-l | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | 运行hilog压力测试,hilogd异常重启,且hilog命令一直无法使用 | 压力测试下,低概率出现日志输出异常,调测场景可正常使用。 | 10月30日 | | I48YPH | 【软总线-组网】测试发现和组网性能(循环离网-发现-组网)110次组网失败3次 | 低概率3/110,失败后重新发起组网即可。 | 10月30日 | | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | 【软总线-组网】标准系统与手机开关网络自组网成功率97%失败3次需分析失败原因 | 低概率出现组网失败。 | 10月30日 | -| [I4BXWY](https://gitee.com/openharmony/multimedia_media_standard/issues/I4BXWY) | Hi3516音频录制后播放有杂音 | 仅在使用此开发板时,影响录制音频的播放体验效果。 | 10月30日 | -| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | 视频录制后前几秒没声音,播放声画不同步,在板子播放会卡顿,音源较远时,有杂音 | 仅在使用此开发板时,影响录制视频的播放体验效果。 | 10月30日 | +| I4BXWY | Hi3516音频录制后播放有杂音 | 仅在使用此开发板时,影响录制音频的播放体验效果。 | 10月30日 | +| I4BXY1 | 视频录制后前几秒没声音,播放声画不同步,在板子播放会卡顿,音源较远时,有杂音 | 仅在使用此开发板时,影响录制视频的播放体验效果。 | 10月30日 | | [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | XTS权限用例压测用户态概率失败 | 仅在重复创建子进程的XTS压力测试场景,设置子进程uid失败,低概率问题。 | 10月30日 | diff --git a/zh-cn/release-notes/OpenHarmony-v3.0.1-LTS.md b/zh-cn/release-notes/OpenHarmony-v3.0.1-LTS.md index ece3fa043559ab4912fa5164812507da3c196aa5..5a165d4d67a45933981e830498fd248dbdb8b904 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.0.1-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v3.0.1-LTS.md @@ -83,27 +83,27 @@ repo forall -c 'git lfs pull' | [I4BJFU](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BJFU) | dyload_posix模块在removefile的时候出现错误 | | [I42N33](https://gitee.com/openharmony/third_party_mksh/issues/I42N33) | 集成测试直接执行cat后无法退出,需要重启设备恢复 | | [I4C8BO](https://gitee.com/openharmony/docs/issues/I4C8BO?from=project-issue) | 3516DV300/3518EV300 使用官网烧写配置媒体子系统(轻量小型)基本功能异常 | -| [I4BWKC](https://gitee.com/openharmony/drivers_framework/issues/I4BWKC) | 3516DV300单板camera驱动压测问题 | -| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | 3516DV300单板ResetDriver接口失败 | +| I4BWKC | 3516DV300单板camera驱动压测问题 | +| I4BW0G | 3516DV300单板ResetDriver接口失败 | | [I4C7ZK](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4C7ZK) | HI3516DV300 小型系统常驻内存超基线 | | [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | HI3518EV300常驻内存超基线 | | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | 运行hilog的压测,hilogd异常重启,且hilog命令一直无法使用 | -| [I4EGMD](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4EGMD) | 修改want的序列化和反序列化方法 | +| I4EGMD | 修改want的序列化和反序列化方法 | | [I4CED3](https://gitee.com/openharmony/account_os_account/issues/I4CED3) | 修复JS API接口返回只有一个内容的问题 | -| [I4BXZ1](https://gitee.com/openharmony/app_samples/issues/I4BXZ1) | 修复[ Picker] 组件点击无响应问题 | -| [I4CMMH](https://gitee.com/openharmony/ace_ace_engine/issues/I4CMMH) | 解决toggle显示异常问题 | -| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | 优化编辑框响应时间 | +| I4BXZ1 | 修复[ Picker] 组件点击无响应问题 | +| I4CMMH | 解决toggle显示异常问题 | +| I4CE7D | 优化编辑框响应时间 | | [I4HI4C](https://gitee.com/openharmony/ai_engine/issues/I4HI4C) | 解决小型系统TDD 用例失败问题,调整用例比较时间范围 | | [I4EUOW](https://gitee.com/openharmony/ai_engine/issues/I4EUOW) | 更改用例执行线程数 | -| [I4HTFS](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/issues/I4HTFS) | 轻量系统bms适配 | +| I4HTFS | 轻量系统bms适配 | | [I4C3BE](https://gitee.com/openharmony/communication_dsoftbus/issues/I4C3BE) | 修复了BLE被动发现频繁更新蓝牙广播,导致蓝牙资源消耗完自动关闭的问题 | | [I4I7QL](https://gitee.com/openharmony/developtools_packing_tool/issues/I4I7QL) | 修复一个ability有2张卡片的时候打包报错问题 | -| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | 解决WiFi ResetDriver概率性失败问题 | +| I4BW0G | 解决WiFi ResetDriver概率性失败问题 | | [I4GBB6](https://gitee.com/openharmony/device_qemu/issues/I4GBB6) | 修复risc-v qemu模拟器运行系统异常问题 | | [I4CE7E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CE7E) | liteos-a内核drivers/mtd/multi_partition/用到了device/hisilicon下的驱动函数实现 | -| [I4JBEH](https://gitee.com/openharmony/drivers_framework/issues/I4JBEH) | 修复了反复使用HDF的DMA传输接口,发生内存泄漏的问题 | -| [I4IGQ0](https://gitee.com/openharmony/drivers_framework/issues/I4IGQ0) | 解决器件探测失败后导致资源释放问题 | -| [I4JPCG](https://gitee.com/openharmony/drivers_framework/issues/I4JPCG) | 解决pwm背光无法设置0的问题 | +| I4JBEH | 修复了反复使用HDF的DMA传输接口,发生内存泄漏的问题 | +| I4IGQ0 | 解决器件探测失败后导致资源释放问题 | +| I4JPCG | 解决pwm背光无法设置0的问题 | | [I4ERM4](https://gitee.com/openharmony/drivers_peripheral/issues/I4ERM4) | 解决显示用例失败的问题 | | [I4CMUY](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4CMUY) | hdf_peripheral_wlan_test_performance.bin测试套执行失败 | | [I4FIP2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FIP2) | a核ioctl支持SIOCGIFBRDADDR选项 | @@ -118,7 +118,7 @@ repo forall -c 'git lfs pull' | [I4C5RW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5RW) | 开启MPU保护任务栈时,遇到OS_TASK_STACK_PROTECT_SIZE宏未定义的错误 | | [I4G4VK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4VK) | 修改inet_addr等宏为函数,外层调用可不包含lwip头文件 | | [I4FVGV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FVGV) | liteos_m核优化lwip默认配置 | -| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | 删除延迟3秒拉起输入法 | +| I4CE7D) | 删除延迟3秒拉起输入法 | | [I4CFOO](https://gitee.com/openharmony/multimedia_media_lite/issues/I4CFOO) | linux多次录像后,不退出应用,重启最后一个录像文件大小为0 | | [I4CLGW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLGW) | pagecache优化 | | [I4HKQ2](https://gitee.com/openharmony/vendor_hisilicon/issues/I4HKQ2) | 测试轻量系统liteOs 获取udid | @@ -132,24 +132,24 @@ repo forall -c 'git lfs pull' | [I4BX4J](https://gitee.com/openharmony/hiviewdfx_hicollie/issues/I4BX4J?from=project-issue) | 3516DV300单板调用hicollie接口失败 | | [I4BX1X](https://gitee.com/openharmony/hiviewdfx_hitrace/issues/I4BX1X?from=project-issue) | 3516DV300单板调用hitrace接口失败 | | [I4BVUL](https://gitee.com/openharmony/communication_wifi/issues/I4BVUL?from=project-issue) | 标准系统与手机切换AP场景发现组网成功率低(91%),不达98% | -| [I4BW6E](https://gitee.com/openharmony/security_deviceauth/issues/I4BW6E) | 标准系统与手机_手机侧循环开关网络_30次左右开始组网失败不再成功 | +| I4BW6E| 标准系统与手机_手机侧循环开关网络_30次左右开始组网失败不再成功 | | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | 标准系统与手机_L2开关网络自组网成功率97%_失败3次_需分析失败原因 | -| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH?from=project-issue) | 测试发现和组网性能(循环离网-发现-组网)_110次组网失败3次 | +| I48YPH | 测试发现和组网性能(循环离网-发现-组网)_110次组网失败3次 | | [I4492M](https://gitee.com/openharmony/communication_dsoftbus/issues/I4492M) | 组网10分钟自动下线规格,实际测试不准确,耗时多了30s左右 | -| [I44W7U](https://gitee.com/openharmony/graphic_standard/issues/I44W7U?from=project-issue) | SubWindow窗口大小不支持缩放,导致播放Video过程中会盖住进度条 | +| I44W7U | SubWindow窗口大小不支持缩放,导致播放Video过程中会盖住进度条 | | [I480Z1](https://gitee.com/openharmony/communication_dsoftbus/issues/I480Z1?from=project-issue) | Softbus_server在执行socketfuzz时,出现crash | -| [I4BGLS](https://gitee.com/openharmony/security_deviceauth/issues/I4BGLS?from=project-issue) | import_signed_auth_info_hilink导入的key用于HiChain连接时的身份标志,导入后加密存储在文件中,属于敏感数据,在返回后没有从堆中清除 | +| I4BGLS | import_signed_auth_info_hilink导入的key用于HiChain连接时的身份标志,导入后加密存储在文件中,属于敏感数据,在返回后没有从堆中清除 | | [I4A10Q](https://gitee.com/openharmony/startup_appspawn/issues/I4A10Q?from=project-issue) | 性能测试3516 3.0.0.6静态KPI劣化严重 | -| [I4BXYT](https://gitee.com/openharmony/developtools_hdc_standard/issues/I4BXYT) | hdc_std在设备重启之后,需要hdc_std kill才能重新发现设备 | -| [I4KUTY](https://gitee.com/openharmony/ace_engine_lite/issues/I4KUTY) | 删除无效的结果返回 | -| [I4DMFV](https://gitee.com/openharmony/ark_js_runtime/issues/I4DMFV) | 修复utf16到utf8的转换 | +| I4BXYT | hdc_std在设备重启之后,需要hdc_std kill才能重新发现设备 | +| I4KUTY | 删除无效的结果返回 | +| I4DMFV | 修复utf16到utf8的转换 | | [I4HGVM](https://gitee.com/openharmony/communication_dsoftbus/issues/I4HGVM) | 增加标准系统对mbedtls的依赖 | -| [I4DLV2](https://gitee.com/openharmony/drivers_framework/issues/I4DLV2) | 修复HidInfo\*类型导致非法内存访问错误的问题 | +| I4DLV2 | 修复HidInfo\*类型导致非法内存访问错误的问题 | | [I4CIJJ](https://gitee.com/openharmony/third_party_flutter/issues/I4CIJJ) | ArkUI支持GPU渲染 | | [I4G31Z](https://gitee.com/openharmony/third_party_freetype/issues/I4G31Z) | 字体引擎版本从2.10.1升级到2.10.4 | | [I4H06M](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4H06M) | OpenType 文本整形引擎版本从2.6.1升级到2.8.1 | | [I4FS7V](https://gitee.com/openharmony/third_party_lwip/issues/I4FS7V) | 使用LWIP_NETCONN_FULLDUPLEX宏来管控conn->mbox_threads_waiting的初始化 | -| [I43KL7](https://gitee.com/openharmony/graphic_standard/issues/I43KL7) | 修改了合成器支持GPU合成 | +| I43KL7 | 修改了合成器支持GPU合成 | ## 遗留缺陷列表 @@ -164,4 +164,4 @@ repo forall -c 'git lfs pull' | [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | WeekPluralNumbertest模块对应json文件配置的有问题,执行用例时报"required device does not exist"导致UN | json文件配置问题,不影响功能 | 2022/1/15 | | [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | 标准系统XTS测试执行测试ActsHiCollieCppTest模块HiCollieCppTest用例3条失败项 | 测试套名称变更导致存在文本校验功能的测试用例不通过,对功能无影响 | 2022/1/15 | | [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | 标准系统XTS测试执行测试ActsFaultLoggerTest模块faultloggertest用例1条失败项 | 测试套名称变更导致存在文本校验功能的测试用例不通过,对功能无影响 | 2022/1/15 | -| [I4NODO](https://gitee.com/openharmony/device_manager/issues/I4NODO) | 标准系统3516分布式业务流转端到端测试失败,无法完成流转 | DM组件_重复创建群组失败,影响使用流转功能(按照issue中提到的操作步骤)的业务,对其他应用无影响 | 2022/1/30 | +| I4NODO| 标准系统3516分布式业务流转端到端测试失败,无法完成流转 | DM组件_重复创建群组失败,影响使用流转功能(按照issue中提到的操作步骤)的业务,对其他应用无影响 | 2022/1/30 | diff --git a/zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md b/zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md index 935207b37dc9be7fd1db88d848000dfbbc300464..6dd84fdfeac418e6c8fb957d68205dbe65d3cf55 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v3.0.2-LTS.md @@ -85,7 +85,7 @@ repo forall -c 'git lfs pull' | [I4V2DN](https://gitee.com/openharmony/xts_acts/issues/I4V2DN?from=project-issue) | ActsLwipTest模块测试中存在两条用例执行超时的失败 | | [I4V3KC](https://gitee.com/openharmony/xts_acts/issues/I4V3KC?from=project-issue) | 分布式调度子系统testPublish0010测试用例执行失败 | | [I4URGA](https://gitee.com/openharmony/applications_sample_camera/issues/I4URGA?from=project-issue) | 设置界面搜WLAN信号时概率出现蓝屏 | -| [I4SDCK](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4SDCK?from=project-issue) | 小型系统HI 3516 GetSrcPath /GetDataPath 获取路径为空或者乱码 | +| I4SDCK | 小型系统HI 3516 GetSrcPath /GetDataPath 获取路径为空或者乱码 | | [I4T6KZ](https://gitee.com/openharmony/communication_dsoftbus/issues/I4T6KZ) | 测试传输相关用例时在 SendMessage SendData4Data处失败 | | I4UOUS | Hi3516小型系统 串口界面的回显日志打印了明文密码 | | [I4OWZO](https://gitee.com/openharmony/third_party_toybox/issues/I4OWZO) | toybox mv命令移动nfs路径下的文件出现异常提示 | @@ -97,7 +97,7 @@ repo forall -c 'git lfs pull' | [I4R4D3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4D3) | pthread_create创建的线程未设置detach属性,主动退出后,OsGetAllTskInfo调用后,相关的任务名为乱码 | | [I4R4A5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4R4A5) | pthread_cond_timedwait接口实现存在计算溢出的问题 | | [I4QJT4](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4QJT4) | 修复UartRead test case 失败问题 | -| [I4U1DM](https://gitee.com/openharmony/distributedschedule_samgr_lite/issues/I4U1DM) | samgr 的 QUEUE_Pop 函数在调用 LFQUE_Pop 函数时未加锁,存在潜在的数据竞争 | +| I4U1DM | samgr 的 QUEUE_Pop 函数在调用 LFQUE_Pop 函数时未加锁,存在潜在的数据竞争 | **表4** 标准系统解决的缺陷ISSUE列表 @@ -106,7 +106,7 @@ repo forall -c 'git lfs pull' | [I4UJNU](https://gitee.com/openharmony/applications_settings/issues/I4UJNU) | 通过设置连接WLAN时,WLAN密码在hilog日志中明文打印 | | [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | XT测试执行测试ActsFaultLoggerTest模块faultloggertest用例时有1条失败项 | | [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | XTS测试执行测试ActsHiCollieCppTest模块HiCollieCppTest用例时有3条失败项 | -| [I4PPXV](https://gitee.com/openharmony/appexecfwk_standard/issues/I4PPXV?from=project-issue) | 打开应用后再退出到桌面,桌面应用图标丢失 | +| I4PPXV | 打开应用后再退出到桌面,桌面应用图标丢失 | | [I4OF9A](https://gitee.com/openharmony/distributeddatamgr_file/issues/I4OF9A?from=project-issue) | file.readText接口读取的text值不稳定 | | [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | WeekPluralNumbertest模块对应json文件配置问题,执行用例时报"required device does not exist"导致此测试套无法执行 | | [I4OUVQ](https://gitee.com/openharmony/xts_tools/issues/I4OUVQ?from=project-issue) | XTS JS用例反复压力测试过程中系统卡死,无法进行测试 | diff --git a/zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md b/zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md index e820a90519f79a8d03934901067454e04f63e427..abf23f7d3675fc90e1c0b70213ce773c4e1726ee 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v3.0.3-LTS.md @@ -86,7 +86,7 @@ repo forall -c 'git lfs pull' | [I4SM0J](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4SM0J) | third_party_harfbuzz仓内使用了 CC BY-NC-SA-3.0 许可证,该许可证限制了内容的商业使用。 | | [I4WPQW](https://gitee.com/openharmony/device_hisilicon_hardware/issues/I4WPQW) | device_hisilicon_hardware仓同步更新libdisplay_layer.so二进制文件。 | | [I4WIVF](https://gitee.com/openharmony/third_party_boost/issues/I4WIVF) | third_party_boost仓下一些文件存在开源协议不兼容的风险。 | -| [I4WRWM](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4WRWM) | aafwk_aafwk_lite仓新增TDD测试用例。 | +| I4WRWM | aafwk_aafwk_lite仓新增TDD测试用例。 | | [I4VPVY](https://gitee.com/openharmony/applications_sample_camera/issues/I4VPVY) | 轻量系统Hi3516DV300从设置菜单搜索WLAN,然后点击2次返回键返回到桌面后,无法从桌面启动应用。 | | [I4UTY0](https://gitee.com/openharmony/applications_photos/issues/I4UTY0) | demos 路径下的 1.jpg 图片文件元数据中存在HP的版权声明。 | | [I4TP6D](https://gitee.com/openharmony/xts_acts/issues/I4TP6D) | 标准系统Hi3516新增acts测试套ActsWorkerJSTest无法正常执行。 | @@ -107,6 +107,4 @@ repo forall -c 'git lfs pull' | [I4YBB0](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YBB0) | 小型系统3516DV300-Linux在系统相机拍照录像后,无图片生成,录制的视频无法播放 | 仅针对此开发板,影响相机录像功能 | 2022/4/1 | | [I4YB87](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YB87) | 小型系统3516DV300-Linux在系统相机拍照录像后,图库中无显示 | 仅针对此开发板,影响相机拍照功能 | 2022/4/1 | | [I4YAGS](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4YAGS?from=project-issue) | 小型系统3516DV300-Linux进入系统相机,画面蓝屏 | 仅针对此开发板,影响相机预览功能 | 2022/4/1 | -| [I4WLBU](https://gitee.com/openharmony/developtools_hdc_standard/issues/I4WLBU?from=project-issue) | 标准系统3516DV300在acts测试过程中烧录后找不到设备,报Device not founded or connected | HDC工具导致acts测试概率报错,对实际功能无影响 | 2022/4/10 | - - +| I4WLBU | 标准系统3516DV300在acts测试过程中烧录后找不到设备,报Device not founded or connected | HDC工具导致acts测试概率报错,对实际功能无影响 | 2022/4/10 | diff --git a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md index 9b9f55b3edd7d5d4f6e4b248e4ca5edac893d5dc..2d26d1b8dfb09d02a14001ad340df42f24ae6f9a 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md @@ -170,7 +170,7 @@ _[Changelog](api-change/v3.1-beta/changelog-v3.1-beta.md)_ | [JS页面弹窗](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) | JS中支持用户自定义弹窗,<dialog/>组件作为容器组件,用户可以自定义弹窗的样式和布局。本示例完成了添加和删除联系人功能,在添加和删除时使用自定义弹窗来实现。 | JS | | [JSList商品列表](https://gitee.com/openharmony/app_samples/tree/master/UI/JsList) | 本示例展示了list控件在商品分类列表中的应用,在listGroup里采用两个list-item分别展示了Group收缩和Group展开的两种列表形态,点击后会弹出相应的list列表。 | JS | | [JSPanel](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel) | JS提供一种轻量级的内容展示面板,此面板可滑动,可自定义触发方式、弹出高度等属性。本示例通过可滑动面板展示了商品详细信息与平台保障。 | JS | -| [JsSvg](https://gitee.com/openharmony/app_samples/tree/master/UI/JsSvg) | 本示例展示了JS中组件及其子组件的使用,包括 。 | JS | +| [JsSvg](https://gitee.com/openharmony/app_samples/tree/master/UI/JsSvg) | 本示例展示了JS中组件及其子组件的使用,包括 。 | JS | | [JS自定义组件](https://gitee.com/openharmony/app_samples/tree/master/UI/JSUICustomComponent) | 自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,提高代码的可读性。本示例展示了JS中自定义组件的使用,包括基本用法、自定义事件、Props和事件参数。 | JS | @@ -200,9 +200,9 @@ _[Changelog](api-change/v3.1-beta/changelog-v3.1-beta.md)_ | ISSUE单号 | 问题描述 | | -------- | -------- | | [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | 运行hilog压力测试,hilogd异常重启,且hilog命令一直无法使用。 | -| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH) | 【软总线-组网】测试发现和组网性能(循环离网-发现-组网)110次组网失败3次。 | +| I48YPH | 【软总线-组网】测试发现和组网性能(循环离网-发现-组网)110次组网失败3次。 | | [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | 【软总线-组网】标准系统与手机开关网络自组网成功率97%失败3次需分析失败原因。 | -| [I4BXY1](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4BXY1) | 视频录制后前几秒没声音,播放声画不同步,在板子播放会卡顿,音源较远时,有杂音。 | +| I4BXY1 | 视频录制后前几秒没声音,播放声画不同步,在板子播放会卡顿,音源较远时,有杂音。 | | [3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D) | XTS权限用例压测用户态概率失败。 | @@ -214,7 +214,7 @@ _[Changelog](api-change/v3.1-beta/changelog-v3.1-beta.md)_ | -------- | -------- | -------- | -------- | | [I4NRS5](https://gitee.com/openharmony/kernel_linux_5.10/issues/I4NRS5) | 【内核子系统】存在cve漏洞 | Linux内核还未发布补丁,暂时挂起,待社区发布补丁后升级同步。 | 待社区发布补丁 | | [I4MGJM](https://gitee.com/openharmony/drivers_peripheral/issues/I4MGJM) | 【hdf/camera】RK3568单板跑camera HDI用例失败 | 拍照和预览正常,可以正常录像,点击结束按钮,不能结束。 | 2021/12/31 | -| [I4OECR](https://gitee.com/openharmony/ark_js_runtime/issues/I4OECR) | XTS运行报ark异常栈(低概率问题) | XTS压力测试低概率偶现(48小时出现1次),仅Log中上报异常栈,对功能无影响。 | 2022/1/5 | +| I4OECR | XTS运行报ark异常栈(低概率问题) | XTS压力测试低概率偶现(48小时出现1次),仅Log中上报异常栈,对功能无影响。 | 2022/1/5 | | [I4OBTW](https://gitee.com/openharmony/ability_ability_runtime/issues/I4OBTW) | 全量执行XTS用例,安装应用后出现批量aa start 失败,影响社区流水线稳定性测试 | XTS压力测试,短时间内批量安装100个应用包,低概率(2个/100个)出现应用无法启动。用户使用无影响。 | 2022/1/5 | -| [I4OLHF](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLHF?from=project-issue) | 【Ark子系统】 由进程com.amsst.amsMissionSnapshotTest导致测试进程异常 | 低概率、偶现,高压力测试偶现问题。 | 2022/1/5 | -| [I4OLUK](https://gitee.com/openharmony/ark_js_runtime/issues/I4OLUK) | 【Ark子系统】 由进程com.ohos.systemui导致进程栈异常 | 低概率、偶现,高压力测试偶现问题。 | 2022/1/5 | +| I4OLHF | 【Ark子系统】 由进程com.amsst.amsMissionSnapshotTest导致测试进程异常 | 低概率、偶现,高压力测试偶现问题。 | 2022/1/5 | +| I4OLUK | 【Ark子系统】 由进程com.ohos.systemui导致进程栈异常 | 低概率、偶现,高压力测试偶现问题。 | 2022/1/5 | diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index 984e715246614522f5be8011bed7a25195794ab0..f17941a51e6a3aeda9802db1bea4f937433a054b 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -5,17 +5,17 @@ - [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md) - - [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md) - - [OpenHarmony v3.1.3 Release (2022-09-30)](OpenHarmony-v3.1.3-release.md) - - [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md) - - [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md) +- [OpenHarmony v3.1.4 Release (2022-11-02)](OpenHarmony-v3.1.4-release.md) +- [OpenHarmony v3.1.3 Release (2022-09-30)](OpenHarmony-v3.1.3-release.md) +- [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md) +- [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](OpenHarmony-v3.1-beta.md) - [OpenHarmony v3.0 LTS (2021-09-30)](OpenHarmony-v3.0-LTS.md) - - [OpenHarmony v3.0.6 LTS (2022-09-15)](OpenHarmony-v3.0.6-LTS.md) - - [OpenHarmony v3.0.5 LTS (2022-07-01)](OpenHarmony-v3.0.5-LTS.md) - - [OpenHarmony v3.0.3 LTS (2022-04-08)](OpenHarmony-v3.0.3-LTS.md) - - [OpenHarmony v3.0.2 LTS (2022-03-18)](OpenHarmony-v3.0.2-LTS.md) - - [OpenHarmony v3.0.1 LTS (2022-01-12)](OpenHarmony-v3.0.1-LTS.md) +- [OpenHarmony v3.0.6 LTS (2022-09-15)](OpenHarmony-v3.0.6-LTS.md) +- [OpenHarmony v3.0.5 LTS (2022-07-01)](OpenHarmony-v3.0.5-LTS.md) +- [OpenHarmony v3.0.3 LTS (2022-04-08)](OpenHarmony-v3.0.3-LTS.md) +- [OpenHarmony v3.0.2 LTS (2022-03-18)](OpenHarmony-v3.0.2-LTS.md) +- [OpenHarmony v3.0.1 LTS (2022-01-12)](OpenHarmony-v3.0.1-LTS.md) ## OpenHarmony 2.x Releases @@ -25,10 +25,9 @@ ## OpenHarmony 1.x Releases - [OpenHarmony v1.0 (2020-09-10)](OpenHarmony-1-0.md) - - [OpenHarmony v1.1.5 LTS (2022-08-24)](OpenHarmony-v1.1.5-LTS.md) - - [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) - - [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md) - - [OpenHarmony v1.1.2 LTS (2021-08-04)](OpenHarmony-v1.1.2-LTS.md) - - [OpenHarmony v1.1.1 LTS (2021-06-22)](OpenHarmony-1-1-1-LTS.md) - - [OpenHarmony v1.1.0 LTS (2021-04-01)](OpenHarmony-1-1-0-LTS.md) - +- [OpenHarmony v1.1.5 LTS (2022-08-24)](OpenHarmony-v1.1.5-LTS.md) +- [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) +- [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md) +- [OpenHarmony v1.1.2 LTS (2021-08-04)](OpenHarmony-v1.1.2-LTS.md) +- [OpenHarmony v1.1.1 LTS (2021-06-22)](OpenHarmony-1-1-1-LTS.md) +- [OpenHarmony v1.1.0 LTS (2021-04-01)](OpenHarmony-1-1-0-LTS.md) diff --git a/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-ability.md similarity index 100% rename from zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md rename to zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-ability.md diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md new file mode 100644 index 0000000000000000000000000000000000000000..216a2b4f3e158dd8246200a2a039b25f09027b7f --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.8.3/changelogs-account_os_account.md @@ -0,0 +1,124 @@ +# 帐号子系统ChangeLog + +## cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更 + +已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更: + +异步接口:通过AsyncCallback或Promise的error对象返回错误信息。 + +同步接口:通过抛出异常的方式返回错误信息。 + +**变更影响** + +基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。 + +**关键接口/组件变更** + +变更前: + - class UserAuth + - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; + - setProperty(request: SetPropertyRequest): Promise<number>; + - cancelAuth(contextID: Uint8Array): number; + - class PINAuth + - registerInputer(inputer: Inputer): boolean; + - UserIdentityManager + - cancel(challenge: Uint8Array): number; + +变更后: + - class UserAuth + - setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): void; + - setProperty(request: SetPropertyRequest): Promise<void>; + - cancelAuth(contextID: Uint8Array): void; + - class PINAuth + - registerInputer(inputer: Inputer): void; + - UserIdentityManager + - cancel(challenge: Uint8Array): void; + +**适配指导** + +异步接口以setProperty为例,示例代码如下: + +``` +import account_osAccount from "@ohos.account.osAccount" +userAuth.setProperty({ + authType: account_osAccount.AuthType.PIN, + key: account_osAccount.SetPropertyType.INIT_ALGORITHM, + setInfo: new Uint8Array([0]) +}, (err) => { + if (err) { + console.log("setProperty failed, error: " + JSON.stringify(err)); + } else { + console.log("setProperty successfully"); + } +}); + +userAuth.setProperty({ + authType: account_osAccount.AuthType.PIN, + key: account_osAccount.SetPropertyType.INIT_ALGORITHM, + setInfo: new Uint8Array([0]) +}).catch((err) => { + if (err) { + console.log("setProperty failed, error: " + JSON.stringify(err)); + } else { + console.log("setProperty successfully"); + } +}); +``` + +同步接口以registerInputer为例,示例代码如下: + +``` +import account_osAccount from "@ohos.account.osAccount" +let pinAuth = new account_osAccount.PINAuth() +let inputer = { + onGetData: (authType, passwordRecipient) => { + let password = new Uint8Array([0]); + passwordRecipient.onSetData(authType, password); + } +} +try { + pinAuth.registerInputer(inputer); +} catch (err) { + console.log("registerInputer failed, error: " + JSON.stringify(err)); +} +``` + +## cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更 + +**变更影响** + +基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。 + +**关键接口/组件变更** + +涉及的常量: + +@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH + +变更前: + +ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth" + +变更后: + +ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth" + +**适配指导** + +提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下: +``` +"abilities": [ + { + "name": "ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + ... + "visible": true, + "skills": { + { + "actions": [ + "ohos.appAccount.action.auth" + ] + } + } + }] +} diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + + diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelogs-arkui.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelogs-arkui.md new file mode 100644 index 0000000000000000000000000000000000000000..4194e320b1aeb7e8502907c7fcb706aee9e60d99 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.1/changelogs-arkui.md @@ -0,0 +1,50 @@ +# arkui子系统ChangeLog + +## cl.arkui.1 xcomponent组件接口变更 + +arkui子系统xcomponent组件接口存在变更: + + - 去除getXComponentSurfaceId和setXComponentSurfaceSize接口的@systemapi标签 + - 指定getXComponentSurfaceId,getXComponentContext和setXComponentSurfaceSize接口的返回值类型 + +开发者需要根据以下说明对应用进行适配。 + + +**变更影响** + +影响已发布的JS接口,应用需要进行适配才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + + - getXComponentSurfaceId:改为public接口,指定返回值类型为string + - setXComponentSurfaceSize:改为public接口,指定返回值类型为void + - getXComponentContext:指定返回值类型为Object + +**适配指导** + +不同场景下的启动规则说明如下: +开发者适配内容: + + - **getXComponentSurfaceId** + - OpenHarmony 3.2-beta3 版本规则: + - 系统接口systemapi。 + - 未指定返回值 + - OpenHarmony 3.2-Beta4 版本新规则: + - 公共接口。 + - 指定返回值类型为string + - 开发者需要按照string类型处理返回值 + - **setXComponentSurfaceSize** + - OpenHarmony 3.2-beta3 版本规则: + - 系统接口systemapi。 + - 未指定返回值 + - OpenHarmony 3.2-Beta4 版本新规则: + - 公共接口。 + - 指定返回值类型为void + - 开发者需要按照void类型处理返回值 + - **getXComponentContext** + - OpenHarmony 3.2-beta3 版本规则: + - 未指定返回值 + - OpenHarmony 3.2-Beta4 版本新规则: + - 指定返回值类型为Object + - 开发者需要按照Object类型处理返回值 + \ No newline at end of file diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.2/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + + diff --git a/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md new file mode 100644 index 0000000000000000000000000000000000000000..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony 3.2.9.3/changelog-x-x.md @@ -0,0 +1,31 @@ +# xxx子系统ChangeLog + +相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。 + +## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字) + +每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。 +以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。 +如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。 + +**变更影响** + +是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。 +是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。 + +**关键的接口/组件变更** + +列举此功能变更涉及的接口/组件变更。 + +**适配指导(可选,不涉及则可以删除)** + +提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。 +例: +在xxx文件中将xxx参数修改为xxx。 + +``` +sample code +``` + + +